Refactor navigation handling
This commit is contained in:
parent
43952508eb
commit
9445539c48
1 changed files with 22 additions and 23 deletions
|
@ -237,6 +237,7 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
|
||||||
glong key;
|
glong key;
|
||||||
GtkTreePath* path;
|
GtkTreePath* path;
|
||||||
const gchar* keyword;
|
const gchar* keyword;
|
||||||
|
gint matches;
|
||||||
|
|
||||||
/* FIXME: Priv is still set after module is disabled */
|
/* FIXME: Priv is still set after module is disabled */
|
||||||
if (!priv)
|
if (!priv)
|
||||||
|
@ -245,17 +246,12 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
|
||||||
if (priv->completion_timeout > 0)
|
if (priv->completion_timeout > 0)
|
||||||
g_source_remove (priv->completion_timeout);
|
g_source_remove (priv->completion_timeout);
|
||||||
|
|
||||||
g_object_get (element, "value", &keyword, NULL);
|
|
||||||
priv->element = element;
|
priv->element = element;
|
||||||
|
|
||||||
key = webkit_dom_ui_event_get_key_code (WEBKIT_DOM_UI_EVENT (dom_event));
|
key = webkit_dom_ui_event_get_key_code (WEBKIT_DOM_UI_EVENT (dom_event));
|
||||||
|
|
||||||
/* Ignore some control chars */
|
/* Ignore some control chars */
|
||||||
if (key < 20 && key != 8)
|
if (key < 20 && key != 8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gint matches = gtk_tree_model_iter_n_children (priv->completion_model, NULL);
|
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
/* ESC key*/
|
/* ESC key*/
|
||||||
|
@ -276,8 +272,13 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
|
||||||
case 38:
|
case 38:
|
||||||
/* Down key */
|
/* Down key */
|
||||||
case 40:
|
case 40:
|
||||||
if (gtk_widget_get_visible (priv->popup))
|
|
||||||
|
if (!gtk_widget_get_visible (priv->popup))
|
||||||
{
|
{
|
||||||
|
formhistory_suggestions_show (priv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
matches = gtk_tree_model_iter_n_children (priv->completion_model, NULL);
|
||||||
if (key == 38)
|
if (key == 38)
|
||||||
{
|
{
|
||||||
if (priv->selection_index == -1)
|
if (priv->selection_index == -1)
|
||||||
|
@ -294,9 +295,6 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
|
||||||
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, NULL, FALSE);
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, NULL, FALSE);
|
||||||
formhistory_suggestion_set (path, priv);
|
formhistory_suggestion_set (path, priv);
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
}
|
|
||||||
else
|
|
||||||
formhistory_suggestions_show (priv);
|
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
/* PgUp, PgDn, Ins */
|
/* PgUp, PgDn, Ins */
|
||||||
|
@ -306,6 +304,7 @@ formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_get (element, "value", &keyword, NULL);
|
||||||
if (!(keyword && *keyword && *keyword != ' '))
|
if (!(keyword && *keyword && *keyword != ' '))
|
||||||
{
|
{
|
||||||
formhistory_suggestions_hide_cb (element, dom_event, priv);
|
formhistory_suggestions_hide_cb (element, dom_event, priv);
|
||||||
|
|
Loading…
Reference in a new issue