[Xfce4-commits] <thunar:master> Add option to only show local thumbnails.

Nick Schermer noreply at xfce.org
Sat Nov 24 21:50:01 CET 2012


Updating branch refs/heads/master
         to 3ef31277ffe1abe842bc5d2374883a92425a8de9 (commit)
       from e2a5402ef831fa5f6500aeb1423b22b3179e6979 (commit)

commit 3ef31277ffe1abe842bc5d2374883a92425a8de9
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Nov 24 21:48:23 2012 +0100

    Add option to only show local thumbnails.

 thunar/thunar-enum-types.c         |   23 +++++++++
 thunar/thunar-enum-types.h         |   18 +++++++
 thunar/thunar-file.c               |   27 +++++++++++
 thunar/thunar-file.h               |    5 +-
 thunar/thunar-gio-extensions.c     |    1 +
 thunar/thunar-icon-factory.c       |   88 +++++++++++++++++++++++++++---------
 thunar/thunar-icon-factory.h       |    3 +
 thunar/thunar-preferences-dialog.c |   59 +++++++++++++++++++++---
 thunar/thunar-preferences.c        |   53 +++++++++++++---------
 thunar/thunar-standard-view.c      |   36 +++++++--------
 10 files changed, 240 insertions(+), 73 deletions(-)

diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c
index 35654a9..92dcf09 100644
--- a/thunar/thunar-enum-types.c
+++ b/thunar/thunar-enum-types.c
@@ -191,6 +191,29 @@ thunar_zoom_level_get_type (void)
 
 
 
+GType
+thunar_thumbnail_mode_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GEnumValue values[] =
+      {
+        { THUNAR_THUMBNAIL_MODE_NEVER,      "THUNAR_THUMBNAIL_MODE_NEVER",      "never",      },
+        { THUNAR_THUMBNAIL_MODE_ONLY_LOCAL, "THUNAR_THUMBNAIL_MODE_ONLY_LOCAL", "only-local", },
+        { THUNAR_THUMBNAIL_MODE_ALWAYS,     "THUNAR_THUMBNAIL_MODE_ALWAYS",     "always",     },
+        { 0,                                NULL,                               NULL,         },
+      };
+
+      type = g_enum_register_static (I_("ThunarThumbnailMode"), values);
+    }
+
+  return type;
+}
+
+
+
 /**
  * thunar_zoom_level_to_icon_size:
  * @zoom_level : a #ThunarZoomLevel.
diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h
index b950052..c372436 100644
--- a/thunar/thunar-enum-types.h
+++ b/thunar/thunar-enum-types.h
@@ -142,6 +142,24 @@ typedef enum
 GType thunar_icon_size_get_type (void) G_GNUC_CONST;
 
 
+#define THUNAR_TYPE_THUMBNAIL_MODE (thunar_thumbnail_mode_get_type ())
+
+/**
+ * ThunarThumbnailsShow:
+ * @THUNAR_THUMBNAIL_MODE_NEVER      : never show thumbnails.
+ * @THUNAR_THUMBNAIL_MODE_ONLY_LOCAL : only show thumbnails on local filesystems.
+ * @THUNAR_THUMBNAIL_MODE_ALWAYS     : always show thumbnails (everywhere).
+ **/
+typedef enum
+{
+  THUNAR_THUMBNAIL_MODE_NEVER,
+  THUNAR_THUMBNAIL_MODE_ONLY_LOCAL,
+  THUNAR_THUMBNAIL_MODE_ALWAYS
+} ThunarThumbnailMode;
+
+GType thunar_thumbnail_mode_get_type (void) G_GNUC_CONST;
+
+
 #define THUNAR_TYPE_RECURSIVE_PERMISSIONS (thunar_recursive_permissions_get_type ())
 
 /**
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 07a983d..f267cb9 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -2604,6 +2604,7 @@ thunar_file_is_parent (const ThunarFile *file,
 }
 
 
+
 /**
  * thunar_file_is_ancestor:
  * @file     : a #ThunarFile instance.
@@ -3426,6 +3427,32 @@ thunar_file_get_preview_icon (const ThunarFile *file)
 
 
 
+GFilesystemPreviewType
+thunar_file_get_preview_type (const ThunarFile *file)
+{
+  GFilesystemPreviewType  preview;
+  GFileInfo              *info;
+
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), G_FILESYSTEM_PREVIEW_TYPE_NEVER);
+  _thunar_return_val_if_fail (G_IS_FILE (file->gfile), G_FILESYSTEM_PREVIEW_TYPE_NEVER);
+
+  info = g_file_query_filesystem_info (file->gfile, G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW, NULL, NULL);
+  if (G_LIKELY (info != NULL))
+    {
+      preview = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW);
+      g_object_unref (G_OBJECT (info));
+    }
+  else
+    {
+      /* assume we don't know */
+      preview = G_FILESYSTEM_PREVIEW_TYPE_NEVER;
+    }
+
+  return preview;
+}
+
+
+
 static const gchar *
 thunar_file_get_icon_name_for_state (const gchar         *icon_name,
                                      ThunarFileIconState  icon_state)
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index d0a2084..74ed6f8 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -228,7 +228,8 @@ ThunarFileThumbState thunar_file_get_thumb_state   (const ThunarFile        *fil
 void             thunar_file_set_thumb_state       (ThunarFile              *file, 
                                                     ThunarFileThumbState     state);
 GIcon            *thunar_file_get_preview_icon     (const ThunarFile        *file);
-const gchar      *thunar_file_get_icon_name        (ThunarFile        *file,
+GFilesystemPreviewType thunar_file_get_preview_type (const ThunarFile *file);
+const gchar      *thunar_file_get_icon_name        (ThunarFile              *file,
                                                     ThunarFileIconState     icon_state,
                                                     GtkIconTheme           *icon_theme);
 
@@ -251,7 +252,7 @@ gchar            *thunar_file_cached_display_name  (const GFile            *file
 GList            *thunar_file_list_get_applications  (GList *file_list);
 GList            *thunar_file_list_to_thunar_g_file_list    (GList *file_list);
 
-gboolean         thunar_file_is_desktop              (const ThunarFile *file);
+gboolean          thunar_file_is_desktop           (const ThunarFile *file);
 
 /**
  * thunar_file_is_root:
diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c
index c7d37fc..d77f72a 100644
--- a/thunar/thunar-gio-extensions.c
+++ b/thunar/thunar-gio-extensions.c
@@ -406,6 +406,7 @@ thunar_g_file_get_free_space (GFile   *file,
 }
 
 
+
 gchar *
 thunar_g_file_get_free_space_string (GFile *file)
 {
diff --git a/thunar/thunar-icon-factory.c b/thunar/thunar-icon-factory.c
index d0544d1..96d783d 100644
--- a/thunar/thunar-icon-factory.c
+++ b/thunar/thunar-icon-factory.c
@@ -48,7 +48,7 @@ enum
 {
   PROP_0,
   PROP_ICON_THEME,
-  PROP_SHOW_THUMBNAILS,
+  PROP_THUMBNAIL_MODE,
 };
 
 
@@ -98,20 +98,20 @@ struct _ThunarIconFactory
 {
   GObject __parent__;
 
-  ThunarPreferences *preferences;
+  ThunarPreferences   *preferences;
 
-  GHashTable        *icon_cache;
+  GHashTable          *icon_cache;
 
-  GtkIconTheme      *icon_theme;
+  GtkIconTheme        *icon_theme;
 
-  guint              show_thumbnails : 1;
+  ThunarThumbnailMode  thumbnail_mode;
 
-  guint              sweep_timer_id;
+  guint                sweep_timer_id;
 
-  gulong             changed_hook_id;
+  gulong               changed_hook_id;
 
   /* stamp that gets bumped when the theme changes */
-  guint              theme_stamp;
+  guint                theme_stamp;
 };
 
 struct _ThunarIconKey
@@ -169,18 +169,19 @@ thunar_icon_factory_class_init (ThunarIconFactoryClass *klass)
                                                         EXO_PARAM_READABLE));
 
   /**
-   * ThunarIconFactory:show-thumbnails:
+   * ThunarIconFactory:thumbnail-mode:
    *
    * Whether this #ThunarIconFactory will try to generate and load thumbnails
    * when loading icons for #ThunarFile<!---->s.
    **/
   g_object_class_install_property (gobject_class,
-                                   PROP_SHOW_THUMBNAILS,
-                                   g_param_spec_boolean ("show-thumbnails",
-                                                         "show-thumbnails",
-                                                         "show-thumbnails",
-                                                         FALSE,
-                                                         EXO_PARAM_READWRITE));
+                                   PROP_THUMBNAIL_MODE,
+                                   g_param_spec_enum ("thumbnail-mode",
+                                                      "thumbnail-mode",
+                                                      "thumbnail-mode",
+                                                      THUNAR_TYPE_THUMBNAIL_MODE,
+                                                      THUNAR_THUMBNAIL_MODE_ONLY_LOCAL,
+                                                      EXO_PARAM_READWRITE));
 }
 
 
@@ -188,6 +189,8 @@ thunar_icon_factory_class_init (ThunarIconFactoryClass *klass)
 static void
 thunar_icon_factory_init (ThunarIconFactory *factory)
 {
+  factory->thumbnail_mode = THUNAR_THUMBNAIL_MODE_ONLY_LOCAL;
+
   /* connect emission hook for the "changed" signal on the GtkIconTheme class. We use the emission
    * hook way here, because that way we can make sure that the icon cache is definetly cleared
    * before any other part of the application gets notified about the icon theme change.
@@ -259,8 +262,8 @@ thunar_icon_factory_get_property (GObject    *object,
       g_value_set_object (value, factory->icon_theme);
       break;
 
-    case PROP_SHOW_THUMBNAILS:
-      g_value_set_boolean (value, factory->show_thumbnails);
+    case PROP_THUMBNAIL_MODE:
+      g_value_set_enum (value, factory->thumbnail_mode);
       break;
 
     default:
@@ -281,8 +284,8 @@ thunar_icon_factory_set_property (GObject      *object,
 
   switch (prop_id)
     {
-    case PROP_SHOW_THUMBNAILS:
-      factory->show_thumbnails = g_value_get_boolean (value);
+    case PROP_THUMBNAIL_MODE:
+      factory->thumbnail_mode = g_value_get_enum (value);
       break;
 
     default:
@@ -667,8 +670,8 @@ thunar_icon_factory_get_for_icon_theme (GtkIconTheme *icon_theme)
 
       /* connect the "show-thumbnails" property to the global preference */
       factory->preferences = thunar_preferences_get ();
-      exo_binding_new (G_OBJECT (factory->preferences), "misc-show-thumbnails",
-                       G_OBJECT (factory), "show-thumbnails");
+      exo_binding_new (G_OBJECT (factory->preferences), "misc-thumbnail-mode",
+                       G_OBJECT (factory), "thumbnail-mode");
     }
   else
     {
@@ -681,6 +684,46 @@ thunar_icon_factory_get_for_icon_theme (GtkIconTheme *icon_theme)
 
 
 /**
+ * thunar_icon_factory_get_thumbnail_mode:
+ * @factory       : a #ThunarIconFactory instance.
+ * @file          : a #ThunarFile.
+ *
+ * Return value: if a Thumbnail show be shown for @file.
+ **/
+gboolean
+thunar_icon_factory_get_show_thumbnail (const ThunarIconFactory *factory,
+                                        const ThunarFile        *file)
+{
+  GFilesystemPreviewType preview;
+
+  _thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (factory), THUNAR_THUMBNAIL_MODE_NEVER);
+  _thunar_return_val_if_fail (file == NULL || THUNAR_IS_FILE (file), THUNAR_THUMBNAIL_MODE_NEVER);
+
+  if (file == NULL
+      || factory->thumbnail_mode == THUNAR_THUMBNAIL_MODE_NEVER)
+    return FALSE;
+
+  /* always create thumbs for local files */
+  if (thunar_file_is_local (file))
+    return TRUE;
+
+  preview = thunar_file_get_preview_type (file);
+
+  /* file system says to never thumbnail anything */
+  if (preview == G_FILESYSTEM_PREVIEW_TYPE_NEVER)
+    return FALSE;
+
+  /* only if the setting is local and the fs reports to be local */
+  if (factory->thumbnail_mode == THUNAR_THUMBNAIL_MODE_ONLY_LOCAL)
+    return preview == G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL;
+
+  /* THUNAR_THUMBNAIL_MODE_ALWAYS */
+  return TRUE;
+}
+
+
+
+/**
  * thunar_icon_factory_load_icon:
  * @factory       : a #ThunarIconFactory instance.
  * @name          : name of the icon to load.
@@ -778,7 +821,8 @@ thunar_icon_factory_load_file_icon (ThunarIconFactory  *factory,
     }
 
   /* check if thumbnails are enabled and we can display a thumbnail for the item */
-  if (G_LIKELY (factory->show_thumbnails && thunar_file_is_regular (file)))
+  if (thunar_icon_factory_get_show_thumbnail (factory, file)
+      && thunar_file_is_regular (file))
     {
       /* determine the preview icon first */
       gicon = thunar_file_get_preview_icon (file);
diff --git a/thunar/thunar-icon-factory.h b/thunar/thunar-icon-factory.h
index 3ceefc6..0a28494 100644
--- a/thunar/thunar-icon-factory.h
+++ b/thunar/thunar-icon-factory.h
@@ -48,6 +48,9 @@ GType                  thunar_icon_factory_get_type           (void) G_GNUC_CONS
 ThunarIconFactory     *thunar_icon_factory_get_default        (void);
 ThunarIconFactory     *thunar_icon_factory_get_for_icon_theme (GtkIconTheme             *icon_theme);
 
+gboolean               thunar_icon_factory_get_show_thumbnail (const ThunarIconFactory  *factory,
+                                                               const ThunarFile         *file);
+
 GdkPixbuf             *thunar_icon_factory_load_icon          (ThunarIconFactory        *factory,
                                                                const gchar              *name,
                                                                gint                      size,
diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index a6efc4d..162b902 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -147,6 +147,41 @@ transform_view_index_to_string (const GValue *src_value,
 
 
 
+static gboolean
+transform_thumbnail_mode_to_index (const GValue *src_value,
+                                   GValue       *dst_value,
+                                   gpointer      user_data)
+{
+  GEnumClass *klass;
+  guint       n;
+
+  klass = g_type_class_ref (THUNAR_TYPE_THUMBNAIL_MODE);
+  for (n = 0; n < klass->n_values; ++n)
+    if (klass->values[n].value == g_value_get_enum (src_value))
+      g_value_set_int (dst_value, n);
+  g_type_class_unref (klass);
+
+  return TRUE;
+}
+
+
+
+static gboolean
+transform_thumbnail_index_to_mode (const GValue *src_value,
+                                   GValue       *dst_value,
+                                   gpointer      user_data)
+{
+  GEnumClass *klass;
+
+  klass = g_type_class_ref (THUNAR_TYPE_THUMBNAIL_MODE);
+  g_value_set_enum (dst_value, klass->values[g_value_get_int (src_value)].value);
+  g_type_class_unref (klass);
+
+  return TRUE;
+}
+
+
+
 static void
 thunar_preferences_dialog_class_init (ThunarPreferencesDialogClass *klass)
 {
@@ -227,6 +262,7 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
   gtk_widget_show (table);
 
   label = gtk_label_new_with_mnemonic (_("View _new folders using:"));
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (label);
 
@@ -242,16 +278,25 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
   gtk_widget_show (combo);
 
+  label = gtk_label_new_with_mnemonic (_("Show thumbnails:"));
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
+  gtk_widget_show (label);
+
+  combo = gtk_combo_box_text_new ();
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Never"));
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Local Files Only"));
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Always"));
+  exo_mutual_binding_new_full (G_OBJECT (dialog->preferences), "misc-thumbnail-mode", G_OBJECT (combo), "active",
+                               transform_thumbnail_mode_to_index, transform_thumbnail_index_to_mode, NULL, NULL);
+  gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+  thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), combo);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+  gtk_widget_show (combo);
+
   button = gtk_check_button_new_with_mnemonic (_("Sort _folders before files"));
   exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-folders-first", G_OBJECT (button), "active");
   gtk_widget_set_tooltip_text (button, _("Select this option to list folders before files when you sort a folder."));
-  gtk_table_attach (GTK_TABLE (table), button, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
-  gtk_widget_show (button);
-
-  button = gtk_check_button_new_with_mnemonic (_("_Show thumbnails"));
-  exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-show-thumbnails", G_OBJECT (button), "active");
-  gtk_widget_set_tooltip_text (button, _("Select this option to display previewable files within a "
-                                         "folder as automatically generated thumbnail icons."));
   gtk_table_attach (GTK_TABLE (table), button, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (button);
 
diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c
index c789fb4..e5d9fb9 100644
--- a/thunar/thunar-preferences.c
+++ b/thunar/thunar-preferences.c
@@ -82,12 +82,12 @@ enum
   PROP_MISC_RECURSIVE_PERMISSIONS,
   PROP_MISC_REMEMBER_GEOMETRY,
   PROP_MISC_SHOW_ABOUT_TEMPLATES,
-  PROP_MISC_SHOW_THUMBNAILS,
   PROP_MISC_SINGLE_CLICK,
   PROP_MISC_SINGLE_CLICK_TIMEOUT,
   PROP_MISC_SMALL_TOOLBAR_ICONS,
   PROP_MISC_TAB_CLOSE_MIDDLE_CLICK,
   PROP_MISC_TEXT_BESIDE_ICONS,
+  PROP_MISC_THUMBNAIL_MODE,
   PROP_SHORTCUTS_ICON_EMBLEMS,
   PROP_SHORTCUTS_ICON_SIZE,
   PROP_TREE_ICON_EMBLEMS,
@@ -99,17 +99,17 @@ enum
 
 static void     thunar_preferences_finalize           (GObject                *object);
 static void     thunar_preferences_get_property       (GObject                *object,
-                          guint                   prop_id,
-                          GValue                 *value,
-                          GParamSpec             *pspec);
+                                                       guint                   prop_id,
+                                                       GValue                 *value,
+                                                       GParamSpec             *pspec);
 static void     thunar_preferences_set_property       (GObject                *object,
-                          guint                   prop_id,
-                          const GValue           *value,
-                          GParamSpec             *pspec);
+                                                       guint                   prop_id,
+                                                       const GValue           *value,
+                                                       GParamSpec             *pspec);
 static void     thunar_preferences_prop_changed       (XfconfChannel          *channel,
-                          const gchar            *prop_name,
-                          const GValue           *value,
-                          ThunarPreferences      *preferences);
+                                                       const gchar            *prop_name,
+                                                       const GValue           *value,
+                                                       ThunarPreferences      *preferences);
 static void     thunar_preferences_load_rc_file       (ThunarPreferences      *preferences);
 
 
@@ -583,18 +583,6 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
                             EXO_PARAM_READWRITE);
 
   /**
-   * ThunarPreferences:misc-show-thumbnails:
-   *
-   * Whether to generate and display thumbnails for previewable files.
-   **/
-  preferences_props[PROP_MISC_SHOW_THUMBNAILS] =
-      g_param_spec_boolean ("misc-show-thumbnails",
-                            "MiscShowThumbnails",
-                            NULL,
-                            TRUE,
-                            EXO_PARAM_READWRITE);
-
-  /**
    * ThunarPreferences:misc-single-click:
    *
    * Whether to use single click navigation.
@@ -660,6 +648,19 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
                             EXO_PARAM_READWRITE);
 
   /**
+   * ThunarPreferences:misc-thumbnail-mode:
+   *
+   * Whether to generate and display thumbnails for previewable files.
+   **/
+  preferences_props[PROP_MISC_THUMBNAIL_MODE] =
+      g_param_spec_enum ("misc-thumbnail-mode",
+                         NULL,
+                         NULL,
+                         THUNAR_TYPE_THUMBNAIL_MODE,
+                         THUNAR_THUMBNAIL_MODE_ONLY_LOCAL,
+                         EXO_PARAM_READWRITE);
+
+  /**
    * ThunarPreferences:shortcuts-icon-emblems:
    *
    * Whether to display emblems for file icons (if defined) in the
@@ -942,6 +943,14 @@ thunar_preferences_load_rc_file (ThunarPreferences *preferences)
       g_value_unset (&src);
     }
 
+  /* manually migrate the thumbnails property */
+  if (!xfce_rc_read_bool_entry (rc, "MiscShowThumbnails", TRUE))
+    {
+      xfconf_channel_set_string (preferences->channel,
+                                 "/misc-thumbnail-mode",
+                                 "THUNAR_THUMBNAIL_MODE_NEVER");
+    }
+
   g_free (pspecs);
   xfce_rc_close (rc);
 
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 665ee6f..e807296 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -280,7 +280,7 @@ static void                 thunar_standard_view_schedule_thumbnail_timeout (Thu
 static void                 thunar_standard_view_schedule_thumbnail_idle    (ThunarStandardView       *standard_view);
 static gboolean             thunar_standard_view_request_thumbnails         (gpointer                  data);
 static gboolean             thunar_standard_view_request_thumbnails_lazy    (gpointer                  data);
-static void                 thunar_standard_view_show_thumbnails_toggled    (ThunarStandardView       *standard_view,
+static void                 thunar_standard_view_thumbnail_mode_toggled     (ThunarStandardView       *standard_view,
                                                                              GParamSpec               *pspec,
                                                                              ThunarIconFactory        *icon_factory);
 static void                 thunar_standard_view_scrolled                   (GtkAdjustment            *adjustment,
@@ -1023,10 +1023,10 @@ thunar_standard_view_realize (GtkWidget *widget)
   icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (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 */
+  /* we need to redraw whenever the "thumbnail_mode" property is toggled */
   g_signal_connect_swapped (standard_view->icon_factory,
-                            "notify::show-thumbnails",
-                            G_CALLBACK (thunar_standard_view_show_thumbnails_toggled),
+                            "notify::thumbnail_mode",
+                            G_CALLBACK (thunar_standard_view_thumbnail_mode_toggled),
                             standard_view);
 }
 
@@ -3576,7 +3576,6 @@ thunar_standard_view_row_changed (ThunarListModel    *model,
                                   ThunarStandardView *standard_view)
 {
   ThunarFile *file;
-  gboolean    show_thumbnails;
 
   _thunar_return_if_fail (THUNAR_IS_LIST_MODEL (model));
   _thunar_return_if_fail (path != NULL);
@@ -3586,8 +3585,9 @@ thunar_standard_view_row_changed (ThunarListModel    *model,
   if (standard_view->priv->thumbnail_request != 0)
     return;
 
-  g_object_get (standard_view->icon_factory, "show-thumbnails", &show_thumbnails, NULL);
-  if (!show_thumbnails)
+  /* leave if this view is not suitable for generating thumbnails */
+  if (!thunar_icon_factory_get_show_thumbnail (standard_view->icon_factory,
+                                               standard_view->priv->current_directory))
     return;
 
   /* queue a thumbnail request */
@@ -3867,18 +3867,15 @@ thunar_standard_view_request_thumbnails_real (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);
   _thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (standard_view->icon_factory), 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)
+  if (!thunar_icon_factory_get_show_thumbnail (standard_view->icon_factory,
+                                               standard_view->priv->current_directory))
     return FALSE;
 
   /* reschedule the source if we're still loading the folder */
@@ -3956,23 +3953,22 @@ thunar_standard_view_request_thumbnails_lazy (gpointer data)
 
 
 static void
-thunar_standard_view_show_thumbnails_toggled (ThunarStandardView *standard_view,
-                                              GParamSpec         *pspec,
-                                              ThunarIconFactory  *icon_factory)
+thunar_standard_view_thumbnail_mode_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));
+  _thunar_return_if_fail (standard_view->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)
+  if (thunar_icon_factory_get_show_thumbnail (icon_factory,
+                                              standard_view->priv->current_directory))
     {
       /* get the vertical adjustment of the view */
-      vadjustment =
-        gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (standard_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);


More information about the Xfce4-commits mailing list