[totem] main: Make it possible to pause icon thumbnailing



commit 8bb0a36a6a09eb95464a622da589d472cda02fb8
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Nov 25 17:05:55 2014 +0100

    main: Make it possible to pause icon thumbnailing
    
    Using g_thread_pool_set_max_threads() with 0 max threads, to freeze
    further processing until we reset the max threads count.

 src/icon-helpers.c |   17 ++++++++++++++++-
 src/icon-helpers.h |    3 +++
 2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/src/icon-helpers.c b/src/icon-helpers.c
index 80323d1..d1d8541 100644
--- a/src/icon-helpers.c
+++ b/src/icon-helpers.c
@@ -30,6 +30,7 @@
 #define GNOME_DESKTOP_USE_UNSTABLE_API 1
 #include <libgnome-desktop/gnome-desktop-thumbnail.h>
 
+#define DEFAULT_MAX_THREADS   5
 #define THUMB_SEARCH_SIZE     256
 #define THUMB_SEARCH_HEIGHT   (THUMB_SEARCH_SIZE / 4 * 3)
 
@@ -430,5 +431,19 @@ totem_grilo_setup_icons (Totem *totem)
                                                  g_object_unref);
 
        factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
-       thumbnail_pool = g_thread_pool_new ((GFunc) thumbnail_media_async_thread, NULL, 5, TRUE, NULL);
+       thumbnail_pool = g_thread_pool_new ((GFunc) thumbnail_media_async_thread, NULL, DEFAULT_MAX_THREADS, 
TRUE, NULL);
+}
+
+void
+totem_grilo_pause_icon_thumbnailing (void)
+{
+       g_return_if_fail (thumbnail_pool != NULL);
+       g_thread_pool_set_max_threads (thumbnail_pool, 0, NULL);
+}
+
+void
+totem_grilo_resume_icon_thumbnailing (void)
+{
+       g_return_if_fail (thumbnail_pool != NULL);
+       g_thread_pool_set_max_threads (thumbnail_pool, DEFAULT_MAX_THREADS, NULL);
 }
diff --git a/src/icon-helpers.h b/src/icon-helpers.h
index 840fe33..bda25e9 100644
--- a/src/icon-helpers.h
+++ b/src/icon-helpers.h
@@ -36,6 +36,9 @@ const GdkPixbuf *totem_grilo_get_video_icon       (void);
 const GdkPixbuf *totem_grilo_get_box_icon         (void);
 const GdkPixbuf *totem_grilo_get_optical_icon     (void);
 
+void             totem_grilo_pause_icon_thumbnailing  (void);
+void             totem_grilo_resume_icon_thumbnailing (void);
+
 void             totem_grilo_get_thumbnail        (GObject             *object,
                                                   GCancellable        *cancellable,
                                                   GAsyncReadyCallback  callback,


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