aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-10-26 05:22:38 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-10-26 07:37:50 +0200
commitf7807cada2c65649be65fad844027f7f0dfbe6d2 (patch)
tree9ae41e82eb7967a975a1193ea6bd1333a6dba033
parent08cf0ef2e636ab2c465fd1ba6fa0ef786c892976 (diff)
downloadlogdiag-f7807cada2c65649be65fad844027f7f0dfbe6d2.tar.gz
logdiag-f7807cada2c65649be65fad844027f7f0dfbe6d2.tar.xz
logdiag-f7807cada2c65649be65fad844027f7f0dfbe6d2.zip
Make the about dialog link work in Windows XP
For some weird reason, GTK+ is trying to connect to URLs first, which typically won't succeed these days.
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/ld-window-main.c43
2 files changed, 43 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bca836a..1305f89 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -224,7 +224,7 @@ set (logdiag_LIBS ${GTK3_LIBRARIES} ${Lua_LIBRARIES} m)
if (WIN32)
find_package (LibIntl REQUIRED)
- list (APPEND logdiag_LIBS ${LIBINTL_LIBRARIES})
+ list (APPEND logdiag_LIBS ${LIBINTL_LIBRARIES} shell32)
endif (WIN32)
# Build the library
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
index af603f8..a86138c 100644
--- a/src/ld-window-main.c
+++ b/src/ld-window-main.c
@@ -13,6 +13,11 @@
#include "ld-window-main.h"
+#ifdef G_OS_WIN32
+#include <gdk/gdkwin32.h>
+#include <shellapi.h>
+#endif
+
struct _LdWindowMainPrivate
{
@@ -1050,10 +1055,37 @@ on_action_user_guide (GtkAction *action, LdWindowMain *self)
g_object_unref (file);
}
+static gboolean
+on_action_about_activate_link (GtkAboutDialog *dialog, gchar *uri,
+ LdWindowMain *self)
+{
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (GTK_WIDGET (self));
+
+#ifdef G_OS_WIN32
+ /* gtk_show_uri() on Windows XP fails, due to trying to establish
+ * an SSL connection, so let's first try to not do that on Windows.
+ * `cmd.exe /c start "" ...` would pop up a command line window,
+ * so use SHELL32.DLL directly. rundll does not cover this.
+ * There doesn't seem to be anything better directly in GIO/GLib.
+ *
+ * When we fail here, we fall back to normal processing.
+ */
+ if ((INT_PTR) ShellExecute (gdk_win32_window_get_handle (window),
+ "open", uri, NULL, NULL, SW_SHOWNORMAL) > 32)
+ return TRUE;
+#endif /* G_OS_WIN32 */
+
+ return FALSE;
+}
+
static void
on_action_about (GtkAction *action, LdWindowMain *self)
{
- gtk_show_about_dialog (GTK_WINDOW (self),
+ GtkWidget *about_dialog;
+
+ about_dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"program-name", PROJECT_NAME,
"logo-icon-name", PROJECT_NAME,
"version", PROJECT_VERSION,
@@ -1061,6 +1093,15 @@ on_action_about (GtkAction *action, LdWindowMain *self)
"copyright", "Copyright 2010 - 2021 Přemysl Eric Janouch",
"website", PROJECT_URL,
NULL);
+
+ g_signal_connect (about_dialog, "activate-link",
+ G_CALLBACK (on_action_about_activate_link), self);
+
+ gtk_window_set_transient_for (GTK_WINDOW (about_dialog), GTK_WINDOW (self));
+ gtk_window_set_modal (GTK_WINDOW (about_dialog), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (about_dialog), TRUE);
+ gtk_dialog_run (GTK_DIALOG (about_dialog));
+ gtk_widget_destroy (about_dialog);
}
static void