Commit 5917e7df authored by Alexander Schwinn's avatar Alexander Schwinn

Add preferences item to toggle the delete in the context menu

(Bug #13327)
parent 8ecb1845
......@@ -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
*/
......
......@@ -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:
*
......
......@@ -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),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment