[Goodies-commits] r5195 - in xfce4-dict/trunk: . lib
Enrico Troeger
enrico at xfce.org
Tue Aug 5 10:30:57 CEST 2008
Author: enrico
Date: 2008-08-05 08:30:57 +0000 (Tue, 05 Aug 2008)
New Revision: 5195
Modified:
xfce4-dict/trunk/ChangeLog
xfce4-dict/trunk/lib/common.c
xfce4-dict/trunk/lib/common.h
Log:
* Improve the code to find a usable browser to open URLs.
* Prevent opening a file manager when there is set an empty search URL.
* Make dict_open_browser() static for common.c as it is not used anywhere else.
Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog 2008-08-04 03:14:07 UTC (rev 5194)
+++ xfce4-dict/trunk/ChangeLog 2008-08-05 08:30:57 UTC (rev 5195)
@@ -1,3 +1,11 @@
+2008-08-03 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * Improve the code to find a usable browser to open URLs.
+ * Prevent opening a file manager when there is set an empty search URL.
+ * Make dict_open_browser() static for common.c as it is not used
+ anywhere else.
+
+
2008-07-16 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Build the static library part with libtool to get correctly linked
Modified: xfce4-dict/trunk/lib/common.c
===================================================================
--- xfce4-dict/trunk/lib/common.c 2008-08-04 03:14:07 UTC (rev 5194)
+++ xfce4-dict/trunk/lib/common.c 2008-08-05 08:30:57 UTC (rev 5195)
@@ -123,30 +123,25 @@
/* taken from xarchiver, thanks Giuseppe */
-gboolean dict_open_browser(DictData *dd, const gchar *uri)
+static gboolean open_browser(DictData *dd, const gchar *uri)
{
gchar *argv[3];
- gchar *browser_path;
+ gchar *browser_path = NULL;
gboolean result = FALSE;
+ guint i = 0;
+ const gchar *browsers[] = {
+ "exo-open", "htmlview", "firefox", "mozilla",
+ "opera", "epiphany", "konqueror", "seamonkey", NULL };
- browser_path = g_find_program_in_path("exo-open");
+ while (browsers[i] != NULL && (browser_path = g_find_program_in_path(browsers[i])) == NULL)
+ i++;
+
if (browser_path == NULL)
- browser_path = g_find_program_in_path("htmlview");
- if (browser_path == NULL)
- browser_path = g_find_program_in_path("firefox");
- if (browser_path == NULL)
- browser_path = g_find_program_in_path("mozilla");
- if (browser_path == NULL)
- browser_path = g_find_program_in_path("opera");
- if (browser_path == NULL)
- browser_path = g_find_program_in_path("epiphany");
- if (browser_path == NULL)
- browser_path = g_find_program_in_path("konqueror");
- if (browser_path == NULL)
- browser_path = g_find_program_in_path("seamonkey");
+ {
+ g_warning("No browser could be found in your path.");
+ return FALSE;
+ }
- if (browser_path == NULL) return FALSE;
-
argv[0] = browser_path;
argv[1] = (gchar*) uri;
argv[2] = NULL;
@@ -154,7 +149,7 @@
result = gdk_spawn_on_screen(gtk_widget_get_screen(dd->window), NULL, argv, NULL,
G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
- g_free (browser_path);
+ g_free(browser_path);
return result;
}
@@ -166,8 +161,13 @@
gchar *uri;
uri = str_replace(g_strdup(dd->web_url), "{word}", dd->searched_word);
- if (! dict_open_browser(dd, uri))
+ if (! NZV(uri))
{
+ xfce_err(_("The search URL is empty. Please check your preferences."));
+ success = FALSE;
+ }
+ else if (! open_browser(dd, uri))
+ {
xfce_err(_("Browser could not be opened. Please check your preferences."));
success = FALSE;
}
Modified: xfce4-dict/trunk/lib/common.h
===================================================================
--- xfce4-dict/trunk/lib/common.h 2008-08-04 03:14:07 UTC (rev 5194)
+++ xfce4-dict/trunk/lib/common.h 2008-08-05 08:30:57 UTC (rev 5195)
@@ -99,7 +99,6 @@
void dict_write_rc_file(DictData *dd);
void dict_read_rc_file(DictData *dd);
void dict_search_word(DictData *dd, const gchar *word);
-gboolean dict_open_browser(DictData *dd, const gchar *uri);
void dict_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y,
GtkSelectionData *data, guint info, guint ltime, DictData *dd);
More information about the Goodies-commits
mailing list