rpms/control-center/devel control-center-2.18.0-gnome-bg.patch, NONE, 1.1 control-center.spec, 1.235, 1.236

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Tue Mar 20 00:09:49 UTC 2007


Author: sandmann

Update of /cvs/dist/rpms/control-center/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv21299

Modified Files:
	control-center.spec 
Added Files:
	control-center-2.18.0-gnome-bg.patch 
Log Message:
Add support for Gnome bg in gnome settings daemon and gnome-wp-capplet

control-center-2.18.0-gnome-bg.patch:
 capplets/background/gnome-wp-capplet.c            |   37 +++
 capplets/background/gnome-wp-info.c               |   21 -
 capplets/background/gnome-wp-info.h               |    1 
 capplets/background/gnome-wp-item.c               |  259 ++++++----------------
 capplets/background/gnome-wp-item.h               |    6 
 capplets/background/gnome-wp-xml.c                |    5 
 gnome-settings-daemon/gnome-settings-background.c |  205 ++++++++++++++---
 7 files changed, 290 insertions(+), 244 deletions(-)

--- NEW FILE control-center-2.18.0-gnome-bg.patch ---
--- control-center-2.18.0/capplets/background/gnome-wp-item.h.gnome-bg	2007-01-02 07:47:00.000000000 -0500
+++ control-center-2.18.0/capplets/background/gnome-wp-item.h	2007-03-19 19:53:29.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 @@
   GdkColor * scolor;
 
   GnomeWPInfo * fileinfo;
-  GnomeWPInfo * uriinfo;
 
   /* Did the user remove us? */
   gboolean deleted;
@@ -62,10 +64,10 @@
 				 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
 
--- control-center-2.18.0/capplets/background/gnome-wp-capplet.c.gnome-bg	2007-03-19 19:52:16.000000000 -0400
+++ control-center-2.18.0/capplets/background/gnome-wp-capplet.c	2007-03-19 19:53:29.000000000 -0400
@@ -17,7 +17,7 @@
  *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
  *
  */
-
+#include <libgnomeui/gnome-bg.h>
 #include "gnome-wp-capplet.h"
 
 enum {
@@ -193,6 +193,39 @@
   }
 }
 
+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, GnomeWPCapplet *capplet) {
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  GtkTreePath *path;
+  GnomeWPItem *item;
+
+  item = g_hash_table_find (capplet->wphash, 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)) {
+    GdkPixbuf *pixbuf = gnome_wp_item_get_thumbnail (item, capplet->thumbs);
+    if (pixbuf) {
+      gtk_list_store_set (GTK_LIST_STORE (capplet->model), &iter,
+			  0, pixbuf,
+			  -1);
+      g_object_unref (pixbuf);
+    }
+  }
+}
+
 static void wp_props_load_wallpaper (gchar * key,
 				     GnomeWPItem * item,
 				     GnomeWPCapplet * capplet) {
@@ -224,6 +257,8 @@
   }
   path = gtk_tree_model_get_path (capplet->model, &iter);
   item->rowref = gtk_tree_row_reference_new (capplet->model, path);
+  g_print ("connecting to %p\n", item->bg);
+  g_signal_connect (item->bg, "changed", G_CALLBACK (on_item_changed), capplet);
   gtk_tree_path_free (path);
 }
 
--- control-center-2.18.0/capplets/background/gnome-wp-info.h.gnome-bg	2007-01-02 07:47:00.000000000 -0500
+++ control-center-2.18.0/capplets/background/gnome-wp-info.h	2007-03-19 19:53:29.000000000 -0400
@@ -40,7 +40,6 @@
 
 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
--- control-center-2.18.0/capplets/background/gnome-wp-xml.c.gnome-bg	2007-03-06 04:40:46.000000000 -0500
+++ control-center-2.18.0/capplets/background/gnome-wp-xml.c	2007-03-19 19:53:29.000000000 -0400
@@ -223,16 +223,17 @@
 	   g_file_test (wp->filename, G_FILE_TEST_EXISTS)) ||
 	  !strcmp (wp->filename, "(none)")) {
 	wp->fileinfo = gnome_wp_info_new (wp->filename, capplet->thumbs);
-
 	if (wp->name == NULL || !strcmp (wp->filename, "(none)")) {
 	  wp->name = g_strdup (wp->fileinfo->name);
 	}
-
+	
 	gnome_wp_item_update_description (wp);
 	g_hash_table_insert (capplet->wphash, wp->filename, wp);
       } else {
 	gnome_wp_item_free (wp);
       }
+
+      gnome_wp_item_ensure_gnome_bg (wp);
     }
   }
   xmlFreeDoc (wplist);
--- control-center-2.18.0/capplets/background/gnome-wp-item.c.gnome-bg	2007-03-06 04:40:46.000000000 -0500
+++ control-center-2.18.0/capplets/background/gnome-wp-item.c	2007-03-19 19:53:29.000000000 -0400
@@ -25,10 +25,61 @@
 #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;
+  
+  g_print ("option is %s\n", item->options);
+  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) {
+    g_print ("set uri to %s\n", item->filename);
+    gnome_bg_set_uri (item->bg, item->filename);
+  }
+  else
+    g_print ("no uri\n");
+
+  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 +105,11 @@
   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 +130,14 @@
     item = NULL;
   }
 
+  if (item) {
+    gnome_wp_item_ensure_gnome_bg (item);
+  
+    g_print ("new item %p with %p as bg\n", item, item->bg);
+  }
+  else
+      g_print ("couldn't create the item\n");
+  
   g_object_unref (client);
 
   return item;
@@ -103,51 +165,14 @@
     gdk_color_free (item->scolor);
 
   gnome_wp_info_free (item->fileinfo);
-  gnome_wp_info_free (item->uriinfo);
 
   gtk_tree_row_reference_free (item->rowref);
 
+  g_object_unref (item->bg);
+  
   item = NULL;
 }
 
-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 +226,19 @@
 
 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);
-      }
-    }
+  GdkPixbuf *pixbuf;
+  double aspect =
+    (double)gdk_screen_get_height (gdk_screen_get_default()) / 
+    gdk_screen_get_width (gdk_screen_get_default());
 
-    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);
+  set_bg_properties (item);
+  
+  pixbuf = gnome_bg_create_thumbnail (item->bg, thumbs, gdk_screen_get_default(), LIST_IMAGE_WIDTH, LIST_IMAGE_WIDTH * aspect);
 
-  return scaled;
+  gnome_bg_get_image_size (item->bg, thumbs, &item->width, &item->height);
+  
+  return pixbuf;
 }
 
 void gnome_wp_item_update_description (GnomeWPItem * item) {
--- control-center-2.18.0/capplets/background/gnome-wp-info.c.gnome-bg	2007-01-08 13:15:11.000000000 -0500
+++ control-center-2.18.0/capplets/background/gnome-wp-info.c	2007-03-19 19:53:29.000000000 -0400
@@ -67,27 +67,6 @@
   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;
--- control-center-2.18.0/gnome-settings-daemon/gnome-settings-background.c.gnome-bg	2007-01-30 11:50:36.000000000 -0500
+++ control-center-2.18.0/gnome-settings-daemon/gnome-settings-background.c	2007-03-19 19:53:29.000000000 -0400
@@ -30,73 +30,148 @@
 #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-background.h"
 #include "gnome-settings-keyboard.h"
 #include "gnome-settings-daemon.h"
 
 #include "preferences.h"
-#include "applier.h"
 
-static BGApplier **bg_appliers;
 static BGPreferences *prefs;
+static GnomeBG *bg;
 
-static guint applier_idle_id = 0;
+static guint timeout_id = 0;
+
+static gboolean nautilus_is_running (void);
 
 static gboolean
-applier_idle (gpointer data)
+apply_prefs (gpointer data)
 {
-	int i;
-	for (i = 0; bg_appliers [i]; i++)
-		bg_applier_apply_prefs (bg_appliers [i], prefs);
-	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 = prefs->wallpaper_filename;
+	
+		placement = GNOME_BG_PLACEMENT_TILED;
+		
+		switch (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 (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 (bg, uri);
+		gnome_bg_set_placement (bg, placement);
+		gnome_bg_set_color (bg, color, prefs->color1, 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 (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 (void)
+{
+	if (timeout_id) {
+		g_source_remove (timeout_id);
+	}
+
+	timeout_id = g_timeout_add (100, apply_prefs, NULL);
+}	
+       
+
+static void
 background_callback (GConfEntry *entry) 
 {
 	bg_preferences_merge_entry (prefs, entry);
 
-	if (applier_idle_id != 0) {
-		g_source_remove (applier_idle_id);
-	}
+	queue_apply ();
+}
 
-	applier_idle_id = g_timeout_add (100, applier_idle, NULL);
+static void
+on_bg_changed (GnomeBG *bg)
+{
+	queue_apply ();
 }
 
 void
 gnome_settings_background_init (GConfClient *client)
 {
-	GdkDisplay *display;
-	int         n_screens;
-	int         i;
-
-	display = gdk_display_get_default ();
-	n_screens = gdk_display_get_n_screens (display);
-
-	bg_appliers = g_new (BGApplier *, n_screens + 1);
-
-	for (i = 0; i < n_screens; i++) {
-		GdkScreen *screen;
-
-		screen = gdk_display_get_screen (display, i);
+	prefs = BG_PREFERENCES (bg_preferences_new ());
 
-		bg_appliers [i] = BG_APPLIER (bg_applier_new_for_screen (BG_APPLIER_ROOT, screen));
-	}
-	bg_appliers [i] = NULL;
+	bg = gnome_bg_new ();
 
-	prefs = BG_PREFERENCES (bg_preferences_new ());
+	g_signal_connect (bg, "changed", G_CALLBACK (on_bg_changed), NULL);
+	
 	bg_preferences_load (prefs);
 
+	apply_prefs (NULL);
+	
 	gnome_settings_daemon_register_callback ("/desktop/gnome/background", background_callback);
 }
 
 void
 gnome_settings_background_load (GConfClient *client)
 {
-	int i;
-
 	/* If this is set, nautilus will draw the background and is
 	 * almost definitely in our session.  however, it may not be
 	 * running yet (so is_nautilus_running() will fail).  so, on
@@ -108,6 +183,70 @@
 	if (gconf_client_get_bool (client, "/apps/nautilus/preferences/show_desktop", NULL))
 		return;
 
-	for (i = 0; bg_appliers [i]; i++)
-		bg_applier_apply_prefs (bg_appliers [i], prefs);
+	apply_prefs (NULL);
+}
+
+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/dist/rpms/control-center/devel/control-center.spec,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -r1.235 -r1.236
--- control-center.spec	19 Mar 2007 15:54:50 -0000	1.235
+++ control-center.spec	20 Mar 2007 00:09:47 -0000	1.236
@@ -3,7 +3,7 @@
 %define pango_version 1.0.99.020703
 %define gtk2_version 2.6.0
 %define gconf2_version 1.2.0
-%define gnome_desktop_version 2.3.0
+%define gnome_desktop_version 2.18.0-2
 %define libgnome_version 2.3.0
 %define libbonobo_version 2.3.0
 %define libgnomeui_version 2.3.0
@@ -21,7 +21,7 @@
 Summary: GNOME Control Center
 Name: control-center
 Version: 2.18.0
-Release: 2%{?dist}
+Release: 3%{?dist}
 Epoch: 1
 License: GPL/LGPL
 Group: User Interface/Desktops
@@ -53,6 +53,8 @@
 
 Patch13: control-center-2.17.91-no-gnome-common.patch
 
+Patch14: control-center-2.18.0-gnome-bg.patch
+
 # call the Fedora/RHEL graphical passwd changing apps
 Patch95: control-center-2.17.91-passwd.patch
 Patch96: control-center-2.17.92-gecos.patch
@@ -79,6 +81,7 @@
 Requires: alsa-lib
 Requires: gnome-menus >= %{gnome_menus_version}
 Requires: usermode >= %{usermode_version}
+Requires: gnome-desktop >= %{gnome_desktop_version}
 
 BuildRequires: autoconf automake libtool
 BuildRequires: esound-devel
@@ -163,6 +166,8 @@
 
 %patch12 -p1 -b .start-at-helper
 %patch13 -p1 -b .no-gnome-common
+%patch14 -p1 -b .gnome-bg.patch
+
 
 # vendor configuration patches
 %patch95 -p1 -b .passwd
@@ -315,6 +320,9 @@
 %{_libdir}/pkgconfig/*
 
 %changelog
+* Mon Mar 19 2007 Soren Sandmann <sandmann at redhat.com> - 2.18.0-3
+- Add control-center-2.18
+
 * Mon Mar 19 2007 Matthias Clasen <mclasen at redhat.com> - 2.18.0-2
 - Don't show the theme installer in the menus
 




More information about the fedora-cvs-commits mailing list