[nautilus/gnome-2-32: 257/283] Enter key when combo box has focus validates new media dialog (#589436)



commit 4edd07eeea73d4539f25212cf41cbb3c8e14bb3d
Author: Marcus Carlson <mdc src gnome org>
Date:   Sun Jul 25 23:52:02 2010 +0200

    Enter key when combo box has focus validates new media dialog (#589436)

 libnautilus-private/nautilus-autorun.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/libnautilus-private/nautilus-autorun.c b/libnautilus-private/nautilus-autorun.c
index 9b2c58f..b315976 100644
--- a/libnautilus-private/nautilus-autorun.c
+++ b/libnautilus-private/nautilus-autorun.c
@@ -30,6 +30,7 @@
 #include <gdk/gdkx.h>
 #include <gio/gdesktopappinfo.h>
 #include <X11/XKBlib.h>
+#include <gdk/gdkkeysyms.h>
 
 #include <eel/eel-glib-extensions.h>
 #include <eel/eel-stock-dialogs.h>
@@ -837,6 +838,15 @@ autorun_always_toggled (GtkToggleButton *togglebutton, AutorunDialogData *data)
 	data->remember = gtk_toggle_button_get_active (togglebutton);
 }
 
+static gboolean
+combo_box_enter_ok (GtkWidget *togglebutton, GdkEventKey *event, GtkDialog *dialog)
+{
+	if (event->keyval == GDK_KP_Enter || event->keyval == GDK_Return) {
+		gtk_dialog_response (dialog, GTK_RESPONSE_OK);
+		return TRUE;
+	}
+	return FALSE;
+}
 
 /* returns TRUE if a folder window should be opened */
 static gboolean
@@ -997,6 +1007,11 @@ show_dialog:
 
 	combo_box = gtk_combo_box_new ();
 	nautilus_autorun_prepare_combo_box (combo_box, x_content_type, FALSE, TRUE, FALSE, autorun_combo_changed, data);
+	g_signal_connect (G_OBJECT (combo_box),
+			  "key-press-event",
+			  G_CALLBACK (combo_box_enter_ok),
+			  dialog);
+
 	gtk_box_pack_start (GTK_BOX (vbox), combo_box, TRUE, TRUE, 0);
 
 	always_check_button = gtk_check_button_new_with_mnemonic (_("_Always perform this action"));



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