Revision: 5918 http://geany.svn.sourceforge.net/geany/?rev=5918&view=rev Author: colombanw Date: 2011-09-15 02:01:38 +0000 (Thu, 15 Sep 2011) Log Message: ----------- Ask the user if spawn fails in utils_open_browser()
Ask the user to configure a valid browser command if spawning it fails rather than falling back to some arbitrary hardcoded defaults.
This avoid spawning an unexpected browser when the configured one is wrong, and gives the user a chance to correctly fix the preference.
Modified Paths: -------------- trunk/ChangeLog trunk/src/utils.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-09-14 14:38:06 UTC (rev 5917) +++ trunk/ChangeLog 2011-09-15 02:01:38 UTC (rev 5918) @@ -1,3 +1,10 @@ +2011-09-15 Colomban Wendling <colomban(at)geany(dot)org> + + * src/utils.c: + Ask the user to configure a valid browser command if spawning it + fails rather than falling back to some arbitrary hardcoded defaults. + + 2011-09-14 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/win32.c:
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2011-09-14 14:38:06 UTC (rev 5917) +++ trunk/src/utils.c 2011-09-15 02:01:38 UTC (rev 5918) @@ -53,6 +53,7 @@ #include "dialogs.h" #include "win32.h" #include "project.h" +#include "ui_utils.h"
#include "utils.h"
@@ -61,8 +62,7 @@ * Tries to open the given URI in a browser. * On Windows, the system's default browser is opened. * On non-Windows systems, the browser command set in the preferences dialog is used. In case - * that fails or it is unset, @c xdg-open is used as fallback as well as some other known - * browsers. + * that fails or it is unset, the user is asked to correct or fill it. * * @param uri The URI to open in the web browser. * @@ -74,38 +74,30 @@ g_return_if_fail(uri != NULL); win32_open_browser(uri); #else - gchar *cmdline; + gboolean again = TRUE;
g_return_if_fail(uri != NULL);
- cmdline = g_strconcat(tool_prefs.browser_cmd, " "", uri, """, NULL); - if (! g_spawn_command_line_async(cmdline, NULL)) + while (again) { - static const gchar *browsers[] = - { - "xdg-open", - "firefox", - "mozilla", - "opera", - "konqueror", - "netscape" - }; - const gchar *argv[3]; - guint i; + gchar *cmdline = g_strconcat(tool_prefs.browser_cmd, " "", uri, """, NULL);
- argv[0] = NULL; - argv[1] = uri; - argv[2] = NULL; - - for (i = 0; i < G_N_ELEMENTS (browsers); i++) + if (g_spawn_command_line_async(cmdline, NULL)) + again = FALSE; + else { - argv[0] = browsers[i]; - if (g_spawn_async(NULL, (gchar**)argv, NULL, G_SPAWN_SEARCH_PATH, - NULL, NULL, NULL, NULL)) - break; + gchar *new_cmd = dialogs_show_input(_("Select Browser"), GTK_WINDOW(main_widgets.window), + _("Failed to spawn the configured browser command. " + "Please correct it or select another one."), + tool_prefs.browser_cmd); + + if (new_cmd == NULL) /* user canceled */ + again = FALSE; + else + setptr(tool_prefs.browser_cmd, new_cmd); } + g_free(cmdline); } - g_free(cmdline); #endif }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.