GtkWidget* popup;
GtkWidget* treeview;
GtkTreeModel* completion_model;
+ gint completion_index;
GtkWidget* entry;
GdkPixbuf* default_icon;
GHashTable* items;
GtkTreeIter* iter,
gpointer data);
+static void
+midori_location_action_popdown_completion (MidoriLocationAction* location_action);
+
static void
midori_location_action_class_init (MidoriLocationActionClass* class)
{
gtk_tree_model_get_iter (action->completion_model, &iter, path);
gtk_tree_path_free (path);
- gtk_widget_hide (action->popup);
- gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (
- GTK_TREE_VIEW (treeview)));
- action->completion_timeout = 0;
+ midori_location_action_popdown_completion (action);
gtk_tree_model_get (action->completion_model, &iter, URI_COL, &uri, -1);
gtk_entry_set_text (GTK_ENTRY (action->entry), uri);
+ g_signal_emit (action, signals[SUBMIT_URI], 0, uri,
+ (event->state & GDK_CONTROL_MASK) ? TRUE : FALSE);
g_free (uri);
return TRUE;
GTK_TREE_VIEW (location_action->treeview)));
}
location_action->completion_timeout = 0;
+ location_action->completion_index = -1;
}
/* Allow this to be used in tests, it's otherwise private */
location_action->secondary_icon = NULL;
location_action->default_icon = NULL;
location_action->completion_timeout = 0;
+ location_action->completion_index = -1;
location_action->key = NULL;
location_action->popup = NULL;
location_action->entry = NULL;
GtkWidget* widget = GTK_WIDGET (entry);
MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
const gchar* text;
- static gint selected = -1;
gboolean is_enter = FALSE;
switch (event->keyval)
{
GtkTreeModel* model = location_action->completion_model;
GtkTreeIter iter;
+ gint selected = location_action->completion_index;
midori_location_action_popdown_completion (location_action);
if (selected > -1 &&
gtk_tree_model_iter_nth_child (model, &iter, NULL, selected))
(event->state & GDK_CONTROL_MASK) ? TRUE : FALSE);
g_free (uri);
- selected = -1;
return TRUE;
}
- selected = -1;
}
if (is_enter)
midori_location_action_popdown_completion (location_action);
text = gtk_entry_get_text (entry);
pango_layout_set_text (gtk_entry_get_layout (entry), text, -1);
- selected = -1;
return TRUE;
}
gint matches = gtk_tree_model_iter_n_children (model, NULL);
GtkTreePath* path;
GtkTreeIter iter;
+ gint selected = location_action->completion_index;
if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down)
selected = MIN (selected + 1, matches -1);
pango_layout_set_text (gtk_entry_get_layout (entry), uri, -1);
g_free (uri);
}
+ location_action->completion_index = selected;
return TRUE;
}
if ((text = gtk_entry_get_text (entry)) && *text)
{
midori_location_action_popup_completion (location_action, widget, "");
- selected = -1;
+ location_action->completion_index = -1;
return FALSE;
}
}