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
This commit is contained in:
Cosimo Cecchi 2011-03-29 23:44:58 -04:00
parent eac562b162
commit 7cef6dc582
3 changed files with 47 additions and 20 deletions

View file

@ -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 * GIcon *
cc_background_item_get_frame_thumbnail (CcBackgroundItem *item, cc_background_item_get_frame_thumbnail (CcBackgroundItem *item,
GnomeDesktopThumbnailFactory *thumbs, GnomeDesktopThumbnailFactory *thumbs,
int width, int width,
int height, int height,
int frame) int frame,
gboolean force_size)
{ {
GdkPixbuf *pixbuf = NULL; GdkPixbuf *pixbuf = NULL;
GIcon *icon = NULL; GIcon *icon = NULL;
@ -171,19 +185,31 @@ cc_background_item_get_frame_thumbnail (CcBackgroundItem *item,
set_bg_properties (item); set_bg_properties (item);
if (frame >= 0) 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, pixbuf = gnome_bg_create_frame_thumbnail (item->priv->bg,
thumbs, thumbs,
gdk_screen_get_default (), gdk_screen_get_default (),
width, width,
height, height,
frame); frame);
else } else {
pixbuf = gnome_bg_create_thumbnail (item->priv->bg, pixbuf = gnome_bg_create_thumbnail (item->priv->bg,
thumbs, thumbs,
gdk_screen_get_default(), gdk_screen_get_default (),
width, width,
height); height);
}
}
if (pixbuf != NULL if (pixbuf != NULL
&& frame != -2 && frame != -2
@ -217,7 +243,7 @@ cc_background_item_get_thumbnail (CcBackgroundItem *item,
int width, int width,
int height) 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 static void

View file

@ -79,7 +79,8 @@ GIcon * cc_background_item_get_frame_thumbnail (CcBackgroundItem
GnomeDesktopThumbnailFactory *thumbs, GnomeDesktopThumbnailFactory *thumbs,
int width, int width,
int height, int height,
int frame); int frame,
gboolean force_size);
GDesktopBackgroundStyle cc_background_item_get_placement (CcBackgroundItem *item); GDesktopBackgroundStyle cc_background_item_get_placement (CcBackgroundItem *item);
GDesktopBackgroundShading cc_background_item_get_shading (CcBackgroundItem *item); GDesktopBackgroundShading cc_background_item_get_shading (CcBackgroundItem *item);

View file

@ -704,7 +704,7 @@ preview_draw_cb (GtkWidget *widget,
priv->thumb_factory, priv->thumb_factory,
preview_width, preview_width,
preview_height, preview_height,
-2); -2, TRUE);
pixbuf = GDK_PIXBUF (icon); pixbuf = GDK_PIXBUF (icon);
} }