diff options
author | Xan Lopez <xan@src.gnome.org> | 2007-05-02 01:13:10 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2007-05-02 01:13:10 +0800 |
commit | be0b0b965e05963d42b9bf21899b4675b0a18e24 (patch) | |
tree | 89e6027cce96af82bb45b68f20923cd945bb9fa1 | |
parent | 9a3819459ea8edf60d3674cb0150566a2c2e1824 (diff) | |
download | gsoc2013-epiphany-be0b0b965e05963d42b9bf21899b4675b0a18e24.tar gsoc2013-epiphany-be0b0b965e05963d42b9bf21899b4675b0a18e24.tar.gz gsoc2013-epiphany-be0b0b965e05963d42b9bf21899b4675b0a18e24.tar.bz2 gsoc2013-epiphany-be0b0b965e05963d42b9bf21899b4675b0a18e24.tar.lz gsoc2013-epiphany-be0b0b965e05963d42b9bf21899b4675b0a18e24.tar.xz gsoc2013-epiphany-be0b0b965e05963d42b9bf21899b4675b0a18e24.tar.zst gsoc2013-epiphany-be0b0b965e05963d42b9bf21899b4675b0a18e24.zip |
Copy the items on the completion list as the user moves through them. The
* lib/widgets/ephy-location-entry.c:
* lib/widgets/ephy-location-entry.h:
* src/ephy-completion-model.c:
* src/ephy-completion-model.h:
* src/ephy-location-action.c:
Copy the items on the completion list as the user moves through
them. The original input can be restored pressing Esc. The tentative
completion can be made definitive pressing Left or Right.
Fixes #409291, #102528
svn path=/trunk/; revision=7020
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | lib/widgets/ephy-location-entry.c | 35 | ||||
-rw-r--r-- | lib/widgets/ephy-location-entry.h | 3 | ||||
-rw-r--r-- | src/ephy-completion-model.c | 28 | ||||
-rw-r--r-- | src/ephy-completion-model.h | 1 | ||||
-rw-r--r-- | src/ephy-location-action.c | 3 |
6 files changed, 81 insertions, 3 deletions
@@ -1,3 +1,17 @@ +2007-05-01 Xan Lopez <xan@gnome.org> + + * lib/widgets/ephy-location-entry.c: + * lib/widgets/ephy-location-entry.h: + * src/ephy-completion-model.c: + * src/ephy-completion-model.h: + * src/ephy-location-action.c: + + Copy the items on the completion list as the user moves through + them. The original input can be restored pressing Esc. The tentative + completion can be made definitive pressing Left or Right. + + Fixes #409291, #102528 + 2007-04-24 Diego Escalante Urrelo <diegoe@gnome.org> * src/popup-commands.c: 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, diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c index 566cc4a0d..c2699ccac 100644 --- a/src/ephy-completion-model.c +++ b/src/ephy-completion-model.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright © 2002 Jorn Baayen <jorn@nl.linux.org> * @@ -444,6 +445,29 @@ init_relevance_col (GValue *value, EphyNode *node, int group) } static void +init_url_col (GValue *value, EphyNode *node, int group) +{ + const char *url = NULL; + + if (group == BOOKMARKS_GROUP) + { + url = ephy_node_get_property_string + (node, EPHY_NODE_BMK_PROP_LOCATION); + } + else if (group == HISTORY_GROUP) + { + url = ephy_node_get_property_string + (node, EPHY_NODE_PAGE_PROP_LOCATION); + } + else + { + url = ""; + } + + g_value_set_string (value, url); +} + +static void ephy_completion_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column, @@ -494,6 +518,10 @@ ephy_completion_model_get_value (GtkTreeModel *tree_model, g_value_init (value, G_TYPE_INT); init_relevance_col (value, node, group); break; + case EPHY_COMPLETION_URL_COL: + g_value_init (value, G_TYPE_STRING); + init_url_col (value, node, group); + break; } } diff --git a/src/ephy-completion-model.h b/src/ephy-completion-model.h index a264ad2fd..6df64d288 100644 --- a/src/ephy-completion-model.h +++ b/src/ephy-completion-model.h @@ -42,6 +42,7 @@ typedef enum EPHY_COMPLETION_RELEVANCE_COL, EPHY_COMPLETION_EXTRA_COL, EPHY_COMPLETION_FAVICON_COL, + EPHY_COMPLETION_URL_COL, N_COL } EphyCompletionColumn; diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index 59aa51573..9c30f0dc6 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -370,7 +370,8 @@ connect_proxy (GtkAction *action, GtkWidget *proxy) EPHY_COMPLETION_KEYWORDS_COL, EPHY_COMPLETION_RELEVANCE_COL, EPHY_COMPLETION_EXTRA_COL, - EPHY_COMPLETION_FAVICON_COL); + EPHY_COMPLETION_FAVICON_COL, + EPHY_COMPLETION_URL_COL); add_completion_actions (action, proxy); |