Debian Codegraph @

libgnome-desktop/gnome-bg/gnome-bg-slide-show.c

raw symbols SCIP
1 /* gnome-bg-slide-show.h
2 *
3 * Copyright (C) 2008, 2013 Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public License
7 * as published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 *
20 */
21
22 #include <string.h>
23 #include <math.h>
24 #include <stdarg.h>
25 #include <stdlib.h>
26
27 #include <gio/gio.h>
28
29 #define GNOME_DESKTOP_USE_UNSTABLE_API
30 #include "gnome-bg-slide-show.h"
31
32 struct _GnomeBGSlideShowPrivate
33 {
34 GFile *file;
35
36 double start_time;
37 double total_duration;
38
39 GQueue *slides;
40
41 gboolean has_multiple_sizes;
42
43 /* used during parsing */
44 struct tm start_tm;
45 GQueue *stack;
46 };
47
48 typedef struct _Slide Slide;
49
50 struct _Slide
51 {
52 double duration; /* in seconds */
53 gboolean fixed;
54
55 GSList *file1;
56 GSList *file2; /* NULL if fixed is TRUE */
57 };
58
59 typedef struct _FileSize FileSize;
60 struct _FileSize
61 {
62 gint width;
63 gint height;
64
65 char *file;
66 };
67
68 enum {
69 PROP_0,
70 PROP_FILE,
71 PROP_START_TIME,
72 PROP_TOTAL_DURATION,
73 PROP_HAS_MULTIPLE_SIZES,
74 };
75
76 G_DEFINE_TYPE_WITH_PRIVATE (GnomeBGSlideShow, gnome_bg_slide_show, G_TYPE_OBJECT)
77
78 static void
79 gnome_bg_slide_show_set_property (GObject *object,
80 guint property_id,
81 const GValue *value,
82 GParamSpec *pspec)
83 {
84 GnomeBGSlideShow *self;
85
86 g_assert (GNOME_BG_IS_SLIDE_SHOW (object));
87
88 self = GNOME_BG_SLIDE_SHOW (object);
89
90 switch (property_id)
91 {
92 case PROP_FILE:
93 self->priv->file = g_object_ref (g_value_get_object (value));
94 break;
95 default:
96 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
97 break;
98 }
99 }
100
101 static void
102 gnome_bg_slide_show_get_property (GObject *object,
103 guint property_id,
104 GValue *value,
105 GParamSpec *pspec)
106 {
107 GnomeBGSlideShow *self;
108
109 g_assert (GNOME_BG_IS_SLIDE_SHOW (object));
110
111 self = GNOME_BG_SLIDE_SHOW (object);
112
113 switch (property_id)
114 {
115 case PROP_FILE:
116 g_value_set_object (value, self->priv->file);
117 break;
118 case PROP_START_TIME:
119 g_value_set_int (value, self->priv->start_time);
120 break;
121 case PROP_TOTAL_DURATION:
122 g_value_set_int (value, self->priv->total_duration);
123 break;
124 case PROP_HAS_MULTIPLE_SIZES:
125 g_value_set_boolean (value, self->priv->has_multiple_sizes);
126 break;
127
128 default:
129 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
130 break;
131 }
132 }
133
134 static void
135 gnome_bg_slide_show_finalize (GObject *object)
136 {
137 GnomeBGSlideShow *self;
138
139 GList *list;
140 GSList *slist;
141 FileSize *size;
142
143 self = GNOME_BG_SLIDE_SHOW (object);
144
145 for (list = self->priv->slides->head; list != NULL; list = list->next) {
146 Slide *slide = list->data;
147
148 for (slist = slide->file1; slist != NULL; slist = slist->next) {
149 size = slist->data;
150 g_free (size->file);
151 g_free (size);
152 }
153 g_slist_free (slide->file1);
154
155 for (slist = slide->file2; slist != NULL; slist = slist->next) {
156 size = slist->data;
157 g_free (size->file);
158 g_free (size);
159 }
160 g_slist_free (slide->file2);
161
162 g_free (slide);
163 }
164
165 g_queue_free (self->priv->slides);
166
167 g_queue_free_full (self->priv->stack, g_free);
168
169 g_object_unref (self->priv->file);
170
171 G_OBJECT_CLASS (gnome_bg_slide_show_parent_class)->finalize (object);
172 }
173
174 static void
175 gnome_bg_slide_show_class_init (GnomeBGSlideShowClass *self_class)
176 {
177 GObjectClass *gobject_class;
178
179 gobject_class = G_OBJECT_CLASS (self_class);
180
181 gobject_class->get_property = gnome_bg_slide_show_get_property;
182 gobject_class->set_property = gnome_bg_slide_show_set_property;
183 gobject_class->finalize = gnome_bg_slide_show_finalize;
184
185 g_object_class_install_property (gobject_class,
186 PROP_FILE,
187 g_param_spec_object ("file",
188 "File",
189 "File",
190 G_TYPE_FILE,
191 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
192
193 g_object_class_install_property (gobject_class,
194 PROP_START_TIME,
195 g_param_spec_double ("start-time",
196 "Start time",
197 "start time",
198 0.0, G_MAXDOUBLE, 0.0,
199 G_PARAM_READABLE));
200
201 g_object_class_install_property (gobject_class,
202 PROP_TOTAL_DURATION,
203 g_param_spec_double ("total-duration",
204 "Start duration",
205 "total duration",
206 0.0, G_MAXDOUBLE, 0.0,
207 G_PARAM_READABLE));
208
209 g_object_class_install_property (gobject_class,
210 PROP_HAS_MULTIPLE_SIZES,
211 g_param_spec_boolean ("has-multiple-sizes",
212 "Has multiple sizes",
213 "Has multiple sizes",
214 FALSE,
215 G_PARAM_READABLE));
216 }
217
218 static void
219 gnome_bg_slide_show_init (GnomeBGSlideShow *self)
220 {
221 self->priv = gnome_bg_slide_show_get_instance_private (self);
222
223 self->priv->stack = g_queue_new ();
224 self->priv->slides = g_queue_new ();
225 }
226
227 /**
228 * gnome_bg_slide_show_new:
229 * @filename: The filename of the slide show
230 *
231 * Creates a new object to manage a slide show.
232 * window background between two #cairo_surface_ts.
233 *
234 * Return value: the new #GnomeBGSlideShow
235 **/
236 GnomeBGSlideShow *
237 gnome_bg_slide_show_new (const char *filename)
238 {
239 GFile *file;
240 GnomeBGSlideShow *self;
241
242 file = g_file_new_for_path (filename);
243
244 self = GNOME_BG_SLIDE_SHOW (g_object_new (GNOME_BG_TYPE_SLIDE_SHOW,
245 "file", file,
246 NULL));
247 g_object_unref (file);
248
249 return self;
250 }
251
252 static void
253 threadsafe_localtime (time_t time, struct tm *tm)
254 {
255 struct tm *res;
256
257 G_LOCK_DEFINE_STATIC (localtime_mutex);
258
259 G_LOCK (localtime_mutex);
260
261 res = localtime (&time);
262 if (tm) {
263 *tm = *res;
264 }
265
266 G_UNLOCK (localtime_mutex);
267 }
268 static gboolean stack_is (GnomeBGSlideShow *self, const char *s1, ...);
269
270 /* Parser for fading background */
271 static void
272 handle_start_element (GMarkupParseContext *context,
273 const gchar *name,
274 const gchar **attr_names,
275 const gchar **attr_values,
276 gpointer user_data,
277 GError **err)
278 {
279 GnomeBGSlideShow *self = user_data;
280 gint i;
281
282 if (strcmp (name, "static") == 0 || strcmp (name, "transition") == 0) {
283 Slide *slide = g_new0 (Slide, 1);
284
285 if (strcmp (name, "static") == 0)
286 slide->fixed = TRUE;
287
288 g_queue_push_tail (self->priv->slides, slide);
289 }
290 else if (strcmp (name, "size") == 0) {
291 Slide *slide = self->priv->slides->tail->data;
292 FileSize *size = g_new0 (FileSize, 1);
293 for (i = 0; attr_names[i]; i++) {
294 if (strcmp (attr_names[i], "width") == 0)
295 size->width = atoi (attr_values[i]);
296 else if (strcmp (attr_names[i], "height") == 0)
297 size->height = atoi (attr_values[i]);
298 }
299 if (self->priv->stack->tail &&
300 (strcmp (self->priv->stack->tail->data, "file") == 0 ||
301 strcmp (self->priv->stack->tail->data, "from") == 0)) {
302 slide->file1 = g_slist_prepend (slide->file1, size);
303 }
304 else if (self->priv->stack->tail &&
305 strcmp (self->priv->stack->tail->data, "to") == 0) {
306 slide->file2 = g_slist_prepend (slide->file2, size);
307 }
308 }
309 g_queue_push_tail (self->priv->stack, g_strdup (name));
310 }
311
312 static void
313 handle_end_element (GMarkupParseContext *context,
314 const gchar *name,
315 gpointer user_data,
316 GError **err)
317 {
318 GnomeBGSlideShow *self = user_data;
319
320 g_free (g_queue_pop_tail (self->priv->stack));
321 }
322
323 static gboolean
324 stack_is (GnomeBGSlideShow *self,
325 const char *s1,
326 ...)
327 {
328 GList *stack = NULL;
329 const char *s;
330 GList *l1, *l2;
331 va_list args;
332
333 stack = g_list_prepend (stack, (gpointer)s1);
334
335 va_start (args, s1);
336
337 s = va_arg (args, const char *);
338 while (s) {
339 stack = g_list_prepend (stack, (gpointer)s);
340 s = va_arg (args, const char *);
341 }
342
343 l1 = stack;
344 l2 = self->priv->stack->head;
345
346 while (l1 && l2) {
347 if (strcmp (l1->data, l2->data) != 0) {
348 g_list_free (stack);
349 return FALSE;
350 }
351
352 l1 = l1->next;
353 l2 = l2->next;
354 }
355
356 g_list_free (stack);
357
358 return (!l1 && !l2);
359 }
360
361 static int
362 parse_int (const char *text)
363 {
364 return strtol (text, NULL, 10);
365 }
366
367 static void
368 handle_text (GMarkupParseContext *context,
369 const gchar *text,
370 gsize text_len,
371 gpointer user_data,
372 GError **err)
373 {
374 GnomeBGSlideShow *self = user_data;
375 Slide *slide = self->priv->slides->tail? self->priv->slides->tail->data : NULL;
376 FileSize *fs;
377 gint i;
378
379 if (stack_is (self, "year", "starttime", "background", NULL)) {
380 self->priv->start_tm.tm_year = parse_int (text) - 1900;
381 }
382 else if (stack_is (self, "month", "starttime", "background", NULL)) {
383 self->priv->start_tm.tm_mon = parse_int (text) - 1;
384 }
385 else if (stack_is (self, "day", "starttime", "background", NULL)) {
386 self->priv->start_tm.tm_mday = parse_int (text);
387 }
388 else if (stack_is (self, "hour", "starttime", "background", NULL)) {
389 self->priv->start_tm.tm_hour = parse_int (text);
390 }
391 else if (stack_is (self, "minute", "starttime", "background", NULL)) {
392 self->priv->start_tm.tm_min = parse_int (text);
393 }
394 else if (stack_is (self, "second", "starttime", "background", NULL)) {
395 self->priv->start_tm.tm_sec = parse_int (text);
396 }
397 else if (stack_is (self, "duration", "static", "background", NULL) ||
398 stack_is (self, "duration", "transition", "background", NULL)) {
399 slide->duration = g_strtod (text, NULL);
400 self->priv->total_duration += slide->duration;
401 }
402 else if (stack_is (self, "file", "static", "background", NULL) ||
403 stack_is (self, "from", "transition", "background", NULL)) {
404 for (i = 0; text[i]; i++) {
405 if (!g_ascii_isspace (text[i]))
406 break;
407 }
408 if (text[i] == 0)
409 return;
410 fs = g_new (FileSize, 1);
411 fs->width = -1;
412 fs->height = -1;
413 fs->file = g_strdup (text);
414 slide->file1 = g_slist_prepend (slide->file1, fs);
415 if (slide->file1->next != NULL)
416 self->priv->has_multiple_sizes = TRUE;
417 }
418 else if (stack_is (self, "size", "file", "static", "background", NULL) ||
419 stack_is (self, "size", "from", "transition", "background", NULL)) {
420 fs = slide->file1->data;
421 fs->file = g_strdup (text);
422 if (slide->file1->next != NULL)
423 self->priv->has_multiple_sizes = TRUE;
424 }
425 else if (stack_is (self, "to", "transition", "background", NULL)) {
426 for (i = 0; text[i]; i++) {
427 if (!g_ascii_isspace (text[i]))
428 break;
429 }
430 if (text[i] == 0)
431 return;
432 fs = g_new (FileSize, 1);
433 fs->width = -1;
434 fs->height = -1;
435 fs->file = g_strdup (text);
436 slide->file2 = g_slist_prepend (slide->file2, fs);
437 if (slide->file2->next != NULL)
438 self->priv->has_multiple_sizes = TRUE;
439 }
440 else if (stack_is (self, "size", "to", "transition", "background", NULL)) {
441 fs = slide->file2->data;
442 fs->file = g_strdup (text);
443 if (slide->file2->next != NULL)
444 self->priv->has_multiple_sizes = TRUE;
445 }
446 }
447
448 /*
449 * Find the FileSize that best matches the given size.
450 * Do two passes; the first pass only considers FileSizes
451 * that are larger than the given size.
452 * We are looking for the image that best matches the aspect ratio.
453 * When two images have the same aspect ratio, prefer the one whose
454 * width is closer to the given width.
455 */
456 static const char *
457 find_best_size (GSList *sizes, gint width, gint height)
458 {
459 GSList *s;
460 gdouble a, d, distance;
461 FileSize *best = NULL;
462 gint pass;
463
464 a = width/(gdouble)height;
465 distance = 10000.0;
466
467 for (pass = 0; pass < 2; pass++) {
468 for (s = sizes; s; s = s->next) {
469 FileSize *size = s->data;
470
471 if (pass == 0 && (size->width < width || size->height < height))
472 continue;
473
474 d = fabs (a - size->width/(gdouble)size->height);
475 if (d < distance) {
476 distance = d;
477 best = size;
478 }
479 else if (d == distance) {
480 if (abs (size->width - width) < abs (best->width - width)) {
481 best = size;
482 }
483 }
484 }
485
486 if (best)
487 break;
488 }
489
490 return best->file;
491 }
492
493 static double
494 now (void)
495 {
496 return (double) g_get_real_time () / 1000000.0;
497 }
498
499 /**
500 * gnome_bg_slide_show_get_current_slide:
501 * @self: a #GnomeBGSlideShow
502 * @width: monitor width
503 * @height: monitor height
504 * @progress: (out) (allow-none): slide progress
505 * @duration: (out) (allow-none): slide duration
506 * @is_fixed: (out) (allow-none): if slide is fixed
507 * @file1: (out) (allow-none) (transfer none): first file in slide
508 * @file2: (out) (allow-none) (transfer none): second file in slide
509 *
510 * Returns the current slides progress.
511 **/
512 void
513 gnome_bg_slide_show_get_current_slide (GnomeBGSlideShow *self,
514 int width,
515 int height,
516 gdouble *progress,
517 double *duration,
518 gboolean *is_fixed,
519 const char **file1,
520 const char **file2)
521 {
522 double delta = fmod (now () - self->priv->start_time, self->priv->total_duration);
523 GList *list;
524 double elapsed;
525 int i;
526
527 if (delta < 0)
528 delta += self->priv->total_duration;
529
530 elapsed = 0;
531 i = 0;
532 for (list = self->priv->slides->head; list != NULL; list = list->next) {
533 Slide *slide = list->data;
534
535 if (elapsed + slide->duration > delta) {
536 if (progress)
537 *progress = (delta - elapsed) / (double)slide->duration;
538 if (duration)
539 *duration = slide->duration;
540
541 if (is_fixed)
542 *is_fixed = slide->fixed;
543
544 if (file1 && slide->file1)
545 *file1 = find_best_size (slide->file1, width, height);
546
547 if (file2 && slide->file2)
548 *file2 = find_best_size (slide->file2, width, height);
549
550 return;
551 }
552
553 i++;
554 elapsed += slide->duration;
555 }
556
557 /* this should never happen since we have slides and we should always
558 * find a current slide for the elapsed time since beginning -- we're
559 * looping with fmod() */
560 g_assert_not_reached ();
561 }
562
563 /**
564 * gnome_bg_slide_show_get_slide:
565 * @self: a #GnomeBGSlideShow
566 * @frame_number: frame number
567 * @width: monitor width
568 * @height: monitor height
569 * @progress: (out) (allow-none): slide progress
570 * @duration: (out) (allow-none): slide duration
571 * @is_fixed: (out) (allow-none): if slide is fixed
572 * @file1: (out) (allow-none) (transfer none): first file in slide
573 * @file2: (out) (allow-none) (transfer none): second file in slide
574 *
575 * Retrieves slide by frame number
576 *
577 * Return value: %TRUE if successful
578 **/
579 gboolean
580 gnome_bg_slide_show_get_slide (GnomeBGSlideShow *self,
581 int frame_number,
582 int width,
583 int height,
584 double *progress,
585 double *duration,
586 gboolean *is_fixed,
587 const char **file1,
588 const char **file2)
589 {
590 double delta = fmod (now () - self->priv->start_time, self->priv->total_duration);
591 GList *l;
592 int i, skipped;
593 gboolean found;
594 double elapsed;
595 Slide *slide;
596
597 if (delta < 0)
598 delta += self->priv->total_duration;
599
600 elapsed = 0;
601 i = 0;
602 skipped = 0;
603 found = FALSE;
604 for (l = self->priv->slides->head; l; l = l->next) {
605 slide = l->data;
606
607 if (!slide->fixed) {
608 elapsed += slide->duration;
609
610 skipped++;
611 continue;
612 }
613 if (i == frame_number) {
614 found = TRUE;
615 break;
616 }
617 i++;
618 elapsed += slide->duration;
619 }
620 if (!found)
621 return FALSE;
622
623 if (progress) {
624 if (elapsed + slide->duration > delta) {
625 *progress = (delta - elapsed) / (double)slide->duration;
626 } else {
627 *progress = 0.0;
628 }
629 }
630
631 if (duration)
632 *duration = slide->duration;
633
634 if (is_fixed)
635 *is_fixed = slide->fixed;
636
637 if (file1)
638 *file1 = find_best_size (slide->file1, width, height);
639
640 if (file2 && slide->file2)
641 *file2 = find_best_size (slide->file2, width, height);
642
643 return TRUE;
644 }
645
646 static gboolean
647 parse_file_contents (GnomeBGSlideShow *self,
648 const char *contents,
649 gsize len,
650 GError **error)
651 {
652 GMarkupParser parser = {
653 handle_start_element,
654 handle_end_element,
655 handle_text,
656 NULL, /* passthrough */
657 NULL, /* error */
658 };
659
660 GMarkupParseContext *context = NULL;
661 time_t t;
662 gboolean failed = FALSE;
663
664 threadsafe_localtime ((time_t)0, &self->priv->start_tm);
665
666 context = g_markup_parse_context_new (&parser, 0, self, NULL);
667
668 if (!g_markup_parse_context_parse (context, contents, len, error)) {
669 failed = TRUE;
670 }
671
672 if (!failed && !g_markup_parse_context_end_parse (context, error)) {
673 failed = TRUE;
674 }
675
676 g_markup_parse_context_free (context);
677
678 if (!failed) {
679 guint queue_length;
680
681 /* Per the API of mktime, use a negative value on tm_isdst, in order to
682 * use the system databases to get the active timezone DST status. */
683 self->priv->start_tm.tm_isdst = -1;
684 t = mktime (&self->priv->start_tm);
685
686 self->priv->start_time = (double)t;
687
688 queue_length = g_queue_get_length (self->priv->slides);
689
690 /* no slides, that's not a slideshow */
691 if (queue_length == 0) {
692 g_set_error_literal (error,
693 G_MARKUP_ERROR,
694 G_MARKUP_ERROR_INVALID_CONTENT,
695 "file is not a slide show since it has no slides");
696 failed = TRUE;
697 /* one slide, there's no transition */
698 } else if (queue_length == 1) {
699 Slide *slide = self->priv->slides->head->data;
700 slide->duration = self->priv->total_duration = G_MAXUINT;
701 }
702 }
703
704 return !failed;
705 }
706
707 /**
708 * gnome_bg_slide_show_load:
709 * @self: a #GnomeBGSlideShow
710 * @error: a #GError
711 *
712 * Tries to load the slide show.
713 *
714 * Return value: %TRUE if successful
715 **/
716 gboolean
717 gnome_bg_slide_show_load (GnomeBGSlideShow *self,
718 GError **error)
719 {
720 char *contents;
721 gsize length;
722 gboolean parsed;
723
724 if (!g_file_load_contents (self->priv->file, NULL, &contents, &length,
725 NULL, NULL)) {
726 return FALSE;
727 }
728
729 parsed = parse_file_contents (self, contents, length, error);
730 g_free (contents);
731
732 return parsed;
733 }
734
735 static void
736 on_file_loaded (GFile *file,
737 GAsyncResult *result,
738 GTask *task)
739 {
740 gboolean loaded;
741 char *contents;
742 gsize length;
743 GError *error = NULL;
744
745 loaded = g_file_load_contents_finish (file, result, &contents, &length, NULL, &error);
746
747 if (!loaded) {
748 g_task_return_error (task, error);
749 g_object_unref (task);
750 return;
751 }
752
753 if (!parse_file_contents (g_task_get_source_object (task), contents, length, &error)) {
754 g_task_return_error (task, error);
755 g_object_unref (task);
756 g_free (contents);
757 return;
758 }
759 g_free (contents);
760
761 g_task_return_boolean (task, TRUE);
762 g_object_unref (task);
763 }
764
765 /**
766 * gnome_bg_slide_show_load_async:
767 * @self: a #GnomeBGSlideShow
768 * @cancellable: a #GCancellable
769 * @callback: the callback
770 * @user_data: user data
771 *
772 * Tries to load the slide show asynchronously.
773 *
774 * Use gnome_bg_slide_show_load_finish() to get the result.
775 **/
776 void
777 gnome_bg_slide_show_load_async (GnomeBGSlideShow *self,
778 GCancellable *cancellable,
779 GAsyncReadyCallback callback,
780 gpointer user_data)
781 {
782 GTask *task;
783
784 g_return_if_fail (GNOME_BG_IS_SLIDE_SHOW (self));
785
786 task = g_task_new (self, cancellable, callback, user_data);
787 g_task_set_source_tag (task, gnome_bg_slide_show_load_async);
788
789 g_file_load_contents_async (self->priv->file, cancellable,
790 (GAsyncReadyCallback) on_file_loaded, task);
791 }
792
793 /**
794 * gnome_bg_slide_show_load_finish:
795 * @self: a #GnomeBGSlideShow
796 * @res: A #GAsyncResult
797 * @error: Return location for errors, or %NULL to ignore
798 *
799 * Finish an asynchronous operation to load the slide show that was
800 * started with gnome_bg_slide_show_load_async().
801 *
802 * Returns: %FALSE on error, %TRUE otherwise
803 * Since: 50.alpha
804 */
805 gboolean
806 gnome_bg_slide_show_load_finish (GnomeBGSlideShow *self,
807 GAsyncResult *res,
808 GError **error)
809 {
810 g_return_val_if_fail (GNOME_BG_IS_SLIDE_SHOW (self), FALSE);
811 g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
812 g_return_val_if_fail (g_async_result_is_tagged (res, gnome_bg_slide_show_load_async), FALSE);
813
814 return g_task_propagate_boolean (G_TASK (res), error);
815 }
816
817 /**
818 * gnome_bg_slide_show_get_start_time:
819 * @self: a #GnomeBGSlideShow
820 *
821 * gets the start time of the slide show
822 *
823 * Return value: a timestamp
824 **/
825 double
826 gnome_bg_slide_show_get_start_time (GnomeBGSlideShow *self)
827 {
828 return self->priv->start_time;
829 }
830
831 /**
832 * gnome_bg_slide_show_get_total_duration:
833 * @self: a #GnomeBGSlideShow
834 *
835 * gets the total duration of the slide show
836 *
837 * Return value: a timestamp
838 **/
839 double
840 gnome_bg_slide_show_get_total_duration (GnomeBGSlideShow *self)
841 {
842 return self->priv->total_duration;
843 }
844
845 /**
846 * gnome_bg_slide_show_get_has_multiple_sizes:
847 * @self: a #GnomeBGSlideShow
848 *
849 * gets whether or not the slide show has multiple sizes for different monitors
850 *
851 * Return value: %TRUE if multiple sizes
852 **/
853 gboolean
854 gnome_bg_slide_show_get_has_multiple_sizes (GnomeBGSlideShow *self)
855 {
856 return self->priv->has_multiple_sizes;
857 }
858
859 /**
860 * gnome_bg_slide_show_get_num_slides:
861 * @self: a #GnomeBGSlideShow
862 *
863 * Returns number of slides in slide show
864 **/
865 int
866 gnome_bg_slide_show_get_num_slides (GnomeBGSlideShow *self)
867 {
868 return g_queue_get_length (self->priv->slides);
869 }