[Rawstudio-commit] r2075 - trunk/src

Anders Brander anders at brander.dk
Thu Oct 16 23:10:40 CEST 2008


Author: abrander
Date: 2008-10-16 23:10:39 +0200 (Thu, 16 Oct 2008)
New Revision: 2075

Modified:
   trunk/src/conf_interface.c
Log:
Ported configuration interface from GConfEngine to GConfClient.

Modified: trunk/src/conf_interface.c
===================================================================
--- trunk/src/conf_interface.c	2008-10-15 03:40:44 UTC (rev 2074)
+++ trunk/src/conf_interface.c	2008-10-16 21:10:39 UTC (rev 2075)
@@ -32,19 +32,8 @@
 static GStaticMutex lock = G_STATIC_MUTEX_INIT;
 
 #ifdef WITH_GCONF
- #include <gconf/gconf.h>
+ #include <gconf/gconf-client.h>
  #define GCONF_PATH "/apps/rawstudio/"
-static GConfEngine *
-get_gconf_engine(void)
-{
-	/* Initialize *engine first time we're called. Otherwise just return the one we've got. */
-	g_static_mutex_lock(&lock);
-	static GConfEngine *engine = NULL;
-	if (!engine)
-		engine = gconf_engine_get_default();
-	g_static_mutex_unlock(&lock);
-	return engine;
-}
 #else
  #ifdef G_OS_WIN32
   #include <windows.h>
@@ -59,13 +48,13 @@
 	gboolean ret = FALSE;
 #ifdef WITH_GCONF
 	GConfValue *gvalue;
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
-	if (engine)
+	if (client)
 	{
 		g_static_mutex_lock(&lock);
-		gvalue = gconf_engine_get(engine, fullname->str, NULL);
+		gvalue = gconf_client_get(client, fullname->str, NULL);
 		g_static_mutex_unlock(&lock);
 		if (gvalue)
 		{
@@ -77,6 +66,7 @@
 			}
 			gconf_value_free(gvalue);
 		}
+		g_object_unref(client);
 	}
 	g_string_free(fullname, TRUE);
 #endif
@@ -94,13 +84,13 @@
 		*boolean_value = default_value;
 #ifdef WITH_GCONF
 	GConfValue *gvalue;
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
-	if (engine)
+	if (client)
 	{
 		g_static_mutex_lock(&lock);
-		gvalue = gconf_engine_get(engine, fullname->str, NULL);
+		gvalue = gconf_client_get(client, fullname->str, NULL);
 		g_static_mutex_unlock(&lock);
 		if (gvalue)
 		{
@@ -112,6 +102,7 @@
 			}
 			gconf_value_free(gvalue);
 		}
+		g_object_unref(client);
 	}
 	g_string_free(fullname, TRUE);
 #endif
@@ -126,12 +117,15 @@
 {
 	gboolean ret = FALSE;
 #ifdef WITH_GCONF
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
 	g_static_mutex_lock(&lock);
-	if (engine)
-		ret = gconf_engine_set_bool(engine, fullname->str, bool_value, NULL);
+	if (client)
+	{
+		ret = gconf_client_set_bool(client, fullname->str, bool_value, NULL);
+		g_object_unref(client);
+	}
 	g_static_mutex_unlock(&lock);
 	g_string_free(fullname, TRUE);
 #endif
@@ -147,13 +141,13 @@
 	gchar *ret=NULL;
 #ifdef WITH_GCONF
 	GConfValue *gvalue;
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
-	if (engine)
+	if (client)
 	{
 		g_static_mutex_lock(&lock);
-		gvalue = gconf_engine_get(engine, fullname->str, NULL);
+		gvalue = gconf_client_get(client, fullname->str, NULL);
 		g_static_mutex_unlock(&lock);
 		if (gvalue)
 		{
@@ -161,6 +155,7 @@
 				ret = g_strdup(gconf_value_get_string(gvalue));
 			gconf_value_free(gvalue);
 		}
+		g_object_unref(client);
 	}
 	g_string_free(fullname, TRUE);
 #endif
@@ -193,18 +188,15 @@
 {
 	gboolean ret = FALSE;
 #ifdef WITH_GCONF
-	GConfValue *gvalue;
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
-	if (engine)
+	if (client)
 	{
 		g_static_mutex_lock(&lock);
-		gvalue = gconf_value_new(GCONF_VALUE_STRING);
-		gconf_value_set_string(gvalue, string_value);
-		ret = gconf_engine_set(engine, fullname->str, gvalue, NULL);
-		gconf_value_free(gvalue);
+		ret = gconf_client_set_string(client, fullname->str, string_value, NULL);
 		g_static_mutex_unlock(&lock);
+		g_object_unref(client);
 	}
 	g_string_free(fullname, TRUE);
 #endif
@@ -218,7 +210,7 @@
 	}
     RegCloseKey(hKey);
 #endif
-	return(ret);
+	return ret;
 }
 
 gboolean
@@ -227,13 +219,13 @@
 	gboolean ret=FALSE;
 #ifdef WITH_GCONF
 	GConfValue *gvalue;
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
-	if (engine)
+	if (client)
 	{
 		g_static_mutex_lock(&lock);
-		gvalue = gconf_engine_get(engine, fullname->str, NULL);
+		gvalue = gconf_client_get(client, fullname->str, NULL);
 		g_static_mutex_unlock(&lock);
 		if (gvalue)
 		{
@@ -244,6 +236,7 @@
 			}
 			gconf_value_free(gvalue);
 		}
+		g_object_unref(client);
 	}
 	g_string_free(fullname, TRUE);
 #endif
@@ -277,12 +270,15 @@
 {
 	gboolean ret = FALSE;
 #ifdef WITH_GCONF
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
 	g_static_mutex_lock(&lock);
-	if (engine)
-		ret = gconf_engine_set_int(engine, fullname->str, integer_value, NULL);
+	if (client)
+	{
+		ret = gconf_client_set_int(client, fullname->str, integer_value, NULL);
+		g_object_unref(client);
+	}
 	g_static_mutex_unlock(&lock);
 	g_string_free(fullname, TRUE);
 #endif
@@ -463,13 +459,13 @@
 	gboolean ret=FALSE;
 #ifdef WITH_GCONF
 	GConfValue *gvalue;
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
-	if (engine)
+	if (client)
 	{
 		g_static_mutex_lock(&lock);
-		gvalue = gconf_engine_get(engine, fullname->str, NULL);
+		gvalue = gconf_client_get(client, fullname->str, NULL);
 		g_static_mutex_unlock(&lock);
 		if (gvalue)
 		{
@@ -480,6 +476,7 @@
 			}
 			gconf_value_free(gvalue);
 		}
+		g_object_unref(client);
 	}
 	g_string_free(fullname, TRUE);
 #endif
@@ -513,12 +510,15 @@
 {
 	gboolean ret = FALSE;
 #ifdef WITH_GCONF
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 	g_string_append(fullname, name);
 	g_static_mutex_lock(&lock);
-	if (engine)
-		ret = gconf_engine_set_float(engine, fullname->str, float_value, NULL);
+	if (client)
+	{
+		ret = gconf_client_set_float(client, fullname->str, float_value, NULL);
+		g_object_unref(client);
+	}
 	g_static_mutex_unlock(&lock);
 	g_string_free(fullname, TRUE);
 #endif
@@ -540,13 +540,16 @@
 {
 	GSList *list = NULL;
 #ifdef WITH_GCONF
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 
 	g_string_append(fullname, name);
 	g_static_mutex_lock(&lock);
-	if (engine)
-		list = gconf_engine_get_list(engine, fullname->str, GCONF_VALUE_STRING, NULL);
+	if (client)
+	{
+		list = gconf_client_get_list(client, fullname->str, GCONF_VALUE_STRING, NULL);
+		g_object_unref(client);
+	}
 	g_static_mutex_unlock(&lock);
 	g_string_free(fullname, TRUE);
 #else
@@ -560,13 +563,16 @@
 {
 	gboolean ret = FALSE;
 #ifdef WITH_GCONF
-	GConfEngine *engine = get_gconf_engine();
+	GConfClient *client = gconf_client_get_default();
 	GString *fullname = g_string_new(GCONF_PATH);
 
 	g_string_append(fullname, name);
 	g_static_mutex_lock(&lock);
-	if (engine)
-		ret = gconf_engine_set_list(engine, fullname->str, GCONF_VALUE_STRING, list, NULL);
+	if (client)
+	{
+		ret = gconf_client_set_list(client, fullname->str, GCONF_VALUE_STRING, list, NULL);
+		g_object_unref(client);
+	}
 	g_static_mutex_unlock(&lock);
 	g_string_free(fullname, TRUE);
 #else




More information about the Rawstudio-commit mailing list