From 6cc03baf4d4180169a139f3902fe22d1dab374ea Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Tue, 21 Aug 2018 22:41:22 +0200 Subject: [PATCH 1/2] Add preferences item to toggle the delete in the context menu (Bug #13327) --- thunar/thunar-preferences-dialog.c | 24 ++++++++++++++++++++++++ thunar/thunar-preferences.c | 15 +++++++++++++++ thunar/thunar-standard-view.c | 4 ++++ 3 files changed, 43 insertions(+) diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c index f3731c71..7e5392ce 100644 --- a/thunar/thunar-preferences-dialog.c +++ b/thunar/thunar-preferences-dialog.c @@ -647,6 +647,30 @@ 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); + + 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 8a5df7c9..4edff330 100644 --- a/thunar/thunar-preferences.c +++ b/thunar/thunar-preferences.c @@ -39,6 +39,7 @@ #endif #include +#include #include #include #include @@ -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, @@ -643,6 +645,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 9b1f917e..99b8e314 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -4461,6 +4461,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; @@ -4504,6 +4505,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)); @@ -4556,6 +4559,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 || show_delete_action, "tooltip", ngettext ("Permanently delete the selected file", "Permanently delete the selected files", n_selected_files), -- 2.11.0