X-Git-Url: http://gitweb.michael.orlitzky.com/?p=xfce4-hdaps.git;a=blobdiff_plain;f=panel-plugin%2Fxfce4-hdaps-dialogs.c;h=8851614a97a095b2cd9654f8f957aed7726d6c4b;hp=c43eafa6d7602e0b5f5411be968f0aae783c8351;hb=a11bba966aac187122a7f04c4e111b58655ff1ec;hpb=d1758a9d54a36f94e9615ed62ebec2de127b97ec diff --git a/panel-plugin/xfce4-hdaps-dialogs.c b/panel-plugin/xfce4-hdaps-dialogs.c index c43eafa..8851614 100644 --- a/panel-plugin/xfce4-hdaps-dialogs.c +++ b/panel-plugin/xfce4-hdaps-dialogs.c @@ -39,19 +39,51 @@ */ #define PLUGIN_WEBSITE "http://michael.orlitzky.com/code/xfce4-hdaps.xhtml" +/* Launch a URI using either gtk_show_uri_on_window (gvfs), exo-open + * or xdg-open. This is used both when you click the author's email + * address, and when you visit the plugin's homepage. + */ +static gboolean launch_uri(GtkWindow *parent, const gchar *uri) { + GError *error = NULL; + gboolean result = gtk_show_uri_on_window(parent, + uri, + GDK_CURRENT_TIME, + &error); + /* First, let's try what the GTK docs say the default is. */ + if (result == TRUE) { + return result; + } + else { + g_warning(_("Error launching URI %s: %s"), uri, error->message); + g_error_free(error); + } -static void hdaps_configure_response(GtkWidget *dialog, - gint response, - HdapsPlugin *hdaps) { - - if (response == GTK_RESPONSE_HELP) { - /* Launch the user's web browser and direct them to the plugin webpage. */ - gboolean spawn_result = g_spawn_command_line_async("xdg-open " PLUGIN_WEBSITE, NULL); + /* Ok, GTK failed, on to the fallbacks. Let's try exo-open first, + since it's part of XFCE. */ + gchar *cmd = g_strdup_printf("%s %s","exo-open", uri); + result = g_spawn_command_line_async(cmd, NULL); - if (G_UNLIKELY(spawn_result == FALSE)) { - g_warning(_("Unable to open the following url: %s"), PLUGIN_WEBSITE); + if (G_UNLIKELY(result == FALSE)) { + g_warning(_("Unable to open URI with exo-open, trying xdg-open: %s"), uri); + g_free(cmd); + cmd = g_strdup_printf("%s %s","xdg-open", uri); + result = g_spawn_command_line_async(cmd, NULL); + if (G_UNLIKELY(result == FALSE)) { + g_warning(_("Unable to open URI with xdg-open, giving up: %s"), uri); } + } + + g_free(cmd); + return result; +} + + +static void hdaps_configure_response(GtkDialog *dialog, + gint response, + HdapsPlugin *hdaps) { + if (response == GTK_RESPONSE_HELP) { + launch_uri(GTK_WINDOW(dialog), PLUGIN_WEBSITE); return; } @@ -76,7 +108,7 @@ static void hdaps_configure_response(GtkWidget *dialog, instead. */ g_object_set_data(G_OBJECT(hdaps->plugin), "dialog", NULL); xfce_panel_plugin_unblock_menu(hdaps->plugin); - gtk_widget_destroy(dialog); + gtk_widget_destroy(GTK_WIDGET(dialog)); return; } @@ -204,14 +236,7 @@ static void hdaps_uri_handler(GtkAboutDialog *about, const gchar *uri, gpointer data) { - gchar *cmd = g_strdup_printf("%s %s","xdg-open", uri); - gboolean spawn_result = 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); + launch_uri(GTK_WINDOW(about), uri); } /* "Close" button handler for the About dialog. */