config_tree_view.h

00001 
00002 /***************************************************************************
00003  *  config_tree_view.h - TreeView class for displaying the configuration
00004  *
00005  *  Created: Wed Sep 24 13:39:47 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 __TOOLS_CONFIG_EDITOR_CONFIG_TREE_VIEW_H_
00024 #define __TOOLS_CONFIG_EDITOR_CONFIG_TREE_VIEW_H_
00025 
00026 #include <gtkmm.h>
00027 #include <libglademm/xml.h>
00028 #include <string>
00029 
00030 namespace fawkes {
00031   class Configuration;
00032   class FawkesNetworkClient;
00033 }
00034 
00035 class ConfigEditDialog;
00036 class ConfigAddDialog;
00037 class ConfigRemoveDialog;
00038 class ConfigEditorPlugin;
00039 
00040 class ConfigTreeView : public Gtk::TreeView
00041 {
00042  public:
00043   ConfigTreeView(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& ref_xml);
00044   virtual ~ConfigTreeView();
00045 
00046   void set_config(fawkes::Configuration* config);
00047   void set_network_client(fawkes::FawkesNetworkClient* client);
00048   void set_config_file(const char* filename);
00049 
00050   void register_plugin( ConfigEditorPlugin* plugin );
00051   void remove_plugin( std::string config_path );
00052   
00053  protected:
00054   void set_value(const char* path, const char* type, bool is_default, bool value);
00055   void set_value(const char* path, const char* type, bool is_default, int value);
00056   void set_value(const char* path, const char* type, bool is_default, uint value);
00057   void set_value(const char* path, const char* type, bool is_default, float value);
00058   void set_value(const char* path, const char* type, bool is_default, std::string value);
00059 
00060   virtual void on_button_press_event_custom(GdkEventButton* event);
00061   virtual void on_menu_edit_selected();
00062   virtual void on_menu_add_selected();
00063   virtual void on_menu_remove_selected();
00064   
00065   class ConfigRecord : public Gtk::TreeModelColumnRecord
00066     {
00067     public:
00068       ConfigRecord()
00069         {
00070           add(node);
00071           add(path);
00072           add(type);
00073           add(is_default);
00074           add(value_bool);
00075           add(value_int);
00076           add(value_uint);
00077           add(value_float);
00078           add(value_string);
00079         }
00080       
00081       Gtk::TreeModelColumn<Glib::ustring> node;          /**< node name */
00082       Gtk::TreeModelColumn<Glib::ustring> path;          /**< config path */
00083       Gtk::TreeModelColumn<Glib::ustring> type;          /**< config value type */
00084       Gtk::TreeModelColumn<bool>          is_default;    /**< default flag */
00085       Gtk::TreeModelColumn<bool>          value_bool;    /**< bool config value */
00086       Gtk::TreeModelColumn<int>           value_int;     /**< int config value */
00087       Gtk::TreeModelColumn<uint>          value_uint;    /**< unsigned int config value */
00088       Gtk::TreeModelColumn<float>         value_float;   /**< float config value */
00089       Gtk::TreeModelColumn<Glib::ustring> value_string;  /**< config value as string */
00090     };
00091   
00092   ConfigRecord m_config_record;
00093   Glib::RefPtr<Gtk::TreeStore> m_config_tree;
00094 
00095   Gtk::Menu m_menu;
00096   ConfigEditDialog* m_dlg_edit;
00097   ConfigAddDialog* m_dlg_add;
00098   ConfigRemoveDialog* m_dlg_remove;
00099 
00100   std::map< std::string, ConfigEditorPlugin* > m_plugins;
00101 
00102   fawkes::Configuration* m_config;
00103   bool m_own_config;
00104 
00105  private:
00106   void read_config();
00107 
00108   Gtk::TreeIter get_iter(const char* path);
00109   Gtk::TreeIter search_path( const char* path );
00110 
00111   bool edit_entry(const Gtk::TreeIter& iter);
00112   bool add_entry(const Gtk::TreeIter& iter);
00113   bool remove_entry(const Gtk::TreeIter& iter);
00114 };
00115 
00116 #endif /* __TOOLS_CONFIG_EDITOR_CONFIG_TREE_VIEW_H_ */

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1