[PATCH] Add accelerators for views



From bug 139908 [1]:

"The Mac Finder uses:
    as Icons      cmd-1
    as List       cmd-2
    as Columns    cmd-3
This makes sense to me.  For Nautilus, we could make Icons = ctrl-1, List =
ctrl-2, and then keep on numbering (ctrl-3, ...) any other views (up to 9, if
anybody has that many).".

Patch attached.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=139908

-- 
Christian Neumair <chris gnome-de org>
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.450
diff -u -p -r1.450 nautilus-window.c
--- src/nautilus-window.c	1 Jul 2005 14:13:49 -0000	1.450
+++ src/nautilus-window.c	2 Jul 2005 10:48:42 -0000
@@ -679,6 +679,10 @@ add_view_as_menu_item (NautilusWindow *w
 	char *action_name;
 	ActivateViewData *data;
 
+	char *accel;
+	char *accel_path;
+	unsigned int accel_keyval;
+
 	info = nautilus_view_factory_lookup (identifier);
 	
 	action_name = g_strdup_printf ("view_as_%d", index);
@@ -687,6 +691,21 @@ add_view_as_menu_item (NautilusWindow *w
 				       _(info->display_location_label),
 				       NULL,
 				       0);
+
+	if (index >= 0 && index <= 9) {
+		accel = g_strdup_printf ("%d", index);
+
+		accel_path = g_strdup_printf ("<Nautilus-Window>/%s", action_name);
+
+		accel_keyval = gdk_keyval_from_name (accel);
+		g_assert (accel_keyval != GDK_VoidSymbol);
+
+		gtk_accel_map_add_entry (accel_path, accel_keyval, GDK_CONTROL_MASK);
+		gtk_action_set_accel_path (GTK_ACTION (action), accel_path);
+
+		g_free (accel);
+		g_free (accel_path);
+	}
 
 	if (window->details->view_as_radio_action != NULL) {
 		gtk_radio_action_set_group (action,

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]