gconfmm  2.28.0
client.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GCONFMM_CLIENT_H
4 #define _GCONFMM_CLIENT_H
5 
6 
7 #include <glibmm.h>
8 
9 // -*- Mode: C++; c-basic-offset: 4 -*-
10 /* $Id: client.hg,v 1.25 2005/03/03 13:17:47 murrayc Exp $ */
11 
12 /* client.hg
13  *
14  * Copyright (C) 2000-2002 GConfmm Development Team
15  *
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2.1 of the License, or (at your option) any later version.
20  *
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  * Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public
27  * License along with this library; if not, write to the Free
28  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29  */
30 
31 #include <gconf/gconf-client.h>
32 
33 #include <glibmm/object.h>
34 
35 #include <glibmm/error.h>
36 #include <gconfmm/value.h>
37 #include <gconfmm/callback.h>
38 #include <gconfmm/entry.h>
39 #include <gconfmm/schema.h>
40 #include <gconfmm/setinterface.h>
41 #include <gconfmm/changeset.h>
42 
43 
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 typedef struct _GConfClient GConfClient;
46 typedef struct _GConfClientClass GConfClientClass;
47 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
48 
49 
50 namespace Gnome
51 {
52 
53 namespace Conf
54 { class Client_Class; } // namespace Conf
55 
56 } // namespace Gnome
57 namespace Gnome
58 {
59 namespace Conf
60 {
61 
68 {
72 };
73 
74 } // namespace Conf
75 
76 } // namespace Gnome
77 
78 
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80 namespace Glib
81 {
82 
83 template <>
84 class Value<Gnome::Conf::ClientErrorHandlingMode> : public Glib::Value_Enum<Gnome::Conf::ClientErrorHandlingMode>
85 {
86 public:
87  static GType value_type() G_GNUC_CONST;
88 };
89 
90 } // namespace Glib
91 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
92 
93 
94 namespace Gnome
95 {
96 
97 namespace Conf
98 {
99 
104 {
108 };
109 
110 } // namespace Conf
111 
112 } // namespace Gnome
113 
114 
115 #ifndef DOXYGEN_SHOULD_SKIP_THIS
116 namespace Glib
117 {
118 
119 template <>
120 class Value<Gnome::Conf::ClientPreloadType> : public Glib::Value_Enum<Gnome::Conf::ClientPreloadType>
121 {
122 public:
123  static GType value_type() G_GNUC_CONST;
124 };
125 
126 } // namespace Glib
127 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
128 
129 
130 namespace Gnome
131 {
132 
133 namespace Conf
134 {
135 
136 
139 class Error : public Glib::Error
140 {
141 public:
142  enum Code
143  {
144  SUCCESS = 0,
149  CORRUPT = 7,
151  IS_DIR = 9,
152  IS_KEY = 10,
154  OAF_ERROR = 12,
159  };
160 
161  Error(Code error_code, const Glib::ustring& error_message);
162  explicit Error(GError* gobject);
163  Code code() const;
164 
165 #ifndef DOXYGEN_SHOULD_SKIP_THIS
166 private:
167 
168 #ifdef GLIBMM_EXCEPTIONS_ENABLED
169  static void throw_func(GError* gobject);
170 #else
171  //When not using exceptions, we just pass the Exception object around without throwing it:
172  static std::auto_ptr<Glib::Error> throw_func(GError* gobject);
173 #endif //GLIBMM_EXCEPTIONS_ENABLED
174 
175  friend void wrap_init(); // uses throw_func()
176 #endif
177 };
178 
179 } // namespace Conf
180 
181 } // namespace Gnome
182 
183 #ifndef DOXYGEN_SHOULD_SKIP_THIS
184 namespace Glib
185 {
186 
187 template <>
188 class Value<Gnome::Conf::Error::Code> : public Glib::Value_Enum<Gnome::Conf::Error::Code>
189 {
190 public:
191  static GType value_type() G_GNUC_CONST;
192 };
193 
194 } // namespace Glib
195 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
196 
197 
198 namespace Gnome
199 {
200 
201 namespace Conf
202 {
203 
204 
205 #ifndef DOXYGEN_SHOULD_SKIP_THIS
206 template <typename T>
207 struct BasicTypeTraits
208 {
209  typedef T CppType;
210  typedef CppType* CType;
211  typedef CppType* CTypeNonConst;
212 
213  static CType to_c_type(CppType val)
214  {
215  CType pVal = new CppType;
216  *pVal = val;
217  return pVal;
218  }
219 
220  static CType to_c_type(CType ptr)
221  { return ptr; }
222 
223  static CppType to_cpp_type(CType ptr)
224  {
225  if(ptr)
226  {
227  return *ptr;
228  }
229  else
230  return CppType();
231  }
232 
233  static void release_c_type(CType ptr)
234  {
235  if(ptr)
236  delete ptr;
237  }
238 };
239 
240 
241 //Template specialization:
242 template <>
243 struct BasicTypeTraits<int>
244 {
245  typedef int CppType;
246  typedef CppType* CType;
247  typedef CppType* CTypeNonConst;
248 
249  static CType to_c_type(CppType val)
250  { return (int*)GINT_TO_POINTER(val); }
251 
252  static CType to_c_type(CType ptr)
253  { return ptr; }
254 
255  static CppType to_cpp_type(CType ptr)
256  {
257  if(ptr)
258  {
259  return GPOINTER_TO_INT(ptr);
260  }
261  else
262  return CppType();
263  }
264 
265  static void release_c_type(CType /* ptr */)
266  {
267  }
268 };
269 
270 template <>
271 struct BasicTypeTraits<bool>
272 {
273  typedef bool CppType;
274  typedef gboolean* CType;
275  typedef gboolean* CTypeNonConst;
276 
277  static CType to_c_type(CppType val)
278  {
279  return (int*)GINT_TO_POINTER(val);
280  }
281 
282  static CType to_c_type(CType ptr)
283  { return ptr; }
284 
285  static CppType to_cpp_type(CType ptr)
286  {
287  if(ptr)
288  {
289  //We use this for gboolean too, because it is actually an int.
290  return GPOINTER_TO_INT(ptr);
291  }
292  else
293  return CppType();
294  }
295 
296  static void release_c_type(CType /* ptr */)
297  {
298 
299  }
300 };
301 
302 #endif //DOXYGEN_SHOULD_SKIP_THIS
303 
304 
315 class Client : public Glib::Object, public SetInterface
316 {
317 
318 #ifndef DOXYGEN_SHOULD_SKIP_THIS
319 
320 public:
321  typedef Client CppObjectType;
322  typedef Client_Class CppClassType;
323  typedef GConfClient BaseObjectType;
324  typedef GConfClientClass BaseClassType;
325 
326 private: friend class Client_Class;
327  static CppClassType client_class_;
328 
329 private:
330  // noncopyable
331  Client(const Client&);
332  Client& operator=(const Client&);
333 
334 protected:
335  explicit Client(const Glib::ConstructParams& construct_params);
336  explicit Client(GConfClient* castitem);
337 
338 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
339 
340 public:
341  virtual ~Client();
342 
343 #ifndef DOXYGEN_SHOULD_SKIP_THIS
344  static GType get_type() G_GNUC_CONST;
345 
346 
347  static GType get_base_type() G_GNUC_CONST;
348 #endif
349 
351  GConfClient* gobj() { return reinterpret_cast<GConfClient*>(gobject_); }
352 
354  const GConfClient* gobj() const { return reinterpret_cast<GConfClient*>(gobject_); }
355 
357  GConfClient* gobj_copy();
358 
359 private:
360 
361 
362 public:
363 
367  static Glib::RefPtr<Client> get_default_client();
368  static Glib::RefPtr<Client> get_client_for_engine(GConfEngine* engine);
369 
383 #ifdef GLIBMM_EXCEPTIONS_ENABLED
384  void add_dir(const Glib::ustring& dir, ClientPreloadType preload = CLIENT_PRELOAD_NONE);
385 #else
386  void add_dir(const Glib::ustring& dir, ClientPreloadType preload, std::auto_ptr<Glib::Error>& error);
387 #endif //GLIBMM_EXCEPTIONS_ENABLED
388 
389 
393 #ifdef GLIBMM_EXCEPTIONS_ENABLED
394  void remove_dir(const Glib::ustring& dir);
395 #else
396  void remove_dir(const Glib::ustring& dir, std::auto_ptr<Glib::Error>& error);
397 #endif //GLIBMM_EXCEPTIONS_ENABLED
398 
399 
400  // API-TODO: Should this return a Connection ?
419  guint notify_add(const Glib::ustring& namespace_section, Callback callback);
420 
421 
427 #ifdef GLIBMM_EXCEPTIONS_ENABLED
428  void notify_remove(guint cnxn);
429 #else
430  void notify_remove(guint cnxn, std::auto_ptr<Glib::Error>& error);
431 #endif //GLIBMM_EXCEPTIONS_ENABLED
432 
433 
440  void notify(const Glib::ustring& key);
441 
442 
443  void set_error_handling(ClientErrorHandlingMode mode);
444 
447  void clear_cache();
448 
455 #ifdef GLIBMM_EXCEPTIONS_ENABLED
456  void preload(const Glib::ustring& dirname, ClientPreloadType type);
457 #else
458  void preload(const Glib::ustring& dirname, ClientPreloadType type, std::auto_ptr<Glib::Error>& error);
459 #endif //GLIBMM_EXCEPTIONS_ENABLED
460 
461 
468 #ifdef GLIBMM_EXCEPTIONS_ENABLED
469  Value get(const Glib::ustring& key) const;
470 #else
471  Value get(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
472 #endif //GLIBMM_EXCEPTIONS_ENABLED
473 
474 
483 #ifdef GLIBMM_EXCEPTIONS_ENABLED
484  Value get_without_default(const Glib::ustring& key) const;
485 #else
486  Value get_without_default(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
487 #endif //GLIBMM_EXCEPTIONS_ENABLED
488 
489 
496 #ifdef GLIBMM_EXCEPTIONS_ENABLED
497  Value get_default_from_schema(const Glib::ustring& key) const;
498 #else
499  Value get_default_from_schema(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
500 #endif //GLIBMM_EXCEPTIONS_ENABLED
501 
502 
511  Entry get_entry(const Glib::ustring& key, bool use_schema_default = true) const;
512 
522 #ifdef GLIBMM_EXCEPTIONS_ENABLED
523  Entry get_entry(const Glib::ustring& key, const char* locale, bool use_schema_default = true) const;
524 #else
525  Entry get_entry(const Glib::ustring& key, const char* locale, bool use_schema_default, std::auto_ptr<Glib::Error>& error) const;
526 #endif //GLIBMM_EXCEPTIONS_ENABLED
527 
528 
534 #ifdef GLIBMM_EXCEPTIONS_ENABLED
535  void unset(const Glib::ustring& key);
536 #else
537  void unset(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error);
538 #endif //GLIBMM_EXCEPTIONS_ENABLED
539 
540 
550 #ifdef GLIBMM_EXCEPTIONS_ENABLED
551  void recursive_unset(const Glib::ustring& key, UnsetFlags flags = UNSET_INCLUDING_SCHEMA_NAMES);
552 #else
553  void recursive_unset(const Glib::ustring& key, UnsetFlags flags, std::auto_ptr<Glib::Error>& error);
554 #endif //GLIBMM_EXCEPTIONS_ENABLED
555 
556 
564 #ifdef GLIBMM_EXCEPTIONS_ENABLED
565  Glib::SListHandle<Entry> all_entries(const Glib::ustring& dir) const;
566 #else
567  Glib::SListHandle<Entry> all_entries(const Glib::ustring& dir, std::auto_ptr<Glib::Error>& error) const;
568 #endif //GLIBMM_EXCEPTIONS_ENABLED
569 
570 
577 #ifdef GLIBMM_EXCEPTIONS_ENABLED
578  Glib::SListHandle<Glib::ustring> all_dirs(const Glib::ustring& dir) const;
579 #else
580  Glib::SListHandle<Glib::ustring> all_dirs(const Glib::ustring& dir, std::auto_ptr<Glib::Error>& error) const;
581 #endif //GLIBMM_EXCEPTIONS_ENABLED
582 
583 
589 #ifdef GLIBMM_EXCEPTIONS_ENABLED
590  void suggest_sync();
591 #else
592  void suggest_sync(std::auto_ptr<Glib::Error>& error);
593 #endif //GLIBMM_EXCEPTIONS_ENABLED
594 
595 
601 #ifdef GLIBMM_EXCEPTIONS_ENABLED
602  bool dir_exists(const Glib::ustring&) const;
603 #else
604  bool dir_exists(const Glib::ustring& p1, std::auto_ptr<Glib::Error>& error) const;
605 #endif //GLIBMM_EXCEPTIONS_ENABLED
606 
607 
613 #ifdef GLIBMM_EXCEPTIONS_ENABLED
614  bool key_is_writable(const Glib::ustring&) const;
615 #else
616  bool key_is_writable(const Glib::ustring& p1, std::auto_ptr<Glib::Error>& error) const;
617 #endif //GLIBMM_EXCEPTIONS_ENABLED
618 
619 
627 #ifdef GLIBMM_EXCEPTIONS_ENABLED
628  double get_float(const Glib::ustring& key) const;
629 #else
630  double get_float(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
631 #endif //GLIBMM_EXCEPTIONS_ENABLED
632 
633 
637 #ifdef GLIBMM_EXCEPTIONS_ENABLED
638  gint get_int(const Glib::ustring& key) const;
639 #else
640  gint get_int(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
641 #endif //GLIBMM_EXCEPTIONS_ENABLED
642 
643 
647 #ifdef GLIBMM_EXCEPTIONS_ENABLED
648  bool get_bool(const Glib::ustring& key) const;
649 #else
650  bool get_bool(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
651 #endif //GLIBMM_EXCEPTIONS_ENABLED
652 
653 
657 #ifdef GLIBMM_EXCEPTIONS_ENABLED
658  Glib::ustring get_string(const Glib::ustring& key) const;
659 #else
660  Glib::ustring get_string(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
661 #endif //GLIBMM_EXCEPTIONS_ENABLED
662 
663 
667 #ifdef GLIBMM_EXCEPTIONS_ENABLED
668  Schema get_schema(const Glib::ustring& key) const;
669 #else
670  Schema get_schema(const Glib::ustring& key, std::auto_ptr<Glib::Error>& error) const;
671 #endif //GLIBMM_EXCEPTIONS_ENABLED
672 
673 
681  SListHandle_ValueInt get_int_list(const Glib::ustring& key) const;
682 
685  SListHandle_ValueBool get_bool_list(const Glib::ustring& key) const;
686 
689  SListHandle_ValueFloat get_float_list(const Glib::ustring& key) const;
690 
693  SListHandle_ValueSchema get_schema_list(const Glib::ustring& key) const;
694 
697  SListHandle_ValueString get_string_list(const Glib::ustring& key) const;
698 
699 
708  ValuePair get_pair(const Glib::ustring& key, ValueTypePair types) const;
709 
710 
717 #ifdef GLIBMM_EXCEPTIONS_ENABLED
718  void set(const Glib::ustring& key, int what);
719 #else
720  void set(const Glib::ustring& key, int what, std::auto_ptr<Glib::Error>& error);
721 #endif //GLIBMM_EXCEPTIONS_ENABLED
722 
723 
727 #ifdef GLIBMM_EXCEPTIONS_ENABLED
728  void set(const Glib::ustring& key, bool what);
729 #else
730  void set(const Glib::ustring& key, bool what, std::auto_ptr<Glib::Error>& error);
731 #endif //GLIBMM_EXCEPTIONS_ENABLED
732 
733 
737 #ifdef GLIBMM_EXCEPTIONS_ENABLED
738  void set(const Glib::ustring& key,double what);
739 #else
740  void set(const Glib::ustring& key, double what, std::auto_ptr<Glib::Error>& error);
741 #endif //GLIBMM_EXCEPTIONS_ENABLED
742 
743 
747 #ifdef GLIBMM_EXCEPTIONS_ENABLED
748  void set(const Glib::ustring& key, const Glib::ustring& what);
749 #else
750  void set(const Glib::ustring& key, const Glib::ustring& what, std::auto_ptr<Glib::Error>& error);
751 #endif //GLIBMM_EXCEPTIONS_ENABLED
752 
753 
757 #ifdef GLIBMM_EXCEPTIONS_ENABLED
758  void set(const Glib::ustring& key, const Schema& what);
759 #else
760  void set(const Glib::ustring& key, const Schema& what, std::auto_ptr<Glib::Error>& error);
761 #endif //GLIBMM_EXCEPTIONS_ENABLED
762 
763 
768 #ifdef GLIBMM_EXCEPTIONS_ENABLED
769  void set(const Glib::ustring& key, const Value& what);
770 #else
771  void set(const Glib::ustring& key, const Value& what, std::auto_ptr<Glib::Error>& error);
772 #endif //GLIBMM_EXCEPTIONS_ENABLED
773 
774 
775  typedef Glib::SListHandle< int, BasicTypeTraits<int> > SListHandleInts;
776  void set_int_list(const Glib::ustring& key, const SListHandleInts& what);
777 
778  typedef Glib::SListHandle< bool, BasicTypeTraits<bool> > SListHandleBools;
779  void set_bool_list(const Glib::ustring& key, const SListHandleBools& what);
780 
781  typedef Glib::SListHandle< double, BasicTypeTraits<double> > SListHandleFloats;
782  void set_float_list(const Glib::ustring& key, const SListHandleFloats& what);
783 
784  void set_schema_list(const Glib::ustring& key, const Glib::SListHandle<Schema>& what);
785  void set_string_list(const Glib::ustring& key, const Glib::SListHandle<Glib::ustring>& what);
786 
796 #ifdef GLIBMM_EXCEPTIONS_ENABLED
797  ChangeSet change_set_from_current(const Glib::SArray& set);
798 #else
799  ChangeSet change_set_from_current(const Glib::SArray& set, std::auto_ptr<Glib::Error>& error);
800 #endif //GLIBMM_EXCEPTIONS_ENABLED
801 
802 
814 #ifdef GLIBMM_EXCEPTIONS_ENABLED
815  void change_set_commit(ChangeSet& set, bool remove_commited);
816 #else
817  void change_set_commit(ChangeSet& set, bool remove_commited, std::auto_ptr<Glib::Error>& error);
818 #endif //GLIBMM_EXCEPTIONS_ENABLED
819 
820 
832 #ifdef GLIBMM_EXCEPTIONS_ENABLED
833  ChangeSet change_set_reverse(const ChangeSet& set);
834 #else
835  ChangeSet change_set_reverse(const ChangeSet& set, std::auto_ptr<Glib::Error>& error);
836 #endif //GLIBMM_EXCEPTIONS_ENABLED
837 
838 
846  Glib::SignalProxy2< void,const Glib::ustring&,const Value& > signal_value_changed();
847 
848 
849  void value_changed(const Glib::ustring& key, const Value& value);
850 
851 #ifndef DOXYGEN_SHOULD_SKIP_THIS
852  // unreturned_error will never be called, as gconfmm
853  // catches all GError's and throw()s them as Gnome::Conf::Error's.
854 
860  Glib::SignalProxy1< void,const Glib::Error& > signal_unreturned_error();
861 
862 
863  void unreturned_error(const Glib::Error& error);
864 #endif
865 
873  Glib::SignalProxy1< void,const Glib::Error& > signal_error();
874 
875 
876  void error(const Glib::Error& error);
877 
878 private:
879  void handle_error(GError* pError) const;
880 
881  GSList* get_list(const Glib::ustring& key, GConfValueType list_type) const;
882 
883 
884 public:
885 
886 public:
887  //C++ methods used to invoke GTK+ virtual functions:
888 #ifdef GLIBMM_VFUNCS_ENABLED
889 #endif //GLIBMM_VFUNCS_ENABLED
890 
891 protected:
892  //GTK+ Virtual Functions (override these to change behaviour):
893 #ifdef GLIBMM_VFUNCS_ENABLED
894 #endif //GLIBMM_VFUNCS_ENABLED
895 
896  //Default Signal Handlers::
897 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
898  virtual void on_value_changed(const Glib::ustring& key, const Value& value);
899  virtual void on_unreturned_error(const Glib::Error& error);
900  virtual void on_error(const Glib::Error& error);
901 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
902 
903 
904 };
905 
906 } /* namespace Conf */
907 } /* namespace Gnome */
908 
909 
910 namespace Glib
911 {
920  Glib::RefPtr<Gnome::Conf::Client> wrap(GConfClient* object, bool take_copy = false);
921 }
922 
923 
924 #endif /* _GCONFMM_CLIENT_H */
925 
std::pair< ValueType, ValueType > ValueTypePair
Definition: value.h:120
GConfClient * gobj()
Provides access to the underlying C GObject.
Definition: client.h:351
Definition: client.h:106
Definition: client.h:146
An Entry stores an entry from a GConf "directory", including a key-value pair, the name of the Schema...
Definition: entry.h:50
Code code() const
Definition: client.h:910
ClientErrorHandlingMode
Definition: client.h:67
Definition: client.h:105
UnsetFlags
Definition: value.h:87
Definition: schema.h:47
Definition: callback.h:33
Definition: client.h:147
Definition: client.h:153
Glib::SListHandle< int, BasicTypeTraits< int > > SListHandleInts
Definition: client.h:775
sigc::slot< void, guint, Entry > Callback
Definition: callback.h:39
Glib::SListHandle< bool, BasicTypeTraits< bool > > SListHandleBools
Definition: client.h:778
Definition: client.h:154
Definition: client.h:151
const GConfClient * gobj() const
Provides access to the underlying C GObject.
Definition: client.h:354
Definition: client.h:158
Code
Definition: client.h:142
Definition: client.h:152
Definition: client.h:144
Definition: client.h:149
Definition: client.h:155
Exception class for Gnome::Conf::Client errors.
Definition: client.h:139
Definition: client.h:156
Glib::SListHandle< double, BasicTypeTraits< double > > SListHandleFloats
Definition: client.h:781
Definition: client.h:71
Definition: client.h:150
Definition: client.h:148
Wrapper for primitive types.
Definition: value.h:141
Definition: client.h:145
A ChangeSet is a set of changes to the GConf database that can be commited and reversed easily...
Definition: changeset.h:57
Definition: client.h:69
The main Gnome::Conf object.
Definition: client.h:315
void wrap_init()
Common Interface for key-value settable objects.
Definition: setinterface.h:47
std::pair< Value, Value > ValuePair
Definition: value.h:119
ClientPreloadType
Definition: client.h:103
Error(Code error_code, const Glib::ustring &error_message)