config_tree_view.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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;
00082 Gtk::TreeModelColumn<Glib::ustring> path;
00083 Gtk::TreeModelColumn<Glib::ustring> type;
00084 Gtk::TreeModelColumn<bool> is_default;
00085 Gtk::TreeModelColumn<bool> value_bool;
00086 Gtk::TreeModelColumn<int> value_int;
00087 Gtk::TreeModelColumn<uint> value_uint;
00088 Gtk::TreeModelColumn<float> value_float;
00089 Gtk::TreeModelColumn<Glib::ustring> value_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