bakery  2.6
Client.h
Go to the documentation of this file.
1 /*
2  * Copyright 2002 Murray Cumming
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 #ifndef BAKERY_CONFIGURATION_CONFCLIENT_H
20 #define BAKERY_CONFIGURATION_CONFCLIENT_H
21 
23 
24 namespace Bakery
25 {
26 
27 namespace Conf
28 {
29 
50 class Client : public sigc::trackable
51 {
52 public:
53  Client(const Glib::ustring& configuration_directory);
54  virtual ~Client();
55 
56 #ifdef GLIBMM_EXCEPTIONS_ENABLED
57  virtual void load();
58  virtual void save();
59 #else
60  virtual void load(std::auto_ptr<Glib::Error>& error);
61  virtual void save(std::auto_ptr<Glib::Error>& error);
62 #endif
63 
65  virtual void add(const Glib::ustring& key, Gtk::Widget& widget);
66  virtual void add_instant(const Glib::ustring& key, Gtk::Widget& widget);
67 
68 protected:
69 
75  virtual void add_implementation(const Glib::ustring& key, Gtk::Widget& widget, bool instant);
76 
78 
79 public:
80 
81 protected:
82  template< class T_Widget >
83  void add_association(const Glib::ustring& key, T_Widget& widget, bool instant)
84  {
85  Glib::ustring full_key = m_directory + "/" + key;
86  AssociationPtr assoc = Association<T_Widget>::create(full_key, widget, instant);
87  m_vecWidgets.push_back(assoc);
88  assoc->add(m_refClient);
89  }
90 
91 private:
92  Glib::RefPtr<Gnome::Conf::Client> m_refClient;
93  Glib::ustring m_directory;
94 
95  typedef std::vector<AssociationPtr> type_vecWidgets;
96  type_vecWidgets m_vecWidgets;
97 };
98 
99 } //namespace Conf
100 
101 } //namespace Bakery
102 
103 
104 #endif //BAKERY_CONFIGURATION_CONFCLIENT_H
virtual void save(std::auto_ptr< Glib::Error > &error)
virtual void add_instant(const Glib::ustring &key, Gtk::Widget &widget)
virtual void add_implementation(const Glib::ustring &key, Gtk::Widget &widget, bool instant)
Override this method to add recognition of additional widget types to a derived class of Client...
virtual void add(const Glib::ustring &key, Gtk::Widget &widget)
e.g. conf_client.add("user_name", m_EntryUserName);
Bakery::Conf::AssociationBase::AssociationPtr AssociationPtr
Definition: Client.h:77
Definition: App.h:29
Client(const Glib::ustring &configuration_directory)
virtual void load(std::auto_ptr< Glib::Error > &error)
static const AssociationPtr create(const Glib::ustring &full_key, T_Widget &widget, bool instant)
Definition: Association.h:42
void add_association(const Glib::ustring &key, T_Widget &widget, bool instant)
Definition: Client.h:83
A shared reference-counting smart-pointer.
Definition: sharedptr.h:31
Configuration Client Allows you to associate widget "values" with configuration keys, and then load() and save() them all at once.
Definition: Client.h:50