]> gitweb.michael.orlitzky.com - xfce4-hdaps.git/commitdiff
xfce4-hdaps-dialogs.c: replace email/url hooks with a signal handler.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 23 Oct 2019 14:58:09 +0000 (10:58 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 26 Oct 2019 14:53:52 +0000 (10:53 -0400)
The old gtk_about_dialog_set_{email,url}_hook() functions that we used
for our custom http(s):// and mailto:// handlers are gone. To achieve
the same goal, they've been replaced by an "activate-link" signal
handler, and both implementation (that is, the hooks) have been
combined into a single call to xdg-open.

panel-plugin/xfce4-hdaps-dialogs.c

index b5d6fb120a4329e1d60dfa9e16b4d05576c30c87..bacd540e22ae00e6a027879e53a5ecf18b43ac04 100644 (file)
@@ -193,41 +193,34 @@ void hdaps_configure(XfcePanelPlugin *plugin,
 
 
 
-/* URL handler used on the About dialog. */
-static void hdaps_url_handler(GtkAboutDialog *about,
-                             const gchar *link,
+/* URI (http(s):// and mailto://) handler used on the About dialog. */
+static void hdaps_uri_handler(GtkAboutDialog *about,
+                             const gchar *uri,
                              gpointer data) {
     gchar *cmd;
 
-    cmd = g_strdup_printf("%s %s","xdg-open", link);
+    cmd = g_strdup_printf("%s %s","xdg-open", uri);
 
-    /* Stolen from xfce4-power-manager. */
     if (!g_spawn_command_line_async(cmd, NULL)) {
       g_free(cmd);
-      cmd = g_strdup_printf("%s %s","xfbrowser4", link);
+      cmd = g_strdup_printf("%s %s","xdg-open", uri);
       g_spawn_command_line_async(cmd, NULL);
     }
     g_free(cmd);
 }
 
 
-/* Email address handler used on the About dialog. */
-static void hdaps_mailto_handler(GtkAboutDialog *about,
-                                const gchar *link,
-                                gpointer data) {
-    gchar *cmd = g_strdup_printf( "%s %s", "xdg-email", link);
-
-    g_spawn_command_line_async(cmd, NULL);
-    g_free(cmd);
-}
-
-
 void hdaps_about(XfcePanelPlugin *plugin) {
   const gchar *authors[] = { "Michael Orlitzky <michael@orlitzky.com>", NULL };
   const gchar *copyright = "Copyright \302\251 2012 Michael Orlitzky";
 
-  gtk_about_dialog_set_url_hook(hdaps_url_handler, NULL, NULL);
-  gtk_about_dialog_set_email_hook(hdaps_mailto_handler, NULL, NULL);
+  /* 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,
+                  "activate-link",
+                  G_CALLBACK(hdaps_uri_handler),
+                  NULL);
 
   gtk_show_about_dialog(NULL,
                        "authors", authors,