[Xfce4-commits] <midori:master> Refactor navigation handling

Christian Dywan noreply at xfce.org
Tue Jan 10 02:08:02 CET 2012


Updating branch refs/heads/master
         to 9445539c48e2e208bf6f1a8ce1193f8d311d16c9 (commit)
       from 43952508ebd93008a08db4a7aa0dea86a541cf14 (commit)

commit 9445539c48e2e208bf6f1a8ce1193f8d311d16c9
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Sat Jan 7 20:07:14 2012 -0400

    Refactor navigation handling

 extensions/formhistory/formhistory-gdom-frontend.c |   43 ++++++++++----------
 1 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/extensions/formhistory/formhistory-gdom-frontend.c b/extensions/formhistory/formhistory-gdom-frontend.c
index 230e1a9..06c9661 100644
--- a/extensions/formhistory/formhistory-gdom-frontend.c
+++ b/extensions/formhistory/formhistory-gdom-frontend.c
@@ -237,6 +237,7 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
     glong key;
     GtkTreePath* path;
     const gchar* keyword;
+    gint matches;
 
     /* FIXME: Priv is still set after module is disabled */
     if (!priv)
@@ -245,17 +246,12 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
     if (priv->completion_timeout > 0)
         g_source_remove (priv->completion_timeout);
 
-    g_object_get (element, "value", &keyword, NULL);
     priv->element = element;
 
     key = webkit_dom_ui_event_get_key_code (WEBKIT_DOM_UI_EVENT (dom_event));
-
     /* Ignore some control chars */
     if (key < 20 && key != 8)
         return;
-
-    gint matches = gtk_tree_model_iter_n_children (priv->completion_model, NULL);
-
     switch (key)
     {
         /* ESC key*/
@@ -276,27 +272,29 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
         case 38:
         /* Down key */
         case 40:
-            if (gtk_widget_get_visible (priv->popup))
+
+            if (!gtk_widget_get_visible (priv->popup))
             {
-                if (key == 38)
-                {
-                    if (priv->selection_index == -1)
-                        priv->selection_index = matches - 1;
-                    else
-                        priv->selection_index = MAX (priv->selection_index - 1, 1);
-                }
+                formhistory_suggestions_show (priv);
+                return;
+            }
+            matches = gtk_tree_model_iter_n_children (priv->completion_model, NULL);
+            if (key == 38)
+            {
+                if (priv->selection_index == -1)
+                    priv->selection_index = matches - 1;
                 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);
-                gtk_tree_path_free (path);
+                    priv->selection_index = MAX (priv->selection_index - 1, 1);
             }
             else
-                formhistory_suggestions_show (priv);
+            {
+                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);
+            gtk_tree_path_free (path);
             return;
             break;
         /* PgUp, PgDn, Ins */
@@ -306,6 +304,7 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
             break;
     }
 
+    g_object_get (element, "value", &keyword, NULL);
     if (!(keyword && *keyword && *keyword != ' '))
     {
         formhistory_suggestions_hide_cb (element, dom_event, priv);


More information about the Xfce4-commits mailing list