Branch: refs/heads/master Author: Thomas Martitz thomas.martitz@mailbox.org Committer: GitHub noreply@github.com Date: Tue, 26 Sep 2023 06:05:18 UTC Commit: b3dde4d21d55f97475b623f714a1156c8d2a46d9 https://github.com/geany/geany/commit/b3dde4d21d55f97475b623f714a1156c8d2a46...
Log Message: ----------- Use gtk_show_uri_on_window() in utils_open_browser() by default (#3178)
Instead of requiring the user to specify a browser just try to use the system default browser through gtk_show_uri_on_window(). This is done when tool_prefs.browser_cmd is empty which is also the new default.
This aligns with windows where we do this already. Though we're bypassing tool_prefs.browser_cmd there entirely, while on non-Windows we still honor tool_prefs.browser_cmd when it's set.
This is primarily useful for flatpak support where we cannot just execute arbitrary commands on the host (unless using flatpak-spawn).
Also, firefox is arguably a bad default these days, given the declined market share.
Modified Paths: -------------- data/geany.glade src/keyfile.c src/utils.c
Modified: data/geany.glade 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -4908,6 +4908,7 @@ <property name="tooltip-text" translatable="yes">Path (and possibly additional arguments) to your favorite browser</property> <property name="primary-icon-activatable">False</property> <property name="secondary-icon-activatable">False</property> + <property name="placeholder-text" translatable="yes">System default</property> </object> <packing> <property name="left-attach">1</property>
Modified: src/keyfile.c 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -91,7 +91,8 @@ #define GEANY_DEFAULT_FONT_MSG_WINDOW "Menlo Medium 12" #define GEANY_DEFAULT_FONT_EDITOR "Menlo Medium 12" #else -#define GEANY_DEFAULT_TOOLS_BROWSER "firefox" +/* Browser chosen by GTK */ +#define GEANY_DEFAULT_TOOLS_BROWSER "" #define GEANY_DEFAULT_FONT_SYMBOL_LIST "Sans 9" #define GEANY_DEFAULT_FONT_MSG_WINDOW "Monospace 9" #define GEANY_DEFAULT_FONT_EDITOR "Monospace 10"
Modified: src/utils.c 27 lines changed, 20 insertions(+), 7 deletions(-) =================================================================== @@ -64,8 +64,10 @@ /** * 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, the user is asked to correct or fill it. + * On non-Windows systems, the browser command can be set in the preferences dialog. + * If unset (empty) the system's default browser is used. If set it specifies the + * command to execute. Either way, if it fails the user is prompted to correct the + * pref. * * @param uri The URI to open in the web browser. * @@ -78,15 +80,26 @@ void utils_open_browser(const gchar *uri) g_return_if_fail(uri != NULL); win32_open_browser(uri); #else - gchar *argv[2] = { (gchar *) uri, NULL }; + gchar *new_cmd, *argv[2] = { (gchar *) uri, NULL };
g_return_if_fail(uri != NULL);
- while (!spawn_async(NULL, tool_prefs.browser_cmd, argv, NULL, NULL, NULL)) + while (1) { - gchar *new_cmd = dialogs_show_input(_("Select Browser"), GTK_WINDOW(main_widgets.window), - _("Failed to spawn the configured browser command. " - "Please correct it or enter another one."), + /* Uses the user's default browser akin to xdg-open (in flatpak through a portal) */ + if (EMPTY(tool_prefs.browser_cmd)) + { + if (gtk_show_uri_on_window(GTK_WINDOW(main_widgets.window), uri, GDK_CURRENT_TIME, NULL)) + break; + } + else if (spawn_async(NULL, tool_prefs.browser_cmd, argv, NULL, NULL, NULL)) + break; + + /* Allow the user to correct the pref. new_cmd may become empty. */ + new_cmd = dialogs_show_input(_("Select Browser"), GTK_WINDOW(main_widgets.window), + _("Failed to spawn the configured browser command. Please " + "enter a valid command or leave it empty in order " + "to spawn the system default browser."), tool_prefs.browser_cmd);
if (new_cmd == NULL) /* user canceled */
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).