Fawkes API  Fawkes Development Version
plugin_tree_view.h
00001 
00002 /***************************************************************************
00003  *  plugin_tree_view.h - Displays a list of Fawkes plugins and allows to
00004  *                       start/stop them
00005  *
00006  *  Created: Fri Sep 26 21:06:37 2008
00007  *  Copyright  2008  Daniel Beck
00008  *             2008  Tim Niemueller [www.niemueller.de]
00009  *
00010  ****************************************************************************/
00011 
00012 /*  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; either version 2 of the License, or
00015  *  (at your option) any later version.
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU Library General Public License for more details.
00021  *
00022  *  Read the full text in the LICENSE.GPL file in the doc directory.
00023  */
00024 
00025 #ifndef __GUI_UTILS_PLUGIN_TREE_VIEW_H_
00026 #define __GUI_UTILS_PLUGIN_TREE_VIEW_H_
00027 
00028 #include <netcomm/fawkes/client_handler.h>
00029 #include <core/utils/lock_queue.h>
00030 #include <gui_utils/connection_dispatcher.h>
00031 
00032 #include <gtkmm.h>
00033 #ifdef HAVE_GLADEMM
00034 #  include <libglademm/xml.h>
00035 #endif
00036 #ifdef HAVE_GCONFMM
00037 #  include <gconfmm.h>
00038 #endif
00039 
00040 namespace fawkes {
00041 #if 0 /* just to make Emacs auto-indent happy */
00042 }
00043 #endif
00044 
00045 class FawkesNetworkClient;
00046 class FawkesNetworkMessage;
00047 
00048 class PluginTreeView
00049 : public Gtk::TreeView
00050 {
00051  public:
00052   PluginTreeView();
00053 #ifdef HAVE_GLADEMM
00054   PluginTreeView(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> ref_xml);
00055 #endif
00056   virtual ~PluginTreeView();
00057 
00058   void set_network_client(fawkes::FawkesNetworkClient* client);
00059   void set_gconf_prefix(Glib::ustring gconf_prefix);
00060 
00061  private:
00062   class PluginRecord : public Gtk::TreeModelColumnRecord
00063   {
00064    public:
00065     PluginRecord()
00066       {
00067         add(index);
00068         add(name);
00069         add(description);
00070         add(loaded);
00071       }
00072 
00073     Gtk::TreeModelColumn<int> index;           /**< an index */
00074     Gtk::TreeModelColumn<Glib::ustring> name;  /**< the name of the plugin */
00075     Gtk::TreeModelColumn<Glib::ustring> description;  /**< description of the plugin */
00076     Gtk::TreeModelColumn<bool> loaded;         /**< the loaded status of the plugin */
00077   };
00078 
00079   void ctor();
00080   void on_status_toggled(const Glib::ustring& path);
00081   void on_connected();
00082   void on_disconnected();
00083   void on_message_received(fawkes::FawkesNetworkMessage *msg);
00084   void on_id_clicked();
00085   void on_status_clicked();
00086   void on_name_clicked();
00087   void on_config_changed();
00088 
00089   void append_plugin_column();
00090 
00091  private:
00092   Glib::RefPtr<Gtk::ListStore> m_plugin_list;
00093 #ifdef HAVE_GCONFMM
00094   Glib::RefPtr<Gnome::Conf::Client> __gconf;
00095 #endif
00096   PluginRecord m_plugin_record;
00097 
00098   sigc::connection __gconf_connection;
00099   Glib::ustring    __gconf_prefix;
00100 
00101   fawkes::ConnectionDispatcher m_dispatcher;
00102 };
00103 
00104 } // end namespace fawkes
00105 
00106 #endif /*  __GUI_UTILS_PLUGIN_TREE_VIEW_H_ */