1 // This file is a part of Simple Launcher
3 // Copyright (C) 2006, 2007, Mikhail Sobolev
5 // Simple Launcher is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License version 2 as published by
7 // the Free Software Foundation.
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 // You should have received a copy of the GNU General Public License along with
15 // this program; if not, write to the Free Software Foundation, Inc., 51
16 // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef _GCONF_WRAPPER_H_
19 #define _GCONF_WRAPPER_H_
23 #include <gconf/gconf-client.h>
27 virtual ~GConfItem() {}
30 GConfItem(); // I do not want to create instances of this class
32 static void allocateClient();
35 // TODO: should I count the references and unref the client when the last user is gone??
36 static GConfClient *ourClient;
39 class GConfKey : public GConfItem {
41 GConfKey(const std::string&);
42 GConfKey(const GConfKey&, const std::string&);
45 const std::string& path() const { return myKeyPath; }
47 std::string merge(const std::string&) const;
50 const std::string myKeyPath;
53 class GConfOption : public GConfItem {
55 GConfOption(const GConfKey& key, const std::string& path): myIsSynchronized(false), myPath(key.merge(path)) { }
57 virtual GConfValueType kind() const = 0;
59 void setGConfValue(const GConfValue *);
60 GConfValue *getGConfValue() const;
61 void unsetGConfValue();
64 mutable bool myIsSynchronized;
65 const std::string myPath;
68 class GConfStringOption : public GConfOption {
70 GConfStringOption(const GConfKey&, const std::string&, const std::string&);
72 virtual GConfValueType kind() const { return GCONF_VALUE_STRING; }
74 const std::string& value() const;
75 const std::string& setValue(const std::string& newValue);
78 mutable std::string myValue;
79 const std::string myDefaultValue;
82 class GConfBooleanOption : public GConfOption {
84 GConfBooleanOption(const GConfKey&, const std::string&, bool);
86 virtual GConfValueType kind() const { return GCONF_VALUE_BOOL; }
89 bool setValue(bool newValue);
93 const bool myDefaultValue;
96 class GConfIntegerOption : public GConfOption {
98 GConfIntegerOption(const GConfKey&, const std::string&, int);
100 virtual GConfValueType kind() const { return GCONF_VALUE_INT; }
103 int setValue(int newValue);
107 const int myDefaultValue;