summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d1758a9)
Now that the signal handler for the "about" dialog works, let's
consolidate the two identical URI launcher routines. The new
factored-out launch_uri() function tries all three approaches
in succession:
1. whatever gtk_show_uri_on_window() does,
2. exo-open, and
3. xdg-open.
If those all fail, it fails. We had to twiddle some things to allow us
to pass a GtkWindow pointer into the launch_uri() function because
gtk_show_uri_on_window() needs one, but that wasn't a big deal.
*/
#define PLUGIN_WEBSITE "http://michael.orlitzky.com/code/xfce4-hdaps.xhtml"
*/
#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);
+ 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);
instead. */
g_object_set_data(G_OBJECT(hdaps->plugin), "dialog", NULL);
xfce_panel_plugin_unblock_menu(hdaps->plugin);
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));
const gchar *uri,
gpointer data) {
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. */
}
/* "Close" button handler for the About dialog. */