From: Carlos Garcia Campos Date: Tue, 12 May 2009 10:01:43 +0000 (+0200) Subject: [shell] Propagate key events from EvWindow to EvView X-Git-Tag: EVINCE_2_27_1~24 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=f81a810207898013bc1dba138f9ed50cb6d765d6;p=evince.git [shell] Propagate key events from EvWindow to EvView EvAnnotationWindow is a GtkWindow that doesn't accept focus, but we manually grab the focus on the text view contained in it to be able to modify the annotation contents. We need to propagate the key events to the view even when the view is not the focused widget. The view will only handle these events when there's a popup window with the focus so that it's possible to type in window annotations. --- diff --git a/shell/ev-window.c b/shell/ev-window.c index bc7d1513..16e10ca3 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -4748,6 +4748,30 @@ ev_window_dispose (GObject *object) G_OBJECT_CLASS (ev_window_parent_class)->dispose (object); } +static gboolean +ev_window_key_press_event (GtkWidget *widget, + GdkEventKey *event) +{ + EvWindow *ev_window = EV_WINDOW (widget); + gboolean handled = FALSE; + + /* Propagate the event to the view first + * It's needed to be able to type in + * annot popups windows + */ + if (ev_window->priv->view) { + g_object_ref (ev_window->priv->view); + if (GTK_WIDGET_IS_SENSITIVE (ev_window->priv->view)) + handled = gtk_widget_event (ev_window->priv->view, (GdkEvent*) event); + g_object_unref (ev_window->priv->view); + } + + if (!handled) + handled = GTK_WIDGET_CLASS (ev_window_parent_class)->key_press_event (widget, event); + + return handled; +} + static void ev_window_class_init (EvWindowClass *ev_window_class) { @@ -4757,6 +4781,7 @@ ev_window_class_init (EvWindowClass *ev_window_class) g_object_class->dispose = ev_window_dispose; g_object_class->finalize = ev_window_finalize; + widget_class->key_press_event = ev_window_key_press_event; widget_class->screen_changed = ev_window_screen_changed; widget_class->window_state_event = ev_window_state_event; widget_class->drag_data_received = ev_window_drag_data_received;