summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-10-03 17:08:03 +0000
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-10-03 17:08:03 +0000
commit2afd4e63cc42c560846a4b7b592a2e24125edfd2 (patch)
tree1dff5b3028f328d11ee095324351776f5816514e
parent5537d9c9ad6e134fda8b2f7f5a877bb6e1f222bb (diff)
downloadepiphany-2afd4e63cc42c560846a4b7b592a2e24125edfd2.tar.gz
Do not create multiple gtk completions, open the url when a match is
2003-10-03 Marco Pesenti Gritti <marco@gnome.org> * lib/widgets/ephy-location-entry.c: (match_selected_cb), (ephy_location_entry_construct_contents), (ephy_location_entry_add_completion): Do not create multiple gtk completions, open the url when a match is selected.
-rw-r--r--ChangeLog9
-rw-r--r--lib/widgets/ephy-location-entry.c49
2 files changed, 44 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index aee4ae7e6..0046ed401 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-10-03 Marco Pesenti Gritti <marco@gnome.org>
+
+ * lib/widgets/ephy-location-entry.c: (match_selected_cb),
+ (ephy_location_entry_construct_contents),
+ (ephy_location_entry_add_completion):
+
+ Do not create multiple gtk completions, open the
+ url when a match is selected.
+
2003-10-02 Marco Pesenti Gritti <marco@gnome.org>
* lib/egg/Makefile.am:
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index fff561e87..1f2753e7b 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -272,10 +272,31 @@ completion_func (GtkEntryCompletion *completion,
return ret;
}
+static gboolean
+match_selected_cb (GtkEntryCompletion *completion,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EphyLocationEntry *le)
+{
+ char *item = NULL;
+
+ gtk_tree_model_get (model, iter,
+ ACTION_COL, &item, -1);
+
+ ephy_location_entry_set_location (le, item);
+ g_signal_emit_by_name (le->priv->entry, "activate");
+
+ g_free (item);
+
+ return TRUE;
+}
+
static void
ephy_location_entry_construct_contents (EphyLocationEntry *le)
{
EphyLocationEntryPrivate *p = le->priv;
+ GtkEntryCompletion *completion;
+ GtkCellRenderer *cell;
LOG ("EphyLocationEntry constructing contents %p", le)
@@ -294,6 +315,20 @@ ephy_location_entry_construct_contents (EphyLocationEntry *le)
p->completion_model = egg_tree_model_union_new
(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+
+ completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_model (completion, le->priv->completion_model);
+ gtk_entry_completion_set_match_func (completion, completion_func, le, NULL);
+ g_signal_connect (completion, "match_selected",
+ G_CALLBACK (match_selected_cb), le);
+
+ cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
+ cell, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "text", TEXT_COL);
+
+ gtk_entry_set_completion (GTK_ENTRY (le->priv->entry), completion);
}
static void
@@ -345,8 +380,6 @@ ephy_location_entry_add_completion (EphyLocationEntry *le,
guint keywords_property)
{
EphyTreeModelNode *node_model;
- GtkEntryCompletion *completion;
- GtkCellRenderer *cell;
int action_col, text_col, keywords_col;
node_model = ephy_tree_model_node_new (root, NULL);
@@ -360,18 +393,6 @@ ephy_location_entry_add_completion (EphyLocationEntry *le,
(EGG_TREE_MODEL_UNION (le->priv->completion_model),
GTK_TREE_MODEL (node_model), text_col, keywords_col,
action_col);
-
- completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (completion, le->priv->completion_model);
- gtk_entry_completion_set_match_func (completion, completion_func, le, NULL);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
- cell, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "text", TEXT_COL);
-
- gtk_entry_set_completion (GTK_ENTRY (le->priv->entry), completion);
}
void