[beryl-commits] r1475 - trunk/beryl-core/settings-backends

quinn at server.beryl-project.org quinn at server.beryl-project.org
Sat Dec 2 00:22:38 CET 2006


Author: quinn
Date: 2006-12-02 00:22:36 +0100 (Sat, 02 Dec 2006)
New Revision: 1475

Modified:
   trunk/beryl-core/settings-backends/gconf.c
Log:
settings-backends:
-some work on the gconf backend


Modified: trunk/beryl-core/settings-backends/gconf.c
===================================================================
--- trunk/beryl-core/settings-backends/gconf.c	2006-12-01 03:02:28 UTC (rev 1474)
+++ trunk/beryl-core/settings-backends/gconf.c	2006-12-01 23:22:36 UTC (rev 1475)
@@ -57,16 +57,13 @@
 }
 
 
-static void set_gslist_from_binding(GSList * list, BerylSettingValue * value)
+static void set_gslist_from_binding(GSList ** plist, BerylSettingValue * value)
 {
+    GSList * list = NULL;
     gboolean bindval = value->value.as_binding.on_bell?1:0;
     gboolean bindbtn = value->value.as_binding.enabled.value.button?1:0;
     gboolean bindkey = value->value.as_binding.enabled.value.key?1:0;
 
-    // Get us some happy empty RAM
-    if (list) g_slist_free(list);
-    list = g_slist_alloc();
-
     list = g_slist_append(list, &value->value.as_binding.button_mod_mask);
     list = g_slist_append(list, &value->value.as_binding.button);
     list = g_slist_append(list, &value->value.as_binding.key_mod_mask);
@@ -75,17 +72,17 @@
     list = g_slist_append(list, &bindval);
     list = g_slist_append(list, &bindbtn);
     list = g_slist_append(list, &bindkey);
+    *plist = list;
 }
 
-static void set_gslist_from_color(GSList *list, BerylSettingValue *value)
+static void set_gslist_from_color(GSList **plist, BerylSettingValue *value)
 {
-    if (list) g_slist_free(list);
-    list = g_slist_alloc();
-
+    GSList * list = NULL;
     list = g_slist_append(list, &value->value.as_color.array.array[0]);
     list = g_slist_append(list, &value->value.as_color.array.array[1]);
     list = g_slist_append(list, &value->value.as_color.array.array[2]);
     list = g_slist_append(list, &value->value.as_color.array.array[3]);
+    *plist = list;
 }
 
 
@@ -148,6 +145,7 @@
     if (!gconf_client_dir_exists(client,gconf_path, &e))
     {
         g_free(keyname);
+	g_free(groupname);
         g_free(gconf_path);
         setting->is_default = TRUE;
         return;
@@ -290,9 +288,19 @@
     }
 
     g_free(keyname);
+    g_free(groupname);
     g_free(gconf_path);
 }
 
+static void append_string(BerylSettingValue * value, GSList ** sl)
+{
+    gchar * s;
+    if (beryl_setting_value_get_string(value,&s))
+    {
+	*sl=g_slist_append(*sl,s);
+    }
+}
+
 void write_setting(BerylSettingsContext * context, BerylSetting * setting)
 {
     gchar *groupname=setting->parent->name?setting->parent->name:"_";
@@ -328,7 +336,7 @@
         case BERYL_SETTING_TYPE_BINDING:
             {
                 GSList *list; 
-                set_gslist_from_binding(list,&setting->value);
+                set_gslist_from_binding(&list,&setting->value);
                 gconf_client_set_list(client,gconf_path, GCONF_VALUE_INT, list, &e);
                 g_slist_free(list);
             }
@@ -336,15 +344,24 @@
         case BERYL_SETTING_TYPE_COLOR:
             {
 		GSList *list; 
-                set_gslist_from_color(list, &setting->value);
+                set_gslist_from_color(&list, &setting->value);
                 gconf_client_set_list(client, gconf_path,GCONF_VALUE_INT,list,&e);
                 g_slist_free(list);
             }
             break;
         case BERYL_SETTING_TYPE_LIST:
-            {
-		gconf_client_set_list(client, gconf_path, beryl_to_gconf_type(setting->info.for_list.list_of_type), setting->value.value.as_list, &e);
-            }
+	    switch(setting->info.for_list.list_of_type)
+	    {
+		case BERYL_SETTING_TYPE_STRING:
+		    {
+			GSList * sl = NULL;
+			g_slist_foreach(setting->value.value.as_list,append_string,&sl);
+			gconf_client_set_list(client,gconf_path,GCONF_VALUE_STRING,sl,&e);
+			g_slist_free(sl);
+		    }
+		    break;
+	    }
+		//gconf_client_set_list(client, gconf_path, beryl_to_gconf_type(setting->info.for_list.list_of_type), setting->value.value.as_list, &e);
             break;
         default:
             break;
@@ -390,7 +407,8 @@
 {
     g_type_init();
 
-    client = gconf_client_get_default();
+    if (!client)
+	client = gconf_client_get_default();
 
     gconf_client_add_dir(context->private_ptr,
 	    "/apps/beryl/", GCONF_CLIENT_PRELOAD_NONE, NULL);




More information about the commits mailing list