[gnome-desktop] gnome-bg: Do not add timeout for one-slide slideshows



commit adf18a2cf78c26a33c7a00210fc29020e935e0c1
Author: Vincent Untz <vuntz gnome org>
Date:   Wed Feb 9 13:10:48 2011 +0100

    gnome-bg: Do not add timeout for one-slide slideshows
    
    If a slideshow is made of only one slide, then there's no animation. So
    we just override the duration of the slide to G_MAXUINT, and we do not
    add timeouts for such durations.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630498

 libgnome-desktop/gnome-bg.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/libgnome-desktop/gnome-bg.c b/libgnome-desktop/gnome-bg.c
index d6829ad..dc26cc1 100644
--- a/libgnome-desktop/gnome-bg.c
+++ b/libgnome-desktop/gnome-bg.c
@@ -1930,10 +1930,13 @@ ensure_timeout (GnomeBG *bg,
 {
 	if (!bg->timeout_id) {
 		double timeout = get_slide_timeout (slide);
-		bg->timeout_id = g_timeout_add_full (
-			G_PRIORITY_LOW,
-			timeout * 1000, on_timeout, bg, NULL);
 
+		/* G_MAXUINT means "only one slide" */
+		if (timeout < G_MAXUINT) {
+			bg->timeout_id = g_timeout_add_full (
+				G_PRIORITY_LOW,
+				timeout * 1000, on_timeout, bg, NULL);
+		}
 	}
 }
 
@@ -2880,16 +2883,24 @@ read_slideshow_file (const char *filename,
 	g_markup_parse_context_free (context);
 
 	if (show) {
+		int len;
+
 		t = mktime (&show->start_tm);
 
 		show->start_time = (double)t;
 			
 		dump_bg (show);
 
+		len = g_queue_get_length (show->slides);
+
 		/* no slides, that's not a slideshow */
-		if (g_queue_get_length (show->slides) == 0) {
+		if (len == 0) {
 			slideshow_unref (show);
 			show = NULL;
+		/* one slide, there's no transition */
+		} else if (len == 1) {
+			Slide *slide = show->slides->head->data;
+			slide->duration = G_MAXUINT;
 		}
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]