Fawkes API  Fawkes Development Version
fuse_image_list_widget.h
1 
2 /***************************************************************************
3  * fuse_image_list_widget.h - Fuse image list widget
4  *
5  * Created: Mon Mar 24 21:01:16 2008
6  * Copyright 2008 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_
24 #define _FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_
25 
26 #include <core/threading/mutex.h>
27 #include <core/utils/lock_list.h>
28 #include <core/utils/lock_queue.h>
29 #include <fvutils/net/fuse_client.h>
30 #include <fvutils/net/fuse_client_handler.h>
31 
32 #include <gtkmm.h>
33 
34 namespace firevision {
35 
36 class FuseImageListWidget : FuseClientHandler, public Gtk::TreeView
37 {
38 public:
41 
42  void add_fountain_service(const char *name, const char *host_name, uint32_t port);
43  void remove_fountain_service(const char *name);
44 
45  void set_toggle_compression_chk(Gtk::CheckButton *chk);
46  void set_auto_update_chk(Gtk::CheckButton *chk);
47  void set_image_list_trv(Gtk::TreeView *trv);
48  Glib::Dispatcher &image_selected();
49 
50  bool auto_update();
51  void set_auto_update(bool active, unsigned int interval_sec = 5);
52 
53  bool get_selected_image(std::string & host_name,
54  unsigned short &port,
55  std::string & image_id,
56  bool & compression);
57 
58  // Fuse client handler
59  void fuse_invalid_server_version(uint32_t local_version, uint32_t remote_version) throw();
60  void fuse_connection_established() throw();
61  void fuse_connection_died() throw();
63 
64 private:
65  /// @cond INTERNALS
66  class ImageRecord : public Gtk::TreeModelColumnRecord
67  {
68  public:
69  ImageRecord()
70  {
71  add(display_text);
72  add(service_name);
73  add(host_name);
74  add(port);
75  add(colorspace);
76  add(image_id);
77  add(width);
78  add(height);
79  add(buffer_size);
80  }
81 
82  Gtk::TreeModelColumn<Glib::ustring> display_text;
83  Gtk::TreeModelColumn<Glib::ustring> service_name;
84  Gtk::TreeModelColumn<Glib::ustring> host_name;
85  Gtk::TreeModelColumn<unsigned int> port;
86  Gtk::TreeModelColumn<Glib::ustring> image_id;
87  Gtk::TreeModelColumn<unsigned int> colorspace;
88  Gtk::TreeModelColumn<unsigned int> width;
89  Gtk::TreeModelColumn<unsigned int> height;
90  Gtk::TreeModelColumn<unsigned int> buffer_size;
91  };
92 
93  struct ClientData
94  {
95  FuseClient *client;
96  std::string service_name;
97  std::string host_name;
98  uint16_t port;
99  bool active;
100  };
101  /// @endcond
102 
103  bool on_image_event(GdkEvent *event);
104  void on_add_host_manually();
105  void on_image_selected();
106  void on_auto_update_toggled();
107  void on_compression_toggled();
108  void get_image_list();
109  void delete_clients();
110  void update_image_list();
111  bool on_update_timeout();
112 
113  fawkes::LockList<ClientData> m_new_clients;
114  fawkes::LockQueue<FuseClient *> m_delete_clients;
115 
116  ClientData m_cur_client;
117 
118 #if GTK_VERSION_LT(3, 0)
119  Gtk::Menu *m_popup_menu;
120 #endif
121  Gtk::CheckButton * m_chk_auto_update;
122  Gtk::CheckButton * m_chk_compression;
123  Gtk::TreeView * m_trv_image_list;
124  Glib::RefPtr<Gtk::TreeStore> m_image_list;
125  fawkes::Mutex m_img_list_mutex;
126 
127  ImageRecord m_image_record;
128 
129  Glib::Dispatcher m_signal_get_image_list;
130  Glib::Dispatcher m_signal_delete_clients;
131  Glib::Dispatcher m_signal_image_selected;
132  Glib::Dispatcher m_signal_update_image_l;
133 
134  bool m_auto_update;
135  unsigned int m_interval_sec;
136  sigc::connection m_timeout_conn;
137 
138  Glib::ustring m_cur_image_id;
139 };
140 
141 } // end namespace firevision
142 
143 #endif /* FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H__ */
firevision::FuseImageListWidget::set_auto_update
void set_auto_update(bool active, unsigned int interval_sec=5)
Set the auto-update status.
Definition: fuse_image_list_widget.cpp:224
firevision::FuseImageListWidget::fuse_invalid_server_version
void fuse_invalid_server_version(uint32_t local_version, uint32_t remote_version)
Definition: fuse_image_list_widget.cpp:420
fawkes::Mutex
Definition: mutex.h:36
fawkes::LockList< ClientData >
firevision::FuseImageListWidget::set_image_list_trv
void set_image_list_trv(Gtk::TreeView *trv)
Assign the TreeView widget to hold the list of images.
Definition: fuse_image_list_widget.cpp:163
firevision::FuseImageListWidget::set_auto_update_chk
void set_auto_update_chk(Gtk::CheckButton *chk)
Assign the CheckButton that enables/disables the auto update function.
Definition: fuse_image_list_widget.cpp:192
firevision::FuseImageListWidget::FuseImageListWidget
FuseImageListWidget()
Constructor.
Definition: fuse_image_list_widget.cpp:43
firevision::FuseImageListWidget::image_selected
Glib::Dispatcher & image_selected()
Access the Dispatcher that is signalled when a new image is selected in the list of images.
Definition: fuse_image_list_widget.cpp:205
firevision::FuseImageListWidget::~FuseImageListWidget
virtual ~FuseImageListWidget()
Destructor.
Definition: fuse_image_list_widget.cpp:75
firevision::FuseImageListWidget::auto_update
bool auto_update()
Get auto-update status.
Definition: fuse_image_list_widget.cpp:214
firevision::FuseImageListWidget::fuse_connection_established
void fuse_connection_established()
Definition: fuse_image_list_widget.cpp:427
fawkes::LockQueue
Definition: lock_queue.h:48
firevision::FuseImageListWidget::get_selected_image
bool get_selected_image(std::string &host_name, unsigned short &port, std::string &image_id, bool &compression)
Get the host name, port, and image id of the selected image.
Definition: fuse_image_list_widget.cpp:250
firevision::FuseImageListWidget::fuse_connection_died
void fuse_connection_died()
Definition: fuse_image_list_widget.cpp:432
firevision::FuseImageListWidget::set_toggle_compression_chk
void set_toggle_compression_chk(Gtk::CheckButton *chk)
Assign the CheckButton to toggle the compression.
Definition: fuse_image_list_widget.cpp:181
firevision::FuseImageListWidget::add_fountain_service
void add_fountain_service(const char *name, const char *host_name, uint32_t port)
Call this method when new Fountain services are discovered.
Definition: fuse_image_list_widget.cpp:102
firevision::FuseNetworkMessage
Definition: fuse_message.h:43
firevision::FuseImageListWidget::fuse_inbound_received
void fuse_inbound_received(FuseNetworkMessage *m)
Definition: fuse_image_list_widget.cpp:443
firevision::FuseImageListWidget::remove_fountain_service
void remove_fountain_service(const char *name)
Call this method when a Fountain service vanishes.
Definition: fuse_image_list_widget.cpp:142