Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
config_tree_view.cpp
1 
2 /***************************************************************************
3  * config_tree_view.cpp - TreeView class for displaying the configuration
4  *
5  * Created: Wed Sep 24 13:45:39 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 #include "config_tree_view.h"
24 #include "config_edit_dialog.h"
25 #include "config_add_dialog.h"
26 #include "config_remove_dialog.h"
27 #include "config_editor_plugin.h"
28 
29 #include <core/exceptions/system.h>
30 #include <config/netconf.h>
31 #include <config/sqlite.h>
32 #include <netcomm/fawkes/client.h>
33 
34 #include <cstring>
35 #include <iostream>
36 #include <sstream>
37 
38 using namespace std;
39 using namespace fawkes;
40 
41 /** @class ConfigTreeView tools/config_editor/config_tree_view.h
42  * Treeview widget for displaying/editing config entries.
43  *
44  * @author Daniel Beck
45  */
46 
47 /** @class ConfigTreeView::ConfigRecord tools/config_editor/config_tree_view.h
48  * Column record class for the config TreeView.
49  *
50  * @author Daniel Beck
51  */
52 
53 /** @var ConfigTreeView::m_config_record
54  * Column record object to access the columns of the storage object.
55  */
56 
57 /** @var ConfigTreeView::m_config_tree
58  * Storage object.
59  */
60 
61 /** @var ConfigTreeView::m_menu
62  * A popup menu to edit the configuration.
63  */
64 
65 /** @var ConfigTreeView::m_dlg_edit
66  * A dialog to edit a config entry.
67  */
68 
69 /** @var ConfigTreeView::m_dlg_add
70  * A dialog to add a config entry.
71  */
72 
73 /** @var ConfigTreeView::m_dlg_remove
74  * A dialog to remove a config entry.
75  */
76 
77 /** @var ConfigTreeView::m_config
78  * The fawkes::Configuration that is displayed and editted.
79  */
80 
81 /** @var ConfigTreeView::m_own_config
82  * True if config was created by ConfigTreeView object.
83  */
84 
85 /** @var ConfigTreeView::m_plugins
86  * A map of registered plugins: config-prefix => config editor plugin.
87  */
88 
89 /** Constructor.
90  * @param cobject pointer to base object type
91  * @param builder Gtk builder
92  */
93 ConfigTreeView::ConfigTreeView(BaseObjectType* cobject,
94  const Glib::RefPtr<Gtk::Builder> &builder)
95  : Gtk::TreeView(cobject)
96 {
97  m_dlg_edit = NULL;
98  builder->get_widget_derived("dlgConfigEdit", m_dlg_edit);
99 
100  m_dlg_add = NULL;
101  builder->get_widget_derived("dlgConfigAdd", m_dlg_add);
102 
103  m_dlg_remove = NULL;
104  builder->get_widget_derived("dlgConfigRemove", m_dlg_remove);
105 
106  m_config_tree = Gtk::TreeStore::create(m_config_record);
107  m_config_tree->set_sort_column(0, Gtk::SORT_ASCENDING);
108 
109  set_model(m_config_tree);
110  append_column("Path", m_config_record.node);
111 
112  Gtk::TreeViewColumn *column = get_column(0);
113  Gtk::CellRendererText *cell =
114 #if GTK_VERSION_GE(3,0)
115  (Gtk::CellRendererText *)column->get_first_cell();
116 #else
117  (Gtk::CellRendererText *)column->get_first_cell_renderer();
118 #endif
119 #ifdef GLIBMM_PROPERTIES_ENABLED
120  column->add_attribute(cell->property_underline(), m_config_record.is_default);
121 #else
122  column->add_attribute(*cell, "underline", m_config_record.is_default);
123 #endif
124 
125  append_column("Value", m_config_record.value_string);
126 
127  /*
128  Gtk::Menu::MenuList& menulist = m_menu.items();
129 
130  menulist.push_back( Gtk::Menu_Helpers::MenuElem("Edit", sigc::mem_fun( *this, &ConfigTreeView::on_menu_edit_selected) ) );
131  menulist.push_back( Gtk::Menu_Helpers::MenuElem("Remove", sigc::mem_fun( *this, &ConfigTreeView::on_menu_remove_selected) ) );
132  menulist.push_back( Gtk::Menu_Helpers::MenuElem("Add", sigc::mem_fun( *this, &ConfigTreeView::on_menu_add_selected) ) );
133  */
134 
135  m_config = NULL;
136  m_own_config = false;
137 
138  signal_button_press_event().connect_notify( sigc::mem_fun(*this, &ConfigTreeView::on_button_press_event_custom) );
139 }
140 
141 /** Destructor. */
143 {
144  if (m_own_config)
145  { delete m_config; }
146 
147  for ( std::map< string, ConfigEditorPlugin* >::iterator iter = m_plugins.begin();
148  iter != m_plugins.end();
149  ++iter )
150  { delete iter->second; }
151 }
152 
153 /** Set the fawkes::Configuration to be displayed.
154  * @param config the fawkes::Configuration; set it to NULL to signal
155  * the unavailability of the config
156  */
157 void
159 {
160  if ( config )
161  {
162  m_config = config;
163  m_own_config = false;
164 
165  // TODO: enable mirror mode if it is a netconf
166  read_config();
167  }
168  else
169  {
170  delete m_config;
171  m_config = NULL;
172  m_config_tree->clear();
173  }
174 
175  for ( std::map< string, ConfigEditorPlugin* >::iterator i = m_plugins.begin();
176  i != m_plugins.end();
177  ++i )
178  { i->second->set_config( m_config ); }
179 }
180 
181 /** Set a network client that is used to open a fawkes::NetworkConfiguration.
182  * @param client a fawkes::NetworkClient; set it to NULL to signal the
183  * unavailability of the client
184  */
185 void
187 {
188  if (client)
189  {
190  NetworkConfiguration* netconf = new NetworkConfiguration(client);
191  netconf->set_mirror_mode(true);
192  m_config = netconf;
193  m_own_config = true;
194 
195  read_config();
196  }
197  else
198  {
199  delete m_config;
200  m_config = NULL;
201  m_config_tree->clear();
202  }
203 
204  for ( std::map< string, ConfigEditorPlugin* >::iterator i = m_plugins.begin();
205  i != m_plugins.end();
206  ++i )
207  { i->second->set_config( m_config ); }
208 }
209 
210 /** Set the file to read the config from.
211  * @param filename the filename of the database file
212  */
213 void
214 ConfigTreeView::set_config_file(const char* filename)
215 {
216  m_config = new SQLiteConfiguration(filename);
217  m_own_config = true;
218 
219  read_config();
220 }
221 
222 /** Register a plugin.
223  * This also initializes the plugin.
224  * @param plugin the new plugin to register
225  */
226 void
228 {
229  plugin->initialize();
230  m_plugins[ plugin->get_config_path() ] = plugin;
231 }
232 
233 /** Remove a plugin.
234  * @param config_path the config prefix corresponding to the plugin to
235  * be removed
236  */
237 void
238 ConfigTreeView::remove_plugin( string config_path )
239 {
240  std::map< string, ConfigEditorPlugin* >::iterator iter = m_plugins.find( config_path );
241 
242  if ( iter != m_plugins.end() )
243  {
244  ConfigEditorPlugin* p = iter->second;
245  m_plugins.erase( iter );
246  delete p;
247  }
248 }
249 
250 void
251 ConfigTreeView::read_config()
252 {
253  if ( !m_config )
254  { return; }
255 
256  m_config_tree->clear();
257 
258  m_config->lock();
260  while ( cit->next() )
261  {
262  if ( cit->is_bool() )
263  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_bool()); }
264  else if ( cit->is_int() )
265  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_int()); }
266  else if ( cit->is_uint() )
267  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_uint()); }
268  else if ( cit->is_float() )
269  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_float()); }
270  else if ( cit->is_string() )
271  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_string()); }
272  }
273 
274  delete cit;
275  m_config->unlock();
276 }
277 
278 
279 /** Add a config entry to the TreeModel storage object.
280  * @param path config path
281  * @param type type of config entry
282  * @param is_default true if config entry is in the default config
283  * @param value the value of the config entry
284  */
285 void
286 ConfigTreeView::set_value(const char* path, const char* type, bool is_default, bool value)
287 {
288  Gtk::TreeModel::Row row;
289  row = *get_iter(path);
290 
291  row[m_config_record.type] = type;
292  row[m_config_record.is_default] = is_default;
293  row[m_config_record.value_bool] = value;
294  row[m_config_record.value_string] = ( value ? "TRUE" : "FALSE" );
295 }
296 
297 /** Add a config entry to the TreeModel storage object.
298  * @param path config path
299  * @param type type of config entry
300  * @param is_default true if config entry is in the default config
301  * @param value the value of the config entry
302  */
303 void
304 ConfigTreeView::set_value(const char* path, const char* type, bool is_default, int value)
305 {
306  Gtk::TreeModel::Row row;
307  row = *get_iter(path);
308 
309  row[m_config_record.type] = type;
310  row[m_config_record.is_default] = is_default;
311  row[m_config_record.value_int] = value;
312 
313  string val_str;
314  stringstream ss;
315  ss << value;
316  ss >> val_str;
317  row[m_config_record.value_string] = val_str;
318 }
319 
320 /** Add a config entry to the TreeModel storage object.
321  * @param path config path
322  * @param type type of config entry
323  * @param is_default true if config entry is in the default config
324  * @param value the value of the config entry
325  */
326 void
327 ConfigTreeView::set_value(const char* path, const char* type, bool is_default, uint value)
328 {
329  Gtk::TreeModel::Row row;
330  row = *get_iter(path);
331 
332  row[m_config_record.type] = type;
333  row[m_config_record.is_default] = is_default;
334  row[m_config_record.value_uint] = value;
335 
336  string val_str;
337  stringstream ss;
338  ss << value;
339  ss >> val_str;
340  row[m_config_record.value_string] = val_str;
341 }
342 
343 /** Add a config entry to the TreeModel storage object.
344  * @param path config path
345  * @param type type of config entry
346  * @param is_default true if config entry is in the default config
347  * @param value the value of the config entry
348  */
349 void
350 ConfigTreeView::set_value(const char* path, const char* type, bool is_default, float value)
351 {
352  Gtk::TreeModel::Row row;
353  row = *get_iter(path);
354 
355  row[m_config_record.type] = type;
356  row[m_config_record.is_default] = is_default;
357  row[m_config_record.value_float] = value;
358 
359  string val_str;
360  stringstream ss;
361  ss << value;
362  ss >> val_str;
363  row[m_config_record.value_string] = val_str;
364 }
365 
366 /** Add a config entry to the TreeModel storage object.
367  * @param path config path
368  * @param type type of config entry
369  * @param is_default true if config entry is in the default config
370  * @param value the value of the config entry
371  */
372 void
373 ConfigTreeView::set_value(const char* path, const char* type, bool is_default, std::string value)
374 {
375  Gtk::TreeModel::Row row;
376  row = *get_iter(path);
377 
378  row[m_config_record.type] = type;
379  row[m_config_record.is_default] = is_default;
380  row[m_config_record.value_string] = value;
381 }
382 
383 Gtk::TreeIter
384 ConfigTreeView::get_iter(const char* p)
385 {
386  char* path;
387  char* full_path;
388 
389  if (asprintf(&full_path, "%s", p) == -1) {
390  throw OutOfMemoryException("get_iter(): asprintf() failed");
391  }
392  char* node = strtok(full_path, "/");
393 
394  if (asprintf(&path, "/%s", node) == -1) {
395  throw OutOfMemoryException("get_iter(): asprintf() failed");
396  }
397 
398  Gtk::TreeModel::Children children = m_config_tree->children();
399  Gtk::TreeIter iter = children.begin();
400 
401  while ( node != NULL )
402  {
403  bool found = false;
404  iter = children.begin();
405 
406  while ( !found && iter != children.end() )
407  {
408  Gtk::TreeModel::Row row = *iter;
409 
410  Glib::ustring r = row[m_config_record.node];
411  if ( strcmp(r.c_str(), node) == 0 )
412  {
413  found = true;
414  children = row.children();
415  iter = children.begin();
416  }
417  else
418  { ++iter; }
419  }
420 
421  if ( !found )
422  {
423  iter = m_config_tree->append(children);
424  Gtk::TreeModel::Row row = *iter;
425  row[m_config_record.node] = Glib::ustring(node);
426  row[m_config_record.path] = Glib::ustring(path);
427 
428  children = row.children();
429  }
430 
431  node = strtok(NULL, "/");
432 
433  char* t;
434  if (asprintf(&t, "%s/%s", path, node) == -1) {
435  throw OutOfMemoryException("get_iter(): asprintf() failed");
436  }
437  free(path);
438  path = t;
439  }
440 
441  free(path);
442  free(full_path);
443 
444  return iter;
445 }
446 
447 Gtk::TreeIter
448 ConfigTreeView::search_path( const char* path )
449 {
450  Gtk::TreeModel::Children children = m_config_tree->children();
451  Gtk::TreeModel::iterator iter = children.begin();
452 
453  while ( iter != children.end() )
454  {
455  Gtk::TreeModel::Row row = *iter;
456  Glib::ustring p = row[ m_config_record.path ];
457  size_t len = strlen( p.c_str() );
458 
459  if ( strncmp( p.c_str(), path, len) == 0 )
460  {
461  if ( strcmp( p.c_str(), path ) == 0 )
462  { return iter; }
463  else
464  { iter = iter->children().begin(); }
465  }
466  else
467  { ++iter; }
468  }
469 
470  return m_config_tree->children().end();
471 }
472 
473 /** Signal handler for the button press event.
474  * @param event a Gdk button event
475  * @return true if signal has been handled, false otherwise
476  */
477 void
479 {
480  if (event->type == GDK_2BUTTON_PRESS)
481  {
482  Gtk::TreeModel::Row row = *( get_selection()->get_selected() );
483  Glib::ustring path = row[ m_config_record.path ];
484 
485  std::map< string, ConfigEditorPlugin* >::iterator i = m_plugins.find( path.c_str() );
486  if ( i != m_plugins.end() )
487  { i->second->run(); }
488  else
489  { edit_entry( get_selection()->get_selected() ); }
490  }
491  else if ( event->type == GDK_BUTTON_PRESS && (event->button == 3) )
492  {
493  //m_menu.popup(event->button, event->time);
494  }
495 }
496 
497 /** Signal handler that is called when the 'edit' entry is selected
498  * from popup menu.
499  */
501 {
502  edit_entry( get_selection()->get_selected() );
503 }
504 
505 /** Signal handler that is called when the 'add' entry is selected
506  * from popup menu.
507  */
508 void
510 {
511  add_entry( get_selection()->get_selected() );
512 }
513 
514 /** Signal handler that is called when the 'remove' entry is selected
515  * from popup menu.
516  */
517 void
519 {
520  remove_entry( get_selection()->get_selected() );
521 }
522 
523 bool
524 ConfigTreeView::edit_entry(const Gtk::TreeIter& iter)
525 {
526  bool ret_val;
527 
528  Gtk::TreeModel::Row row = *iter;
529  Glib::ustring type = row[m_config_record.type];
530 
531  if (type == "") //if type is empty the row is a directory...
532  { ret_val = false; }
533  else
534  {
535  int result;
536  Glib::ustring path = row[m_config_record.path];
537  Glib::ustring value = row[m_config_record.value_string];
538  bool is_default = row[m_config_record.is_default];
539 
540  m_dlg_edit->init(path, type, value);
541  Gtk::Window* parent = dynamic_cast<Gtk::Window*>( get_toplevel() );
542  m_dlg_edit->set_transient_for(*parent);
543  result = m_dlg_edit->run();
544 
545  switch (result)
546  {
547  case Gtk::RESPONSE_OK:
548  {
549  Glib::ustring value = m_dlg_edit->get_value();
550 
551  const char* p = path.c_str();
552  const char* t = type.c_str();
553 
554  is_default = m_dlg_edit->get_is_default();
555  if (is_default) m_config->erase(p);
556 
557  if ( m_config->is_bool(p) )
558  {
559  bool b = false;
560  if (value == "TRUE")
561  { b = true; }
562  else if (value == "FALSE")
563  { b = false; }
564 
565  if (!is_default) m_config->set_bool(p, b);
566  else m_config->set_default_bool(p, b);
567  set_value(p, t, is_default, b);
568  }
569  else if ( m_config->is_int(p) )
570  {
571  int i;
572  i = atoi( value.c_str() );
573 
574  if (!is_default) m_config->set_int(p, i);
575  else m_config->set_default_int(p, i);
576  set_value(p, t, is_default, i);
577  }
578  else if ( m_config->is_uint(p) )
579  {
580  int i;
581  i = atoi( value.c_str() );
582  if ( 0 <= i)
583  {
584  if (!is_default) m_config->set_uint(p, (unsigned int) i);
585  else m_config->set_default_uint( p, (unsigned int) i );
586  set_value(p, t, is_default, (unsigned int) i);
587  }
588  }
589  else if ( m_config->is_float(p) )
590  {
591  float f;
592  f = atof( value.c_str() );
593 
594  if (!is_default) m_config->set_float(p, f);
595  else m_config->set_default_float(p, f);
596  set_value(p, t, is_default, f);
597  }
598  else if ( m_config->is_string(p) )
599  {
600  string s( value.c_str() );
601 
602  if (!is_default) m_config->set_string(p, s);
603  else m_config->set_default_string(p, s);
604  set_value(p, t, is_default, s);
605  }
606 
607  ret_val = true;
608 
609  break;
610  }
611 
612  default:
613  ret_val = false;
614  break;
615  }
616 
617  m_dlg_edit->hide();
618  }
619 
620  return ret_val;
621 }
622 
623 bool
624 ConfigTreeView::remove_entry(const Gtk::TreeIter& iter)
625 {
626  bool ret_val = false;
627  int result;
628  Gtk::TreeModel::Row row = *iter;
629  Glib::ustring type = row[m_config_record.type];
630  bool is_default = row[m_config_record.is_default];
631 
632  if (type == "") //if type is empty the row is a directory -> return
633  { ret_val = false; }
634  else
635  {
636  Glib::ustring path = row[m_config_record.path];
637  m_dlg_remove->init(path, is_default);
638 
639  Gtk::Window* parent = dynamic_cast<Gtk::Window*>( get_toplevel() );
640  m_dlg_remove->set_transient_for(*parent);
641  result = m_dlg_remove->run();
642 
643  switch (result)
644  {
645  case Gtk::RESPONSE_OK:
646  {
647  const char* p = path.c_str();
648  bool rem_default = m_dlg_remove->get_remove_default();
649  m_config->erase(p);
650  if (rem_default) m_config->erase_default(p);
651 
652  Gtk::TreePath tree_path = m_config_tree->get_path(iter);
653  m_config_tree->erase(iter);
654  m_config_tree->row_deleted(tree_path);
655 
657  if (!rem_default && cit->next()) //reenter the default value
658  {
659  if ( cit->is_bool() )
660  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_bool()); }
661  else if ( cit->is_int() )
662  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_int()); }
663  else if ( cit->is_uint() )
664  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_uint()); }
665  else if ( cit->is_float() )
666  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_float()); }
667  else if ( cit->is_string() )
668  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_string()); }
669  }
670 
671  break;
672  }
673 
674  default:
675  ret_val = false;
676  break;
677  }
678 
679  m_dlg_remove->hide();
680  }
681 
682  return ret_val;
683 }
684 
685 bool
686 ConfigTreeView::add_entry(const Gtk::TreeIter& iter)
687 {
688  bool ret_val = false;
689  int result;
690  Gtk::TreeModel::Row row = *iter;
691  Glib::ustring path = row[m_config_record.path];
692 
693  m_dlg_add->init(path);
694 
695  Gtk::Window* parent = dynamic_cast<Gtk::Window*>( get_toplevel() );
696  m_dlg_add->set_transient_for(*parent);
697  result = m_dlg_add->run();
698 
699  switch (result)
700  {
701  case Gtk::RESPONSE_OK:
702  {
703  Glib::ustring type = m_dlg_add->get_type();
704  Glib::ustring path = m_dlg_add->get_path();
705  Glib::ustring value = m_dlg_add->get_value();
706  bool is_default = m_dlg_add->get_is_default();
707 
708  const char* t = type.c_str();
709  const char* p = path.c_str();
710 
711  ret_val = true;
712 
713  if ( type == "bool" )
714  {
715  bool b = false;
716 
717  if ( value == "TRUE" || value == "true" )
718  { b = true; }
719  else if ( value == "FALSE" || value == "false" )
720  { b = false; }
721 
722  if (!is_default) m_config->set_bool(p, b);
723  else m_config->set_default_bool(p, b);
724  set_value(p, t, is_default, b);
725  }
726 
727  else if ( type == "int" )
728  {
729  int i;
730  i = atoi( value.c_str() );
731 
732  if (!is_default) m_config->set_int(p, i);
733  else m_config->set_default_int(p, i);
734  set_value(p, t, is_default, i);
735  }
736 
737  else if ( type == "uint" )
738  {
739  int i;
740  i = atoi( value.c_str() );
741  if ( 0 <= i)
742  {
743  if (!is_default) m_config->set_uint(p, (unsigned int) i);
744  else m_config->set_default_uint( p, (unsigned int) i);
745  set_value(p, t, is_default, (unsigned int) i);
746  }
747  }
748 
749  else if ( type == "float" )
750  {
751  float f;
752  f = atof( value.c_str() );
753 
754  if (!is_default) m_config->set_float(p, f);
755  else m_config->set_default_float(p, f);
756  set_value(p, t, is_default, f);
757  }
758 
759  else if ( type == "string")
760  {
761  string s( value.c_str() );
762 
763  if (!is_default) m_config->set_string(p, s);
764  else m_config->set_default_string(p, s);
765  set_value(p, t, is_default, s);
766  }
767 
768  else
769  {
770  ret_val = false;
771  cout << "Unknown type." << endl;
772  }
773 
774  break;
775  }
776 
777  default:
778  ret_val = false;
779  break;
780  }
781 
782  m_dlg_add->hide();
783 
784  return ret_val;
785 }
void init(const Glib::ustring &path)
Initialize the dialog.
Glib::ustring get_value() const
Get the value of the new entry.
virtual ValueIterator * iterator()=0
Iterator for all values.
Gtk::TreeModelColumn< bool > value_bool
bool config value
virtual void set_default_float(const char *path, float f)=0
Set new default value in configuration of type float.
Simple Fawkes network client.
Definition: client.h:51
virtual bool is_string(const char *path)=0
Check if a value is of type string.
virtual void set_default_int(const char *path, int i)=0
Set new default value in configuration of type int.
bool m_own_config
True if config was created by ConfigTreeView object.
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 const char * type() const =0
Type of value.
Configuration storage using SQLite.
Definition: sqlite.h:39
virtual bool is_bool() const =0
Check if current value is a bool.
virtual void on_menu_add_selected()
Signal handler that is called when the &#39;add&#39; entry is selected from popup menu.
virtual ValueIterator * search(const char *path)=0
Iterator with search results.
Glib::ustring get_path() const
Get the path of the new entry.
virtual bool next()=0
Check if there is another element and advance to this if possible.
virtual float get_float() const =0
Get float value.
virtual void set_int(const char *path, int i)=0
Set new value in configuration of type int.
virtual unsigned int get_uint() const =0
Get unsigned int value.
Gtk::TreeModelColumn< Glib::ustring > value_string
config value as string
virtual bool is_float() const =0
Check if current value is a float.
virtual void set_bool(const char *path, bool b)=0
Set new value in configuration of type bool.
virtual bool is_int() const =0
Check if current value is a int.
Glib::ustring get_value() const
Get the value of the entry widget.
virtual bool get_bool() const =0
Get bool value.
Glib::ustring get_type() const
Get the type of the new entry.
virtual void set_float(const char *path, float f)=0
Set new value in configuration of type float.
virtual ~ConfigTreeView()
Destructor.
Gtk::TreeModelColumn< Glib::ustring > type
config value type
ConfigAddDialog * m_dlg_add
A dialog to add a config entry.
virtual int get_int() const =0
Get int value.
void register_plugin(ConfigEditorPlugin *plugin)
Register a plugin.
virtual bool is_bool(const char *path)=0
Check if a value is of type bool.
bool get_remove_default() const
Get the remove default flag of the entry to be deleted.
void remove_plugin(std::string config_path)
Remove a plugin.
virtual bool is_string() const =0
Check if current value is a string.
virtual void erase_default(const char *path)=0
Erase the given default value from the configuration.
virtual void erase(const char *path)=0
Erase the given value from the configuration.
void initialize()
Initialize the plugin.
virtual void set_default_bool(const char *path, bool b)=0
Set new default value in configuration of type bool.
ConfigEditDialog * m_dlg_edit
A dialog to edit a config entry.
virtual void set_default_uint(const char *path, unsigned int uint)=0
Set new default value in configuration of type unsigned int.
Glib::RefPtr< Gtk::TreeStore > m_config_tree
Storage object.
fawkes::Configuration * m_config
The fawkes::Configuration that is displayed and editted.
virtual bool is_uint() const =0
Check if current value is a unsigned int.
virtual void on_menu_remove_selected()
Signal handler that is called when the &#39;remove&#39; entry is selected from popup menu.
virtual std::string get_string() const =0
Get string value.
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.
virtual void set_mirror_mode(bool mirror)
Enable or disable mirror mode.
Definition: netconf.cpp:1270
virtual const char * path() const =0
Path of value.
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.
virtual bool is_float(const char *path)=0
Check if a value is of type float.
Gtk::TreeModelColumn< Glib::ustring > path
config path
void init(const Glib::ustring &path, const Glib::ustring &type, const Glib::ustring &value)
Initialize the dialog.
virtual void unlock()=0
Unlock the config.
virtual bool is_uint(const char *path)=0
Check if a value is of type unsigned int.
Gtk::TreeModelColumn< int > value_int
int config value
void set_config_file(const char *filename)
Set the file to read the config from.
bool get_is_default() const
Get the default flag of the new entry.
std::string get_config_path() const
Get the config prefix specified for this config editor plugin.
Iterator interface to iterate over config values.
Definition: config.h:68
Gtk::TreeModelColumn< float > value_float
float config value
virtual void on_button_press_event_custom(GdkEventButton *event)
Signal handler for the button press event.
virtual bool is_default() const =0
Check if current value was read from the default config.
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.
void init(const Glib::ustring &path, bool is_default)
Initialize the dialog.
bool get_is_default() const
Get the default flag of the new entry.
virtual void set_default_string(const char *path, std::string &s)=0
Set new default value in configuration of type string.
virtual bool is_int(const char *path)=0
Check if a value is of type int.
ConfigTreeView(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder)
Constructor.
Interface for configuration handling.
Definition: config.h:63
virtual void set_uint(const char *path, unsigned int uint)=0
Set new value in configuration of type unsigned int.
virtual void set_string(const char *path, std::string &s)=0
Set new value in configuration of type string.
System ran out of memory and desired operation could not be fulfilled.
Definition: system.h:32
virtual void lock()=0
Lock the config.
Remote configuration via Fawkes net.
Definition: netconf.h:48