[maemo-commits] [maemo-commits] r8446 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . src

From: www-data at stage.maemo.org www-data at stage.maemo.org
Date: Wed Nov 29 13:06:11 EET 2006
Author: lucasr
Date: 2006-11-29 13:06:10 +0200 (Wed, 29 Nov 2006)
New Revision: 8446

Modified:
   projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog
   projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-desktop.c
Log:
2006-11-29  Lucas Rocha  <lucas.rocha at nokia.com>

	* src/hd-desktop.c: container configuration saving support after
	plugins selection.


Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog	2006-11-29 11:01:13 UTC (rev 8445)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog	2006-11-29 11:06:10 UTC (rev 8446)
@@ -1,3 +1,8 @@
+2006-11-29  Lucas Rocha  <lucas.rocha at nokia.com>
+
+	* src/hd-desktop.c: container configuration saving support after
+	plugins selection.
+
 2006-11-28  Johan Bilien  <johan.bilien at nokia.com>
 
 	* libhildondesktop/hildon-home-window.c: Removed references to

Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-desktop.c
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-desktop.c	2006-11-29 11:01:13 UTC (rev 8445)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-desktop.c	2006-11-29 11:06:10 UTC (rev 8446)
@@ -59,6 +59,65 @@
 
 static void hd_desktop_load_containers (HDDesktop *desktop);
 
+static void 
+hd_desktop_plugin_list_to_conf (GList *plugin_list, const gchar *config_file)
+{
+  GKeyFile *keyfile;
+  GList *iter;
+  GError *error = NULL;
+  gchar *buffer;
+  gint buffer_size;
+
+  g_return_if_fail (config_file != NULL);
+
+  keyfile = g_key_file_new ();
+
+  for (iter = g_list_first (plugin_list); iter; iter = g_list_next (iter))
+  {
+    g_key_file_set_string (keyfile,
+                           (gchar *) iter->data,
+                           "", 
+                           "");
+
+    /* No way to add only a group without keys. We need to 
+       remove the empty key */
+    g_key_file_remove_key (keyfile,
+                           (gchar *) iter->data,
+                            "",
+                            &error);
+
+    if (error)
+    {
+      g_warning ("Error saving desktop configuration file: %s", error->message);
+      g_error_free (error);
+
+      return;
+    }
+  }
+
+  buffer = g_key_file_to_data (keyfile, &buffer_size, &error);
+
+  if (error)
+  {
+    g_warning ("Error saving desktop configuration file: %s", error->message);
+    g_error_free (error);
+
+    return;
+  }
+
+  g_file_set_contents (config_file, buffer, buffer_size, &error);
+
+  if (error)
+  {
+    g_warning ("Error saving desktop configuration file: %s", error->message);
+    g_error_free (error);
+
+    return;
+  }
+
+  g_key_file_free (keyfile);
+}
+
 static GList *
 hd_desktop_plugin_list_from_conf (const gchar *config_file)
 {
@@ -100,8 +159,8 @@
 static void 
 hd_desktop_select_plugins (HildonDesktopWindow *window, gpointer user_data)
 {
-/*  const gchar *config_file; */
   const gchar *plugin_dir;
+  gchar *config_file;
   GList *loaded_plugins = NULL;
   GList *selected_plugins = NULL;
   HDDesktopPrivate *priv;
@@ -113,7 +172,12 @@
 
   loaded_plugins = gtk_container_get_children (window->container);
 
-/*  config_file = hildon_desktop_window_get_config_file (window); */
+  config_file = g_build_filename (priv->config_path, 
+                                  hildon_desktop_window_get_config_file (window),
+                                  NULL);
+
+  g_debug ("Config file: %s", config_file);
+
   plugin_dir = hildon_desktop_window_get_plugin_dir (window);
 
   selected_plugins = hd_select_plugins_dialog_run (loaded_plugins, 
@@ -123,8 +187,9 @@
                           selected_plugins,
                           window->container);
 
-  /*Save container file here */
+  hd_desktop_plugin_list_to_conf (selected_plugins, config_file);
 
+  g_free (config_file);
   g_list_free (selected_plugins);
   g_list_free (loaded_plugins);
 }
@@ -408,7 +473,7 @@
     }
 
     hildon_desktop_window_set_config_file (HILDON_DESKTOP_WINDOW (container), 
-                                           container_config);
+                                           container_config_file);
 
     hildon_desktop_window_set_plugin_dir (HILDON_DESKTOP_WINDOW (container), 
                                           plugin_dir);


More information about the maemo-commits mailing list