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

Enrico Troeger enrico at xfce.org
Tue Apr 15 16:02:15 CEST 2008


Author: enrico
Date: 2008-04-15 14:02:15 +0000 (Tue, 15 Apr 2008)
New Revision: 4579

Modified:
   xfce4-dict/trunk/ChangeLog
   xfce4-dict/trunk/Makefile.am
   xfce4-dict/trunk/lib/common.h
   xfce4-dict/trunk/src/xfce4-dict.c
Log:
Concatenate text command line arguments as one string as search text.


Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog	2008-04-15 14:02:10 UTC (rev 4578)
+++ xfce4-dict/trunk/ChangeLog	2008-04-15 14:02:15 UTC (rev 4579)
@@ -3,6 +3,7 @@
  * Update Readme.
  * Reformat ChangeLog.
  * Add "-h" command line option if GLib supports printing the help text.
+ * Concatenate text command line arguments as one string as search text.
 
 
 2008-04-14  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: xfce4-dict/trunk/Makefile.am
===================================================================
--- xfce4-dict/trunk/Makefile.am	2008-04-15 14:02:10 UTC (rev 4578)
+++ xfce4-dict/trunk/Makefile.am	2008-04-15 14:02:15 UTC (rev 4579)
@@ -13,6 +13,7 @@
 
 
 EXTRA_DIST =													\
+	xfce4-dict.1												\
 	intltool-extract.in											\
 	intltool-merge.in											\
 	intltool-update.in											\
@@ -28,6 +29,7 @@
 
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
 
+man_MANS=xfce4-dict.1
 
 install-data-hook:
 	@-if test -z "$(DESTDIR)"; then								\

Modified: xfce4-dict/trunk/lib/common.h
===================================================================
--- xfce4-dict/trunk/lib/common.h	2008-04-15 14:02:10 UTC (rev 4578)
+++ xfce4-dict/trunk/lib/common.h	2008-04-15 14:02:15 UTC (rev 4579)
@@ -27,7 +27,7 @@
 	((ptr) && (ptr)[0])
 
 
-#define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/xfce4-dict"
+#define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/applications/xfce4-dict"
 
 #define DICT_FLAGS_FOCUS_PANEL_ENTRY	1
 #define DICT_FLAGS_MODE_DICT			2

Modified: xfce4-dict/trunk/src/xfce4-dict.c
===================================================================
--- xfce4-dict/trunk/src/xfce4-dict.c	2008-04-15 14:02:10 UTC (rev 4578)
+++ xfce4-dict/trunk/src/xfce4-dict.c	2008-04-15 14:02:15 UTC (rev 4579)
@@ -102,11 +102,27 @@
 }
 
 
+static gchar *get_search_text(gint count, gchar **values)
+{
+	GString *str = g_string_sized_new(128);
+	gint i;
+
+	for (i = 1; i < count; i++)
+	{
+		g_string_append(str, values[i]);
+		if (i < (count - 1))
+			g_string_append_c(str, ' ');
+	}
+	return g_string_free(str, FALSE);
+}
+
+
 gint main(gint argc, gchar *argv[])
 {
 	DictData *dd;
 	GOptionContext *context;
 	gchar flags;
+	gchar *search_text;
 
 #ifdef ENABLE_NLS
 	xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
@@ -146,9 +162,15 @@
 
 	flags = get_flags();
 
+	/* concatenate remaining command line arguments */
+	search_text = get_search_text(argc, argv);
+
 	/* try to find an existing panel plugin and pop it up */
-	if (dict_find_panel_plugin(flags, (argc > 1) ? argv[1] : NULL))
+	if (dict_find_panel_plugin(flags, search_text))
+	{
+		g_free(search_text);
 		exit(0);
+	}
 
 	/* no plugin found, start stand-alone app */
 
@@ -172,8 +194,11 @@
 
 	/* search text from command line options, if any */
 	/* TODO take all remaining args, not only argv[1] */
-	if (argc > 1)
-		dict_search_word(dd, argv[1]);
+	if (search_text != NULL)
+	{
+		dict_search_word(dd, search_text);
+		g_free(search_text);
+	}
 
 	dict_gui_status_add(dd, _("Ready."));
 




More information about the Goodies-commits mailing list