client.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _GCONFMM_CLIENT_H
00004 #define _GCONFMM_CLIENT_H
00005 
00006 
00007 #include <glibmm.h>
00008 
00009 // -*- Mode: C++; c-basic-offset: 4 -*-
00010 /* $Id: client.hg,v 1.25 2005/03/03 13:17:47 murrayc Exp $ */
00011 
00012 /* client.hg
00013  * 
00014  * Copyright (C) 2000-2002 GConfmm Development Team
00015  *
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Library General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2 of the License, or (at your option) any later version.
00020  *
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Library General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU Library General Public
00027  * License along with this library; if not, write to the Free
00028  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00029  */
00030 
00031 #include <gconf/gconf-client.h>
00032 
00033 #include <glibmm/object.h>
00034 
00035 #include <glibmm/error.h>
00036 #include <gconfmm/value.h>
00037 #include <gconfmm/callback.h>
00038 #include <gconfmm/entry.h>
00039 #include <gconfmm/schema.h>
00040 #include <gconfmm/setinterface.h>
00041 #include <gconfmm/changeset.h>
00042 
00043 
00044 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00045 typedef struct _GConfClient GConfClient;
00046 typedef struct _GConfClientClass GConfClientClass;
00047 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00048 
00049 
00050 namespace Gnome
00051 {
00052 
00053 namespace Conf
00054 { class Client_Class; } // namespace Conf
00055 
00056 } // namespace Gnome
00057 namespace Gnome
00058 {
00059 namespace Conf
00060 {
00061 
00067 enum ClientErrorHandlingMode
00068 {
00069   CLIENT_HANDLE_NONE,
00070   CLIENT_HANDLE_UNRETURNED,
00071   CLIENT_HANDLE_ALL
00072 };
00073 
00074 } // namespace Conf
00075 
00076 } // namespace Gnome
00077 
00078 
00079 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00080 namespace Glib
00081 {
00082 
00083 template <>
00084 class Value<Gnome::Conf::ClientErrorHandlingMode> : public Glib::Value_Enum<Gnome::Conf::ClientErrorHandlingMode>
00085 {
00086 public:
00087   static GType value_type() G_GNUC_CONST;
00088 };
00089 
00090 } // namespace Glib
00091 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00092 
00093 
00094 namespace Gnome
00095 {
00096 
00097 namespace Conf
00098 {
00099 
00103 enum ClientPreloadType
00104 {
00105   CLIENT_PRELOAD_NONE,
00106   CLIENT_PRELOAD_ONELEVEL,
00107   CLIENT_PRELOAD_RECURSIVE
00108 };
00109 
00110 } // namespace Conf
00111 
00112 } // namespace Gnome
00113 
00114 
00115 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00116 namespace Glib
00117 {
00118 
00119 template <>
00120 class Value<Gnome::Conf::ClientPreloadType> : public Glib::Value_Enum<Gnome::Conf::ClientPreloadType>
00121 {
00122 public:
00123   static GType value_type() G_GNUC_CONST;
00124 };
00125 
00126 } // namespace Glib
00127 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00128 
00129 
00130 namespace Gnome
00131 {
00132 
00133 namespace Conf
00134 {
00135 
00136 
00139 class Error : public Glib::Error
00140 {
00141 public:
00142   enum Code
00143   {
00144     SUCCESS = 0,
00145     NO_SERVER = 2,
00146     NO_PERMISSION = 3,
00147     BAD_ADDRESS = 4,
00148     PARSE_ERROR = 6,
00149     CORRUPT = 7,
00150     TYPE_MISMATCH = 8,
00151     IS_DIR = 9,
00152     IS_KEY = 10,
00153     OVERRIDDEN = 11,
00154     OAF_ERROR = 12,
00155     LOCAL_ENGINE = 13,
00156     LOCK_FAILED = 14,
00157     NO_WRITABLE_DATABASE = 15,
00158     IN_SHUTDOWN = 16
00159   };
00160 
00161   Error(Code error_code, const Glib::ustring& error_message);
00162   explicit Error(GError* gobject);
00163   Code code() const;
00164 
00165 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00166 private:
00167   static void throw_func(GError* gobject);
00168   friend void wrap_init(); // uses throw_func()
00169 #endif
00170 };
00171 
00172 } // namespace Conf
00173 
00174 } // namespace Gnome
00175 
00176 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00177 namespace Glib
00178 {
00179 
00180 template <>
00181 class Value<Gnome::Conf::Error::Code> : public Glib::Value_Enum<Gnome::Conf::Error::Code>
00182 {
00183 public:
00184   static GType value_type() G_GNUC_CONST;
00185 };
00186 
00187 } // namespace Glib
00188 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00189 
00190 
00191 namespace Gnome
00192 {
00193 
00194 namespace Conf
00195 {
00196 
00197 
00198 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00199 template <typename T>
00200 struct BasicTypeTraits 
00201 {
00202   typedef T CppType;
00203   typedef CppType* CType;
00204   typedef CppType* CTypeNonConst;
00205 
00206   static CType to_c_type(CppType val)
00207   {
00208     CType pVal = new CppType;
00209     *pVal = val;
00210     return pVal;
00211   }
00212 
00213   static CType to_c_type(CType ptr)
00214   { return ptr; } 
00215   
00216   static CppType to_cpp_type(CType ptr)
00217   {
00218     if(ptr)
00219     {
00220       return *ptr;
00221     }
00222     else
00223       return CppType();
00224   }
00225   
00226   static void release_c_type(CType ptr)
00227   {
00228     if(ptr)
00229       delete ptr;
00230   }
00231 };
00232 
00233 
00234 //Template specialization:
00235 template <>
00236 struct BasicTypeTraits<int> 
00237 {
00238   typedef int CppType;
00239   typedef CppType* CType;
00240   typedef CppType* CTypeNonConst;
00241 
00242   static CType to_c_type(CppType val)
00243   { return (int*)GINT_TO_POINTER(val); }
00244 
00245   static CType to_c_type(CType ptr)
00246   { return ptr; } 
00247   
00248   static CppType to_cpp_type(CType ptr)
00249   {
00250     if(ptr)
00251     {
00252       return GPOINTER_TO_INT(ptr);
00253     }
00254     else
00255       return CppType();
00256   }
00257   
00258   static void release_c_type(CType /* ptr */)
00259   {
00260   }
00261 };
00262 
00263 template <>
00264 struct BasicTypeTraits<bool> 
00265 {
00266   typedef bool CppType;
00267   typedef gboolean* CType;
00268   typedef gboolean* CTypeNonConst;
00269 
00270   static CType to_c_type(CppType val)
00271   {
00272     return (int*)GINT_TO_POINTER(val);
00273   }
00274 
00275   static CType to_c_type(CType ptr)
00276   { return ptr; } 
00277   
00278   static CppType to_cpp_type(CType ptr)
00279   {
00280     if(ptr)
00281     {
00282       //We use this for gboolean too, because it is actually an int.
00283       return GPOINTER_TO_INT(ptr);
00284     }
00285     else
00286       return CppType();
00287   }
00288   
00289   static void release_c_type(CType /* ptr */)
00290   {
00291 
00292   }
00293 };
00294 
00295 #endif //DOXYGEN_SHOULD_SKIP_THIS
00296 
00297 
00308 class Client : public Glib::Object, public SetInterface
00309 {
00310     
00311 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00312 
00313 public:
00314   typedef Client CppObjectType;
00315   typedef Client_Class CppClassType;
00316   typedef GConfClient BaseObjectType;
00317   typedef GConfClientClass BaseClassType;
00318 
00319 private:  friend class Client_Class;
00320   static CppClassType client_class_;
00321 
00322 private:
00323   // noncopyable
00324   Client(const Client&);
00325   Client& operator=(const Client&);
00326 
00327 protected:
00328   explicit Client(const Glib::ConstructParams& construct_params);
00329   explicit Client(GConfClient* castitem);
00330 
00331 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00332 
00333 public:
00334   virtual ~Client();
00335 
00336 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00337   static GType get_type()      G_GNUC_CONST;
00338   static GType get_base_type() G_GNUC_CONST;
00339 #endif
00340 
00342   GConfClient*       gobj()       { return reinterpret_cast<GConfClient*>(gobject_); }
00343 
00345   const GConfClient* gobj() const { return reinterpret_cast<GConfClient*>(gobject_); }
00346 
00348   GConfClient* gobj_copy();
00349 
00350 private:
00351 
00352     
00353 public:
00354     
00358     static Glib::RefPtr<Client> get_default_client();
00359     static Glib::RefPtr<Client> get_client_for_engine(GConfEngine* engine);
00360     
00374   void add_dir(const Glib::ustring& dir, ClientPreloadType preload = CLIENT_PRELOAD_NONE);
00375 
00379   void remove_dir(const Glib::ustring& dir);
00380 
00381     // API-TODO: Should this return a Connection ?
00400     guint notify_add(const Glib::ustring& namespace_section, Callback callback);
00401     
00402     
00408   void notify_remove(guint cnxn);
00409     
00410     
00411   void set_error_handling(ClientErrorHandlingMode mode);
00412     
00415   void clear_cache();
00416     
00423   void preload(const Glib::ustring& dirname, ClientPreloadType type);
00424     
00431   Value get(const Glib::ustring& key) const;
00432 
00441   Value get_without_default(const Glib::ustring& key) const;
00442 
00449   Value get_default_from_schema(const Glib::ustring& key) const;
00450 
00459     Entry get_entry(const Glib::ustring& key, bool use_schema_default = true) const;
00460       
00470   Entry get_entry(const Glib::ustring& key, const char* locale, bool use_schema_default = true) const;
00471     
00477   void unset(const Glib::ustring& key);
00478     
00486   Glib::SListHandle<Entry> all_entries(const Glib::ustring& dir) const;
00487 
00494   Glib::SListHandle<Glib::ustring> all_dirs(const Glib::ustring& dir) const;
00495     
00501   void suggest_sync();
00502 
00508   bool dir_exists(const Glib::ustring&) const;
00509 
00515   bool key_is_writable(const Glib::ustring&) const;
00516     
00524   double get_float(const Glib::ustring& key) const;
00525 
00529   gint get_int(const Glib::ustring& key) const;
00530 
00534   bool get_bool(const Glib::ustring& key) const;
00535 
00539   Glib::ustring get_string(const Glib::ustring& key) const;
00540 
00544   Schema get_schema(const Glib::ustring& key) const;
00545 
00553     SListHandle_ValueInt    get_int_list(const Glib::ustring& key) const;
00554 
00557     SListHandle_ValueBool   get_bool_list(const Glib::ustring& key) const;
00558 
00561     SListHandle_ValueFloat  get_float_list(const Glib::ustring& key) const;
00562 
00565     SListHandle_ValueSchema get_schema_list(const Glib::ustring& key) const;
00566 
00569     SListHandle_ValueString get_string_list(const Glib::ustring& key) const;
00570     
00571     
00580     ValuePair get_pair(const Glib::ustring& key, ValueTypePair types) const;
00581     
00582     
00589   void set(const Glib::ustring& key, int what);
00590 
00594   void set(const Glib::ustring& key, bool what);
00595 
00599   void set(const Glib::ustring& key,double what);
00600 
00604   void set(const Glib::ustring& key, const Glib::ustring& what);
00605 
00609   void set(const Glib::ustring& key, const Schema& what);
00610 
00615   void set(const Glib::ustring& key, const Value& what);
00616     
00617 
00618     typedef Glib::SListHandle< int, BasicTypeTraits<int> > SListHandleInts;
00619     void set_int_list(const Glib::ustring& key, const SListHandleInts& what);
00620     
00621     typedef Glib::SListHandle< bool, BasicTypeTraits<bool> > SListHandleBools;
00622     void set_bool_list(const Glib::ustring& key, const SListHandleBools& what);
00623     
00624     typedef Glib::SListHandle< double, BasicTypeTraits<double> > SListHandleFloats;
00625     void set_float_list(const Glib::ustring& key, const SListHandleFloats& what);
00626     
00627     void set_schema_list(const Glib::ustring& key, const Glib::SListHandle<Schema>& what);
00628     void set_string_list(const Glib::ustring& key, const Glib::SListHandle<Glib::ustring>& what);
00629     
00639   ChangeSet change_set_from_current(const Glib::SArray& set);
00640     
00641 
00653   void change_set_commit(ChangeSet& set, bool remove_commited);
00654 
00666   ChangeSet change_set_reverse(const ChangeSet& set);
00667 
00673   Glib::SignalProxy2< void,const Glib::ustring&,const Value& > signal_value_changed();
00674 
00675     
00676   void value_changed(const Glib::ustring& key, const Value& value);
00677 
00678 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00679     // unreturned_error will never be called, as gconfmm
00680     // catches all GError's and throw()s them as Gnome::Conf::Error's.
00681     
00682 
00683   Glib::SignalProxy1< void,const Glib::Error& > signal_unreturned_error();
00684 
00685     
00686   void unreturned_error(const Glib::Error& error);
00687 #endif
00688 
00694   Glib::SignalProxy1< void,const Glib::Error& > signal_error();
00695 
00696     
00697   void error(const Glib::Error& error);
00698     
00699 private:
00700     void handle_error(GError* pError) const;
00701     
00702     GSList* get_list(const Glib::ustring& key, GConfValueType list_type) const;
00703 
00704 
00705 public:
00706 
00707 public:
00708   //C++ methods used to invoke GTK+ virtual functions:
00709 
00710 protected:
00711   //GTK+ Virtual Functions (override these to change behaviour):
00712 
00713   //Default Signal Handlers::
00714   virtual void on_value_changed(const Glib::ustring& key, const Value& value);
00715   virtual void on_unreturned_error(const Glib::Error& error);
00716   virtual void on_error(const Glib::Error& error);
00717 
00718 
00719 };
00720 
00721 } /* namespace Conf */
00722 } /* namespace Gnome */
00723 
00724 
00725 namespace Glib
00726 {
00732   Glib::RefPtr<Gnome::Conf::Client> wrap(GConfClient* object, bool take_copy = false);
00733 }
00734 
00735 
00736 #endif /* _GCONFMM_CLIENT_H */
00737 

Generated on Fri Mar 17 08:33:16 2006 for gconfmm by  doxygen 1.4.6