bakery  2.6
AssociationBase.h
Go to the documentation of this file.
1 /*
2  * Copyright 2002 The Bakery team
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_ASSOCIATIONBASE_H
20 #define BAKERY_CONFIGURATION_ASSOCIATIONBASE_H
21 
22 #include <gconfmm.h>
23 #include <gtkmm/widget.h>
25 
26 namespace Bakery
27 {
28 
29 namespace Conf
30 {
31 
34 class AssociationBase : public sigc::trackable
35 {
36 public:
39 
40  void add(const Glib::RefPtr<Gnome::Conf::Client>& conf_client);
41 
42 #ifdef GLIBMM_EXCEPTIONS_ENABLED
43  void load();
44  void save();
45 #else
46  // TODO: Ignore errors in these functions?
47  void load(std::auto_ptr<Glib::Error>& error);
48  void save(std::auto_ptr<Glib::Error>& error);
49 #endif
50 
51  virtual ~AssociationBase();
52 
53 protected:
54  AssociationBase(const Glib::ustring& full_key, bool instant);
55  AssociationBase(const AssociationBase& other); // Not implemented
56 
57 
58  bool is_instant() const;
59  Glib::ustring get_key() const;
60  Glib::RefPtr<const Gnome::Conf::Client> get_conf_client() const;
61  Glib::RefPtr<Gnome::Conf::Client> get_conf_client();
62 
63  typedef sigc::slot<void> Callback;
64  virtual void connect_widget(Callback on_widget_changed) = 0;
65 
66 #ifdef GLIBMM_EXCEPTIONS_ENABLED
67  virtual void load_widget() = 0;
68  virtual void save_widget() = 0;
69 #else
70  virtual void load_widget(std::auto_ptr<Glib::Error>& error) = 0;
71  virtual void save_widget(std::auto_ptr<Glib::Error>& error) = 0;
72 #endif
73 
74  void on_widget_changed();
75  void on_conf_changed(guint cnxn_id, Gnome::Conf::Entry entry);
76 
77  Glib::ustring m_key;
78  bool m_instant;
79  Glib::RefPtr<Gnome::Conf::Client> m_conf_client;
80 };
81 
82 } //namespace Conf
83 
84 } //namespace Bakery
85 
86 #endif //BAKERY_CONFIGURATION_ASSOCIATIONBASE_H