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 class ImageRecord : public Gtk::TreeModelColumnRecord 00071 { 00072 public: 00073 ImageRecord() 00074 { 00075 add(display_text); 00076 add(service_name); 00077 add(host_name); 00078 add(port); 00079 add(colorspace); 00080 add(image_id); 00081 add(width); 00082 add(height); 00083 add(buffer_size); 00084 } 00085 00086 Gtk::TreeModelColumn<Glib::ustring> display_text; 00087 Gtk::TreeModelColumn<Glib::ustring> service_name; 00088 Gtk::TreeModelColumn<Glib::ustring> host_name; 00089 Gtk::TreeModelColumn<unsigned int> port; 00090 Gtk::TreeModelColumn<Glib::ustring> image_id; 00091 Gtk::TreeModelColumn<unsigned int> colorspace; 00092 Gtk::TreeModelColumn<unsigned int> width; 00093 Gtk::TreeModelColumn<unsigned int> height; 00094 Gtk::TreeModelColumn<unsigned int> buffer_size; 00095 }; 00096 00097 struct ClientData 00098 { 00099 FuseClient* client; 00100 std::string service_name; 00101 std::string host_name; 00102 uint16_t port; 00103 bool active; 00104 }; 00105 00106 bool on_image_event(GdkEvent *event); 00107 void on_add_host_manually(); 00108 void on_image_selected(); 00109 void on_auto_update_toggled(); 00110 void on_compression_toggled(); 00111 void get_image_list(); 00112 void delete_clients(); 00113 void update_image_list(); 00114 bool on_update_timeout(); 00115 00116 fawkes::LockList<ClientData> m_new_clients; 00117 fawkes::LockQueue<FuseClient*> m_delete_clients; 00118 00119 ClientData m_cur_client; 00120 00121 Gtk::Menu* m_popup_menu; 00122 Gtk::CheckButton* m_chk_auto_update; 00123 Gtk::CheckButton* m_chk_compression; 00124 Gtk::TreeView* m_trv_image_list; 00125 Glib::RefPtr<Gtk::TreeStore> m_image_list; 00126 fawkes::Mutex m_img_list_mutex; 00127 00128 ImageRecord m_image_record; 00129 00130 Glib::Dispatcher m_signal_get_image_list; 00131 Glib::Dispatcher m_signal_delete_clients; 00132 Glib::Dispatcher m_signal_image_selected; 00133 Glib::Dispatcher m_signal_update_image_l; 00134 00135 bool m_auto_update; 00136 unsigned int m_interval_sec; 00137 sigc::connection m_timeout_conn; 00138 00139 Glib::ustring m_cur_image_id; 00140 }; 00141 00142 } // end namespace firevision 00143 00144 #endif /* __FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_ */