X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=panel-plugin%2Fxfce4-hdaps-dialogs.c;h=c43eafa6d7602e0b5f5411be968f0aae783c8351;hb=d1758a9d54a36f94e9615ed62ebec2de127b97ec;hp=4a995df484056e4cbfa2dbba8bb23266d1bb734f;hpb=0062dd83ce22be86d90c8f4320c6634650017069;p=xfce4-hdaps.git diff --git a/panel-plugin/xfce4-hdaps-dialogs.c b/panel-plugin/xfce4-hdaps-dialogs.c index 4a995df..c43eafa 100644 --- a/panel-plugin/xfce4-hdaps-dialogs.c +++ b/panel-plugin/xfce4-hdaps-dialogs.c @@ -203,41 +203,55 @@ void hdaps_configure(XfcePanelPlugin *plugin, static void hdaps_uri_handler(GtkAboutDialog *about, const gchar *uri, gpointer data) { - gchar *cmd; - cmd = g_strdup_printf("%s %s","xdg-open", uri); + gchar *cmd = g_strdup_printf("%s %s","xdg-open", uri); + gboolean spawn_result = g_spawn_command_line_async(cmd, NULL); - if (!g_spawn_command_line_async(cmd, NULL)) { - g_free(cmd); - cmd = g_strdup_printf("%s %s","xdg-open", uri); - g_spawn_command_line_async(cmd, NULL); + if (G_UNLIKELY(spawn_result == FALSE)) { + g_warning(_("Unable to open the following uri: %s"), uri); } + g_free(cmd); } +/* "Close" button handler for the About dialog. */ +static void hdaps_close_handler (GtkAboutDialog *about, + gint response_id, + gpointer user_data) { + /* This will cause the dialog to be destroyed */ + gtk_widget_destroy(GTK_WIDGET(about)); +} void hdaps_about(XfcePanelPlugin *plugin) { const gchar *authors[] = { "Michael Orlitzky ", NULL }; const gchar *copyright = "Copyright \302\251 2019 Michael Orlitzky"; + GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); + + gtk_about_dialog_set_authors(about, authors); + gtk_about_dialog_set_copyright(about, copyright); + gtk_about_dialog_set_program_name(about, PACKAGE_NAME); + gtk_about_dialog_set_logo_icon_name(about, PACKAGE_NAME); + gtk_about_dialog_set_license(about, LICENSE_AGPL3); + gtk_about_dialog_set_version(about, PACKAGE_VERSION); + gtk_about_dialog_set_website(about, PLUGIN_WEBSITE); + gtk_about_dialog_set_website_label(about, "xfce4-hdaps homepage"); + /* Use a custom URI handler for http(s):// and mailto:// URIs. The - default behavior apparently needs gio/gvfs to work, and I don't - have those installed. */ - g_signal_connect(plugin, + default behavior apparently needs gio/gvfs to work, so we want + to add some fallbacks. */ + g_signal_connect(about, "activate-link", G_CALLBACK(hdaps_uri_handler), NULL); - gtk_show_about_dialog(NULL, - "authors", authors, - "copyright", copyright, - "destroy-with-parent", TRUE, - "license", LICENSE_AGPL3, - "logo-icon-name", PACKAGE_NAME, - "icon-name", PACKAGE_NAME, - "program-name", PACKAGE_NAME, - "version", PACKAGE_VERSION, - "website", PLUGIN_WEBSITE, - "website-label", "xfce4-hdaps homepage", - NULL); + /* To close the dialog when "close" is clicked, we have to connect + * the response signal to a handler that actually does it. + */ + g_signal_connect(about, + "response", + G_CALLBACK(hdaps_close_handler), + NULL); + gtk_widget_show(GTK_WIDGET(about)); + return; }