]> spindle.queued.net Git - midori/commitdiff
Fix keyboard navigation in suggestions
authorAlexander Butenko <a.butenka@gmail.com>
Sun, 8 Jan 2012 02:55:18 +0000 (22:55 -0400)
committerChristian Dywan <christian@twotoasts.de>
Tue, 10 Jan 2012 01:15:41 +0000 (02:15 +0100)
extensions/formhistory/formhistory-frontend.h
extensions/formhistory/formhistory-gdom-frontend.c

index ee91971785b21b588b30867d34259ef0bbdc4f88..3f7469f8d79be9ddc2b14c825cd1c098c09e211e 100644 (file)
@@ -35,7 +35,7 @@ typedef struct
     GtkWidget* popup;
     GtkWidget* root;
     gchar* oldkeyword;
-    guint selection_index;
+    glong selection_index;
     #else
     gchar* jsforms;
     #endif
index 18efd82d3d1a95fec8dc50b65b0232e0cd884dba..2912347a4c329d425a02024174889337ed2aaae1 100644 (file)
@@ -272,16 +272,18 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
             matches = gtk_tree_model_iter_n_children (priv->completion_model, NULL);
             if (key == 38)
             {
-                if (priv->selection_index == -1)
+                if (priv->selection_index <= 0)
                     priv->selection_index = matches - 1;
                 else
-                    priv->selection_index = MAX (priv->selection_index - 1, 1);
+                    priv->selection_index = MAX (priv->selection_index - 1, 0);
             }
             else
             {
-                priv->selection_index = MIN (priv->selection_index + 1, matches -1);
+                if (priv->selection_index == matches - 1)
+                    priv->selection_index = 0;
+                else
+                    priv->selection_index = MIN (priv->selection_index + 1, matches -1);
             }
-
             path = gtk_tree_path_new_from_indices (priv->selection_index, -1);
             gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, NULL, FALSE);
             formhistory_suggestion_set (path, priv);