From 7823285b1ec4d059d5cedd60e6379896bae89ad4 Mon Sep 17 00:00:00 2001 From: Evangelos Foutras Date: Sun, 30 Jun 2019 14:14:49 +0300 Subject: [PATCH] Replace Trash action with Delete as needed (Bug #15352) We keep the grayed out "Move to Trash" action in directories which are not writable, but otherwise we show the "Delete" action for files that cannot be trashed. Regardless of the "Move to Trash" action's visibility, it should remain sensitive for keyboard shortcuts to work (i.e.: pressing the Delete key). Follow-up fix for https://bugzilla.xfce.org/show_bug.cgi?id=15352. --- thunar/thunar-standard-view.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index 029dd409..17b1baa3 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -4472,6 +4472,7 @@ thunar_standard_view_selection_changed (ThunarStandardView *standard_view) gboolean pastable; gboolean writable; gboolean trashed; + gboolean hide_trash_action; gboolean show_delete_action; GList *lp, *selected_files; gint n_selected_files = 0; @@ -4516,11 +4517,16 @@ thunar_standard_view_selection_changed (ThunarStandardView *standard_view) /* and setup the new selected files list */ standard_view->priv->selected_files = selected_files; - /* check whether the folder displayed by the view is writable/in the trash/can be trashed */ + /* check whether the folder displayed by the view is writable/in the trash */ current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view)); writable = (current_directory != NULL && thunar_file_is_writable (current_directory)); trashed = (current_directory != NULL && thunar_file_is_trashed (current_directory)); + /* if moving to trash is not applicable, replace it with the delete action */ + hide_trash_action = trashed || !trashable || !thunar_g_vfs_is_uri_scheme_supported ("trash"); + /* but only if the directory is writable -- keep "move to trash" otherwise */ + hide_trash_action &= writable; + 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 */ @@ -4565,8 +4571,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS /* update the "Move to Trash" action */ g_object_set (G_OBJECT (standard_view->priv->action_move_to_trash), - "sensitive", (n_selected_files > 0) && trashable, - "visible", !trashed && thunar_g_vfs_is_uri_scheme_supported ("trash"), + "sensitive", (n_selected_files > 0) && writable, + "visible", !hide_trash_action, "tooltip", ngettext ("Move the selected file to the Trash", "Move the selected files to the Trash", n_selected_files), @@ -4575,7 +4581,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, + "visible", hide_trash_action || show_delete_action, "tooltip", ngettext ("Permanently delete the selected file", "Permanently delete the selected files", n_selected_files), -- 2.22.0