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
34namespace firevision {
35
36class FuseImageListWidget : FuseClientHandler, public Gtk::TreeView
37{
38public:
40 virtual ~FuseImageListWidget();
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) noexcept;
60 void fuse_connection_established() noexcept;
61 void fuse_connection_died() noexcept;
63
64private:
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__ */
Queue with a lock.
Definition: lock_queue.h:45
Mutex mutual exclusion lock.
Definition: mutex.h:33
This widget displays all available Fuse images in a tree view.
void fuse_invalid_server_version(uint32_t local_version, uint32_t remote_version) noexcept
Invalid version string received.
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 set_image_list_trv(Gtk::TreeView *trv)
Assign the TreeView widget to hold the list of images.
void fuse_connection_died() noexcept
Connection died.
void fuse_inbound_received(FuseNetworkMessage *m) noexcept
Message received.
void set_auto_update(bool active, unsigned int interval_sec=5)
Set the auto-update status.
void add_fountain_service(const char *name, const char *host_name, uint32_t port)
Call this method when new Fountain services are discovered.
bool auto_update()
Get auto-update status.
Glib::Dispatcher & image_selected()
Access the Dispatcher that is signalled when a new image is selected in the list of images.
void set_auto_update_chk(Gtk::CheckButton *chk)
Assign the CheckButton that enables/disables the auto update function.
void fuse_connection_established() noexcept
Connection has been established.
void set_toggle_compression_chk(Gtk::CheckButton *chk)
Assign the CheckButton to toggle the compression.
void remove_fountain_service(const char *name)
Call this method when a Fountain service vanishes.
FUSE Network Message.
Definition: fuse_message.h:40