[Xfce4-commits] [xfce/thunar] 01/02: Add preferences item to toggle the delete in the context menu (Bug #13327)

noreply at xfce.org noreply at xfce.org
Wed Sep 12 22:35:02 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       x   f   c   e   -   4   .   1   4   
   in repository xfce/thunar.

commit 5917e7dfb57df71336accc2062b43e861ef0342e
Author: Alexander Schwinn <alexxcons at xfce.org>
Date:   Tue Aug 21 22:41:22 2018 +0200

    Add preferences item to toggle the delete in the context menu
    (Bug #13327)
---
 thunar/thunar-preferences-dialog.c | 27 +++++++++++++++++++++++++++
 thunar/thunar-preferences.c        | 15 +++++++++++++++
 thunar/thunar-standard-view.c      |  4 ++++
 3 files changed, 46 insertions(+)

diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index 7346056..5d5c81e 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -647,6 +647,33 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
   gtk_widget_set_hexpand (button, TRUE);
   gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1);
   gtk_widget_show (button);
+
+  if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
+    {
+      frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
+      gtk_widget_show (frame);
+
+      label = gtk_label_new (_("Context Menu"));
+      gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ());
+      gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+      gtk_widget_show (label);
+
+      grid = gtk_grid_new ();
+      gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+      gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
+      gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
+      gtk_container_add (GTK_CONTAINER (frame), grid);
+      gtk_widget_show (grid);
+
+      button = gtk_check_button_new_with_mnemonic (_("Show action to permanently delete files and folders"));
+      exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-show-delete-action", G_OBJECT (button), "active");
+      gtk_widget_set_tooltip_text (button, _("Select this option to show the 'Delete' action in the context menu"));
+      gtk_widget_set_hexpand (button, TRUE);
+      gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1);
+      gtk_widget_show (button);
+    }
+
   /*
      Advanced
    */
diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c
index f7a71ad..4455f89 100644
--- a/thunar/thunar-preferences.c
+++ b/thunar/thunar-preferences.c
@@ -39,6 +39,7 @@
 #endif
 
 #include <thunar/thunar-enum-types.h>
+#include <thunar/thunar-gio-extensions.h>
 #include <thunar/thunar-gobject-extensions.h>
 #include <thunar/thunar-preferences.h>
 #include <thunar/thunar-private.h>
@@ -86,6 +87,7 @@ enum
   PROP_MISC_RECURSIVE_PERMISSIONS,
   PROP_MISC_REMEMBER_GEOMETRY,
   PROP_MISC_SHOW_ABOUT_TEMPLATES,
+  PROP_MISC_SHOW_DELETE_ACTION,
   PROP_MISC_SINGLE_CLICK,
   PROP_MISC_SINGLE_CLICK_TIMEOUT,
   PROP_MISC_SMALL_TOOLBAR_ICONS,
@@ -642,6 +644,19 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
                             TRUE,
                             EXO_PARAM_READWRITE);
 
+ /**
+   * ThunarPreferences:misc-show-delete-action:
+   *
+   * Whether to display a "delete" action to permanently delete files and folders
+   * If trash is not supported, "delete" is displayed by default.
+   **/
+  preferences_props[PROP_MISC_SHOW_DELETE_ACTION] =
+      g_param_spec_boolean ("misc-show-delete-action",
+                            "MiscShowDeleteAction",
+                            NULL,
+                            !thunar_g_vfs_is_uri_scheme_supported ("trash"),
+                            EXO_PARAM_READWRITE);
+
   /**
    * ThunarPreferences:misc-single-click:
    *
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 45069da..f8655a7 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -4431,6 +4431,7 @@ thunar_standard_view_selection_changed (ThunarStandardView *standard_view)
   gboolean    pastable;
   gboolean    writable;
   gboolean    trashed;
+  gboolean    show_delete_action;
   GList      *lp, *selected_files;
   gint        n_selected_files = 0;
 
@@ -4474,6 +4475,8 @@ thunar_standard_view_selection_changed (ThunarStandardView *standard_view)
   writable = (current_directory != NULL && thunar_file_is_writable (current_directory));
   trashed = (current_directory != NULL && thunar_file_is_trashed (current_directory));
 
+  g_object_get (G_OBJECT (standard_view->preferences), "misc-show-delete-action", &show_delete_action, NULL);
+
   /* check whether the clipboard contains data that can be pasted here */
   pastable = (standard_view->clipboard != NULL && thunar_clipboard_manager_get_can_paste (standard_view->clipboard));
 
@@ -4526,6 +4529,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   /* update the "Delete" action */
   g_object_set (G_OBJECT (standard_view->priv->action_delete),
                 "sensitive", (n_selected_files > 0) && writable,
+                "visible", trashed || !thunar_g_vfs_is_uri_scheme_supported ("trash") || show_delete_action,
                 "tooltip", ngettext ("Permanently delete the selected file",
                                      "Permanently delete the selected files",
                                      n_selected_files),

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


More information about the Xfce4-commits mailing list