Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * fuse_image_list_widget.h - Fuse image list widget 00004 * 00005 * Created: Mon Mar 24 21:01:16 2008 00006 * Copyright 2008 Daniel Beck 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_ 00024 #define __FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_ 00025 00026 #include <fvutils/net/fuse_client_handler.h> 00027 #include <fvutils/net/fuse_client.h> 00028 00029 #include <core/utils/lock_queue.h> 00030 #include <core/utils/lock_list.h> 00031 #include <core/threading/mutex.h> 00032 00033 #include <gtkmm.h> 00034 00035 namespace firevision { 00036 #if 0 /* just to make Emacs auto-indent happy */ 00037 } 00038 #endif 00039 00040 class FuseImageListWidget : FuseClientHandler, public Gtk::TreeView 00041 { 00042 public: 00043 FuseImageListWidget(); 00044 virtual ~FuseImageListWidget(); 00045 00046 void add_fountain_service( const char* name, 00047 const char* host_name, 00048 uint32_t port ); 00049 void remove_fountain_service(const char* name); 00050 00051 void set_toggle_compression_chk(Gtk::CheckButton* chk); 00052 void set_auto_update_chk(Gtk::CheckButton* chk); 00053 void set_image_list_trv(Gtk::TreeView* trv); 00054 Glib::Dispatcher& image_selected(); 00055 00056 bool auto_update(); 00057 void set_auto_update(bool active, unsigned int interval_sec = 5); 00058 00059 bool get_selected_image( std::string& host_name, unsigned short& port, 00060 std::string& image_id, bool& compression ); 00061 00062 // Fuse client handler 00063 void fuse_invalid_server_version( uint32_t local_version, 00064 uint32_t remote_version ) throw(); 00065 void fuse_connection_established() throw(); 00066 void fuse_connection_died() throw(); 00067 void fuse_inbound_received(FuseNetworkMessage *m) throw(); 00068 00069 private: 00070 /// @cond INTERNALS 00071 class ImageRecord : public Gtk::TreeModelColumnRecord 00072 { 00073 public: 00074 ImageRecord() 00075 { 00076 add(display_text); 00077 add(service_name); 00078 add(host_name); 00079 add(port); 00080 add(colorspace); 00081 add(image_id); 00082 add(width); 00083 add(height); 00084 add(buffer_size); 00085 } 00086 00087 Gtk::TreeModelColumn<Glib::ustring> display_text; 00088 Gtk::TreeModelColumn<Glib::ustring> service_name; 00089 Gtk::TreeModelColumn<Glib::ustring> host_name; 00090 Gtk::TreeModelColumn<unsigned int> port; 00091 Gtk::TreeModelColumn<Glib::ustring> image_id; 00092 Gtk::TreeModelColumn<unsigned int> colorspace; 00093 Gtk::TreeModelColumn<unsigned int> width; 00094 Gtk::TreeModelColumn<unsigned int> height; 00095 Gtk::TreeModelColumn<unsigned int> buffer_size; 00096 }; 00097 00098 struct ClientData 00099 { 00100 FuseClient* client; 00101 std::string service_name; 00102 std::string host_name; 00103 uint16_t port; 00104 bool active; 00105 }; 00106 /// @endcond 00107 00108 bool on_image_event(GdkEvent *event); 00109 void on_add_host_manually(); 00110 void on_image_selected(); 00111 void on_auto_update_toggled(); 00112 void on_compression_toggled(); 00113 void get_image_list(); 00114 void delete_clients(); 00115 void update_image_list(); 00116 bool on_update_timeout(); 00117 00118 fawkes::LockList<ClientData> m_new_clients; 00119 fawkes::LockQueue<FuseClient*> m_delete_clients; 00120 00121 ClientData m_cur_client; 00122 00123 Gtk::Menu* m_popup_menu; 00124 Gtk::CheckButton* m_chk_auto_update; 00125 Gtk::CheckButton* m_chk_compression; 00126 Gtk::TreeView* m_trv_image_list; 00127 Glib::RefPtr<Gtk::TreeStore> m_image_list; 00128 fawkes::Mutex m_img_list_mutex; 00129 00130 ImageRecord m_image_record; 00131 00132 Glib::Dispatcher m_signal_get_image_list; 00133 Glib::Dispatcher m_signal_delete_clients; 00134 Glib::Dispatcher m_signal_image_selected; 00135 Glib::Dispatcher m_signal_update_image_l; 00136 00137 bool m_auto_update; 00138 unsigned int m_interval_sec; 00139 sigc::connection m_timeout_conn; 00140 00141 Glib::ustring m_cur_image_id; 00142 }; 00143 00144 } // end namespace firevision 00145 00146 #endif /* __FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_ */