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
This commit is contained in:
Denis Washington 2008-01-15 01:47:41 +00:00 committed by Søren Sandmann Pedersen
parent 4c12566cfa
commit 45a77d648e
12 changed files with 320 additions and 241 deletions

View file

@ -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> 2007-12-22 Thomas Wood <thos@gnome.org>
* theme-installer.c: (transfer_done_tgz_tbz), * theme-installer.c: (transfer_done_tgz_tbz),

View file

@ -29,6 +29,7 @@
#include <string.h> #include <string.h>
#include <gconf/gconf-client.h> #include <gconf/gconf-client.h>
#include <libgnomeui/gnome-thumbnail.h> #include <libgnomeui/gnome-thumbnail.h>
#include <libgnomeui/gnome-bg.h>
typedef enum { typedef enum {
GNOME_WP_SHADE_TYPE_SOLID, GNOME_WP_SHADE_TYPE_SOLID,
@ -112,6 +113,43 @@ get_selected_item (AppearanceData *data,
return item; 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 static void
wp_props_load_wallpaper (gchar *key, wp_props_load_wallpaper (gchar *key,
GnomeWPItem *item, GnomeWPItem *item,
@ -140,6 +178,7 @@ wp_props_load_wallpaper (gchar *key,
path = gtk_tree_model_get_path (data->wp_model, &iter); path = gtk_tree_model_get_path (data->wp_model, &iter);
item->rowref = gtk_tree_row_reference_new (data->wp_model, path); 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); gtk_tree_path_free (path);
} }

View file

@ -67,27 +67,6 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
return new; 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) { void gnome_wp_info_free (GnomeWPInfo * info) {
if (info == NULL) { if (info == NULL) {
return; return;

View file

@ -40,7 +40,6 @@ struct _GnomeWPInfo {
GnomeWPInfo * gnome_wp_info_new (const gchar * uri, GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
GnomeThumbnailFactory * thumbs); GnomeThumbnailFactory * thumbs);
GnomeWPInfo * gnome_wp_info_dup (const GnomeWPInfo * info);
void gnome_wp_info_free (GnomeWPInfo * info); void gnome_wp_info_free (GnomeWPInfo * info);
#endif #endif

View file

@ -25,10 +25,56 @@
#include <gnome.h> #include <gnome.h>
#include <string.h> #include <string.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomeui/gnome-bg.h>
#include "gnome-wp-item.h" #include "gnome-wp-item.h"
#include "gnome-wp-utils.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, GnomeWPItem * gnome_wp_item_new (const gchar * filename,
GHashTable * wallpapers, GHashTable * wallpapers,
GnomeThumbnailFactory * thumbnails) { GnomeThumbnailFactory * thumbnails) {
@ -46,7 +92,8 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
item->fileinfo = gnome_wp_info_new (item->filename, thumbnails); item->fileinfo = gnome_wp_info_new (item->filename, thumbnails);
if (item->fileinfo != NULL && 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 (item->name == NULL) {
if (g_utf8_validate (item->fileinfo->name, -1, NULL)) if (g_utf8_validate (item->fileinfo->name, -1, NULL))
item->name = g_strdup (item->fileinfo->name); item->name = g_strdup (item->fileinfo->name);
@ -88,6 +135,10 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
item = NULL; item = NULL;
} }
if (item) {
gnome_wp_item_ensure_gnome_bg (item);
}
g_object_unref (client); g_object_unref (client);
return item; return item;
@ -111,43 +162,14 @@ void gnome_wp_item_free (GnomeWPItem * item) {
gdk_color_free (item->scolor); gdk_color_free (item->scolor);
gnome_wp_info_free (item->fileinfo); 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); gtk_tree_row_reference_free (item->rowref);
g_free (item); 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, static void collect_save_options (GdkPixbuf * pixbuf,
gchar *** keys, gchar *** keys,
gchar *** vals, gchar *** vals,
@ -201,153 +223,18 @@ static void collect_save_options (GdkPixbuf * pixbuf,
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
GnomeThumbnailFactory * thumbs) { GnomeThumbnailFactory * thumbs) {
GdkPixbuf * pixbuf, * bgpixbuf; GdkPixbuf *pixbuf;
GdkPixbuf * scaled = NULL; double aspect =
gint sw, sh, bw, bh, pw, ph, tw, th; (double)gdk_screen_get_height (gdk_screen_get_default()) /
gdouble ratio; gdk_screen_get_width (gdk_screen_get_default());
sw = sh = bw = bh = pw = ph = tw = th = 0; 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);
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 return pixbuf;
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;
} }
void gnome_wp_item_update_description (GnomeWPItem * item) { 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)")) { if (!strcmp (item->filename, "(none)")) {
item->description = g_strdup (item->name); item->description = g_strdup (item->name);
} else { } 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); gchar *dirname = g_path_get_dirname (item->filename);
/* translators: <b>wallpaper name</b> /* translators: <b>wallpaper name</b>
* mime type, x pixel(s) by y pixel(s) * 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" "%s, %d %s by %d %s\n"
"Folder: %s"), "Folder: %s"),
item->name, item->name,
gnome_vfs_mime_get_description (item->fileinfo->mime_type), description,
item->width, item->width,
ngettext ("pixel", "pixels", item->width), ngettext ("pixel", "pixels", item->width),
item->height, item->height,

View file

@ -24,6 +24,7 @@
#include <libgnomeui/gnome-thumbnail.h> #include <libgnomeui/gnome-thumbnail.h>
#include <gnome-wp-info.h> #include <gnome-wp-info.h>
#include <libgnomevfs/gnome-vfs.h> #include <libgnomevfs/gnome-vfs.h>
#include <libgnomeui/gnome-bg.h>
#ifndef _GNOME_WP_ITEM_H_ #ifndef _GNOME_WP_ITEM_H_
#define _GNOME_WP_ITEM_H_ #define _GNOME_WP_ITEM_H_
@ -31,6 +32,8 @@
typedef struct _GnomeWPItem GnomeWPItem; typedef struct _GnomeWPItem GnomeWPItem;
struct _GnomeWPItem { struct _GnomeWPItem {
GnomeBG *bg;
gchar * name; gchar * name;
gchar * filename; gchar * filename;
gchar * description; gchar * description;
@ -45,7 +48,6 @@ struct _GnomeWPItem {
GdkColor * scolor; GdkColor * scolor;
GnomeWPInfo * fileinfo; GnomeWPInfo * fileinfo;
GnomeWPInfo * uriinfo;
/* Did the user remove us? */ /* Did the user remove us? */
gboolean deleted; gboolean deleted;
@ -59,10 +61,10 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
GHashTable * wallpapers, GHashTable * wallpapers,
GnomeThumbnailFactory * thumbnails); GnomeThumbnailFactory * thumbnails);
void gnome_wp_item_free (GnomeWPItem * item); void gnome_wp_item_free (GnomeWPItem * item);
GnomeWPItem * gnome_wp_item_dup (GnomeWPItem * item);
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item, GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
GnomeThumbnailFactory * thumbs); GnomeThumbnailFactory * thumbs);
void gnome_wp_item_update_description (GnomeWPItem * item); void gnome_wp_item_update_description (GnomeWPItem * item);
void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item);
#endif #endif

View file

@ -231,7 +231,11 @@ static void gnome_wp_xml_load_xml (AppearanceData *data,
g_hash_table_insert (data->wp_hash, wp->filename, wp); g_hash_table_insert (data->wp_hash, wp->filename, wp);
} else { } else {
gnome_wp_item_free (wp); gnome_wp_item_free (wp);
wp = NULL;
} }
if (wp)
gnome_wp_item_ensure_gnome_bg (wp);
} }
} }
xmlFreeDoc (wplist); xmlFreeDoc (wplist);

View file

@ -95,7 +95,7 @@ COMMON_MODULES="gtk+-2.0 >= 2.3.0 dnl
libglade-2.0 >= 2.0.0 dnl libglade-2.0 >= 2.0.0 dnl
libbonobo-2.0 dnl libbonobo-2.0 dnl
libbonoboui-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(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(CAPPLET, $COMMON_MODULES)
PKG_CHECK_MODULES(GNOMECC, $COMMON_MODULES libgnome-menu >= 2.10.1 libpanelapplet-2.0) 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/sound/gnome-settings-sound.desktop.in
capplets/windows/Makefile capplets/windows/Makefile
capplets/windows/window-properties.desktop.in capplets/windows/window-properties.desktop.in
#gnome-settings-daemon/Makefile gnome-settings-daemon/Makefile
#gnome-settings-daemon/actions/Makefile gnome-settings-daemon/actions/Makefile
#gnome-settings-daemon/gnome-settings-daemon.pc gnome-settings-daemon/gnome-settings-daemon.pc
#gnome-settings-daemon/xrdb/Makefile gnome-settings-daemon/xrdb/Makefile
help/Makefile help/Makefile
libbackground/Makefile libbackground/Makefile
libslab/Makefile libslab/Makefile

View file

@ -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> 2008-01-14 Denis Washington <denisw@svn.gnome.org>
* gnome-settings-mouse.c: * gnome-settings-mouse.c:

View file

@ -30,11 +30,13 @@
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include <gconf/gconf.h> #include <gconf/gconf.h>
#include <libgnomeui/gnome-bg.h>
#include <X11/Xatom.h>
#include <string.h>
#include "gnome-settings-module.h" #include "gnome-settings-module.h"
#include "preferences.h" #include "preferences.h"
#include "applier.h"
typedef struct _GnomeSettingsModuleBackground GnomeSettingsModuleBackground; typedef struct _GnomeSettingsModuleBackground GnomeSettingsModuleBackground;
typedef struct _GnomeSettingsModuleBackgroundClass GnomeSettingsModuleBackgroundClass; typedef struct _GnomeSettingsModuleBackgroundClass GnomeSettingsModuleBackgroundClass;
@ -42,11 +44,13 @@ typedef struct _GnomeSettingsModuleBackgroundClass GnomeSettingsModuleBackground
struct _GnomeSettingsModuleBackground { struct _GnomeSettingsModuleBackground {
GnomeSettingsModule parent; GnomeSettingsModule parent;
BGApplier **bg_appliers;
BGPreferences *prefs; BGPreferences *prefs;
guint applier_idle_id; GnomeBG *bg;
guint timeout_id;
}; };
static gboolean nautilus_is_running (void);
struct _GnomeSettingsModuleBackgroundClass { struct _GnomeSettingsModuleBackgroundClass {
GnomeSettingsModuleClass parent_class; GnomeSettingsModuleClass parent_class;
}; };
@ -59,19 +63,103 @@ static gboolean gnome_settings_module_background_initialize (GnomeSettingsModule
static gboolean gnome_settings_module_background_start (GnomeSettingsModule *module); static gboolean gnome_settings_module_background_start (GnomeSettingsModule *module);
static gboolean static gboolean
applier_idle (gpointer data) apply_prefs (gpointer data)
{ {
GnomeSettingsModuleBackground *module; GnomeSettingsModuleBackground *module;
int i;
module = (GnomeSettingsModuleBackground *) data; module = (GnomeSettingsModuleBackground *) data;
for (i = 0; module->bg_appliers [i]; i++) if (!nautilus_is_running()) {
bg_applier_apply_prefs (module->bg_appliers [i], module->prefs); GdkDisplay *display;
module->applier_idle_id = 0; 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; 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 static void
background_callback (GConfClient *client, background_callback (GConfClient *client,
guint cnxn_id, guint cnxn_id,
@ -84,13 +172,17 @@ background_callback (GConfClient *client,
bg_preferences_merge_entry (module_bg->prefs, entry); bg_preferences_merge_entry (module_bg->prefs, entry);
if (module_bg->applier_idle_id != 0) { queue_apply (user_data);
g_source_remove (module_bg->applier_idle_id);
}
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 static void
gnome_settings_module_background_class_init (GnomeSettingsModuleBackgroundClass *klass) gnome_settings_module_background_class_init (GnomeSettingsModuleBackgroundClass *klass)
{ {
@ -105,7 +197,7 @@ gnome_settings_module_background_class_init (GnomeSettingsModuleBackgroundClass
static void static void
gnome_settings_module_background_init (GnomeSettingsModuleBackground *module) gnome_settings_module_background_init (GnomeSettingsModuleBackground *module)
{ {
module->applier_idle_id = 0; module->timeout_id = 0;
} }
GType GType
@ -145,28 +237,17 @@ gnome_settings_module_background_initialize (GnomeSettingsModule *module,
GConfClient *config_client) GConfClient *config_client)
{ {
GnomeSettingsModuleBackground *module_bg; GnomeSettingsModuleBackground *module_bg;
GdkDisplay *display;
int n_screens;
int i;
module_bg = (GnomeSettingsModuleBackground *) module; 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->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); bg_preferences_load (module_bg->prefs);
apply_prefs (module_bg);
gconf_client_notify_add (config_client, gconf_client_notify_add (config_client,
"/desktop/gnome/background", "/desktop/gnome/background",
background_callback, background_callback,
@ -181,7 +262,6 @@ static gboolean
gnome_settings_module_background_start (GnomeSettingsModule *module) gnome_settings_module_background_start (GnomeSettingsModule *module)
{ {
GnomeSettingsModuleBackground *module_bg; GnomeSettingsModuleBackground *module_bg;
int i;
module_bg = (GnomeSettingsModuleBackground *) module; module_bg = (GnomeSettingsModuleBackground *) module;
@ -197,8 +277,72 @@ gnome_settings_module_background_start (GnomeSettingsModule *module)
"/apps/nautilus/preferences/show_desktop", NULL)) "/apps/nautilus/preferences/show_desktop", NULL))
return TRUE; return TRUE;
for (i = 0; module_bg->bg_appliers [i]; i++) apply_prefs (module_bg);
bg_applier_apply_prefs (module_bg->bg_appliers [i], module_bg->prefs);
return TRUE; 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;
}

View file

@ -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> 2007-04-16 Jens Granseuer <jensgr@gmx.net>
Patch by: Erich Schubert <erich@debian.org> Patch by: Erich Schubert <erich@debian.org>

View file

@ -9,5 +9,4 @@ INCLUDES = \
noinst_LTLIBRARIES = libbackground.la noinst_LTLIBRARIES = libbackground.la
libbackground_la_SOURCES = \ libbackground_la_SOURCES = \
applier.c applier.h \
preferences.c preferences.h preferences.c preferences.h