[gimp] app: select the second item on hitting down in action search entry.



commit 47a165dc6cd6cfc8fc27eae9107781d92e4a2b75
Author: Jehan <jehan girinstud io>
Date:   Sun Nov 23 01:40:33 2014 +0100

    app: select the second item on hitting down in action search entry.
    
    Since the first action of the list can be run directly with Enter while
    the entry is focused, hitting "Down" means one wants to select the next
    item of the list. So let's jump directly to the second item on the first
    "Down" key pressed.

 app/dialogs/action-search-dialog.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/app/dialogs/action-search-dialog.c b/app/dialogs/action-search-dialog.c
index aa4ba75..17a6ad7 100644
--- a/app/dialogs/action-search-dialog.c
+++ b/app/dialogs/action-search-dialog.c
@@ -74,6 +74,9 @@ typedef struct
 } SearchDialog;
 
 
+static gboolean     action_search_entry_key_pressed        (GtkWidget         *widget,
+                                                            GdkEventKey       *event,
+                                                            SearchDialog      *private);
 static void         action_search_entry_key_released       (GtkWidget         *widget,
                                                             GdkEventKey       *event,
                                                             SearchDialog      *private);
@@ -158,6 +161,9 @@ action_search_dialog_create (Gimp *gimp)
       g_signal_connect (private->keyword_entry, "key-release-event",
                         G_CALLBACK (action_search_entry_key_released),
                         private);
+      g_signal_connect (private->keyword_entry, "key-press-event",
+                        G_CALLBACK (action_search_entry_key_pressed),
+                        private);
 
       g_signal_connect (private->results_list, "key-press-event",
                         G_CALLBACK (action_search_list_key_pressed),
@@ -180,6 +186,29 @@ action_search_dialog_create (Gimp *gimp)
 }
 
 /* Private Functions */
+static gboolean
+action_search_entry_key_pressed (GtkWidget    *widget,
+                                 GdkEventKey  *event,
+                                 SearchDialog *private)
+{
+  gboolean event_processed = FALSE;
+
+  if (event->keyval == GDK_KEY_Down)
+    {
+      GtkTreeView *tree_view = GTK_TREE_VIEW (private->results_list);
+
+      /* When hitting the down key while editing, select directly the
+       * second item, since the first could have run directly with
+       * Enter. */
+      gtk_tree_selection_select_path (gtk_tree_view_get_selection (tree_view),
+                                      gtk_tree_path_new_from_string ("1"));
+      gtk_widget_grab_focus (GTK_WIDGET (private->results_list));
+      event_processed = TRUE;
+    }
+
+  return event_processed;
+}
+
 static void
 action_search_entry_key_released (GtkWidget    *widget,
                                   GdkEventKey  *event,


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