diff options
author | Denis Washington <denisw@svn.gnome.org> | 2008-01-15 01:47:41 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2008-01-15 01:47:41 +0000 |
commit | 45a77d648e41589d59bc4f2c3067328d9bd3fc47 (patch) | |
tree | c23fe3151b50d3d82c748ecc3bd975c2ae655578 | |
parent | 4c12566cfacc5a7aba43c3981a7beaafd0188dc9 (diff) | |
download | gnome-control-center-45a77d648e41589d59bc4f2c3067328d9bd3fc47.tar.gz |
Index: gnome-settings-daemon/ChangeLog
===================================================================
--- gnome-settings-daemon/ChangeLog (revision 8392)
+++ gnome-settings-daemon/ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2008-01-14 Soren Sandmann <sandmann@daimi.au.dk>
+
+ * gnome-settings-background.c: Use GnomeBG from gnome-desktop
+
+
+
2008-01-14 Denis Washington <denisw@svn.gnome.org>
* gnome-settings-mouse.c:
===================================================================
--- libbackground/ChangeLog (revision 8336)
+++ libbackground/ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2008-01-14 Soren Sandmann <sandmann@daimi.au.dk>
+
+ * applier.[ch]: Delete these files
+
+ * Makefile.am: Remove them here.
+
2007-04-16 Jens Granseuer <jensgr@gmx.net>
Patch by: Erich Schubert <erich@debian.org>
Index: capplets/appearance/ChangeLog
===================================================================
--- capplets/appearance/ChangeLog (revision 8392)
+++ capplets/appearance/ChangeLog (working copy)
@@ -1,3 +1,13 @@
+2008-01-14 Soren Sandmann <sandmann@redhat.com>
+
+ * appearance-desktop.c: Update list model when the background
+ changes.
+ * gnome-wp-item.c: Create a GnomeBG for the item.
+ * gnome-wp-item.h: Add a GnomeBG field - Remove
+ gnome_wp_item_dup() function.
+ * gnome-wp-info.c: Delete gnome_wp_item_dup() function.
+ * gnome-wp-xml.c: Ensure that a GnomeBG exists.
+
2007-12-22 Thomas Wood <thos@gnome.org>
* theme-installer.c: (transfer_done_tgz_tbz),
svn path=/trunk/; revision=8393
-rw-r--r-- | capplets/appearance/ChangeLog | 10 | ||||
-rw-r--r-- | capplets/appearance/appearance-desktop.c | 39 | ||||
-rw-r--r-- | capplets/appearance/gnome-wp-info.c | 21 | ||||
-rw-r--r-- | capplets/appearance/gnome-wp-info.h | 1 | ||||
-rw-r--r-- | capplets/appearance/gnome-wp-item.c | 253 | ||||
-rw-r--r-- | capplets/appearance/gnome-wp-item.h | 6 | ||||
-rw-r--r-- | capplets/appearance/gnome-wp-xml.c | 4 | ||||
-rw-r--r-- | configure.in | 10 | ||||
-rw-r--r-- | gnome-settings-daemon/ChangeLog | 4 | ||||
-rw-r--r-- | gnome-settings-daemon/gnome-settings-background.c | 208 | ||||
-rw-r--r-- | libbackground/ChangeLog | 6 | ||||
-rw-r--r-- | libbackground/Makefile.am | 1 |
12 files changed, 321 insertions, 242 deletions
diff --git a/capplets/appearance/ChangeLog b/capplets/appearance/ChangeLog index 22e1b3236..17e439512 100644 --- a/capplets/appearance/ChangeLog +++ b/capplets/appearance/ChangeLog @@ -1,3 +1,13 @@ +2008-01-14 Soren Sandmann <sandmann@redhat.com> + + * appearance-desktop.c: Update list model when the background + changes. + * gnome-wp-item.c: Create a GnomeBG for the item. + * gnome-wp-item.h: Add a GnomeBG field - Remove + gnome_wp_item_dup() function. + * gnome-wp-info.c: Delete gnome_wp_item_dup() function. + * gnome-wp-xml.c: Ensure that a GnomeBG exists. + 2007-12-22 Thomas Wood <thos@gnome.org> * theme-installer.c: (transfer_done_tgz_tbz), diff --git a/capplets/appearance/appearance-desktop.c b/capplets/appearance/appearance-desktop.c index 32ab70740..51310f633 100644 --- a/capplets/appearance/appearance-desktop.c +++ b/capplets/appearance/appearance-desktop.c @@ -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, @@ -112,6 +113,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, @@ -140,6 +178,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 --git a/capplets/appearance/gnome-wp-info.c b/capplets/appearance/gnome-wp-info.c index 12ada351a..c49d0decd 100644 --- a/capplets/appearance/gnome-wp-info.c +++ b/capplets/appearance/gnome-wp-info.c @@ -67,27 +67,6 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri, 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 --git a/capplets/appearance/gnome-wp-info.h b/capplets/appearance/gnome-wp-info.h index 2f58406eb..f8cf69074 100644 --- a/capplets/appearance/gnome-wp-info.h +++ b/capplets/appearance/gnome-wp-info.h @@ -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 --git a/capplets/appearance/gnome-wp-item.c b/capplets/appearance/gnome-wp-item.c index e2ab08b09..8cd68d60c 100644 --- a/capplets/appearance/gnome-wp-item.c +++ b/capplets/appearance/gnome-wp-item.c @@ -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) { @@ -46,7 +92,8 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename, item->fileinfo = gnome_wp_info_new (item->filename, thumbnails); if (item->fileinfo != NULL && - g_str_has_prefix (item->fileinfo->mime_type, "image/")) { + (g_str_has_prefix (item->fileinfo->mime_type, "image/") || + strcmp (item->fileinfo->mime_type, "application/xml") == 0)) { if (item->name == NULL) { if (g_utf8_validate (item->fileinfo->name, -1, NULL)) item->name = g_strdup (item->fileinfo->name); @@ -88,6 +135,10 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename, item = NULL; } + if (item) { + gnome_wp_item_ensure_gnome_bg (item); + } + g_object_unref (client); return item; @@ -111,43 +162,14 @@ void gnome_wp_item_free (GnomeWPItem * item) { 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; - - 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->options = g_strdup (item->options); - new_item->shade_type = g_strdup (item->shade_type); - - new_item->pcolor = gdk_color_copy (item->pcolor); - new_item->scolor = gdk_color_copy (item->scolor); - - 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 +223,18 @@ static void collect_save_options (GdkPixbuf * pixbuf, 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) { @@ -356,6 +243,12 @@ void gnome_wp_item_update_description (GnomeWPItem * item) { if (!strcmp (item->filename, "(none)")) { item->description = g_strdup (item->name); } else { + gchar *description; + + if (strcmp (item->fileinfo->mime_type, "application/xml") == 0) + description = _("Slide Show"); + else + description = gnome_vfs_mime_get_description (item->fileinfo->mime_type); gchar *dirname = g_path_get_dirname (item->filename); /* translators: <b>wallpaper name</b> * mime type, x pixel(s) by y pixel(s) @@ -365,7 +258,7 @@ void gnome_wp_item_update_description (GnomeWPItem * item) { "%s, %d %s by %d %s\n" "Folder: %s"), item->name, - gnome_vfs_mime_get_description (item->fileinfo->mime_type), + description, item->width, ngettext ("pixel", "pixels", item->width), item->height, diff --git a/capplets/appearance/gnome-wp-item.h b/capplets/appearance/gnome-wp-item.h index 776960fa3..9b15deda3 100644 --- a/capplets/appearance/gnome-wp-item.h +++ b/capplets/appearance/gnome-wp-item.h @@ -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; @@ -45,7 +48,6 @@ struct _GnomeWPItem { GdkColor * scolor; GnomeWPInfo * fileinfo; - GnomeWPInfo * uriinfo; /* Did the user remove us? */ gboolean deleted; @@ -59,10 +61,10 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename, 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 --git a/capplets/appearance/gnome-wp-xml.c b/capplets/appearance/gnome-wp-xml.c index 36f1aefe2..bab6c8c95 100644 --- a/capplets/appearance/gnome-wp-xml.c +++ b/capplets/appearance/gnome-wp-xml.c @@ -231,7 +231,11 @@ static void gnome_wp_xml_load_xml (AppearanceData *data, 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 --git a/configure.in b/configure.in index eb73c4164..1cccaceb9 100644 --- a/configure.in +++ b/configure.in @@ -95,7 +95,7 @@ COMMON_MODULES="gtk+-2.0 >= 2.3.0 dnl libglade-2.0 >= 2.0.0 dnl libbonobo-2.0 dnl libbonoboui-2.0 dnl - gnome-desktop-2.0 >= 2.2.0" + gnome-desktop-2.0 >= 2.21.4" PKG_CHECK_MODULES(LIBSLAB, $COMMON_MODULES gnome-desktop-2.0 librsvg-2.0 libgnome-menu pango eel-2.0) PKG_CHECK_MODULES(CAPPLET, $COMMON_MODULES) PKG_CHECK_MODULES(GNOMECC, $COMMON_MODULES libgnome-menu >= 2.10.1 libpanelapplet-2.0) @@ -518,10 +518,10 @@ capplets/sound/Makefile capplets/sound/gnome-settings-sound.desktop.in capplets/windows/Makefile capplets/windows/window-properties.desktop.in -#gnome-settings-daemon/Makefile -#gnome-settings-daemon/actions/Makefile -#gnome-settings-daemon/gnome-settings-daemon.pc -#gnome-settings-daemon/xrdb/Makefile +gnome-settings-daemon/Makefile +gnome-settings-daemon/actions/Makefile +gnome-settings-daemon/gnome-settings-daemon.pc +gnome-settings-daemon/xrdb/Makefile help/Makefile libbackground/Makefile libslab/Makefile diff --git a/gnome-settings-daemon/ChangeLog b/gnome-settings-daemon/ChangeLog index 8a9a51b7a..91bbe7f66 100644 --- a/gnome-settings-daemon/ChangeLog +++ b/gnome-settings-daemon/ChangeLog @@ -1,3 +1,7 @@ +2008-01-14 Soren Sandmann <sandmann@daimi.au.dk> + + * gnome-settings-background.c: Use GnomeBG from gnome-desktop + 2008-01-14 Denis Washington <denisw@svn.gnome.org> * gnome-settings-mouse.c: diff --git a/gnome-settings-daemon/gnome-settings-background.c b/gnome-settings-daemon/gnome-settings-background.c index 10155d7a3..5da9a82de 100644 --- a/gnome-settings-daemon/gnome-settings-background.c +++ b/gnome-settings-daemon/gnome-settings-background.c @@ -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 _GnomeSettingsModuleBackgroundClass GnomeSettingsModuleBackground 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_background_initialize (GnomeSettingsModule 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_init (GnomeSettingsModuleBackgroundClass 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_initialize (GnomeSettingsModule *module, 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, @@ -181,7 +262,6 @@ static gboolean gnome_settings_module_background_start (GnomeSettingsModule *module) { GnomeSettingsModuleBackground *module_bg; - int i; module_bg = (GnomeSettingsModuleBackground *) module; @@ -197,8 +277,72 @@ gnome_settings_module_background_start (GnomeSettingsModule *module) "/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; +} + diff --git a/libbackground/ChangeLog b/libbackground/ChangeLog index c958a0421..6c142ed2b 100644 --- a/libbackground/ChangeLog +++ b/libbackground/ChangeLog @@ -1,3 +1,9 @@ +2008-01-14 Soren Sandmann <sandmann@daimi.au.dk> + + * applier.[ch]: Delete these files + + * Makefile.am: Remove them here. + 2007-04-16 Jens Granseuer <jensgr@gmx.net> Patch by: Erich Schubert <erich@debian.org> diff --git a/libbackground/Makefile.am b/libbackground/Makefile.am index 0486b2be7..df3c7f783 100644 --- a/libbackground/Makefile.am +++ b/libbackground/Makefile.am @@ -9,5 +9,4 @@ INCLUDES = \ noinst_LTLIBRARIES = libbackground.la libbackground_la_SOURCES = \ - applier.c applier.h \ preferences.c preferences.h |