[Xfce4-commits] [apps/xfce4-dict] 01/01: Append web search link to successful queries (bug #12154)

noreply at xfce.org noreply at xfce.org
Mon Jun 12 02:11:24 CEST 2017


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-dict.

commit 4224d2c30cd6b766c02355ca4729fab2e85b7ced
Author: Andre Miranda <andre42m at gmail.com>
Date:   Sun Jun 11 21:10:55 2017 -0300

    Append web search link to successful queries (bug #12154)
---
 lib/dictd.c | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/lib/dictd.c b/lib/dictd.c
index f1814be..b46a4aa 100644
--- a/lib/dictd.c
+++ b/lib/dictd.c
@@ -371,6 +371,28 @@ static void clear_query_buffer(DictData *dd)
 }
 
 
+static void append_web_search_link(DictData *dd, gboolean prepend_whitespace)
+{
+	gchar *label = _(dict_prefs_get_web_url_label(dd));
+	gchar *text = g_strdup_printf(
+		/* for translators: the first wildcard is the search term, the second wildcard
+			* is the name of the preferred web search engine */
+		_("Search \"%s\" using \"%s\""),
+		dd->searched_word, label);
+
+	if (prepend_whitespace)
+		gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n\n", 2);
+
+	gtk_text_buffer_insert_with_tags_by_name(dd->main_textbuffer, &dd->textiter,
+		_("Web Search:"), -1, TAG_HEADING, NULL);
+
+	gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
+	gtk_text_buffer_insert_with_tags_by_name(dd->main_textbuffer, &dd->textiter,
+		text, -1, TAG_LINK, NULL);
+	g_free(text);
+}
+
+
 static gboolean process_server_response(DictData *dd)
 {
 	gint max_lines, i;
@@ -434,23 +456,8 @@ static gboolean process_server_response(DictData *dd)
 		/* if we had no luck searching a word, maybe we have a typo so try searching with
 		 * spell check and offer a Web search*/
 		if (NZV(dd->web_url))
-		{
-			gchar *label = _(dict_prefs_get_web_url_label(dd));
-			gchar *text = g_strdup_printf(
-				/* for translators: the first wildcard is the search term, the second wildcard
-				 * is the name of the preferred web search engine */
-				_("Search \"%s\" using \"%s\""),
-				dd->searched_word, label);
+			append_web_search_link (dd, TRUE);
 
-			gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n\n", 2);
-			gtk_text_buffer_insert_with_tags_by_name(dd->main_textbuffer, &dd->textiter,
-				_("Web Search:"), -1, TAG_HEADING, NULL);
-
-			gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
-			gtk_text_buffer_insert_with_tags_by_name(dd->main_textbuffer, &dd->textiter,
-				text, -1, TAG_LINK, NULL);
-			g_free(text);
-		}
 		if (NZV(dd->spell_bin))
 		{
 			gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
@@ -492,6 +499,9 @@ static gboolean process_server_response(DictData *dd)
 	{
 		i = process_response_content(dd, lines, i, max_lines, header, body);
 	}
+
+	append_web_search_link (dd, FALSE);
+
 	g_strfreev(lines);
 	clear_query_buffer(dd);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list