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 <fvutils/net/fuse_client_handler.h>
27 #include <fvutils/net/fuse_client.h>
28 
29 #include <core/utils/lock_queue.h>
30 #include <core/utils/lock_list.h>
31 #include <core/threading/mutex.h>
32 
33 #include <gtkmm.h>
34 
35 namespace firevision {
36 #if 0 /* just to make Emacs auto-indent happy */
37 }
38 #endif
39 
40 class FuseImageListWidget : FuseClientHandler, public Gtk::TreeView
41 {
42  public:
44  virtual ~FuseImageListWidget();
45 
46  void add_fountain_service( const char* name,
47  const char* host_name,
48  uint32_t port );
49  void remove_fountain_service(const char* name);
50 
51  void set_toggle_compression_chk(Gtk::CheckButton* chk);
52  void set_auto_update_chk(Gtk::CheckButton* chk);
53  void set_image_list_trv(Gtk::TreeView* trv);
54  Glib::Dispatcher& image_selected();
55 
56  bool auto_update();
57  void set_auto_update(bool active, unsigned int interval_sec = 5);
58 
59  bool get_selected_image( std::string& host_name, unsigned short& port,
60  std::string& image_id, bool& compression );
61 
62  // Fuse client handler
63  void fuse_invalid_server_version( uint32_t local_version,
64  uint32_t remote_version ) throw();
65  void fuse_connection_established() throw();
66  void fuse_connection_died() throw();
68 
69  private:
70  /// @cond INTERNALS
71  class ImageRecord : public Gtk::TreeModelColumnRecord
72  {
73  public:
74  ImageRecord()
75  {
76  add(display_text);
77  add(service_name);
78  add(host_name);
79  add(port);
80  add(colorspace);
81  add(image_id);
82  add(width);
83  add(height);
84  add(buffer_size);
85  }
86 
87  Gtk::TreeModelColumn<Glib::ustring> display_text;
88  Gtk::TreeModelColumn<Glib::ustring> service_name;
89  Gtk::TreeModelColumn<Glib::ustring> host_name;
90  Gtk::TreeModelColumn<unsigned int> port;
91  Gtk::TreeModelColumn<Glib::ustring> image_id;
92  Gtk::TreeModelColumn<unsigned int> colorspace;
93  Gtk::TreeModelColumn<unsigned int> width;
94  Gtk::TreeModelColumn<unsigned int> height;
95  Gtk::TreeModelColumn<unsigned int> buffer_size;
96  };
97 
98  struct ClientData
99  {
100  FuseClient* client;
101  std::string service_name;
102  std::string host_name;
103  uint16_t port;
104  bool active;
105  };
106  /// @endcond
107 
108  bool on_image_event(GdkEvent *event);
109  void on_add_host_manually();
110  void on_image_selected();
111  void on_auto_update_toggled();
112  void on_compression_toggled();
113  void get_image_list();
114  void delete_clients();
115  void update_image_list();
116  bool on_update_timeout();
117 
118  fawkes::LockList<ClientData> m_new_clients;
119  fawkes::LockQueue<FuseClient*> m_delete_clients;
120 
121  ClientData m_cur_client;
122 
123 #if GTK_VERSION_LT(3,0)
124  Gtk::Menu* m_popup_menu;
125 #endif
126  Gtk::CheckButton* m_chk_auto_update;
127  Gtk::CheckButton* m_chk_compression;
128  Gtk::TreeView* m_trv_image_list;
129  Glib::RefPtr<Gtk::TreeStore> m_image_list;
130  fawkes::Mutex m_img_list_mutex;
131 
132  ImageRecord m_image_record;
133 
134  Glib::Dispatcher m_signal_get_image_list;
135  Glib::Dispatcher m_signal_delete_clients;
136  Glib::Dispatcher m_signal_image_selected;
137  Glib::Dispatcher m_signal_update_image_l;
138 
139  bool m_auto_update;
140  unsigned int m_interval_sec;
141  sigc::connection m_timeout_conn;
142 
143  Glib::ustring m_cur_image_id;
144 };
145 
146 } // end namespace firevision
147 
148 #endif /* __FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_ */
Glib::Dispatcher & image_selected()
Access the Dispatcher that is signalled when a new image is selected in the list of images...
This widget displays all available Fuse images in a tree view.
void add_fountain_service(const char *name, const char *host_name, uint32_t port)
Call this method when new Fountain services are discovered.
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.
void fuse_invalid_server_version(uint32_t local_version, uint32_t remote_version)
Invalid version string received.
bool auto_update()
Get auto-update status.
void set_auto_update_chk(Gtk::CheckButton *chk)
Assign the CheckButton that enables/disables the auto update function.
FUSE Network Message.
Definition: fuse_message.h:41
void set_auto_update(bool active, unsigned int interval_sec=5)
Set the auto-update status.
void fuse_connection_established()
Connection has been established.
Queue with a lock.
Definition: lock_queue.h:43
void fuse_inbound_received(FuseNetworkMessage *m)
Message received.
void fuse_connection_died()
Connection died.
void remove_fountain_service(const char *name)
Call this method when a Fountain service vanishes.
void set_toggle_compression_chk(Gtk::CheckButton *chk)
Assign the CheckButton to toggle the compression.
Mutex mutual exclusion lock.
Definition: mutex.h:32
void set_image_list_trv(Gtk::TreeView *trv)
Assign the TreeView widget to hold the list of images.