aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <diegoe@src.gnome.org>2008-08-15 06:47:39 +0800
committerDiego Escalante Urrelo <diegoe@src.gnome.org>2008-08-15 06:47:39 +0800
commitaefbb7f4a30188b281becee9d61b4b519c625a9f (patch)
tree76bb433a45c34fa885bb8398e96741bfddfefc88 /lib/widgets
parent82a8ea1c5dbe7e892763d1f7395fe7d69c7a485d (diff)
downloadgsoc2013-epiphany-aefbb7f4a30188b281becee9d61b4b519c625a9f.tar
gsoc2013-epiphany-aefbb7f4a30188b281becee9d61b4b519c625a9f.tar.gz
gsoc2013-epiphany-aefbb7f4a30188b281becee9d61b4b519c625a9f.tar.bz2
gsoc2013-epiphany-aefbb7f4a30188b281becee9d61b4b519c625a9f.tar.lz
gsoc2013-epiphany-aefbb7f4a30188b281becee9d61b4b519c625a9f.tar.xz
gsoc2013-epiphany-aefbb7f4a30188b281becee9d61b4b519c625a9f.tar.zst
gsoc2013-epiphany-aefbb7f4a30188b281becee9d61b4b519c625a9f.zip
Port the location bar to use GRegex.
Use a simple regex matching the input text, implements the same behaviour of the current bar, plus: - substring suggestions (closes: #151932) - unicode support (closes: #343906) - diacritics in topic keywords (closes: #328162) - completion on history items titles (closes: #534218) Also, of course, closes: #517960 - port the url bar to GRegex. svn path=/trunk/; revision=8419
Diffstat (limited to 'lib/widgets')
-rw-r--r--lib/widgets/ephy-location-entry.c52
-rw-r--r--lib/widgets/ephy-location-entry.h9
2 files changed, 51 insertions, 10 deletions
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 5773ddaf5..6c3944e2c 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -54,6 +54,7 @@ struct _EphyLocationEntryPrivate
GdkColor secure_fg_colour;
GtkCellRenderer *extracell;
+ GRegex *regex;
char *before_completion;
char *saved_text;
@@ -214,6 +215,12 @@ ephy_location_entry_finalize (GObject *object)
{
g_object_unref (priv->favicon);
}
+
+ if (priv->regex)
+ {
+ g_regex_unref (priv->regex);
+ priv->regex = NULL;
+ }
parent_class->finalize (object);
}
@@ -328,6 +335,8 @@ editable_changed_cb (GtkEditable *editable,
EphyLocationEntry *entry)
{
EphyLocationEntryPrivate *priv = entry->priv;
+ const char *text;
+ char *pattern;
update_address_state (entry);
@@ -338,6 +347,25 @@ editable_changed_cb (GtkEditable *editable,
priv->user_changed = TRUE;
priv->can_redo = FALSE;
}
+
+ if (priv->regex)
+ {
+ g_regex_unref (priv->regex);
+ priv->regex = NULL;
+ }
+
+ text = gtk_entry_get_text (GTK_ENTRY (editable));
+
+ if (g_str_has_prefix (text, "re:"))
+ pattern = g_strdup (text+3);
+ else
+ pattern = g_regex_escape_string (text, -1);
+
+ priv->regex = g_regex_new (pattern,
+ G_REGEX_CASELESS | G_REGEX_OPTIMIZE,
+ G_REGEX_MATCH_NOTEMPTY, NULL);
+
+ g_free (pattern);
update_favicon (entry);
@@ -499,7 +527,7 @@ entry_drag_motion_cb (GtkWidget *widget,
{
g_signal_stop_emission_by_name (widget, "drag_motion");
}
-
+
return FALSE;
}
@@ -908,7 +936,8 @@ ephy_location_entry_init (EphyLocationEntry *le)
p->user_changed = FALSE;
p->block_update = FALSE;
p->saved_text = NULL;
-
+ p->regex = NULL;
+
ephy_location_entry_construct_contents (le);
gtk_tool_item_set_expand (GTK_TOOL_ITEM (le), TRUE);
@@ -932,8 +961,8 @@ cursor_on_match_cb (GtkEntryCompletion *completion,
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);
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
@@ -972,15 +1001,16 @@ extracell_data_func (GtkCellLayout *cell_layout,
}
void
-ephy_location_entry_set_completion_func (EphyLocationEntry *le,
- GtkEntryCompletionMatchFunc completion_func,
- gpointer user_data)
+ephy_location_entry_set_match_func (EphyLocationEntry *le,
+ GtkEntryCompletionMatchFunc match_func,
+ gpointer user_data,
+ GDestroyNotify notify)
{
EphyLocationEntryPrivate *priv = le->priv;
GtkEntryCompletion *completion;
completion = gtk_entry_get_completion (GTK_ENTRY (priv->icon_entry->entry));
- gtk_entry_completion_set_match_func (completion, completion_func, user_data, NULL);
+ gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
}
void
@@ -1298,3 +1328,11 @@ ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
gtk_widget_set_tooltip_text (priv->lock_ebox, tooltip);
}
+
+GRegex *
+ephy_location_entry_get_regex (EphyLocationEntry *entry)
+{
+ EphyLocationEntryPrivate *priv = entry->priv;
+
+ return priv->regex;
+}
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index a949d949b..3c558dfa5 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -82,9 +82,10 @@ void ephy_location_entry_set_location (EphyLocationEntry *le,
const char *address,
const char *typed_address);
-void ephy_location_entry_set_completion_func (EphyLocationEntry *le,
- GtkEntryCompletionMatchFunc completion_func,
- gpointer user_data);
+void ephy_location_entry_set_match_func (EphyLocationEntry *le,
+ GtkEntryCompletionMatchFunc match_func,
+ gpointer user_data,
+ GDestroyNotify notify);
const char *ephy_location_entry_get_location (EphyLocationEntry *le);
@@ -92,6 +93,8 @@ gboolean ephy_location_entry_get_can_undo (EphyLocationEntry *le);
gboolean ephy_location_entry_get_can_redo (EphyLocationEntry *entry);
+GRegex * ephy_location_entry_get_regex (EphyLocationEntry *entry);
+
gboolean ephy_location_entry_reset (EphyLocationEntry *entry);
void ephy_location_entry_undo_reset (EphyLocationEntry *entry);