[nautilus] Disable Trash/Delete key bindings when appropriate
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus] Disable Trash/Delete key bindings when appropriate
- Date: Tue, 1 Dec 2009 10:34:02 +0000 (UTC)
commit e7c171acb8060436969139210060874f3a43d835
Author: Michael Terry <michael terry canonical com>
Date: Tue Dec 1 11:32:12 2009 +0100
Disable Trash/Delete key bindings when appropriate
This makes trash/delete key binding be enabled/disabled just like
the menu items are.
src/file-manager/fm-actions.h | 3 +
src/file-manager/fm-directory-view.c | 69 ++++++++++++++---------
src/file-manager/nautilus-directory-view-ui.xml | 3 +
3 files changed, 48 insertions(+), 27 deletions(-)
---
diff --git a/src/file-manager/fm-actions.h b/src/file-manager/fm-actions.h
index 0294ea3..e0162e1 100644
--- a/src/file-manager/fm-actions.h
+++ b/src/file-manager/fm-actions.h
@@ -59,8 +59,11 @@
#define FM_ACTION_INVERT_SELECTION "Invert Selection"
#define FM_ACTION_SELECT_PATTERN "Select Pattern"
#define FM_ACTION_TRASH "Trash"
+#define FM_ACTION_TRASH2 "Trash2"
+#define FM_ACTION_TRASH3 "Trash3"
#define FM_ACTION_LOCATION_TRASH "LocationTrash"
#define FM_ACTION_DELETE "Delete"
+#define FM_ACTION_DELETE2 "Delete2"
#define FM_ACTION_LOCATION_DELETE "LocationDelete"
#define FM_ACTION_RESTORE_FROM_TRASH "Restore From Trash"
#define FM_ACTION_LOCATION_RESTORE_FROM_TRASH "LocationRestoreFromTrash"
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index eaa82a8..c8dac1e 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -7033,10 +7033,22 @@ static const GtkActionEntry directory_view_entries[] = {
/* label, accelerator */ N_("Mo_ve to Trash"), NULL,
/* tooltip */ N_("Move each selected item to the Trash"),
G_CALLBACK (action_trash_callback) },
+ /* name, stock id */ { "Trash2", NAUTILUS_ICON_TRASH,
+ /* label, accelerator */ N_("Mo_ve to Trash"), "Delete",
+ /* tooltip */ N_("Move each selected item to the Trash"),
+ G_CALLBACK (action_trash_callback) },
+ /* name, stock id */ { "Trash3", NAUTILUS_ICON_TRASH,
+ /* label, accelerator */ N_("Mo_ve to Trash"), "KP_Delete",
+ /* tooltip */ N_("Move each selected item to the Trash"),
+ G_CALLBACK (action_trash_callback) },
/* name, stock id */ { "Delete", NULL,
/* label, accelerator */ N_("_Delete"), "<shift>Delete",
/* tooltip */ N_("Delete each selected item, without moving to the Trash"),
G_CALLBACK (action_delete_callback) },
+ /* name, stock id */ { "Delete2", NULL,
+ /* label, accelerator */ N_("_Delete"), "<shift>KP_Delete",
+ /* tooltip */ N_("Delete each selected item, without moving to the Trash"),
+ G_CALLBACK (action_delete_callback) },
/* name, stock id */ { "Restore From Trash", NULL,
/* label, accelerator */ N_("_Restore"), NULL,
NULL,
@@ -8386,6 +8398,14 @@ real_update_menus (FMDirectoryView *view)
GAppInfo *app;
GIcon *app_icon;
GtkWidget *menuitem;
+ gint i;
+ gchar *trash_actions[] = {FM_ACTION_TRASH,
+ FM_ACTION_TRASH2,
+ FM_ACTION_TRASH3,
+ NULL};
+ gchar *delete_actions[] = {FM_ACTION_DELETE,
+ FM_ACTION_DELETE2,
+ NULL};
selection = fm_directory_view_get_selection (view);
selection_count = g_list_length (selection);
@@ -8589,27 +8609,31 @@ real_update_menus (FMDirectoryView *view)
show_separate_delete_command = show_delete_command_auto_value;
}
- action = gtk_action_group_get_action (view->details->dir_action_group,
- FM_ACTION_TRASH);
- g_object_set (action,
- "label", label,
- "tooltip", tip,
- "icon-name", all_selected_items_in_trash (view) ?
- NAUTILUS_ICON_DELETE : NAUTILUS_ICON_TRASH_FULL,
- NULL);
- gtk_action_set_sensitive (action, can_delete_files);
-
- action = gtk_action_group_get_action (view->details->dir_action_group,
- FM_ACTION_DELETE);
- gtk_action_set_visible (action, show_separate_delete_command);
-
- if (show_separate_delete_command) {
+ for (i = 0; trash_actions[i]; ++i) {
+ action = gtk_action_group_get_action (view->details->dir_action_group, trash_actions[i]);
g_object_set (action,
- "label", _("_Delete"),
- "icon-name", NAUTILUS_ICON_DELETE,
+ "label", label,
+ "tooltip", tip,
+ "icon-name", all_selected_items_in_trash (view) ?
+ NAUTILUS_ICON_DELETE :
+ NAUTILUS_ICON_TRASH_FULL,
NULL);
+ gtk_action_set_sensitive (action, can_delete_files);
+ }
+
+ for (i = 0; delete_actions[i]; ++i) {
+ action = gtk_action_group_get_action (view->details->dir_action_group,
+ delete_actions[i]);
+ gtk_action_set_visible (action, show_separate_delete_command);
+
+ if (show_separate_delete_command) {
+ g_object_set (action,
+ "label", _("_Delete"),
+ "icon-name", NAUTILUS_ICON_DELETE,
+ NULL);
+ }
+ gtk_action_set_sensitive (action, can_delete_files);
}
- gtk_action_set_sensitive (action, can_delete_files);
action = gtk_action_group_get_action (view->details->dir_action_group,
@@ -10498,7 +10522,6 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
{
GtkWidgetClass *widget_class;
GtkScrolledWindowClass *scrolled_window_class;
- GtkBindingSet *binding_set;
widget_class = GTK_WIDGET_CLASS (klass);
scrolled_window_class = GTK_SCROLLED_WINDOW_CLASS (klass);
@@ -10662,14 +10685,6 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
eel_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
- binding_set = gtk_binding_set_by_class (klass);
- gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0,
- "trash", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0,
- "trash", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_SHIFT_MASK,
- "delete", 0);
-
klass->trash = real_trash;
klass->delete = real_delete;
}
diff --git a/src/file-manager/nautilus-directory-view-ui.xml b/src/file-manager/nautilus-directory-view-ui.xml
index e4dfb29..56d6d93 100644
--- a/src/file-manager/nautilus-directory-view-ui.xml
+++ b/src/file-manager/nautilus-directory-view-ui.xml
@@ -3,6 +3,9 @@
<accelerator action="OpenCloseParent"/>
<accelerator action="PropertiesAccel"/>
<accelerator action="RenameSelectAll"/>
+<accelerator action="Trash2"/>
+<accelerator action="Trash3"/>
+<accelerator action="Delete2"/>
<menubar name="MenuBar">
<menu action="File">
<placeholder name="New Items Placeholder">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]