[gnome-control-center] background: don't use the GnomeBG thumbnails for the preview area
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] background: don't use the GnomeBG thumbnails for the preview area
- Date: Wed, 30 Mar 2011 14:42:45 +0000 (UTC)
commit 7cef6dc582a9cdf3a7d3df30a3679a2ab9e94f26
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Mar 29 23:44:58 2011 -0400
background: don't use the GnomeBG thumbnails for the preview area
Instead, use gnome_bg_draw(), which renders the preview directly at the
desired size.
https://bugzilla.gnome.org/show_bug.cgi?id=646180
panels/background/cc-background-item.c | 56 ++++++++++++++++++++++--------
panels/background/cc-background-item.h | 3 +-
panels/background/cc-background-panel.c | 8 ++--
3 files changed, 47 insertions(+), 20 deletions(-)
---
diff --git a/panels/background/cc-background-item.c b/panels/background/cc-background-item.c
index af1951a..a29a126 100644
--- a/panels/background/cc-background-item.c
+++ b/panels/background/cc-background-item.c
@@ -156,12 +156,26 @@ update_size (CcBackgroundItem *item)
}
}
+static GdkPixbuf *
+render_at_size (GnomeBG *bg,
+ gint width,
+ gint height)
+{
+ GdkPixbuf *pixbuf;
+
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height);
+ gnome_bg_draw (bg, pixbuf, gdk_screen_get_default (), FALSE);
+
+ return pixbuf;
+}
+
GIcon *
cc_background_item_get_frame_thumbnail (CcBackgroundItem *item,
GnomeDesktopThumbnailFactory *thumbs,
int width,
int height,
- int frame)
+ int frame,
+ gboolean force_size)
{
GdkPixbuf *pixbuf = NULL;
GIcon *icon = NULL;
@@ -171,19 +185,31 @@ cc_background_item_get_frame_thumbnail (CcBackgroundItem *item,
set_bg_properties (item);
- if (frame >= 0)
- pixbuf = gnome_bg_create_frame_thumbnail (item->priv->bg,
- thumbs,
- gdk_screen_get_default (),
- width,
- height,
- frame);
- else
- pixbuf = gnome_bg_create_thumbnail (item->priv->bg,
- thumbs,
- gdk_screen_get_default(),
- width,
- height);
+ if (force_size) {
+ /* FIXME: this doesn't play nice with slideshow stepping at all,
+ * because it will always render the current slideshow frame, which
+ * might not be what we want.
+ * We're lacking an API to draw a high-res GnomeBG manually choosing
+ * the slideshow frame though, so we can't do much better than this
+ * for now.
+ */
+ pixbuf = render_at_size (item->priv->bg, width, height);
+ } else {
+ if (frame >= 0) {
+ pixbuf = gnome_bg_create_frame_thumbnail (item->priv->bg,
+ thumbs,
+ gdk_screen_get_default (),
+ width,
+ height,
+ frame);
+ } else {
+ pixbuf = gnome_bg_create_thumbnail (item->priv->bg,
+ thumbs,
+ gdk_screen_get_default (),
+ width,
+ height);
+ }
+ }
if (pixbuf != NULL
&& frame != -2
@@ -217,7 +243,7 @@ cc_background_item_get_thumbnail (CcBackgroundItem *item,
int width,
int height)
{
- return cc_background_item_get_frame_thumbnail (item, thumbs, width, height, -1);
+ return cc_background_item_get_frame_thumbnail (item, thumbs, width, height, -1, FALSE);
}
static void
diff --git a/panels/background/cc-background-item.h b/panels/background/cc-background-item.h
index 4781dc7..dc91703 100644
--- a/panels/background/cc-background-item.h
+++ b/panels/background/cc-background-item.h
@@ -79,7 +79,8 @@ GIcon * cc_background_item_get_frame_thumbnail (CcBackgroundItem
GnomeDesktopThumbnailFactory *thumbs,
int width,
int height,
- int frame);
+ int frame,
+ gboolean force_size);
GDesktopBackgroundStyle cc_background_item_get_placement (CcBackgroundItem *item);
GDesktopBackgroundShading cc_background_item_get_shading (CcBackgroundItem *item);
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 752317c..42b37cc 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -701,10 +701,10 @@ preview_draw_cb (GtkWidget *widget,
{
GIcon *icon;
icon = cc_background_item_get_frame_thumbnail (priv->current_background,
- priv->thumb_factory,
- preview_width,
- preview_height,
- -2);
+ priv->thumb_factory,
+ preview_width,
+ preview_height,
+ -2, TRUE);
pixbuf = GDK_PIXBUF (icon);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]