[Xfce4-commits] <thunar:master> Respect ThunarIconFactory::show-thumbnails. Fixes a regression.

Jannis Pohlmann noreply at xfce.org
Tue Dec 27 13:14:01 CET 2011


Updating branch refs/heads/master
         to dfc55a2b3a3769b3846500136dc393cfde0ae523 (commit)
       from 679ad00ae31e1d48d061635f186f79e18981d5f0 (commit)

commit dfc55a2b3a3769b3846500136dc393cfde0ae523
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Tue Dec 27 13:12:38 2011 +0100

    Respect ThunarIconFactory::show-thumbnails. Fixes a regression.
    
    Whenever show-thumbnails is toggled, we need to either show thumbnails
    again immediately or cancel any pending requests to put tumbler back
    into idle mode.

 NEWS                          |    1 +
 thunar/thunar-standard-view.c |   52 +++++++++++++++++++++++++++++++++++++----
 2 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 015a7cf..c02e6a5 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,7 @@
   Fix by Lionel Le Folgoc<lionel at lefolgoc.net>.
 - Fix sorting of filenames with large numbers (bug #5356).
   Patch by Eric Koegel.
+- Respect ThunarIconFactory::show-thumbnails. Fixes a regression.
 
 1.3.0
 =====
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 2478d7e..356488d 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -266,6 +266,9 @@ static void                 thunar_standard_view_cancel_thumbnailing        (Thu
 static void                 thunar_standard_view_schedule_thumbnail_timeout (ThunarStandardView       *standard_view);
 static void                 thunar_standard_view_schedule_thumbnail_idle    (ThunarStandardView       *standard_view);
 static gboolean             thunar_standard_view_request_thumbnails         (ThunarStandardView       *standard_view);
+static void                 thunar_standard_view_show_thumbnails_toggled    (ThunarStandardView       *standard_view,
+                                                                             GParamSpec               *pspec,
+                                                                             ThunarIconFactory        *icon_factory);
 static void                 thunar_standard_view_scrolled                   (GtkAdjustment            *adjustment,
                                                                              ThunarStandardView       *standard_view);
 static void                 thunar_standard_view_size_allocate              (ThunarStandardView       *standard_view,
@@ -913,7 +916,10 @@ thunar_standard_view_realize (GtkWidget *widget)
   standard_view->icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);
 
   /* we need to redraw whenever the "show-thumbnails" property is toggled */
-  g_signal_connect_swapped (G_OBJECT (standard_view->icon_factory), "notify::show-thumbnails", G_CALLBACK (gtk_widget_queue_draw), standard_view);
+  g_signal_connect_swapped (standard_view->icon_factory,
+                            "notify::show-thumbnails",
+                            G_CALLBACK (thunar_standard_view_show_thumbnails_toggled),
+                            standard_view);
 }
 
 
@@ -3380,17 +3386,22 @@ thunar_standard_view_request_thumbnails (ThunarStandardView *standard_view)
   GtkTreePath *path;
   GtkTreeIter  iter;
   ThunarFile  *file;
+  gboolean     show_thumbnails;
   gboolean     valid_iter;
   GList       *visible_files = NULL;
 
   _thunar_return_val_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view), FALSE);
 
+  /* determine whether the user wants us to create thumbnails */
+  g_object_get (standard_view->icon_factory, "show-thumbnails", &show_thumbnails, NULL);
+
+  /* do nothing if we are not supposed to show thumbnails at all */
+  if (!show_thumbnails)
+    return FALSE;
+
   /* reschedule the source if we're still loading the folder */
   if (thunar_view_get_loading (THUNAR_VIEW (standard_view)))
-    {
-      g_debug ("weird, this should never happen");
-      return TRUE;
-    }
+    return TRUE;
 
   /* compute visible item range */
   if ((*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->get_visible_range) (standard_view,
@@ -3447,6 +3458,37 @@ thunar_standard_view_request_thumbnails (ThunarStandardView *standard_view)
 
 
 static void
+thunar_standard_view_show_thumbnails_toggled (ThunarStandardView *standard_view,
+                                              GParamSpec         *pspec,
+                                              ThunarIconFactory  *icon_factory)
+{
+  GtkAdjustment *vadjustment;
+  gboolean       show_thumbnails;
+
+  _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
+  _thunar_return_if_fail (THUNAR_IS_ICON_FACTORY (icon_factory));
+
+  /* check whether the user wants us to generate thumbnails */
+  g_object_get (icon_factory, "show-thumbnails", &show_thumbnails, NULL);
+  if (show_thumbnails)
+    {
+      /* get the vertical adjustment of the view */
+      vadjustment = 
+        gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (standard_view));
+
+      /* fake a scroll event to generate thumbnail requests */
+      thunar_standard_view_scrolled (vadjustment, standard_view);
+    }
+  else
+    {
+      /* cancel any pending thumbnail requests */
+      thunar_standard_view_cancel_thumbnailing (standard_view);
+    }
+}
+
+
+
+static void
 thunar_standard_view_scrolled (GtkAdjustment      *adjustment,
                                ThunarStandardView *standard_view)
 {


More information about the Xfce4-commits mailing list