Make clicking completion suggestion actually open the address
This commit is contained in:
parent
cabc3f0764
commit
0145cb3171
1 changed files with 13 additions and 9 deletions
|
@ -44,6 +44,7 @@ struct _MidoriLocationAction
|
||||||
GtkWidget* popup;
|
GtkWidget* popup;
|
||||||
GtkWidget* treeview;
|
GtkWidget* treeview;
|
||||||
GtkTreeModel* completion_model;
|
GtkTreeModel* completion_model;
|
||||||
|
gint completion_index;
|
||||||
GtkWidget* entry;
|
GtkWidget* entry;
|
||||||
GdkPixbuf* default_icon;
|
GdkPixbuf* default_icon;
|
||||||
GHashTable* items;
|
GHashTable* items;
|
||||||
|
@ -134,6 +135,9 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
|
||||||
GtkTreeIter* iter,
|
GtkTreeIter* iter,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_location_action_popdown_completion (MidoriLocationAction* location_action);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_location_action_class_init (MidoriLocationActionClass* class)
|
midori_location_action_class_init (MidoriLocationActionClass* class)
|
||||||
{
|
{
|
||||||
|
@ -318,13 +322,12 @@ midori_location_action_treeview_button_press_cb (GtkWidget* treeview,
|
||||||
gtk_tree_model_get_iter (action->completion_model, &iter, path);
|
gtk_tree_model_get_iter (action->completion_model, &iter, path);
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
|
|
||||||
gtk_widget_hide (action->popup);
|
midori_location_action_popdown_completion (action);
|
||||||
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (
|
|
||||||
GTK_TREE_VIEW (treeview)));
|
|
||||||
action->completion_timeout = 0;
|
|
||||||
|
|
||||||
gtk_tree_model_get (action->completion_model, &iter, URI_COL, &uri, -1);
|
gtk_tree_model_get (action->completion_model, &iter, URI_COL, &uri, -1);
|
||||||
gtk_entry_set_text (GTK_ENTRY (action->entry), uri);
|
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);
|
g_free (uri);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -502,6 +505,7 @@ midori_location_action_popdown_completion (MidoriLocationAction* location_action
|
||||||
GTK_TREE_VIEW (location_action->treeview)));
|
GTK_TREE_VIEW (location_action->treeview)));
|
||||||
}
|
}
|
||||||
location_action->completion_timeout = 0;
|
location_action->completion_timeout = 0;
|
||||||
|
location_action->completion_index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allow this to be used in tests, it's otherwise private */
|
/* Allow this to be used in tests, it's otherwise private */
|
||||||
|
@ -613,6 +617,7 @@ midori_location_action_init (MidoriLocationAction* location_action)
|
||||||
location_action->secondary_icon = NULL;
|
location_action->secondary_icon = NULL;
|
||||||
location_action->default_icon = NULL;
|
location_action->default_icon = NULL;
|
||||||
location_action->completion_timeout = 0;
|
location_action->completion_timeout = 0;
|
||||||
|
location_action->completion_index = -1;
|
||||||
location_action->key = NULL;
|
location_action->key = NULL;
|
||||||
location_action->popup = NULL;
|
location_action->popup = NULL;
|
||||||
location_action->entry = NULL;
|
location_action->entry = NULL;
|
||||||
|
@ -846,7 +851,6 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
GtkWidget* widget = GTK_WIDGET (entry);
|
GtkWidget* widget = GTK_WIDGET (entry);
|
||||||
MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
|
MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
|
||||||
const gchar* text;
|
const gchar* text;
|
||||||
static gint selected = -1;
|
|
||||||
gboolean is_enter = FALSE;
|
gboolean is_enter = FALSE;
|
||||||
|
|
||||||
switch (event->keyval)
|
switch (event->keyval)
|
||||||
|
@ -864,6 +868,7 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
{
|
{
|
||||||
GtkTreeModel* model = location_action->completion_model;
|
GtkTreeModel* model = location_action->completion_model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
gint selected = location_action->completion_index;
|
||||||
midori_location_action_popdown_completion (location_action);
|
midori_location_action_popdown_completion (location_action);
|
||||||
if (selected > -1 &&
|
if (selected > -1 &&
|
||||||
gtk_tree_model_iter_nth_child (model, &iter, NULL, selected))
|
gtk_tree_model_iter_nth_child (model, &iter, NULL, selected))
|
||||||
|
@ -877,10 +882,8 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
(event->state & GDK_CONTROL_MASK) ? TRUE : FALSE);
|
(event->state & GDK_CONTROL_MASK) ? TRUE : FALSE);
|
||||||
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
selected = -1;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
selected = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_enter)
|
if (is_enter)
|
||||||
|
@ -895,7 +898,6 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
midori_location_action_popdown_completion (location_action);
|
midori_location_action_popdown_completion (location_action);
|
||||||
text = gtk_entry_get_text (entry);
|
text = gtk_entry_get_text (entry);
|
||||||
pango_layout_set_text (gtk_entry_get_layout (entry), text, -1);
|
pango_layout_set_text (gtk_entry_get_layout (entry), text, -1);
|
||||||
selected = -1;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,6 +922,7 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
gint matches = gtk_tree_model_iter_n_children (model, NULL);
|
gint matches = gtk_tree_model_iter_n_children (model, NULL);
|
||||||
GtkTreePath* path;
|
GtkTreePath* path;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
gint selected = location_action->completion_index;
|
||||||
|
|
||||||
if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down)
|
if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down)
|
||||||
selected = MIN (selected + 1, matches -1);
|
selected = MIN (selected + 1, matches -1);
|
||||||
|
@ -943,6 +946,7 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
pango_layout_set_text (gtk_entry_get_layout (entry), uri, -1);
|
pango_layout_set_text (gtk_entry_get_layout (entry), uri, -1);
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
}
|
}
|
||||||
|
location_action->completion_index = selected;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,7 +963,7 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
if ((text = gtk_entry_get_text (entry)) && *text)
|
if ((text = gtk_entry_get_text (entry)) && *text)
|
||||||
{
|
{
|
||||||
midori_location_action_popup_completion (location_action, widget, "");
|
midori_location_action_popup_completion (location_action, widget, "");
|
||||||
selected = -1;
|
location_action->completion_index = -1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue