diff options
Diffstat (limited to 'src/nautilus-query-editor.c')
-rw-r--r-- | src/nautilus-query-editor.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c index b95dbe5c8..a1dc0a63e 100644 --- a/src/nautilus-query-editor.c +++ b/src/nautilus-query-editor.c @@ -58,6 +58,7 @@ struct _NautilusQueryEditor enum { ACTIVATED, + FOCUS_VIEW, CHANGED, CANCEL, LAST_SIGNAL @@ -271,6 +272,15 @@ nautilus_query_editor_class_init (NautilusQueryEditorClass *class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[FOCUS_VIEW] = + g_signal_new ("focus-view", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + /** * NautilusQueryEditor::location: * @@ -727,8 +737,30 @@ gboolean nautilus_query_editor_handle_event (NautilusQueryEditor *self, GdkEvent *event) { + guint keyval; + GdkModifierType state; + g_return_val_if_fail (NAUTILUS_IS_QUERY_EDITOR (self), GDK_EVENT_PROPAGATE); g_return_val_if_fail (event != NULL, GDK_EVENT_PROPAGATE); + if (G_UNLIKELY (!gdk_event_get_keyval (event, &keyval))) + { + g_return_val_if_reached (GDK_EVENT_PROPAGATE); + } + + gdk_event_get_state (event, &state); + + /* In the case of key up/down we want to move the focus to the view, since + * the user is probably trying to navigate the files + */ + if (gtk_widget_has_focus (GTK_WIDGET (self->entry))) + { + if (keyval == GDK_KEY_Down || keyval == GDK_KEY_Up) + { + g_signal_emit (self, signals[FOCUS_VIEW], 0); + return GDK_EVENT_STOP; + } + } + return gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (self->entry), event); } |