rpms/control-center/devel gnome-bg.patch, NONE, 1.1 control-center.spec, 1.295, 1.296

Matthias Clasen (mclasen) fedora-extras-commits at redhat.com
Thu Aug 16 06:52:07 UTC 2007


Author: mclasen

Update of /cvs/extras/rpms/control-center/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9760

Modified Files:
	control-center.spec 
Added Files:
	gnome-bg.patch 
Log Message:
fix the background patch


gnome-bg.patch:

--- NEW FILE gnome-bg.patch ---
diff -up gnome-control-center-2.19.90/capplets/appearance/gnome-wp-info.h.gnome-bg gnome-control-center-2.19.90/capplets/appearance/gnome-wp-info.h
--- gnome-control-center-2.19.90/capplets/appearance/gnome-wp-info.h.gnome-bg	2007-05-03 08:33:46.000000000 -0400
+++ gnome-control-center-2.19.90/capplets/appearance/gnome-wp-info.h	2007-08-16 02:35:10.000000000 -0400
@@ -40,7 +40,6 @@ struct _GnomeWPInfo {
 
 GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
 				 GnomeThumbnailFactory * thumbs);
-GnomeWPInfo * gnome_wp_info_dup (const GnomeWPInfo * info);
 void gnome_wp_info_free (GnomeWPInfo * info);
 
 #endif
diff -up gnome-control-center-2.19.90/capplets/appearance/gnome-wp-xml.c.gnome-bg gnome-control-center-2.19.90/capplets/appearance/gnome-wp-xml.c
--- gnome-control-center-2.19.90/capplets/appearance/gnome-wp-xml.c.gnome-bg	2007-08-13 17:39:44.000000000 -0400
+++ gnome-control-center-2.19.90/capplets/appearance/gnome-wp-xml.c	2007-08-16 02:35:10.000000000 -0400
@@ -235,7 +235,11 @@ static void gnome_wp_xml_load_xml (Appea
 	g_hash_table_insert (data->wp_hash, wp->filename, wp);
       } else {
 	gnome_wp_item_free (wp);
+        wp = NULL;
       }
+
+      if (wp)
+        gnome_wp_item_ensure_gnome_bg (wp);
     }
   }
   xmlFreeDoc (wplist);
diff -up gnome-control-center-2.19.90/capplets/appearance/gnome-wp-info.c.gnome-bg gnome-control-center-2.19.90/capplets/appearance/gnome-wp-info.c
--- gnome-control-center-2.19.90/capplets/appearance/gnome-wp-info.c.gnome-bg	2007-05-03 08:33:46.000000000 -0400
+++ gnome-control-center-2.19.90/capplets/appearance/gnome-wp-info.c	2007-08-16 02:35:10.000000000 -0400
@@ -67,27 +67,6 @@ GnomeWPInfo * gnome_wp_info_new (const g
   return new;
 }
 
-GnomeWPInfo * gnome_wp_info_dup (const GnomeWPInfo * info) {
-  GnomeWPInfo * new;
-
-  if (info == NULL) {
-    return NULL;
-  }
-
-  new = g_new0 (GnomeWPInfo, 1);
-
-  new->uri = g_strdup (info->uri);
-  new->thumburi = g_strdup (info->uri);
-
-  new->name = g_strdup (info->name);
-  new->mime_type = g_strdup (info->mime_type);
-
-  new->size = info->size;
-  new->mtime = info->mtime;
-
-  return new;
-}
-
 void gnome_wp_info_free (GnomeWPInfo * info) {
   if (info == NULL) {
     return;
diff -up gnome-control-center-2.19.90/capplets/appearance/gnome-wp-item.h.gnome-bg gnome-control-center-2.19.90/capplets/appearance/gnome-wp-item.h
--- gnome-control-center-2.19.90/capplets/appearance/gnome-wp-item.h.gnome-bg	2007-05-03 08:33:46.000000000 -0400
+++ gnome-control-center-2.19.90/capplets/appearance/gnome-wp-item.h	2007-08-16 02:35:10.000000000 -0400
@@ -24,6 +24,7 @@
 #include <libgnomeui/gnome-thumbnail.h>
 #include <gnome-wp-info.h>
 #include <libgnomevfs/gnome-vfs.h>
+#include <libgnomeui/gnome-bg.h>
 
 #ifndef _GNOME_WP_ITEM_H_
 #define _GNOME_WP_ITEM_H_
@@ -31,6 +32,8 @@
 typedef struct _GnomeWPItem GnomeWPItem;
 
 struct _GnomeWPItem {
+  GnomeBG *bg;
+    
   gchar * name;
   gchar * filename;
   gchar * description;
@@ -48,7 +51,6 @@ struct _GnomeWPItem {
   GdkColor * scolor;
 
   GnomeWPInfo * fileinfo;
-  GnomeWPInfo * uriinfo;
 
   /* Did the user remove us? */
   gboolean deleted;
@@ -62,10 +64,10 @@ GnomeWPItem * gnome_wp_item_new (const g
 				 GHashTable * wallpapers,
 				 GnomeThumbnailFactory * thumbnails);
 void gnome_wp_item_free (GnomeWPItem * item);
-GnomeWPItem * gnome_wp_item_dup (GnomeWPItem * item);
 GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
 					 GnomeThumbnailFactory * thumbs);
 void gnome_wp_item_update_description (GnomeWPItem * item);
+void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item);
 
 #endif
 
diff -up gnome-control-center-2.19.90/capplets/appearance/appearance-desktop.c.gnome-bg gnome-control-center-2.19.90/capplets/appearance/appearance-desktop.c
--- gnome-control-center-2.19.90/capplets/appearance/appearance-desktop.c.gnome-bg	2007-08-13 17:39:44.000000000 -0400
+++ gnome-control-center-2.19.90/capplets/appearance/appearance-desktop.c	2007-08-16 02:40:50.000000000 -0400
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <gconf/gconf-client.h>
 #include <libgnomeui/gnome-thumbnail.h>
+#include <libgnomeui/gnome-bg.h>
 
 typedef enum {
   GNOME_WP_SHADE_TYPE_SOLID,
@@ -113,6 +114,43 @@ get_selected_item (AppearanceData *data,
   return item;
 }
 
+static gboolean predicate (gpointer key, gpointer value, gpointer data)
+{
+  GnomeBG *bg = data;
+  GnomeWPItem *item = value;
+
+  return item->bg == bg;
+}
+
+static void on_item_changed (GnomeBG *bg, AppearanceData *data) {
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  GtkTreePath *path;
+  GnomeWPItem *item;
+
+  item = g_hash_table_find (data->wp_hash, predicate, bg);
+
+  if (!item)
+    return;
+  
+  model = gtk_tree_row_reference_get_model (item->rowref);
+  path = gtk_tree_row_reference_get_path (item->rowref);
+
+  if (gtk_tree_model_get_iter (model, &iter, path)) {
+    g_signal_handlers_block_by_func (bg, G_CALLBACK (on_item_changed), data);
+      
+    GdkPixbuf *pixbuf = gnome_wp_item_get_thumbnail (item, data->thumb_factory);
+    if (pixbuf) {
+      gtk_list_store_set (GTK_LIST_STORE (data->wp_model), &iter,
+                          0, pixbuf,
+                         -1);
+      g_object_unref (pixbuf);
+    }
+
+    g_signal_handlers_unblock_by_func (bg, G_CALLBACK (on_item_changed), data);
+  }
+}
+
 static void
 wp_props_load_wallpaper (gchar *key,
                          GnomeWPItem *item,
@@ -141,6 +179,7 @@ wp_props_load_wallpaper (gchar *key,
 
   path = gtk_tree_model_get_path (data->wp_model, &iter);
   item->rowref = gtk_tree_row_reference_new (data->wp_model, path);
+  g_signal_connect (item->bg, "changed", G_CALLBACK (on_item_changed), data);
   gtk_tree_path_free (path);
 }
 
diff -up gnome-control-center-2.19.90/capplets/appearance/gnome-wp-item.c.gnome-bg gnome-control-center-2.19.90/capplets/appearance/gnome-wp-item.c
--- gnome-control-center-2.19.90/capplets/appearance/gnome-wp-item.c.gnome-bg	2007-07-30 16:26:57.000000000 -0400
+++ gnome-control-center-2.19.90/capplets/appearance/gnome-wp-item.c	2007-08-16 02:35:10.000000000 -0400
@@ -25,10 +25,56 @@
 #include <gnome.h>
 #include <string.h>
 #include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <libgnomeui/gnome-bg.h>
 
 #include "gnome-wp-item.h"
 #include "gnome-wp-utils.h"
 
+static void set_bg_properties (GnomeWPItem *item)
+{
+  GnomeBGColorType color;
+  GnomeBGPlacement placement;
+
+  color = GNOME_BG_COLOR_SOLID;
+  
+  if (item->shade_type) {
+    if (!strcmp (item->shade_type, "horizontal-gradient")) {
+      color = GNOME_BG_COLOR_H_GRADIENT;
+    } else if (!strcmp (item->shade_type, "vertical-gradient")) {
+      color = GNOME_BG_COLOR_V_GRADIENT;
+    }
+  }
+
+  placement = GNOME_BG_PLACEMENT_TILED;
+  
+  if (item->options) {
+    if (!strcmp (item->options, "centered")) {
+      placement = GNOME_BG_PLACEMENT_CENTERED;
+    } else if (!strcmp (item->options, "stretched")) {
+      placement = GNOME_BG_PLACEMENT_FILL_SCREEN;
+    } else if (!strcmp (item->options, "scaled")) {
+      placement = GNOME_BG_PLACEMENT_SCALED;
+    } else if (!strcmp (item->options, "zoom")) {
+      placement = GNOME_BG_PLACEMENT_ZOOMED;
+    }
+  }
+
+  if (item->filename)
+    gnome_bg_set_uri (item->bg, item->filename);
+
+  gnome_bg_set_color (item->bg, color, item->pcolor, item->scolor);
+  gnome_bg_set_placement (item->bg, placement);
+}
+
+void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item)
+{
+  if (!item->bg) {
+    item->bg = gnome_bg_new ();
+
+    set_bg_properties (item);
+  }
+}
+
 GnomeWPItem * gnome_wp_item_new (const gchar * filename,
 				 GHashTable * wallpapers,
 				 GnomeThumbnailFactory * thumbnails) {
@@ -54,8 +100,11 @@ GnomeWPItem * gnome_wp_item_new (const g
   item->pcolor = gdk_color_copy (&color1);
   item->scolor = gdk_color_copy (&color2);
 
-  if (item->fileinfo != NULL &&
+  if (item->fileinfo != NULL) {
+#if 0
+      &&
       !strncmp (item->fileinfo->mime_type, "image/", strlen ("image/"))) {
+#endif
     if (item->name == NULL) {
       if (g_utf8_validate (item->fileinfo->name, -1, NULL))
 	item->name = g_strdup (item->fileinfo->name);
@@ -76,6 +125,10 @@ GnomeWPItem * gnome_wp_item_new (const g
     item = NULL;
   }
 
+  if (item) {
+    gnome_wp_item_ensure_gnome_bg (item);
+  }
+  
   g_object_unref (client);
 
   return item;
@@ -103,51 +156,14 @@ void gnome_wp_item_free (GnomeWPItem * i
     gdk_color_free (item->scolor);
 
   gnome_wp_info_free (item->fileinfo);
-  gnome_wp_info_free (item->uriinfo);
+  if (item->bg)
+    g_object_unref (item->bg);
 
   gtk_tree_row_reference_free (item->rowref);
 
   g_free (item);
 }
 
-GnomeWPItem * gnome_wp_item_dup (GnomeWPItem * item) {
-  GnomeWPItem * new_item;
-  GdkColor color1, color2;
-
-  if (item == NULL) {
-    return NULL;
-  }
-
-  new_item = g_new0 (GnomeWPItem, 1);
-
-  new_item->name = g_strdup (item->name);
-  new_item->filename = g_strdup (item->filename);
-  new_item->description = g_strdup (item->description);
-  new_item->imguri = g_strdup (item->imguri);
-  new_item->options = g_strdup (item->options);
-  new_item->shade_type = g_strdup (item->shade_type);
-
-  new_item->pri_color = g_strdup (item->pri_color);
-  new_item->sec_color = g_strdup (item->sec_color);
-
-  gdk_color_parse (item->pri_color, &color1);
-  gdk_color_parse (item->sec_color, &color2);
-
-  item->pcolor = gdk_color_copy (&color1);
-  item->scolor = gdk_color_copy (&color2);
-
-  new_item->fileinfo = gnome_wp_info_dup (item->fileinfo);
-  new_item->uriinfo = gnome_wp_info_dup (item->uriinfo);
-
-  new_item->rowref = gtk_tree_row_reference_copy (item->rowref);
-
-  new_item->deleted = item->deleted;
-  new_item->width = item->width;
-  new_item->height = item->height;
-
-  return new_item;
-}
-
 static void collect_save_options (GdkPixbuf * pixbuf,
 				  gchar *** keys,
 				  gchar *** vals,
@@ -201,153 +217,18 @@ static void collect_save_options (GdkPix
 
 GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
 					 GnomeThumbnailFactory * thumbs) {
-  GdkPixbuf * pixbuf, * bgpixbuf;
-  GdkPixbuf * scaled = NULL;
-  gint sw, sh, bw, bh, pw, ph, tw, th;
-  gdouble ratio;
-
-  sw = sh = bw = bh = pw = ph = tw = th = 0;
-
-  /*
-     Get the size of the screen and calculate our aspect ratio divisor
-     We do this, so that images are thumbnailed as they would look on
-     the screen in reality
-  */
-  sw = gdk_screen_get_width (gdk_screen_get_default ());
-  sh = gdk_screen_get_height (gdk_screen_get_default ());
-  ratio = (gdouble) sw / (gdouble) LIST_IMAGE_WIDTH;
-  bw = sw / ratio;
-  bh = sh / ratio;
-
-  /*
-     Create the pixbuf for the background colors, which will show up for
-     oddly sized images, smaller images that are centered, or alpha images
-  */
-  if (!strcmp (item->shade_type, "solid")) {
-    bgpixbuf = gnome_wp_pixbuf_new_solid (item->pcolor, bw, bh);
-  } else if (!strcmp (item->shade_type, "vertical-gradient")) {
-    bgpixbuf = gnome_wp_pixbuf_new_gradient (GTK_ORIENTATION_VERTICAL,
-					     item->pcolor, item->scolor,
-					     bw, bh);
-  } else {
-    bgpixbuf = gnome_wp_pixbuf_new_gradient (GTK_ORIENTATION_HORIZONTAL,
-					     item->pcolor, item->scolor,
-					     bw, bh);
-  }
-
-  /*
-     Load up the thumbnail image using the thumbnail spec
-     If the image doesn't exist, we create it
-     If we are creating the thumbnail for "No Wallpaper", then we just copy
-     the background colors pixbuf we created above, here
-  */
-  pixbuf = NULL;
-  if (!strcmp (item->filename, "(none)")) {
-    return bgpixbuf;
-  } else {
-    gchar * escaped_path, * thumbnail_filename;
-
-    escaped_path = gnome_vfs_escape_path_string (item->filename);
-    thumbnail_filename = gnome_thumbnail_factory_lookup (thumbs,
-                                                         escaped_path,
-                                                         item->fileinfo->mtime);
-
-    if (thumbnail_filename == NULL) {
-    pixbuf = gnome_thumbnail_factory_generate_thumbnail (thumbs,
-							 escaped_path,
-							 item->fileinfo->mime_type);
-    gnome_thumbnail_factory_save_thumbnail (thumbs, pixbuf,
-					    escaped_path,
-					    item->fileinfo->mtime);
-       g_object_unref (pixbuf);
-       pixbuf = NULL;
-
-       thumbnail_filename = gnome_thumbnail_factory_lookup (thumbs,
-                                                            escaped_path,
-                                                            item->fileinfo->mtime);
-    }
-
-    if (thumbnail_filename != NULL) {
-
-      pixbuf = gdk_pixbuf_new_from_file (thumbnail_filename, NULL);
-
-      if (pixbuf != NULL) {
-      	g_free (item->fileinfo->thumburi);
-        item->fileinfo->thumburi = thumbnail_filename;
-        thumbnail_filename = NULL;
-      }
-
-      g_free (thumbnail_filename);
-    }
-
-    g_free (escaped_path);
-  }
-
-  if (pixbuf != NULL) {
-    const gchar * w_val, * h_val;
-
-    w_val = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width");
-    h_val = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height");
-    if (item->width <= 0 || item->height <= 0) {
-      if (w_val && h_val) {
-	item->width = atoi (w_val);
-	item->height = atoi (h_val);
-      } else {
-	gchar ** keys = NULL;
-	gchar ** vals = NULL;
-
-        gdk_pixbuf_get_file_info (item->filename,
-                                  &item->width, &item->height);
-	collect_save_options (pixbuf, &keys, &vals, item->width, item->height);
-	gdk_pixbuf_savev (pixbuf, item->fileinfo->thumburi, "png",
-			  keys, vals, NULL);
-
-	g_strfreev (keys);
-	g_strfreev (vals);
-      }
-    }
-
-    pw = gdk_pixbuf_get_width (pixbuf);
-    ph = gdk_pixbuf_get_height (pixbuf);
-
-    if (item->width <= bw && item->height <= bh)
-      ratio = 1.0;
-
-    tw = item->width / ratio;
-    th = item->height / ratio;
-
-    if (!strcmp (item->options, "wallpaper")) {
-      scaled = gnome_wp_pixbuf_tile (pixbuf, bgpixbuf, tw, th);
-    } else if (!strcmp (item->options, "centered")) {
-      scaled = gnome_wp_pixbuf_center (pixbuf, bgpixbuf, tw, th);
-    } else if (!strcmp (item->options, "stretched")) {
-      scaled = gnome_wp_pixbuf_center (pixbuf, bgpixbuf, bw, bh);
-    } else if (!strcmp (item->options, "scaled")) {
-      if ((gdouble) ph * (gdouble) bw > (gdouble) pw * (gdouble) bh) {
-	tw = 0.5 + (gdouble) pw * (gdouble) bh / (gdouble) ph;
-	th = bh;
-      } else {
-	th = 0.5 + (gdouble) ph * (gdouble) bw / (gdouble) pw;
-	tw = bw;
-      }
-      scaled = gnome_wp_pixbuf_center (pixbuf, bgpixbuf, tw, th);
-    } else if (!strcmp (item->options, "zoom")) {
-      if ((gdouble) ph * (gdouble) bw < (gdouble) pw * (gdouble) bh) {
-	tw = 0.5 + (gdouble) pw * (gdouble) bh / (gdouble) ph;
-	th = bh;
-      } else {
-	th = 0.5 + (gdouble) ph * (gdouble) bw / (gdouble) pw;
-	tw = bw;
-      }
-      scaled = gnome_wp_pixbuf_center (pixbuf, bgpixbuf, tw, th);
-    }
-
-    g_object_unref (pixbuf);
-  }
-
-  g_object_unref (bgpixbuf);
-
-  return scaled;
+  GdkPixbuf *pixbuf;
+  double aspect =
+    (double)gdk_screen_get_height (gdk_screen_get_default()) / 
+    gdk_screen_get_width (gdk_screen_get_default());
+
+  set_bg_properties (item);
+  
+  pixbuf = gnome_bg_create_thumbnail (item->bg, thumbs, gdk_screen_get_default(), LIST_IMAGE_WIDTH, LIST_IMAGE_WIDTH * aspect);
+
+  gnome_bg_get_image_size (item->bg, thumbs, &item->width, &item->height);
+  
+  return pixbuf;
 }
 
 void gnome_wp_item_update_description (GnomeWPItem * item) {
diff -up gnome-control-center-2.19.90/gnome-settings-daemon/gnome-settings-background.c.gnome-bg gnome-control-center-2.19.90/gnome-settings-daemon/gnome-settings-background.c
--- gnome-control-center-2.19.90/gnome-settings-daemon/gnome-settings-background.c.gnome-bg	2007-07-02 08:30:05.000000000 -0400
+++ gnome-control-center-2.19.90/gnome-settings-daemon/gnome-settings-background.c	2007-08-16 02:35:10.000000000 -0400
@@ -30,11 +30,13 @@
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 #include <gconf/gconf.h>
+#include <libgnomeui/gnome-bg.h>
+#include <X11/Xatom.h>
+#include <string.h>
 
 #include "gnome-settings-module.h"
 
 #include "preferences.h"
-#include "applier.h"
 
 typedef struct _GnomeSettingsModuleBackground      GnomeSettingsModuleBackground;
 typedef struct _GnomeSettingsModuleBackgroundClass GnomeSettingsModuleBackgroundClass;
@@ -42,11 +44,13 @@ typedef struct _GnomeSettingsModuleBackg
 struct _GnomeSettingsModuleBackground {
 	GnomeSettingsModule parent;
 
-	BGApplier **bg_appliers;
 	BGPreferences *prefs;
-	guint applier_idle_id;
+        GnomeBG *bg;
+        guint timeout_id;
 };
 
+static gboolean nautilus_is_running (void);
+
 struct _GnomeSettingsModuleBackgroundClass {
 	GnomeSettingsModuleClass parent_class;
 };
@@ -59,20 +63,104 @@ static gboolean gnome_settings_module_ba
 static gboolean gnome_settings_module_background_start (GnomeSettingsModule *module);
 
 static gboolean
-applier_idle (gpointer data)
+apply_prefs (gpointer data)
 {
 	GnomeSettingsModuleBackground *module;
-	int i;
 
 	module = (GnomeSettingsModuleBackground *) data;
 
-	for (i = 0; module->bg_appliers [i]; i++)
-		bg_applier_apply_prefs (module->bg_appliers [i], module->prefs);
-	module->applier_idle_id = 0;
+        if (!nautilus_is_running()) {
+                GdkDisplay *display;
+                int n_screens, i;
+                GnomeBGPlacement placement;
+                GnomeBGColorType color;
+                const char *uri;
+ 
+                display = gdk_display_get_default ();
+                n_screens = gdk_display_get_n_screens (display);
+ 
+                uri = module->prefs->wallpaper_filename;
+ 
+                placement = GNOME_BG_PLACEMENT_TILED;
+ 
+                switch (module->prefs->wallpaper_type) {
+                case WPTYPE_TILED:
+                        placement = GNOME_BG_PLACEMENT_TILED;
+                        break;
+                case WPTYPE_CENTERED:
+                        placement = GNOME_BG_PLACEMENT_CENTERED;
+                        break;
+                case WPTYPE_SCALED:
+                        placement = GNOME_BG_PLACEMENT_SCALED;
+                        break;
+                case WPTYPE_STRETCHED:
+                        placement = GNOME_BG_PLACEMENT_FILL_SCREEN;
+                        break;
+                case WPTYPE_ZOOM:
+                        placement = GNOME_BG_PLACEMENT_ZOOMED;
+                        break;
+                case WPTYPE_NONE:
+                case WPTYPE_UNSET:
+                        uri = NULL;
+                        break;
+                }
+ 
+                switch (module->prefs->orientation) {
+                case ORIENTATION_SOLID:
+                        color = GNOME_BG_COLOR_SOLID;
+                        break;
+                case ORIENTATION_HORIZ:
+                        color = GNOME_BG_COLOR_H_GRADIENT;
+                        break;
+                case ORIENTATION_VERT:
+                        color = GNOME_BG_COLOR_V_GRADIENT;
+                        break;
+                default:
+                        color = GNOME_BG_COLOR_SOLID;
+                        break;
+                }
+ 
+                gnome_bg_set_uri (module->bg, uri);
+                gnome_bg_set_placement (module->bg, placement);
+                gnome_bg_set_color (module->bg, color, module->prefs->color1, module->prefs->color2);
+ 
+                for (i = 0; i < n_screens; ++i) {
+                        GdkScreen *screen;
+                        GdkWindow *root_window;
+                        GdkPixmap *pixmap;
+ 
+                        screen = gdk_display_get_screen (display, i);
+ 
+                        root_window = gdk_screen_get_root_window (screen);
+ 
+                        pixmap = gnome_bg_create_pixmap (module->bg, root_window,
+                                                         gdk_screen_get_width (screen),
+                                                         gdk_screen_get_height (screen),
+                                                         TRUE);
+
+                        gnome_bg_set_pixmap_as_root (screen, pixmap);
+
+                        g_object_unref (pixmap);
+                }
+        }
+
 	return FALSE;
 }
 
 static void
+queue_apply (gpointer data)
+{
+	GnomeSettingsModuleBackground *module;
+
+	module = (GnomeSettingsModuleBackground *) data;
+	if (module->timeout_id) {
+		g_source_remove (module->timeout_id);
+	}
+
+	module->timeout_id = g_timeout_add (100, apply_prefs, data);
+}
+
+static void
 background_callback (GConfClient *client,
                      guint cnxn_id,
                      GConfEntry *entry,
@@ -84,13 +172,17 @@ background_callback (GConfClient *client
 
 	bg_preferences_merge_entry (module_bg->prefs, entry);
 
-	if (module_bg->applier_idle_id != 0) {
-		g_source_remove (module_bg->applier_idle_id);
-	}
+	queue_apply (user_data);
+}
 
-	module_bg->applier_idle_id = g_timeout_add (100, applier_idle, module_bg);
+static void
+on_bg_changed (GnomeBG *bg,
+               gpointer user_data)
+{
+	queue_apply (user_data);
 }
 
+
 static void
 gnome_settings_module_background_class_init (GnomeSettingsModuleBackgroundClass *klass)
 {
@@ -105,7 +197,7 @@ gnome_settings_module_background_class_i
 static void
 gnome_settings_module_background_init (GnomeSettingsModuleBackground *module)
 {
-	module->applier_idle_id = 0;
+	module->timeout_id = 0;
 }
 
 GType
@@ -145,28 +237,17 @@ gnome_settings_module_background_initial
 					     GConfClient *config_client)
 {
 	GnomeSettingsModuleBackground *module_bg;
-	GdkDisplay *display;
-	int         n_screens;
-	int         i;
 
 	module_bg = (GnomeSettingsModuleBackground *) module;
-	display = gdk_display_get_default ();
-	n_screens = gdk_display_get_n_screens (display);
-
-	module_bg->bg_appliers = g_new (BGApplier *, n_screens + 1);
-
-	for (i = 0; i < n_screens; i++) {
-		GdkScreen *screen;
-
-		screen = gdk_display_get_screen (display, i);
-
-		module_bg->bg_appliers [i] = BG_APPLIER (bg_applier_new_for_screen (BG_APPLIER_ROOT, screen));
-	}
-	module_bg->bg_appliers [i] = NULL;
 
 	module_bg->prefs = BG_PREFERENCES (bg_preferences_new ());
+	module_bg->bg = gnome_bg_new ();
+
+        g_signal_connect (module_bg->bg, "changed", G_CALLBACK (on_bg_changed), module_bg);
 	bg_preferences_load (module_bg->prefs);
 
+        apply_prefs (module_bg);
+
 	gconf_client_notify_add (config_client,
 	                         "/desktop/gnome/background",
 	                         background_callback,
@@ -197,8 +278,72 @@ gnome_settings_module_background_start (
 				   "/apps/nautilus/preferences/show_desktop", NULL))
 		return TRUE;
 
-	for (i = 0; module_bg->bg_appliers [i]; i++)
-		bg_applier_apply_prefs (module_bg->bg_appliers [i], module_bg->prefs);
+	apply_prefs (module_bg);
 
 	return TRUE;
 }
+
+static gboolean
+nautilus_is_running (void)
+{
+	Atom window_id_atom;
+	Window nautilus_xid;
+	Atom actual_type;
+	int actual_format;
+	unsigned long nitems, bytes_after;
+	unsigned char *data;
+	int retval;
+	Atom wmclass_atom;
+	gboolean running;
+	gint error;
+
+	window_id_atom = XInternAtom (GDK_DISPLAY (),
+				      "NAUTILUS_DESKTOP_WINDOW_ID", True);
+
+	if (window_id_atom == None) return FALSE;
+
+	retval = XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
+				     window_id_atom, 0, 1, False, XA_WINDOW,
+				     &actual_type, &actual_format, &nitems,
+				     &bytes_after, &data);
+
+	if (data != NULL) {
+		nautilus_xid = *(Window *) data;
+		XFree (data);
+	} else {
+		return FALSE;
+	}
+
+	if (actual_type != XA_WINDOW) return FALSE;
+	if (actual_format != 32) return FALSE;
+
+	wmclass_atom = XInternAtom (GDK_DISPLAY (), "WM_CLASS", False);
+
+	gdk_error_trap_push ();
+
+	retval = XGetWindowProperty (GDK_DISPLAY (), nautilus_xid,
+				     wmclass_atom, 0, 24, False, XA_STRING,
+				     &actual_type, &actual_format, &nitems,
+				     &bytes_after, &data);
+
+	error = gdk_error_trap_pop ();
+
+	if (error == BadWindow) return FALSE;
+
+	if (actual_type == XA_STRING &&
+	    nitems == 24 &&
+	    bytes_after == 0 &&
+	    actual_format == 8 &&
+	    data != NULL &&
+	    !strcmp ((char *)data, "desktop_window") &&
+	    !strcmp ((char *)data + strlen ((char *)data) + 1, "Nautilus"))
+		running = TRUE;
+	else
+		running = FALSE;
+
+	if (data != NULL)
+		XFree (data);
+
+	return running;
+}
+


Index: control-center.spec
===================================================================
RCS file: /cvs/extras/rpms/control-center/devel/control-center.spec,v
retrieving revision 1.295
retrieving revision 1.296
diff -u -r1.295 -r1.296
--- control-center.spec	14 Aug 2007 05:04:34 -0000	1.295
+++ control-center.spec	16 Aug 2007 06:51:29 -0000	1.296
@@ -22,7 +22,7 @@
 Summary: GNOME Control Center
 Name: control-center
 Version: 2.19.90
-Release: 1%{?dist}
+Release: 2%{?dist}
 Epoch: 1
 License: GPLv2+ and GFDL+
 Group: User Interface/Desktops
@@ -51,7 +51,7 @@
 Patch13: control-center-2.19.3-no-gnome-common.patch
 
 # FIXME: figure out how this applies to the new appearance capplet
-#Patch14: control-center-2.19.1-gnome-bg.patch
+Patch14: gnome-bg.patch
 
 # http://bugzilla.gnome.org/show_bug.cgi?id=430889
 # disable for now, upstream plans conflicting changes
@@ -187,7 +187,7 @@
 
 #%patch12 -p1 -b .start-at-helper
 %patch13 -p1 -b .no-gnome-common
-#%patch14 -p1 -b .gnome-bg
+%patch14 -p1 -b .gnome-bg
 #%patch16 -p1 -b .be-more-async
 
 # vendor configuration patches
@@ -380,6 +380,9 @@
 %dir %{_datadir}/gnome-control-center/keybindings
 
 %changelog
+* Thu Aug 16 2007 Matthias Clasen <mclasen at redhat.com> - 2.19.90-2
+- Port Soerens background patch to the appearance capplet
+
 * Mon Aug 13 2007 Matthias Clasen <mclasen at redhat.com> - 2.19.90-1
 - Update to 2.19.90
 - Build the sound capplet again




More information about the fedora-extras-commits mailing list