made the gconf wrapper more useful; properly added it to the project
authormishas <mikhail.sobolev@gmail.com>
Wed, 4 Apr 2007 14:54:01 +0000 (14:54 +0000)
committermishas <mikhail.sobolev@gmail.com>
Wed, 4 Apr 2007 14:54:01 +0000 (14:54 +0000)
git-svn-id: file:///svnroot/simple-launcher/trunk@150 3ba93dab-e023-0410-b42a-de7732cf370a

Makefile
gconf-wrapper.cc
gconf-wrapper.h

index 9e28432..1cbed79 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,13 @@
 GTKCFLAGS := $(shell pkg-config gtk+-2.0 --cflags)
 GTKLIBS := $(shell pkg-config gtk+-2.0 --libs)
 
+GCONFCFLAGS := $(shell pkg-config gconf-2.0 --cflags)
+GCONFLIBS := $(shell pkg-config gconf-2.0 --libs)
+
 DBUSCFLAGS := $(shell pkg-config dbus-1 --cflags)
 DBUSLIBS := $(shell pkg-config dbus-1 --libs)
 
-CXXFLAGS=-Wall -g -MMD $(GTKCFLAGS) $(DBUSCFLAGS)
+CXXFLAGS=-Wall -g -MMD $(GTKCFLAGS) $(DBUSCFLAGS) $(GCONFCFLAGS)
 #LDFLAGS = -module -avoid-version
 LDFLAGS = -shared
 LIBS = -lstdc++
index 93eb1c0..049d851 100644 (file)
 // Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "gconf-wrapper.h"
+
+GConfClientWrapper::GConfClientWrapper() {
+       myClient = gconf_client_get_default();
+}
+
+GConfClientWrapper::~GConfClientWrapper() {
+}
+
+GConfKey GConfClientWrapper::getKey(const std::string& path) {
+       // FIXME: check if path points to a good place :)
+       return GConfKey(*this, path);
+}
+
+GConfKey::GConfKey(GConfClientWrapper& wrapper, const std::string& path) : myWrapper(wrapper), myPath(path) {
+}
index 6cc0a4c..7d622e5 100644 (file)
 
 #include <string>
 
-class GConfWrapper {
+#include <gconf/gconf-client.h>
+
+class GConfClientWrapper {
+  friend class GConfKey;
+
 public:
-  GConfWrapper(const std::string&);
- ~GConfWrapper();
+  GConfClientWrapper();
+ ~GConfClientWrapper();
+
+  GConfKey getKey(const std::string&);
 
+protected:
   bool getBool(const std::string& name);
   void setBool(const std::string& name, bool);
 
   int getInt(const std::string& name);
   void setInt(const std::string& name, int);
+
+private:
+  GConfClient *myClient;
+};
+
+class GConfKey {
+public:
+  GConfKey(GConfClientWrapper&, const std::string&);
+  GConfKey(const GConfKey& what) : myWrapper(what.myWrapper), myPath(what.myPath) { }
+ ~GConfKey();
+
+  GConfKey& operator = (const GConfKey& what) {
+    myWrapper = what.myWrapper;
+    myPath = what.myPath;
+
+    return *this;
+  }
+
+  bool getBool(const std::string& name, bool defvalue = false);
+  void setBool(const std::string& name, bool value);
+
+  int getInt(const std::string& name, int defvalue = 0);
+  void setInt(const std::string& name, int value);
+
+private:
+  GConfClientWrapper& myWrapper;
+  std::string myPath;
 };
 
 #endif