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

Enrico Troeger enrico at xfce.org
Mon Jan 19 19:59:50 CET 2009


Author: enrico
Date: 2009-01-19 18:59:50 +0000 (Mon, 19 Jan 2009)
New Revision: 6506

Modified:
   xfce4-dict/trunk/ChangeLog
   xfce4-dict/trunk/lib/common.c
   xfce4-dict/trunk/lib/common.h
   xfce4-dict/trunk/lib/gui.c
   xfce4-dict/trunk/src/xfce4-dict.c
   xfce4-dict/trunk/xfce4-dict.1
Log:
Properly escape URIs when using Web based search (works only with GLib >= 2.16).
Add '--verbose' command line option for the stand-alone application.

Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog	2009-01-19 18:59:42 UTC (rev 6505)
+++ xfce4-dict/trunk/ChangeLog	2009-01-19 18:59:50 UTC (rev 6506)
@@ -3,6 +3,9 @@
  * Improve some strings, thanks to Jérôme Guelfucci for the suggestions.
  * Use less spacing for spell checker results and don't display any
    failed searches if used as fallback for a dictionary search.
+ * Properly escape URIs when using Web based search
+   (works only with GLib >= 2.16).
+ * Add '--verbose' command line option for the stand-alone application.
 
 
 2008-12-05  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: xfce4-dict/trunk/lib/common.c
===================================================================
--- xfce4-dict/trunk/lib/common.c	2009-01-19 18:59:42 UTC (rev 6505)
+++ xfce4-dict/trunk/lib/common.c	2009-01-19 18:59:50 UTC (rev 6506)
@@ -162,7 +162,18 @@
 	gboolean success = TRUE;
 	gchar *uri;
 
+#if GLIB_CHECK_VERSION(2, 16, 0)
+	gchar *tmp = str_replace(g_strdup(dd->web_url), "{word}", dd->searched_word);
+	uri = g_uri_escape_string(tmp,
+			G_URI_RESERVED_CHARS_GENERIC_DELIMITERS G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS,
+			FALSE);
+	if (uri != NULL)
+		g_free(tmp);
+	else
+		uri = tmp;
+#else
 	uri = str_replace(g_strdup(dd->web_url), "{word}", dd->searched_word);
+#endif
 	if (! NZV(uri))
 	{
 		xfce_err(_("The search URL is empty. Please check your preferences."));

Modified: xfce4-dict/trunk/lib/common.h
===================================================================
--- xfce4-dict/trunk/lib/common.h	2009-01-19 18:59:42 UTC (rev 6505)
+++ xfce4-dict/trunk/lib/common.h	2009-01-19 18:59:50 UTC (rev 6506)
@@ -74,6 +74,7 @@
 	gchar *spell_bin;
 	gchar *spell_dictionary;
 
+	gboolean verbose_mode;
 	gboolean is_plugin;	/* specify whether the panel plugin loaded or not */
 
 	/* status values */

Modified: xfce4-dict/trunk/lib/gui.c
===================================================================
--- xfce4-dict/trunk/lib/gui.c	2009-01-19 18:59:42 UTC (rev 6505)
+++ xfce4-dict/trunk/lib/gui.c	2009-01-19 18:59:50 UTC (rev 6506)
@@ -288,6 +288,8 @@
 
 	gtk_statusbar_pop(GTK_STATUSBAR(dd->statusbar), 1);
 	gtk_statusbar_push(GTK_STATUSBAR(dd->statusbar), 1, string);
+	if (dd->verbose_mode)
+		g_message("%s", string);
 }
 
 

Modified: xfce4-dict/trunk/src/xfce4-dict.c
===================================================================
--- xfce4-dict/trunk/src/xfce4-dict.c	2009-01-19 18:59:42 UTC (rev 6505)
+++ xfce4-dict/trunk/src/xfce4-dict.c	2009-01-19 18:59:50 UTC (rev 6506)
@@ -44,6 +44,7 @@
 static gboolean mode_dict = FALSE;
 static gboolean mode_web = FALSE;
 static gboolean mode_spell = FALSE;
+static gboolean verbose_mode = FALSE;
 
 static GOptionEntry cli_options[] =
 {
@@ -53,6 +54,7 @@
 	{ "text-field", 't', 0, G_OPTION_ARG_NONE, &focus_panel_entry, N_("Grab the focus on the text field in the panel"), NULL },
 	{ "ignore-plugin", 'i', 0, G_OPTION_ARG_NONE, &ignore_plugin, N_("Start stand-alone application even if the panel plugin is loaded"), NULL },
 	{ "clipboard", 'c', 0, G_OPTION_ARG_NONE, &use_clipboard, N_("Grabs the PRIMARY selection content and uses it as search text"), NULL },
+	{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_mode, N_("Be verbose"), NULL },
 	{ "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Show version information"), NULL },
 	{ NULL, 0, 0, 0, NULL, NULL, NULL }
 };
@@ -175,6 +177,7 @@
 
 	dd = dict_create_dictdata();
 	dd->is_plugin = FALSE;
+	dd->verbose_mode = verbose_mode;
 
 	g_thread_init(NULL);
 

Modified: xfce4-dict/trunk/xfce4-dict.1
===================================================================
--- xfce4-dict/trunk/xfce4-dict.1	2009-01-19 18:59:42 UTC (rev 6505)
+++ xfce4-dict/trunk/xfce4-dict.1	2009-01-19 18:59:50 UTC (rev 6506)
@@ -32,6 +32,8 @@
 The search method can be specified with the \-d, \-w and \-s options, if not specified the
 default search method is used.
 If the PRIMARY clipboard doesn't contain any text, the normal clipboard is used.
+.IP "\fB-v\fP, \fB\-\-verbose\fP         " 10
+Be verbose (print useful status messages).
 .IP "\fB-V\fP, \fB\-\-version\fP         " 10
 Show version information.
 .IP "\fB-?\fP, \fB\-\-help\fP         " 10




More information about the Goodies-commits mailing list