25 #include <gui_utils/plugin_tree_view.h> 26 #include <netcomm/fawkes/client.h> 27 #include <plugin/net/messages.h> 28 #include <plugin/net/list_message.h> 29 #include <gui_utils/twolines_cellrenderer.h> 64 PluginTreeView::PluginTreeView()
65 : m_dispatcher(FAWKES_CID_PLUGINMANAGER)
75 const Glib::RefPtr<Gtk::Builder> builder)
76 : Gtk::TreeView(cobject),
77 m_dispatcher(FAWKES_CID_PLUGINMANAGER)
84 PluginTreeView::ctor()
86 m_plugin_list = Gtk::ListStore::create(m_plugin_record);
87 set_model(m_plugin_list);
89 append_column(
"#", m_plugin_record.index);
90 append_column_editable(
"Status", m_plugin_record.loaded);
91 append_plugin_column();
94 Gtk::TreeViewColumn *column = get_column(0);
95 column->signal_clicked().connect(sigc::mem_fun(*
this, &PluginTreeView::on_id_clicked));
96 column = get_column(1);
97 column->signal_clicked().connect(sigc::mem_fun(*
this, &PluginTreeView::on_status_clicked));
99 Gtk::CellRendererToggle* renderer;
100 renderer =
dynamic_cast<Gtk::CellRendererToggle*
>( get_column_cell_renderer(1) );
101 renderer->signal_toggled().connect( sigc::mem_fun(*
this, &PluginTreeView::on_status_toggled));
103 set_search_column(1);
105 m_dispatcher.
signal_connected().connect(sigc::mem_fun(*
this, &PluginTreeView::on_connected));
106 m_dispatcher.
signal_disconnected().connect(sigc::mem_fun(*
this, &PluginTreeView::on_disconnected));
125 __gconf->remove_dir(__gconf_prefix);
149 __gconf = Gnome::Conf::Client::get_default_client();
151 __gconf->remove_dir(__gconf_prefix);
154 __gconf->add_dir(gconf_prefix);
155 __gconf_prefix = gconf_prefix;
157 if (__gconf_connection) {
158 __gconf_connection.disconnect();
160 __gconf_connection = __gconf->signal_value_changed().connect(sigc::hide(sigc::hide(sigc::mem_fun(*
this, &PluginTreeView::on_config_changed))));
167 PluginTreeView::on_connected()
196 PluginTreeView::on_disconnected()
198 m_plugin_list->clear();
205 if (msg->
cid() != FAWKES_CID_PLUGINMANAGER)
return;
208 unsigned int msgid = msg->
msgid();
214 Glib::ustring name =
"";
221 printf(
"Invalid message size (load succeeded)\n");
234 printf(
"Invalid message size (load failed)\n");
247 printf(
"Invalid message size (unload succeeded)\n");
260 printf(
"Invalid message size (unload failed)\n");
271 for ( iter = m_plugin_list->children().begin();
272 iter != m_plugin_list->children().end();
275 Glib::ustring n = (*iter)[m_plugin_record.name];
278 (*iter)[m_plugin_record.loaded] = loaded;
285 m_plugin_list->clear();
289 char *plugin_name = plm->
next();
290 char *plugin_desc = NULL;
292 plugin_desc = plm->
next();
294 plugin_desc = strdup(
"Unknown, malformed plugin list message?");
297 Gtk::TreeModel::Row row = *m_plugin_list->append();
298 unsigned int index = m_plugin_list->children().size();
299 row[m_plugin_record.index] = index;
300 row[m_plugin_record.name] = plugin_name;
301 row[m_plugin_record.description] = plugin_desc;
302 row[m_plugin_record.loaded] =
false;
311 printf(
"Obtaining list of available plugins failed\n");
318 char* name = plm->
next();
321 for ( iter = m_plugin_list->children().begin();
322 iter != m_plugin_list->children().end();
325 Glib::ustring n = (*iter)[m_plugin_record.name];
328 (*iter)[m_plugin_record.loaded] =
true;
338 printf(
"Obtaining list of loaded plugins failed\n");
344 printf(
"received message with msg-id %d\n", msg->
msgid());
353 PluginTreeView::on_status_toggled(
const Glib::ustring& path)
357 Gtk::TreeModel::Row row = *m_plugin_list->get_iter(path);
358 Glib::ustring plugin_name = row[m_plugin_record.name];
359 bool loaded = row[m_plugin_record.loaded];
364 strncpy(m->
name, plugin_name.c_str(), PLUGIN_MSG_NAME_LENGTH);
374 strncpy(m->
name, plugin_name.c_str(), PLUGIN_MSG_NAME_LENGTH);
387 PluginTreeView::on_id_clicked()
389 m_plugin_list->set_sort_column(0, Gtk::SORT_ASCENDING);
396 PluginTreeView::on_status_clicked()
398 m_plugin_list->set_sort_column(2, Gtk::SORT_DESCENDING);
405 PluginTreeView::on_name_clicked()
407 m_plugin_list->set_sort_column(1, Gtk::SORT_ASCENDING);
414 PluginTreeView::on_config_changed()
416 Gtk::TreeViewColumn *plugin_col = get_column(2);
417 if (plugin_col) remove_column(*plugin_col);
419 append_plugin_column();
426 PluginTreeView::append_plugin_column()
428 #if GTKMM_MAJOR_VERSION > 2 || ( GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 14 ) 429 bool description_as_tooltip =
false;
433 description_as_tooltip = __gconf->get_bool(__gconf_prefix +
"/description_as_tooltip");
438 #if GTKMM_MAJOR_VERSION > 2 || ( GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 14 ) 439 if (description_as_tooltip)
442 append_column(
"Plugin", m_plugin_record.name);
443 #if GTKMM_MAJOR_VERSION > 2 || ( GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 14 ) 444 set_tooltip_column(2);
449 Gtk::TreeViewColumn *tlcol =
450 new Gtk::TreeViewColumn(
"Plugin", *Gtk::manage(twolines_renderer));
451 append_column(*Gtk::manage(tlcol));
453 # ifdef GLIBMM_PROPERTIES_ENABLED 454 tlcol->add_attribute(twolines_renderer->property_line1(), m_plugin_record.name);
455 tlcol->add_attribute(twolines_renderer->property_line2(), m_plugin_record.description);
457 tlcol->add_attribute(*twolines_renderer,
"line1", m_plugin_record.name);
458 tlcol->add_attribute(*twolines_renderer,
"line2", m_plugin_record.description);
461 set_tooltip_column(-1);
465 set_headers_clickable();
466 Gtk::TreeViewColumn *plugin_col = get_column(2);
467 if (plugin_col) plugin_col->signal_clicked().connect(sigc::mem_fun(*
this, &PluginTreeView::on_name_clicked));
void * payload() const
Get payload buffer.
char * next()
Get next plugin from list.
request list of available plugins
plugin unloaded (plugin_unloaded_msg_t)
sigc::signal< void > signal_disconnected()
Get "disconnected" signal.
listing available plugins failed
sigc::signal< void > signal_connected()
Get "connected" signal.
Unsubscribe from watching load/unload events.
Simple Fawkes network client.
Gtk cell renderer for two lines of text in a cell.
unsigned short int cid() const
Get component ID.
char name[PLUGIN_MSG_NAME_LENGTH]
name of the plugin that has been loaded
Fawkes library namespace.
void enqueue(FawkesNetworkMessage *message)
Enqueue message to send.
Representation of a message that is sent over the network.
PluginTreeView()
Constructor.
void set_client(FawkesNetworkClient *client)
Set Fawkes network client.
MT * msgc() const
Get correctly parsed output.
char name[PLUGIN_MSG_NAME_LENGTH]
name of the plugin to load.
list of loaded plugins (plugin_list_msg_t)
plugin unload failed (plugin_unload_failed_msg_t)
char name[PLUGIN_MSG_NAME_LENGTH]
name of plugin that could not be unloaded
plugin loaded (plugin_loaded_msg_t)
char name[PLUGIN_MSG_NAME_LENGTH]
name of plugin that could not be unloaded
request plugin unload (plugin_unload_msg_t)
list of available plugins (plugin_list_msg_t)
Base class for exceptions in Fawkes.
void set_gconf_prefix(Glib::ustring gconf_prefix)
Set Gconf prefix.
listing loaded plugins failed
char name[PLUGIN_MSG_NAME_LENGTH]
name of the plugin that has been unloaded
bool has_next()
Check if more list elements are available.
void print_trace()
Prints trace to stderr.
unsigned short int msgid() const
Get message type ID.
request lif of loaded plugins
request plugin load (plugin_load_msg_t)
void set_network_client(fawkes::FawkesNetworkClient *client)
Set the network client.
void deregister_handler(unsigned int component_id)
Deregister handler.
sigc::signal< void, FawkesNetworkMessage * > signal_message_received()
Get "message received" signal.
Subscribe for watching load/unload events.
plugin load failed (plugin_load_failed_msg_t)
bool connected() const
Check if connection is alive.
char name[PLUGIN_MSG_NAME_LENGTH]
name of te plugin to unload.
virtual ~PluginTreeView()
Destructor.
FawkesNetworkClient * get_client()
Get client.
size_t payload_size() const
Get payload size.