[Goodies-commits] r7365 - in xfce4-dict/trunk: . lib

Enrico Troeger enrico at xfce.org
Mon May 18 20:12:30 CEST 2009


Author: enrico
Date: 2009-05-18 18:12:30 +0000 (Mon, 18 May 2009)
New Revision: 7365

Modified:
   xfce4-dict/trunk/ChangeLog
   xfce4-dict/trunk/lib/gui.c
   xfce4-dict/trunk/lib/spell.c
Log:
Allow clearing tags for a specific word (unused so far).
If the search term contains more than word and the dictionary search fails, show the spell check results of all parts of the search term.

Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog	2009-05-18 18:12:26 UTC (rev 7364)
+++ xfce4-dict/trunk/ChangeLog	2009-05-18 18:12:30 UTC (rev 7365)
@@ -1,3 +1,15 @@
+2009-05-18  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * lib/common.c, lib/common.h, lib/dictd.c, lib/gui.c:
+   When offering a Web search link for a failed search, display the full
+   target URI as tooltip.
+   Minor other improvements.
+ * lib/gui.c, lib/spell.c:
+   Allow clearing tags for a specific word (unused so far).
+   If the search term contains more than word and the dictionary search
+   fails, show the spell check results of all parts of the search term.
+
+
 2009-05-17  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * lib/gui.c, lib/speedreader.c:

Modified: xfce4-dict/trunk/lib/gui.c
===================================================================
--- xfce4-dict/trunk/lib/gui.c	2009-05-18 18:12:26 UTC (rev 7364)
+++ xfce4-dict/trunk/lib/gui.c	2009-05-18 18:12:30 UTC (rev 7365)
@@ -309,6 +309,19 @@
 #endif
 
 
+static void textview_apply_or_remove_tags(GtkTextBuffer *buffer, const gchar *tag,
+										  GtkTextIter *start, GtkTextIter *end)
+{
+	g_return_if_fail(tag != NULL);
+
+	if (*tag == '\0')
+		gtk_text_buffer_remove_all_tags(buffer, start, end);
+	else
+		gtk_text_buffer_apply_tag_by_name(buffer, tag, start, end);
+}
+
+
+/* An empty string as tag name will clear all tags on the given word */
 void dict_gui_textview_apply_tag_to_word(GtkTextBuffer *buffer, const gchar *word,
 										 GtkTextIter *pos, const gchar *first_tag, ...)
 {
@@ -324,12 +337,12 @@
 	{
 		va_list args;
 
-		gtk_text_buffer_apply_tag_by_name(buffer, first_tag, &start, &end);
+		textview_apply_or_remove_tags(buffer, first_tag, &start, &end);
 
 		va_start(args, first_tag);
 		for (; s = va_arg(args, gchar*), s != NULL;)
 		{
-			gtk_text_buffer_apply_tag_by_name(buffer, s, &start, &end);
+			textview_apply_or_remove_tags(buffer, s, &start, &end);
 		}
 		va_end(args);
 	}

Modified: xfce4-dict/trunk/lib/spell.c
===================================================================
--- xfce4-dict/trunk/lib/spell.c	2009-05-18 18:12:26 UTC (rev 7364)
+++ xfce4-dict/trunk/lib/spell.c	2009-05-18 18:12:30 UTC (rev 7365)
@@ -83,20 +83,17 @@
 				count = atoi(tmp);
 				if (! iod->quiet)
 					dict_gui_status_add(dd, ngettext("%d suggestion found.",
-													"%d suggestions found.",
-													count), count);
+													 "%d suggestions found.",
+													 count), count);
 
 				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
-				tmp = g_strdup_printf(_("Suggestions for \"%s\":"), iod->word);
+				tmp = g_strdup_printf(_("Suggestions for \"%s\" (%s):"),
+					iod->word, dd->spell_dictionary);
 				gtk_text_buffer_insert_with_tags_by_name(
 					dd->main_textbuffer, &dd->textiter, tmp, -1, "bold", NULL);
 				dict_gui_textview_apply_tag_to_word(dd->main_textbuffer, iod->word, &dd->textiter,
 					TAG_ERROR, TAG_BOLD, NULL);
 				g_free(tmp);
-				/* TODO include the dictionary string into the above message */
-				tmp = g_strdup_printf(" (%s)", dd->spell_dictionary);
-				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, tmp, -1);
-				g_free(tmp);
 				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
 
 				tmp = strchr(msg, ':') + 2;
@@ -106,28 +103,23 @@
 			else if (msg[0] == '*' && ! iod->quiet)
 			{
 				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
-				tmp = g_strdup_printf(_("\"%s\" is spelled correctly."), iod->word);
+				tmp = g_strdup_printf(_("\"%s\" is spelled correctly (%s)."),
+					iod->word, dd->spell_dictionary);
 				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, tmp, -1);
 				dict_gui_textview_apply_tag_to_word(dd->main_textbuffer, iod->word, &dd->textiter,
 					TAG_SUCCESS, TAG_BOLD, NULL);
 				g_free(tmp);
-				tmp = g_strdup_printf(" (%s)", dd->spell_dictionary);
-				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, tmp, -1);
-				g_free(tmp);
 				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
 			}
 			else if (msg[0] == '#' && ! iod->quiet)
 			{
 				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
-				tmp = g_strdup_printf(_("No suggestions could be found for \"%s\"."),
-					iod->word);
+				tmp = g_strdup_printf(_("No suggestions could be found for \"%s\" (%s)."),
+					iod->word, dd->spell_dictionary);
 				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, tmp, -1);
 				dict_gui_textview_apply_tag_to_word(dd->main_textbuffer, iod->word, &dd->textiter,
 					TAG_ERROR, TAG_BOLD, NULL);
 				g_free(tmp);
-				tmp = g_strdup_printf(" (%s)", dd->spell_dictionary);
-				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, tmp, -1);
-				g_free(tmp);
 				gtk_text_buffer_insert(dd->main_textbuffer, &dd->textiter, "\n", 1);
 			}
 			g_free(msg);
@@ -220,7 +212,8 @@
 				&stdin_fd, &stdout_fd, &stderr_fd, &error))
 		{
 			iod = g_new(iodata, 1);
-			iod->quiet = quiet;
+			/* if we have more than search term, show them all even if quiet mode was requested */
+			iod->quiet = quiet && (tts_len == 1);
 			iod->dd = dd;
 			iod->word = g_strdup(tts[i]);
 




More information about the Goodies-commits mailing list