gnome-control-center r8489 - trunk/capplets/appearance



Author: jensg
Date: Sat Feb 16 00:03:24 2008
New Revision: 8489
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=8489&view=rev

Log:
2008-02-16  Jens Granseuer  <jensgr gmx net>

	* appearance-desktop.c: (wp_option_menu_set), (wp_load_stuffs):
	* gnome-wp-item.c: (gnome_wp_item_update), (gnome_wp_item_new):
	* gnome-wp-item.h: always apply the current GConf settings to the
	initially selected wallpaper so that we don't modify the settings if
	GConf state and the definition in backgrounds.xml are not identical
	(bug #516746)

	* gnome-wp-xml.c: (gnome_wp_xml_load_xml): get rid of redundant if


Modified:
   trunk/capplets/appearance/ChangeLog
   trunk/capplets/appearance/appearance-desktop.c
   trunk/capplets/appearance/gnome-wp-item.c
   trunk/capplets/appearance/gnome-wp-item.h
   trunk/capplets/appearance/gnome-wp-xml.c

Modified: trunk/capplets/appearance/appearance-desktop.c
==============================================================================
--- trunk/capplets/appearance/appearance-desktop.c	(original)
+++ trunk/capplets/appearance/appearance-desktop.c	Sat Feb 16 00:03:24 2008
@@ -274,31 +274,21 @@
   }
   else
   {
+    gint style;
+
     if (!strcmp (value, "centered"))
-    {
-      gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
-                                GNOME_WP_SCALE_TYPE_CENTERED);
-    }
+      style = GNOME_WP_SCALE_TYPE_CENTERED;
     else if (!strcmp (value, "stretched"))
-    {
-      gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
-                                GNOME_WP_SCALE_TYPE_STRETCHED);
-    }
+      style = GNOME_WP_SCALE_TYPE_STRETCHED;
     else if (!strcmp (value, "scaled"))
-    {
-      gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
-                                GNOME_WP_SCALE_TYPE_SCALED);
-    }
+      style = GNOME_WP_SCALE_TYPE_SCALED;
     else if (!strcmp (value, "zoom"))
-    {
-      gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
-                                GNOME_WP_SCALE_TYPE_ZOOM);
-    }
-    else if (!strcmp (value, "none"))
-    {
-      gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
-                                GNOME_WP_SCALE_TYPE_TILED);
-    }
+      style = GNOME_WP_SCALE_TYPE_ZOOM;
+    else
+      style = GNOME_WP_SCALE_TYPE_TILED;
+
+    gtk_combo_box_set_active (GTK_COMBO_BOX (data->wp_style_menu),
+                              style);
   }
 }
 
@@ -878,8 +868,8 @@
 wp_load_stuffs (void *user_data)
 {
   AppearanceData *data;
-  gchar * imagepath, * style, * uri;
-  GnomeWPItem * item;
+  gchar *imagepath, *style, *uri;
+  GnomeWPItem *item;
 
   data = (AppearanceData *) user_data;
 
@@ -887,8 +877,6 @@
   g_hash_table_foreach (data->wp_hash, (GHFunc) wp_props_load_wallpaper,
                         data);
 
-  /*gdk_window_set_cursor (data->window->window, NULL);*/
-
   style = gconf_client_get_string (data->client,
                                    WP_OPTIONS_KEY,
                                    NULL);
@@ -910,22 +898,21 @@
 
   item = g_hash_table_lookup (data->wp_hash, imagepath);
 
-  if (item != NULL && strcmp (style, "none") != 0)
+  if (item != NULL)
   {
-    if (item->deleted == TRUE)
-    {
-      item->deleted = FALSE;
-      wp_props_load_wallpaper (item->filename, item, data);
-    }
-
-    select_item (data, item, FALSE);
+    /* update with the current gconf settings */
+    gnome_wp_item_update (item);
 
-    wp_option_menu_set (data, item->options, FALSE);
-    wp_option_menu_set (data, item->shade_type, TRUE);
-
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_pcpicker), item->pcolor);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (data->wp_scpicker), item->scolor);
+    if (strcmp (style, "none") != 0)
+    {
+      if (item->deleted == TRUE)
+      {
+        item->deleted = FALSE;
+        wp_props_load_wallpaper (item->filename, item, data);
+      }
 
+      select_item (data, item, FALSE);
+    }
   }
   else if (strcmp (style, "none") != 0)
   {

Modified: trunk/capplets/appearance/gnome-wp-item.c
==============================================================================
--- trunk/capplets/appearance/gnome-wp-item.c	(original)
+++ trunk/capplets/appearance/gnome-wp-item.c	Sat Feb 16 00:03:24 2008
@@ -74,17 +74,53 @@
   }
 }
 
-GnomeWPItem * gnome_wp_item_new (const gchar * filename,
-				 GHashTable * wallpapers,
-				 GnomeThumbnailFactory * thumbnails) {
-  GnomeWPItem * item = NULL;
+void gnome_wp_item_update (GnomeWPItem *item) {
+  GConfClient *client;
   GdkColor color1 = { 0, 0, 0, 0 }, color2 = { 0, 0, 0, 0 };
-  gchar * col_str;
-  GConfClient * client;
+  gchar *col_str;
 
   client = gconf_client_get_default ();
 
-  item = g_new0 (GnomeWPItem, 1);
+  g_free (item->options);
+  item->options = gconf_client_get_string (client, WP_OPTIONS_KEY, NULL);
+  if (item->options == NULL || !strcmp (item->options, "none")) {
+    g_free (item->options);
+    item->options = g_strdup ("scaled");
+  }
+
+  g_free (item->shade_type);
+  item->shade_type = gconf_client_get_string (client, WP_SHADING_KEY, NULL);
+  if (item->shade_type == NULL)
+    item->shade_type = g_strdup ("solid");
+
+  col_str = gconf_client_get_string (client, WP_PCOLOR_KEY, NULL);
+  if (col_str != NULL) {
+    gdk_color_parse (col_str, &color1);
+    g_free (col_str);
+  }
+
+  col_str = gconf_client_get_string (client, WP_SCOLOR_KEY, NULL);
+  if (col_str != NULL) {
+    gdk_color_parse (col_str, &color2);
+    g_free (col_str);
+  }
+
+  g_object_unref (client);
+
+  if (item->pcolor != NULL)
+    gdk_color_free (item->pcolor);
+
+  if (item->scolor != NULL)
+    gdk_color_free (item->scolor);
+
+  item->pcolor = gdk_color_copy (&color1);
+  item->scolor = gdk_color_copy (&color2);
+}
+
+GnomeWPItem * gnome_wp_item_new (const gchar * filename,
+				 GHashTable * wallpapers,
+				 GnomeThumbnailFactory * thumbnails) {
+  GnomeWPItem *item = g_new0 (GnomeWPItem, 1);
 
   item->filename = gnome_vfs_unescape_string_for_display (filename);
 
@@ -101,32 +137,9 @@
 					 NULL, NULL);
     }
 
-    item->options = gconf_client_get_string (client, WP_OPTIONS_KEY, NULL);
-    if (item->options == NULL || !strcmp (item->options, "none")) {
-      g_free (item->options);
-      item->options = g_strdup ("scaled");
-    }
-
-    item->shade_type = gconf_client_get_string (client, WP_SHADING_KEY, NULL);
-    if (item->shade_type == NULL)
-      item->shade_type = g_strdup ("solid");
-
-    col_str = gconf_client_get_string (client, WP_PCOLOR_KEY, NULL);
-    if (col_str != NULL) {
-      gdk_color_parse (col_str, &color1);
-      g_free (col_str);
-    }
-
-    col_str = gconf_client_get_string (client, WP_SCOLOR_KEY, NULL);
-    if (col_str != NULL) {
-      gdk_color_parse (col_str, &color2);
-      g_free (col_str);
-    }
-
-    item->pcolor = gdk_color_copy (&color1);
-    item->scolor = gdk_color_copy (&color2);
-
+    gnome_wp_item_update (item);
     gnome_wp_item_update_description (item);
+    gnome_wp_item_ensure_gnome_bg (item);
 
     g_hash_table_insert (wallpapers, item->filename, item);
   } else {
@@ -134,12 +147,6 @@
     item = NULL;
   }
 
-  if (item) {
-    gnome_wp_item_ensure_gnome_bg (item);
-  }
-
-  g_object_unref (client);
-
   return item;
 }
 

Modified: trunk/capplets/appearance/gnome-wp-item.h
==============================================================================
--- trunk/capplets/appearance/gnome-wp-item.h	(original)
+++ trunk/capplets/appearance/gnome-wp-item.h	Sat Feb 16 00:03:24 2008
@@ -43,7 +43,7 @@
 
 struct _GnomeWPItem {
   GnomeBG *bg;
-    
+
   gchar * name;
   gchar * filename;
   gchar * description;
@@ -73,6 +73,7 @@
 void gnome_wp_item_free (GnomeWPItem * item);
 GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
 					 GnomeThumbnailFactory * thumbs);
+void gnome_wp_item_update (GnomeWPItem * item);
 void gnome_wp_item_update_description (GnomeWPItem * item);
 void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item);
 

Modified: trunk/capplets/appearance/gnome-wp-xml.c
==============================================================================
--- trunk/capplets/appearance/gnome-wp-xml.c	(original)
+++ trunk/capplets/appearance/gnome-wp-xml.c	Sat Feb 16 00:03:24 2008
@@ -227,13 +227,11 @@
 
 	gnome_wp_item_update_description (wp);
 	g_hash_table_insert (data->wp_hash, wp->filename, wp);
+        gnome_wp_item_ensure_gnome_bg (wp);
       } else {
 	gnome_wp_item_free (wp);
         wp = NULL;
       }
-
-      if (wp)
-        gnome_wp_item_ensure_gnome_bg (wp);
     }
   }
   xmlFreeDoc (wplist);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]