[epiphany] Highlight string matches in location bar
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Highlight string matches in location bar
- Date: Mon, 17 Dec 2018 23:48:03 +0000 (UTC)
commit 9c8333bf89f27a8064e57a1139f59abba4926259
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Mon Dec 17 12:41:44 2018 +0100
Highlight string matches in location bar
Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/164
lib/ephy-suggestion.c | 10 ++--------
src/ephy-suggestion-model.c | 18 +++++++++++++++---
2 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/lib/ephy-suggestion.c b/lib/ephy-suggestion.c
index f61989cbf..09199f362 100644
--- a/lib/ephy-suggestion.c
+++ b/lib/ephy-suggestion.c
@@ -131,7 +131,6 @@ ephy_suggestion_new (const char *title,
const char *uri)
{
EphySuggestion *suggestion;
- char *escaped_title = g_markup_escape_text (title, -1);
char *decoded_uri = ephy_uri_decode (uri);
char *escaped_uri = g_markup_escape_text (decoded_uri, -1);
@@ -139,11 +138,10 @@ ephy_suggestion_new (const char *title,
"icon-name", "web-browser-symbolic",
"id", uri,
"subtitle", escaped_uri,
- "title", escaped_title,
+ "title", title,
"unescaped-title", title,
NULL);
- g_free (escaped_title);
g_free (decoded_uri);
g_free (escaped_uri);
@@ -155,18 +153,14 @@ ephy_suggestion_new_without_subtitle (const char *title,
const char *uri)
{
EphySuggestion *suggestion;
- char *escaped_title;
- escaped_title = g_markup_escape_text (title, -1);
suggestion = g_object_new (EPHY_TYPE_SUGGESTION,
"icon-name", "web-browser-symbolic",
"id", uri,
- "title", escaped_title,
+ "title", title,
"unescaped-title", title,
NULL);
- g_free (escaped_title);
-
return suggestion;
}
diff --git a/src/ephy-suggestion-model.c b/src/ephy-suggestion-model.c
index fb70be375..364f85159 100644
--- a/src/ephy-suggestion-model.c
+++ b/src/ephy-suggestion-model.c
@@ -292,8 +292,12 @@ add_bookmarks (EphySuggestionModel *self,
if (should_add_bookmark_to_model (self, query, title, url)) {
EphySuggestion *suggestion;
+ g_autofree gchar *escaped_title = NULL;
+ g_autofree gchar *markup = NULL;
- suggestion = ephy_suggestion_new (title, url);
+ escaped_title = g_markup_escape_text (title, -1);
+ markup = dzl_fuzzy_highlight (escaped_title, query, FALSE);
+ suggestion = ephy_suggestion_new (markup, url);
load_favicon (self, suggestion, url);
g_sequence_append (self->items, suggestion);
@@ -314,8 +318,12 @@ add_history (EphySuggestionModel *self,
for (const GList *p = urls; p != NULL; p = p->next) {
EphyHistoryURL *url = (EphyHistoryURL *)p->data;
EphySuggestion *suggestion;
+ g_autofree gchar *escaped_title = NULL;
+ g_autofree gchar *markup = NULL;
- suggestion = ephy_suggestion_new (url->title, url->url);
+ escaped_title = g_markup_escape_text (url->title, -1);
+ markup = dzl_fuzzy_highlight (escaped_title, query, FALSE);
+ suggestion = ephy_suggestion_new (markup, url->url);
load_favicon (self, suggestion, url->url);
g_sequence_append (self->items, suggestion);
@@ -341,9 +349,13 @@ add_search_engines (EphySuggestionModel *self,
for (guint i = 0; engines[i] != NULL; i++) {
EphySuggestion *suggestion;
char *address;
+ g_autofree gchar *escaped_title = NULL;
+ g_autofree gchar *markup = NULL;
address = ephy_search_engine_manager_build_search_address (manager, engines[i], query);
- suggestion = ephy_suggestion_new_without_subtitle (engines[i], address);
+ escaped_title = g_markup_escape_text (engines[i], -1);
+ markup = dzl_fuzzy_highlight (escaped_title, query, FALSE);
+ suggestion = ephy_suggestion_new_without_subtitle (markup, address);
load_favicon (self, suggestion, address);
g_sequence_append (self->items, suggestion);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]