[Xfce4-commits] [xfce/thunar] 01/01: Add property to enable/disable frames on thumbnails (Bug #14433)

noreply at xfce.org noreply at xfce.org
Sun Jun 24 22:23:36 CEST 2018


This is an automated email from the git hooks/post-receive script.

a   l   e   x       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit 6e2b1d762ba177fba19e0bb4d466f5a1ed524df4
Author: Alexander Schwinn <acs82 at gmx.de>
Date:   Sun Jun 24 22:23:14 2018 +0200

    Add property to enable/disable frames on thumbnails
    (Bug #14433)
---
 thunar/thunar-icon-factory.c       | 43 +++++++++++++++++++++++++++++++-------
 thunar/thunar-preferences-dialog.c | 11 ++++++++--
 thunar/thunar-preferences.c        | 15 +++++++++++++
 thunar/thunar-standard-view.c      | 29 +++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 9 deletions(-)

diff --git a/thunar/thunar-icon-factory.c b/thunar/thunar-icon-factory.c
index b924350..eec5394 100644
--- a/thunar/thunar-icon-factory.c
+++ b/thunar/thunar-icon-factory.c
@@ -49,6 +49,7 @@ enum
   PROP_0,
   PROP_ICON_THEME,
   PROP_THUMBNAIL_MODE,
+  PROP_THUMBNAIL_DRAW_FRAMES,
 };
 
 
@@ -106,6 +107,8 @@ struct _ThunarIconFactory
 
   ThunarThumbnailMode  thumbnail_mode;
 
+  gboolean             thumbnail_draw_frames;
+
   guint                sweep_timer_id;
 
   gulong               changed_hook_id;
@@ -182,6 +185,21 @@ thunar_icon_factory_class_init (ThunarIconFactoryClass *klass)
                                                       THUNAR_TYPE_THUMBNAIL_MODE,
                                                       THUNAR_THUMBNAIL_MODE_ONLY_LOCAL,
                                                       EXO_PARAM_READWRITE));
+
+  /**
+   * ThunarIconFactory:thumbnail-draw-frames:
+   * 
+   * Whether to draw black frames around thumbnails.
+   * This looks neat, but will delay the first draw a bit.
+   * May have an impact on older systems, on folders with many pictures.
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_THUMBNAIL_DRAW_FRAMES,
+                                   g_param_spec_boolean ("thumbnail-draw-frames",
+                                                         "thumbnail-draw-frames",
+                                                         "thumbnail-draw-frames",
+                                                         FALSE,
+                                                         EXO_PARAM_READWRITE));
 }
 
 
@@ -266,6 +284,10 @@ thunar_icon_factory_get_property (GObject    *object,
       g_value_set_enum (value, factory->thumbnail_mode);
       break;
 
+    case PROP_THUMBNAIL_DRAW_FRAMES:
+      g_value_set_boolean (value, factory->thumbnail_draw_frames);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -288,6 +310,10 @@ thunar_icon_factory_set_property (GObject      *object,
       factory->thumbnail_mode = g_value_get_enum (value);
       break;
 
+    case PROP_THUMBNAIL_DRAW_FRAMES:
+      factory->thumbnail_draw_frames = g_value_get_boolean (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -432,6 +458,8 @@ thunar_icon_factory_load_from_file (ThunarIconFactory *factory,
   gint       width;
   gint       height;
 
+  _thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (factory), NULL);
+
   /* try to load the image from the file */
   pixbuf = gdk_pixbuf_new_from_file (path, NULL);
   if (G_LIKELY (pixbuf != NULL))
@@ -440,14 +468,15 @@ thunar_icon_factory_load_from_file (ThunarIconFactory *factory,
       width = gdk_pixbuf_get_width (pixbuf);
       height = gdk_pixbuf_get_height (pixbuf);
 
-      /* check if we want to add a frame to the image (we really don't
-       * want to do this for icons displayed in the details view).
-       */
       needs_frame = FALSE;
-      /* Disabled for 1.8.0 release, will be made optional later
-       * needs_frame = (strstr (path, G_DIR_SEPARATOR_S ".cache/thumbnails" G_DIR_SEPARATOR_S) != NULL)
-       *         && (size >= 32) && thumbnail_needs_frame (pixbuf, width, height);
-       */
+      if (factory->thumbnail_draw_frames)
+        {
+          /* check if we want to add a frame to the image (we really don't
+           * want to do this for icons displayed in the details view).
+           * */
+          needs_frame = (strstr (path, G_DIR_SEPARATOR_S ".cache/thumbnails" G_DIR_SEPARATOR_S) != NULL)
+                && (size >= 32) && thumbnail_needs_frame (pixbuf, width, height);
+        }
 
       /* be sure to make framed thumbnails fit into the size */
       if (G_LIKELY (needs_frame))
diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index dd19f6d..88f4bf9 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -296,18 +296,25 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
   gtk_widget_show (combo);
 
+  button = gtk_check_button_new_with_mnemonic (_("Draw frames around thumbnails"));
+  exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-thumbnail-draw-frames", G_OBJECT (button), "active");
+  gtk_widget_set_tooltip_text (button, _("Select this option to draw black frames around thumbnails."));
+  gtk_widget_set_hexpand (button, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), button, 0, 2, 2, 1);
+  gtk_widget_show (button);
+
   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_widget_set_hexpand (button, TRUE);
-  gtk_grid_attach (GTK_GRID (grid), button, 0, 2, 2, 1);
+  gtk_grid_attach (GTK_GRID (grid), button, 0, 3, 2, 1);
   gtk_widget_show (button);
 
   button = gtk_check_button_new_with_mnemonic (_("Show file size in binary format"));
   exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-file-size-binary", G_OBJECT (button), "active");
   gtk_widget_set_tooltip_text (button, _("Select this option to show file size in binary format instead of decimal."));
   gtk_widget_set_hexpand (button, TRUE);
-  gtk_grid_attach (GTK_GRID (grid), button, 0, 3, 2, 1);
+  gtk_grid_attach (GTK_GRID (grid), button, 0, 4, 2, 1);
   gtk_widget_show (button);
 
   frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c
index db92bf2..4b3efc2 100644
--- a/thunar/thunar-preferences.c
+++ b/thunar/thunar-preferences.c
@@ -90,6 +90,7 @@ enum
   PROP_MISC_TAB_CLOSE_MIDDLE_CLICK,
   PROP_MISC_TEXT_BESIDE_ICONS,
   PROP_MISC_THUMBNAIL_MODE,
+  PROP_MISC_THUMBNAIL_DRAW_FRAMES,
   PROP_MISC_FILE_SIZE_BINARY,
   PROP_SHORTCUTS_ICON_EMBLEMS,
   PROP_SHORTCUTS_ICON_SIZE,
@@ -694,6 +695,20 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
                          EXO_PARAM_READWRITE);
 
   /**
+   * ThunarPreferences:misc-thumbnail-draw-frames:
+   *
+   * Whether to draw black frames around thumbnails.
+   * This looks neat, but will delay the first draw a bit.
+   * May have an impact on older systems, on folders with many pictures.
+   **/
+  preferences_props[PROP_MISC_THUMBNAIL_DRAW_FRAMES] =
+      g_param_spec_boolean ("misc-thumbnail-draw-frames",
+                            NULL,
+                            NULL,
+                            FALSE,
+                            EXO_PARAM_READWRITE);
+
+  /**
    * ThunarPreferences:misc-file-size-binary:
    *
    * Show file size in binary format instead of decimal.
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 09c802b..8fb5e03 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -77,6 +77,7 @@ enum
   PROP_STATUSBAR_TEXT,
   PROP_UI_MANAGER,
   PROP_ZOOM_LEVEL,
+  PROP_THUMBNAIL_DRAW_FRAMES,
   N_PROPERTIES
 };
 
@@ -515,6 +516,20 @@ thunar_standard_view_class_init (ThunarStandardViewClass *klass)
                            NULL,
                            EXO_PARAM_READABLE);
 
+  /**
+   * ThunarStandardView:thumbnail-draw-frames:
+   *
+   * Whether to draw black frames around thumbnails.
+   * This looks neat, but will delay the first draw a bit.
+   * May have an impact on older systems, on folders with many pictures.
+   **/
+  standard_view_props[PROP_THUMBNAIL_DRAW_FRAMES] =
+      g_param_spec_boolean ("thumbnail-draw-frames",
+                            "thumbnail-draw-frames",
+                            "thumbnail-draw-frames",
+                            FALSE,
+                            EXO_PARAM_READWRITE);
+
   /* override ThunarComponent's properties */
   g_iface = g_type_default_interface_peek (THUNAR_TYPE_COMPONENT);
   standard_view_props[PROP_SELECTED_FILES] =
@@ -785,6 +800,9 @@ thunar_standard_view_constructor (GType                  type,
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-single-click", G_OBJECT (view), "single-click");
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-single-click-timeout", G_OBJECT (view), "single-click-timeout");
 
+  /* apply the thumbnail frame preferences */
+  exo_binding_new (G_OBJECT (standard_view->preferences), "misc-thumbnail-draw-frames", G_OBJECT (standard_view), "thumbnail-draw-frames");
+
   /* apply the default sort column and sort order */
   g_object_get (G_OBJECT (standard_view->preferences), "last-sort-column", &sort_column, "last-sort-order", &sort_order, NULL);
   gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), sort_column, sort_order);
@@ -949,6 +967,7 @@ thunar_standard_view_get_property (GObject    *object,
                                    GParamSpec *pspec)
 {
   ThunarFile *current_directory;
+  gboolean thumbnail_draw_frames;
 
   switch (prop_id)
     {
@@ -992,6 +1011,11 @@ thunar_standard_view_get_property (GObject    *object,
       g_value_set_enum (value, thunar_view_get_zoom_level (THUNAR_VIEW (object)));
       break;
 
+    case PROP_THUMBNAIL_DRAW_FRAMES:
+      g_object_get (G_OBJECT (THUNAR_STANDARD_VIEW(object)->icon_factory), "thumbnail-draw-frames", &thumbnail_draw_frames, NULL);
+      g_value_set_boolean (value, thumbnail_draw_frames);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1034,6 +1058,11 @@ thunar_standard_view_set_property (GObject      *object,
       thunar_view_set_zoom_level (THUNAR_VIEW (object), g_value_get_enum (value));
       break;
 
+    case PROP_THUMBNAIL_DRAW_FRAMES:
+      g_object_set (G_OBJECT (standard_view->icon_factory), "thumbnail-draw-frames", g_value_get_boolean (value), NULL);
+      thunar_standard_view_reload(THUNAR_VIEW (object), TRUE);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list