1
// -*- Mode: C++; c-basic-offset: 4 -*-
2
/* $Id: changeset.hg,v 1.4 2006/06/05 17:54:23 murrayc Exp $ */
6
* Copyright (C) 2002 GConfmm Development Team
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Library General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Library General Public License for more details.
18
* You should have received a copy of the GNU Library General Public
19
* License along with this library; if not, write to the Free
20
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
#include <glibmm/ustring.h>
24
#include <gconfmm/value.h>
25
#include <gconfmm/setinterface.h>
26
#include <sigc++/slot.h>
31
typedef struct _GConfChangeSet GConfChangeSet;
40
/** A ChangeSet is a set of changes to the GConf database that can be commited
41
* and reversed easily. The changes can be both set and unset operations.
42
* Currently the ChangeSet operations are not atomic, and not specially optimized
43
* for. However, it is suitable for use, for instance, preferences dialogs.
45
* The set*() methods do not throw errors, they simply store the keys and the values.
47
* @see Client::change_set_from_current(), Client::change_set_commit(),
48
* Client::change_set_reverse().
50
class ChangeSet : public SetInterface
52
_CLASS_GENERIC(ChangeSet,GConfChangeSet)
53
_IGNORE(gconf_change_set_new, gconf_change_set_ref, gconf_change_set_unref)
54
_IGNORE(gconf_change_set_set_user_data, gconf_change_set_get_user_data)
57
explicit ChangeSet(GConfChangeSet* castitem, bool make_a_copy = false);
59
ChangeSet(const ChangeSet& src);
60
ChangeSet& operator=(const ChangeSet& src);
63
GConfChangeSet* gobj() { return gobject_; }
64
const GConfChangeSet* gobj() const { return gobject_; }
65
GConfChangeSet* gobj_copy() const;
68
GConfChangeSet* gobject_;
71
/** Clear all entries.
72
* After this method, commiting the changeset is a no-op. */
73
_WRAP_METHOD(void clear(), gconf_change_set_clear)
75
/** Returns the number of keys in the changeset. */
76
_WRAP_METHOD(unsigned int size() const, gconf_change_set_size)
78
/** Remove the specified key from the changeset.
79
* This means that the given key will not be modified by a commit. */
80
_WRAP_METHOD(void remove(const Glib::ustring& key), gconf_change_set_remove)
82
/** Check whether the given key will be modified by a commit operation.
83
* @return 0 if the key will not be modified, else the modified value.
84
* Remember to delete the Value. */
85
Value* exists(const Glib::ustring& key) const;
86
_IGNORE(gconf_change_set_check_value)
88
/** Unset the given key.
89
* Mark the key, so that it will be removed from the configuration database during a commit. */
90
_WRAP_METHOD(void unset(const Glib::ustring& key), gconf_change_set_unset)
92
//Hand-code these, because we need to ignore the Glib::Error argument when using --enable-api-exceptions=no:
93
//We must match the virtual method signatures in SetInterface, even though these implementations of that
94
//interface do not actually throw exceptions.
95
//_WRAP_METHOD(void set(const Glib::ustring& key, bool what), gconf_change_set_set_bool)
96
//_WRAP_METHOD(void set(const Glib::ustring& key, int what), gconf_change_set_set_int)
97
//_WRAP_METHOD(void set(const Glib::ustring& key, double what), gconf_change_set_set_float)
98
//_WRAP_METHOD(void set(const Glib::ustring& key, const Glib::ustring& what), gconf_change_set_set_string)
99
//_WRAP_METHOD(void set(const Glib::ustring& key, const Schema& val), gconf_change_set_set_schema)
100
//_WRAP_METHOD(void set(const Glib::ustring& key, const Value& what), gconf_change_set_set)
101
_IGNORE(gconf_change_set_set_list, gconf_change_set_set_pair)
102
_IGNORE(gconf_change_set_set_nocopy)
104
#ifdef GLIBMM_EXCEPTIONS_ENABLED
105
virtual void set(const Glib::ustring& key, const Value& value);
106
virtual void set(const Glib::ustring& key, bool what);
107
virtual void set(const Glib::ustring& key, int what);
108
virtual void set(const Glib::ustring& key, double what);
109
virtual void set(const Glib::ustring& key, const Glib::ustring& what);
110
virtual void set(const Glib::ustring& key, const Schema& what);
112
virtual void set(const Glib::ustring& key, const Value& value, std::auto_ptr<Glib::Error>& error);
113
virtual void set(const Glib::ustring& key, bool what, std::auto_ptr<Glib::Error>& error);
114
virtual void set(const Glib::ustring& key, int what, std::auto_ptr<Glib::Error>& error);
115
virtual void set(const Glib::ustring& key, double what, std::auto_ptr<Glib::Error>& error);
116
virtual void set(const Glib::ustring& key, const Glib::ustring& what, std::auto_ptr<Glib::Error>& error);
117
virtual void set(const Glib::ustring& key, const Schema& what, std::auto_ptr<Glib::Error>& error);
118
#endif //GLIBMM_EXCEPTIONS_ENABLED
120
_IGNORE(gconf_change_set_set_bool, gconf_change_set_set_int, gconf_change_set_set_float,
121
gconf_change_set_set_string, gconf_change_set_set_schema, gconf_change_set_set)
123
typedef sigc::slot<void, const Glib::ustring&, const Value&> ForeachSlot;
124
/** Iterate over the keys marked in this ChangeSet.
125
* Calls @p slot for each key-value pair that is marked in the ChangeSet.
126
* Keys marked unset will have a Value with type VALUE_INVALID.
128
void for_each(const ForeachSlot& slot);
129
_IGNORE(gconf_change_set_foreach)
131
static GConfChangeSet* do_ref(GConfChangeSet*);