[PATCH] override GtkWindow key-press-event handler



The attached patch should fix issues where handlers registered with
GtkActionGroups override those registered with child widgets, cf. bug
345528 [1].

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

-- 
Christian Neumair <chris gnome-de org>
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.465
diff -u -p -r1.465 nautilus-window.c
--- src/nautilus-window.c	21 Jun 2006 16:26:23 -0000	1.465
+++ src/nautilus-window.c	21 Jun 2006 19:31:34 -0000
@@ -742,6 +742,35 @@ nautilus_window_realize (GtkWidget *widg
 	update_cursor (NAUTILUS_WINDOW (widget));
 }
 
+/* try to propagate key press event to children before handling
+ * mnemonics related to action groups. This is for instance relevant
+ * when the GtkAction file deletion keybinding would be activated
+ * instead of the rename widget text deletion keybinding.
+ */
+static gint
+nautilus_window_key_press_event (GtkWidget   *widget,
+				 GdkEventKey *event)
+{
+	GtkWindow *window = GTK_WINDOW (widget);
+
+	if (!gtk_window_propagate_key_event (window, event) &&
+	    !gtk_window_activate_key (window, event)) {
+		/* skip GtkWindow handler, directly use GtkWidget method */
+
+		static GtkWidgetClass *gtk_widget_class = NULL;
+		if (gtk_widget_class == NULL) {
+			gtk_widget_class = g_type_class_peek (gtk_widget_get_type ());
+			g_assert (gtk_widget_class != NULL);
+			g_assert (gtk_widget_class->key_press_event != NULL);
+		}
+
+		return GTK_WIDGET_CLASS (gtk_widget_class)->key_press_event (widget, event);
+	}
+
+	return TRUE;
+
+}
+
 /*
  * Main API
  */
@@ -1583,6 +1612,7 @@ nautilus_window_class_init (NautilusWind
 	GTK_WIDGET_CLASS (class)->show = nautilus_window_show;
 	GTK_WIDGET_CLASS (class)->size_request = nautilus_window_size_request;
 	GTK_WIDGET_CLASS (class)->realize = nautilus_window_realize;
+	GTK_WIDGET_CLASS (class)->key_press_event = nautilus_window_key_press_event;
 	class->add_current_location_to_history_list = real_add_current_location_to_history_list;
 	class->get_title = real_get_title;
 	class->set_title = real_set_title;


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