[gnome-desktop] Add more slideshow api
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-desktop] Add more slideshow api
- Date: Sat, 15 Aug 2009 04:30:39 +0000 (UTC)
commit 28553aa57508b43d7eeb1f03a2a3dd06f4b45623
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 15 00:28:41 2009 -0400
Add more slideshow api
Add a function to allow 'single-stepping' through a slideshow.
libgnome-desktop/gnome-bg.c | 90 +++++++++++++++++++++++++++++---
libgnome-desktop/libgnomeui/gnome-bg.h | 7 ++-
2 files changed, 88 insertions(+), 9 deletions(-)
---
diff --git a/libgnome-desktop/gnome-bg.c b/libgnome-desktop/gnome-bg.c
index e8a05a7..a882551 100644
--- a/libgnome-desktop/gnome-bg.c
+++ b/libgnome-desktop/gnome-bg.c
@@ -177,7 +177,8 @@ static GdkPixbuf *create_img_thumbnail (GnomeBG *bg,
GnomeDesktopThumbnailFactory *factory,
GdkScreen *screen,
int dest_width,
- int dest_height);
+ int dest_height,
+ int frame_num);
static SlideShow * get_as_slideshow (GnomeBG *bg,
const char *filename);
static Slide * get_current_slide (SlideShow *show,
@@ -1055,7 +1056,7 @@ fit_factor (int from_width, int from_height,
GdkPixbuf *
gnome_bg_create_thumbnail (GnomeBG *bg,
- GnomeDesktopThumbnailFactory *factory,
+ GnomeDesktopThumbnailFactory *factory,
GdkScreen *screen,
int dest_width,
int dest_height)
@@ -1069,7 +1070,7 @@ gnome_bg_create_thumbnail (GnomeBG *bg,
draw_color (bg, result);
- thumb = create_img_thumbnail (bg, factory, screen, dest_width, dest_height);
+ thumb = create_img_thumbnail (bg, factory, screen, dest_width, dest_height, -1);
if (thumb) {
draw_image (bg->placement, thumb, result);
@@ -1747,12 +1748,16 @@ scale_thumbnail (GnomeBGPlacement placement,
return thumb;
}
+/* frame_num determines which slide to thumbnail.
+ * -1 means 'current slide'.
+ */
static GdkPixbuf *
-create_img_thumbnail (GnomeBG *bg,
+create_img_thumbnail (GnomeBG *bg,
GnomeDesktopThumbnailFactory *factory,
- GdkScreen *screen,
- int dest_width,
- int dest_height)
+ GdkScreen *screen,
+ int dest_width,
+ int dest_height,
+ int frame_num)
{
if (bg->filename) {
GdkPixbuf *thumb = get_as_thumbnail (bg, factory, bg->filename);
@@ -1771,7 +1776,10 @@ create_img_thumbnail (GnomeBG *bg,
slideshow_ref (show);
- slide = get_current_slide (show, &alpha);
+ if (frame_num == -1)
+ slide = get_current_slide (show, &alpha);
+ else
+ slide = g_queue_peek_nth (show->slides, frame_num);
if (slide->fixed) {
GdkPixbuf *tmp;
@@ -2636,6 +2644,9 @@ slideshow_changes_with_size (SlideShow *show)
return show->changes_with_size;
}
+/*
+ * Returns whether the background is a slideshow.
+ */
gboolean
gnome_bg_changes_with_time (GnomeBG *bg)
{
@@ -2650,3 +2661,66 @@ gnome_bg_changes_with_time (GnomeBG *bg)
return FALSE;
}
+/* Creates a thumbnail for a certain frame, where 'frame' is somewhat
+ * vaguely defined as 'suitable point to show while single-stepping
+ * through the slideshow'. Returns NULL if frame_num is out of bounds.
+ */
+GdkPixbuf *
+gnome_bg_create_frame_thumbnail (GnomeBG *bg,
+ GnomeDesktopThumbnailFactory *factory,
+ GdkScreen *screen,
+ int dest_width,
+ int dest_height,
+ int frame_num)
+{
+ SlideShow *show;
+ GdkPixbuf *result;
+ GdkPixbuf *thumb;
+ GList *l;
+ int i, skipped;
+ gboolean found;
+
+ g_return_val_if_fail (bg != NULL, FALSE);
+
+ show = get_as_slideshow (bg, bg->filename);
+
+ if (!show)
+ return NULL;
+
+
+ if (frame_num < 0 || frame_num >= g_queue_get_length (show->slides))
+ return NULL;
+
+ i = 0;
+ skipped = 0;
+ found = FALSE;
+ for (l = show->slides->head; l; l = l->next) {
+ Slide *slide = l->data;
+ if (!slide->fixed) {
+ skipped++;
+ continue;
+ }
+ if (i == frame_num) {
+ found = TRUE;
+ break;
+ }
+ i++;
+ }
+ if (!found)
+ return NULL;
+
+
+ result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, dest_width, dest_height);
+
+ draw_color (bg, result);
+
+ thumb = create_img_thumbnail (bg, factory, screen, dest_width, dest_height, frame_num + skipped);
+
+ if (thumb) {
+ draw_image (bg->placement, thumb, result);
+ g_object_unref (thumb);
+ }
+
+ return result;
+}
+
diff --git a/libgnome-desktop/libgnomeui/gnome-bg.h b/libgnome-desktop/libgnomeui/gnome-bg.h
index 99361c1..80b101f 100644
--- a/libgnome-desktop/libgnomeui/gnome-bg.h
+++ b/libgnome-desktop/libgnomeui/gnome-bg.h
@@ -105,7 +105,12 @@ GdkPixbuf * gnome_bg_create_thumbnail (GnomeBG *bg,
gboolean gnome_bg_is_dark (GnomeBG *bg);
gboolean gnome_bg_changes_with_size (GnomeBG *bg);
gboolean gnome_bg_changes_with_time (GnomeBG *bg);
-
+GdkPixbuf * gnome_bg_create_frame_thumbnail (GnomeBG *bg,
+ GnomeDesktopThumbnailFactory *factory,
+ GdkScreen *screen,
+ int dest_width,
+ int dest_height,
+ int frame_num);
/* Set a pixmap as root - not a GnomeBG method. At some point
* if we decide to stabilize the API then we may want to make
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]