diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 7e40717f..edea0fb3 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -1308,17 +1308,38 @@ maybe_escape_uri (const char *uri) return g_strdup (uri); } +#ifndef WIN32 +static gchar ** +fe_open_url_env_sanitized (void) +{ + gchar **env = g_get_environ (); + const char *vars[] = {"LD_LIBRARY_PATH", "LD_PRELOAD", "APPDIR", "APPIMAGE", "ARGV0", NULL}; + int i; + + for (i = 0; vars[i]; i++) + { + gchar **tmp_env = env; + env = g_environ_unsetenv (tmp_env, vars[i]); + if (env != tmp_env) + g_strfreev (tmp_env); + } + + return env; +} +#endif + static void fe_open_url_inner (const char *url) { GError *error = NULL; char *escaped_url = maybe_escape_uri (url); - gboolean opened = g_app_info_launch_default_for_uri (escaped_url, NULL, &error); + gboolean opened = FALSE; +#ifdef WIN32 + opened = g_app_info_launch_default_for_uri (escaped_url, NULL, &error); if (!opened) { g_clear_error (&error); -#ifdef WIN32 gunichar2 *url_utf16 = g_utf8_to_utf16 (escaped_url, -1, NULL, NULL, NULL); if (url_utf16 != NULL) @@ -1326,22 +1347,11 @@ fe_open_url_inner (const char *url) opened = ((INT_PTR) ShellExecuteW (0, L"open", url_utf16, NULL, NULL, SW_SHOWNORMAL)) > 32; g_free (url_utf16); } + } #else + { gchar *xdg_open_argv[] = {(gchar *) "xdg-open", escaped_url, NULL}; - gchar **spawn_env = NULL; - - spawn_env = g_get_environ (); - { - gchar **tmp_env = spawn_env; - spawn_env = g_environ_unsetenv (tmp_env, "LD_LIBRARY_PATH"); - if (spawn_env != tmp_env) - g_strfreev (tmp_env); - - tmp_env = spawn_env; - spawn_env = g_environ_unsetenv (tmp_env, "LD_PRELOAD"); - if (spawn_env != tmp_env) - g_strfreev (tmp_env); - } + gchar **spawn_env = fe_open_url_env_sanitized (); if (g_spawn_async (NULL, xdg_open_argv, spawn_env, G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, @@ -1354,19 +1364,26 @@ fe_open_url_inner (const char *url) g_clear_error (&error); } - if (!opened && gtk_show_uri_on_window (NULL, escaped_url, GDK_CURRENT_TIME, &error)) - { - opened = TRUE; - } - else if (!opened) - { - g_clear_error (&error); - } - g_strfreev (spawn_env); -#endif } + if (!opened) + { + opened = g_app_info_launch_default_for_uri (escaped_url, NULL, &error); + if (!opened) + g_clear_error (&error); + } + + if (!opened && gtk_show_uri_on_window (NULL, escaped_url, GDK_CURRENT_TIME, &error)) + { + opened = TRUE; + } + else if (!opened) + { + g_clear_error (&error); + } +#endif + if (!opened) { g_warning ("Unable to open URL '%s' using system default application", escaped_url); diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 153eaf0f..90fa4847 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1888,7 +1888,8 @@ menu_about (GtkWidget *wid, gpointer sess) GtkWidget *license; GtkWidget *close; GtkWidget *actions; - GtkWidget *default_close; + GList *children; + GList *child; static const gchar *empty_people[] = { NULL }; theme_manager_attach_window (GTK_WIDGET (dialog)); char comment[512]; @@ -1917,13 +1918,14 @@ menu_about (GtkWidget *wid, gpointer sess) gtk_about_dialog_set_logo (dialog, pix_zoitechat); gtk_about_dialog_set_copyright (dialog, "\302\251 1998-2010 Peter \305\275elezn\303\275\n\302\251 2009-2014 Berke Viktor\n\302\251 2015-2025 Patrick Griffis\n\302\251 2026 deepend"); gtk_about_dialog_set_comments (dialog, comment); - default_close = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); - if (default_close) - gtk_widget_destroy (default_close); + actions = gtk_dialog_get_action_area (GTK_DIALOG (dialog)); + children = gtk_container_get_children (GTK_CONTAINER (actions)); + for (child = children; child; child = child->next) + gtk_widget_destroy (GTK_WIDGET (child->data)); + g_list_free (children); website = gtk_dialog_add_button (GTK_DIALOG (dialog), "Website", GTK_RESPONSE_HELP); license = gtk_dialog_add_button (GTK_DIALOG (dialog), "License", GTK_RESPONSE_APPLY); close = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Close"), GTK_RESPONSE_CLOSE); - actions = gtk_widget_get_parent (close); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (actions), website, TRUE); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (actions), license, TRUE); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (actions), close, FALSE);