00001 /* 00002 * Copyright 2002 The Bakery team 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this library; if not, write to the Free 00016 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef BAKERY_CONFIGURATION_ASSOCIATIONBASE_H 00020 #define BAKERY_CONFIGURATION_ASSOCIATIONBASE_H 00021 00022 #include <gconfmm.h> 00023 #include <gtkmm/widget.h> 00024 #include <bakery/Utilities/sharedptr.h> 00025 00026 namespace Bakery 00027 { 00028 00029 namespace Conf 00030 { 00031 00034 class AssociationBase : public sigc::trackable 00035 { 00036 public: 00037 typedef sharedptr<AssociationBase> AssociationPtr; 00038 typedef sharedptr<const AssociationBase> AssociationConstPtr; 00039 00040 void add(const Glib::RefPtr<Gnome::Conf::Client>& conf_client); 00041 00042 #ifdef GLIBMM_EXCEPTIONS_ENABLED 00043 void load(); 00044 void save(); 00045 #else 00046 // TODO: Ignore errors in these functions? 00047 void load(std::auto_ptr<Glib::Error>& error); 00048 void save(std::auto_ptr<Glib::Error>& error); 00049 #endif 00050 00051 virtual ~AssociationBase(); 00052 00053 protected: 00054 AssociationBase(const Glib::ustring& full_key, bool instant); 00055 AssociationBase(const AssociationBase& other); // Not implemented 00056 00057 00058 bool is_instant() const; 00059 Glib::ustring get_key() const; 00060 Glib::RefPtr<const Gnome::Conf::Client> get_conf_client() const; 00061 Glib::RefPtr<Gnome::Conf::Client> get_conf_client(); 00062 00063 typedef sigc::slot<void> Callback; 00064 virtual void connect_widget(Callback on_widget_changed) = 0; 00065 00066 #ifdef GLIBMM_EXCEPTIONS_ENABLED 00067 virtual void load_widget() = 0; 00068 virtual void save_widget() = 0; 00069 #else 00070 virtual void load_widget(std::auto_ptr<Glib::Error>& error) = 0; 00071 virtual void save_widget(std::auto_ptr<Glib::Error>& error) = 0; 00072 #endif 00073 00074 void on_widget_changed(); 00075 void on_conf_changed(guint cnxn_id, Gnome::Conf::Entry entry); 00076 00077 Glib::ustring m_key; 00078 bool m_instant; 00079 Glib::RefPtr<Gnome::Conf::Client> m_conf_client; 00080 }; 00081 00082 } //namespace Conf 00083 00084 } //namespace Bakery 00085 00086 #endif //BAKERY_CONFIGURATION_ASSOCIATIONBASE_H