+GConfClient *GConfItem::ourClient = NULL;
+
+GConfItem::GConfItem() {
+ validateClient();
+}
+
+void GConfItem::validateClient() {
+ if (ourClient == NULL) {
+ ourClient = gconf_client_get_default();
+ }
+}
+
+GConfKey::GConfKey(const std::string& path): myKeyPath(path) {
+}
+
+GConfStringValue::GConfStringValue(const GConfKey& key, const std::string& name, const std::string& defaultValue):
+ GConfOption(key, name),
+ myDefaultValue(defaultValue) {
+}
+
+const std::string& GConfStringValue::value() const {
+ if (!myIsSynchronized) {
+ GConfValue *value = getGConfValue(GCONF_VALUE_STRING);
+
+ if (value == NULL) {
+ myValue = myDefaultValue;
+ } else {
+ myValue = gconf_value_get_string(value);
+
+ gconf_value_free(value);
+ }
+
+ myIsSynchronized = true;
+ }
+
+ return myValue;
+}
+
+const std::string& GConfStringValue::setValue(const std::string& newValue) {
+ if (!myIsSynchronized || (myValue != newValue)) {
+ myValue = newValue;
+
+ if (myValue == myDefaultValue) {
+ unsetGConfValue();
+ } else {
+ GConfValue *value = gconf_value_new(GCONF_VALUE_STRING);
+
+ gconf_value_set_string(value, myValue.c_str());
+
+ setGConfValue(value);
+
+ gconf_value_free(value);
+ }
+
+ myIsSynchronized = true;
+ }
+
+ return myValue;
+}
+
+GConfBooleanValue::GConfBooleanValue(const GConfKey& key, const std::string& name, bool defaultValue):
+ GConfOption(key, name),
+ myDefaultValue(defaultValue) {
+}
+
+bool GConfBooleanValue::value() const {
+ if (!myIsSynchronized) {
+ GConfValue *value = getGConfValue(GCONF_VALUE_BOOL);
+
+ if (value == NULL) {
+ myValue = myDefaultValue;
+ } else {
+ myValue = gconf_value_get_bool(value);
+
+ gconf_value_free(value);
+ }
+
+ myIsSynchronized = true;
+ }
+
+ return myValue;
+}
+
+bool GConfBooleanValue::setValue(bool newValue) {
+ if (!myIsSynchronized || (myValue != newValue)) {
+ myValue = newValue;
+
+ if (myValue == myDefaultValue) {
+ unsetGConfValue();
+ } else {
+ GConfValue *value = gconf_value_new(GCONF_VALUE_BOOL);
+
+ gconf_value_set_bool(value, myValue);
+
+ setGConfValue(value);
+
+ gconf_value_free(value);
+ }
+
+ myIsSynchronized = true;
+ }
+
+ return myValue;