diff options
Diffstat (limited to 'lib/widgets')
-rw-r--r-- | lib/widgets/ephy-location-entry.c | 35 | ||||
-rw-r--r-- | lib/widgets/ephy-location-entry.h | 3 |
2 files changed, 36 insertions, 2 deletions
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c index 235eb56ab..084234935 100644 --- a/lib/widgets/ephy-location-entry.c +++ b/lib/widgets/ephy-location-entry.c @@ -53,6 +53,7 @@ #include <gtk/gtkseparatormenuitem.h> #include <gtk/gtkalignment.h> #include <gtk/gtkclipboard.h> +#include <gtk/gtkversion.h> #include <string.h> @@ -78,6 +79,7 @@ struct _EphyLocationEntryPrivate guint relevance_col; guint extra_col; guint favicon_col; + guint url_col; guint hash; @@ -994,6 +996,29 @@ sort_func (GtkTreeModel *model, return valueb - valuea; } +#if GTK_CHECK_VERSION (2, 11, 0) +static gboolean +cursor_on_match_cb (GtkEntryCompletion *completion, + GtkTreeModel *model, + GtkTreeIter *iter, + EphyLocationEntry *le) +{ + char *item = NULL; + GtkWidget *entry; + + gtk_tree_model_get (model, iter, + le->priv->url_col, + &item, -1); + + entry = gtk_entry_completion_get_entry (completion); + gtk_entry_set_text (GTK_ENTRY (entry), item); + + g_free (item); + + return TRUE; +} +#endif /* GTK+ 2.11.0 */ + void ephy_location_entry_set_completion (EphyLocationEntry *le, GtkTreeModel *model, @@ -1002,7 +1027,8 @@ ephy_location_entry_set_completion (EphyLocationEntry *le, guint keywords_col, guint relevance_col, guint extra_col, - guint favicon_col) + guint favicon_col, + guint url_col) { EphyLocationEntryPrivate *priv = le->priv; GtkTreeModel *sort_model; @@ -1015,6 +1041,7 @@ ephy_location_entry_set_completion (EphyLocationEntry *le, le->priv->relevance_col = relevance_col; le->priv->extra_col = extra_col; le->priv->favicon_col = favicon_col; + le->priv->url_col = url_col; sort_model = gtk_tree_model_sort_new_with_model (model); g_object_unref (model); @@ -1062,6 +1089,12 @@ ephy_location_entry_set_completion (EphyLocationEntry *le, gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion), extracell, "text", extra_col); +#if GTK_CHECK_VERSION (2, 11, 0) + g_object_set (completion, "inline-selection", TRUE, NULL); + g_signal_connect (completion, "cursor-on-match", + G_CALLBACK (cursor_on_match_cb), le); +#endif + gtk_entry_set_completion (GTK_ENTRY (priv->icon_entry->entry), completion); g_object_unref (completion); } diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h index 262a9cfd3..549416c23 100644 --- a/lib/widgets/ephy-location-entry.h +++ b/lib/widgets/ephy-location-entry.h @@ -73,7 +73,8 @@ void ephy_location_entry_set_completion (EphyLocationEntry *le, guint keywords_col, guint relevance_col, guint extra_col, - guint favicon_col); + guint favicon_col, + guint url_col); void ephy_location_entry_set_location (EphyLocationEntry *le, const char *address, |