Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
config_tree_view.h
1 
2 /***************************************************************************
3  * config_tree_view.h - TreeView class for displaying the configuration
4  *
5  * Created: Wed Sep 24 13:39:47 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 __TOOLS_CONFIG_EDITOR_CONFIG_TREE_VIEW_H_
24 #define __TOOLS_CONFIG_EDITOR_CONFIG_TREE_VIEW_H_
25 
26 #include <gtkmm.h>
27 #include <string>
28 
29 namespace fawkes {
30  class Configuration;
31  class FawkesNetworkClient;
32 }
33 
34 class ConfigEditDialog;
35 class ConfigAddDialog;
36 class ConfigRemoveDialog;
37 class ConfigEditorPlugin;
38 
39 class ConfigTreeView : public Gtk::TreeView
40 {
41  public:
42  ConfigTreeView(BaseObjectType* cobject,
43  const Glib::RefPtr<Gtk::Builder>& builder);
44  virtual ~ConfigTreeView();
45 
46  void set_config(fawkes::Configuration* config);
48  void set_config_file(const char* filename);
49 
50  void register_plugin( ConfigEditorPlugin* plugin );
51  void remove_plugin( std::string config_path );
52 
53  protected:
54  void set_value(const char* path, const char* type, bool is_default, bool value);
55  void set_value(const char* path, const char* type, bool is_default, int value);
56  void set_value(const char* path, const char* type, bool is_default, uint value);
57  void set_value(const char* path, const char* type, bool is_default, float value);
58  void set_value(const char* path, const char* type, bool is_default, std::string value);
59 
60  virtual void on_button_press_event_custom(GdkEventButton* event);
61  virtual void on_menu_edit_selected();
62  virtual void on_menu_add_selected();
63  virtual void on_menu_remove_selected();
64 
65  class ConfigRecord : public Gtk::TreeModelColumnRecord
66  {
67  public:
68  ConfigRecord()
69  {
70  add(node);
71  add(path);
72  add(type);
73  add(is_default);
74  add(value_bool);
75  add(value_int);
76  add(value_uint);
77  add(value_float);
78  add(value_string);
79  }
80 
81  Gtk::TreeModelColumn<Glib::ustring> node; /**< node name */
82  Gtk::TreeModelColumn<Glib::ustring> path; /**< config path */
83  Gtk::TreeModelColumn<Glib::ustring> type; /**< config value type */
84  Gtk::TreeModelColumn<bool> is_default; /**< default flag */
85  Gtk::TreeModelColumn<bool> value_bool; /**< bool config value */
86  Gtk::TreeModelColumn<int> value_int; /**< int config value */
87  Gtk::TreeModelColumn<uint> value_uint; /**< unsigned int config value */
88  Gtk::TreeModelColumn<float> value_float; /**< float config value */
89  Gtk::TreeModelColumn<Glib::ustring> value_string; /**< config value as string */
90  };
91 
93  Glib::RefPtr<Gtk::TreeStore> m_config_tree;
94 
95  Gtk::Menu m_menu;
99 
100  std::map< std::string, ConfigEditorPlugin* > m_plugins;
101 
104 
105  private:
106  void read_config();
107 
108  Gtk::TreeIter get_iter(const char* path);
109  Gtk::TreeIter search_path( const char* path );
110 
111  bool edit_entry(const Gtk::TreeIter& iter);
112  bool add_entry(const Gtk::TreeIter& iter);
113  bool remove_entry(const Gtk::TreeIter& iter);
114 };
115 
116 #endif /* __TOOLS_CONFIG_EDITOR_CONFIG_TREE_VIEW_H_ */
Gtk::TreeModelColumn< bool > value_bool
bool config value
Dialog to add a config entry.
Simple Fawkes network client.
Definition: client.h:51
bool m_own_config
True if config was created by ConfigTreeView object.
Treeview widget for displaying/editing config entries.
virtual void on_menu_edit_selected()
Signal handler that is called when the &#39;edit&#39; entry is selected from popup menu.
Gtk::TreeModelColumn< uint > value_uint
unsigned int config value
virtual void on_menu_add_selected()
Signal handler that is called when the &#39;add&#39; entry is selected from popup menu.
Gtk::TreeModelColumn< Glib::ustring > value_string
config value as string
Dialog to edit a config value.
virtual ~ConfigTreeView()
Destructor.
Gtk::TreeModelColumn< Glib::ustring > type
config value type
ConfigAddDialog * m_dlg_add
A dialog to add a config entry.
void register_plugin(ConfigEditorPlugin *plugin)
Register a plugin.
void remove_plugin(std::string config_path)
Remove a plugin.
ConfigEditDialog * m_dlg_edit
A dialog to edit a config entry.
Glib::RefPtr< Gtk::TreeStore > m_config_tree
Storage object.
fawkes::Configuration * m_config
The fawkes::Configuration that is displayed and editted.
Dialog to remove a config entry.
Gtk::Menu m_menu
A popup menu to edit the configuration.
virtual void on_menu_remove_selected()
Signal handler that is called when the &#39;remove&#39; entry is selected from popup menu.
Gtk::TreeModelColumn< Glib::ustring > node
node name
void set_value(const char *path, const char *type, bool is_default, bool value)
Add a config entry to the TreeModel storage object.
Column record class for the config TreeView.
void set_network_client(fawkes::FawkesNetworkClient *client)
Set a network client that is used to open a fawkes::NetworkConfiguration.
ConfigRecord m_config_record
Column record object to access the columns of the storage object.
std::map< std::string, ConfigEditorPlugin * > m_plugins
A map of registered plugins: config-prefix =&gt; config editor plugin.
Gtk::TreeModelColumn< Glib::ustring > path
config path
Gtk::TreeModelColumn< int > value_int
int config value
void set_config_file(const char *filename)
Set the file to read the config from.
Gtk::TreeModelColumn< float > value_float
float config value
virtual void on_button_press_event_custom(GdkEventButton *event)
Signal handler for the button press event.
ConfigRemoveDialog * m_dlg_remove
A dialog to remove a config entry.
Gtk::TreeModelColumn< bool > is_default
default flag
void set_config(fawkes::Configuration *config)
Set the fawkes::Configuration to be displayed.
Base class for plugins for the Fawkes config editor.
ConfigTreeView(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder)
Constructor.
Interface for configuration handling.
Definition: config.h:63