[Xfce4-commits] <thunar:master> Reduce tumbler traffic on startup of Thunar.

Nick Schermer noreply at xfce.org
Mon Oct 22 21:18:01 CEST 2012


Updating branch refs/heads/master
         to b486702c2387c90c416e85c71b984b1a22bf1439 (commit)
       from 7fe78dee5a0b1a279a5a44efc15ad9bf0dd7af5a (commit)

commit b486702c2387c90c416e85c71b984b1a22bf1439
Author: Nick Schermer <nick at xfce.org>
Date:   Mon Oct 22 21:12:11 2012 +0200

    Reduce tumbler traffic on startup of Thunar.
    
    Create the tumbnailercache on demand and keep a reference
    in daemon mode on the thumbnailer so the scheme/content-type
    table doesn't need to be generated each time.
    
    Tumbler is also not started now in --daemon mode and will be
    less restarted when no images are visible.

 thunar/thunar-application.c   |   20 ++++++++++++++++++--
 thunar/thunar-standard-view.c |    1 +
 thunar/thunar-thumbnailer.c   |    1 +
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c
index f31a277..47ad8f6 100644
--- a/thunar/thunar-application.c
+++ b/thunar/thunar-application.c
@@ -55,6 +55,7 @@
 #include <thunar/thunar-progress-dialog.h>
 #include <thunar/thunar-renamer-dialog.h>
 #include <thunar/thunar-thumbnail-cache.h>
+#include <thunar/thunar-thumbnailer.h>
 #include <thunar/thunar-util.h>
 #include <thunar/thunar-view.h>
 
@@ -137,6 +138,7 @@ struct _ThunarApplication
   GList                 *windows;
 
   ThunarThumbnailCache  *thumbnail_cache;
+  ThunarThumbnailer     *thumbnailer;
 
   gboolean               daemon;
 
@@ -213,7 +215,6 @@ thunar_application_init (ThunarApplication *application)
 
   /* initialize the application */
   application->preferences = thunar_preferences_get ();
-  application->thumbnail_cache = thunar_thumbnail_cache_new ();
 
   application->files_to_launch = NULL;
   application->progress_dialog = NULL;
@@ -279,6 +280,10 @@ thunar_application_finalize (GObject *object)
   if (G_UNLIKELY (application->show_dialogs_timer_id != 0))
     g_source_remove (application->show_dialogs_timer_id);
 
+  /* drop ref on the thumbnailer */
+  if (application->thumbnailer != NULL)
+    g_object_unref (application->thumbnailer);
+
   /* drop the open windows (this includes the progress dialog) */
   for (lp = application->windows; lp != NULL; lp = lp->next)
     {
@@ -288,7 +293,8 @@ thunar_application_finalize (GObject *object)
   g_list_free (application->windows);
 
   /* release the thumbnail cache */
-  g_object_unref (G_OBJECT (application->thumbnail_cache));
+  if (application->thumbnail_cache != NULL)
+    g_object_unref (G_OBJECT (application->thumbnail_cache));
 
   /* disconnect from the preferences */
   g_object_unref (G_OBJECT (application->preferences));
@@ -528,6 +534,12 @@ thunar_application_window_destroyed (GtkWidget         *window,
   _thunar_return_if_fail (THUNAR_IS_APPLICATION (application));
   _thunar_return_if_fail (g_list_find (application->windows, window) != NULL);
 
+  /* take a ref on the thumbnailer in daemon mode, this way we don't
+   * need to build the content-type / scheme match table
+   */
+  if (application->thumbnailer == NULL && application->daemon)
+    application->thumbnailer = thunar_thumbnailer_get ();
+
   application->windows = g_list_remove (application->windows, window);
 
   /* terminate the application if we don't have any more
@@ -2044,6 +2056,10 @@ ThunarThumbnailCache *
 thunar_application_get_thumbnail_cache (ThunarApplication *application)
 {
   _thunar_return_val_if_fail (THUNAR_IS_APPLICATION (application), NULL);
+
+  if (application->thumbnail_cache == NULL)
+    application->thumbnail_cache = thunar_thumbnail_cache_new ();
+
   return g_object_ref (application->thumbnail_cache);
 }
 
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index f04e2cf..7f17cf0 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -746,6 +746,7 @@ thunar_standard_view_finalize (GObject *object)
   _thunar_assert (standard_view->clipboard == NULL);
 
   /* release the thumbnailer */
+  g_signal_handlers_disconnect_by_func (standard_view->priv->thumbnailer, thunar_standard_view_finished_thumbnailing, standard_view);
   g_object_unref (standard_view->priv->thumbnailer);
 
   /* release the scroll_to_file reference (if any) */
diff --git a/thunar/thunar-thumbnailer.c b/thunar/thunar-thumbnailer.c
index 4c53159..998b864 100644
--- a/thunar/thunar-thumbnailer.c
+++ b/thunar/thunar-thumbnailer.c
@@ -947,6 +947,7 @@ thunar_thumbnailer_queue_files (ThunarThumbnailer *thumbnailer,
 }
 
 
+
 void
 thunar_thumbnailer_dequeue (ThunarThumbnailer *thumbnailer,
                             guint              request)


More information about the Xfce4-commits mailing list