[PATCH] Don't use gtk_show_about_dialog() for the about dialog

Lubomir I. Ivanov neolit123 at gmail.com
Mon Feb 25 10:56:50 PST 2013


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

There is a bug in GTK 2.2x where the links in the about dialog
(and URI's in general) do not work on Windows. To solve that
we add the OS specific method subsurface_launch_for_uri().
But to dispatch URI requests from the about dialog we need to
set a hook either with gtk_about_dialog_set_url_hook() (which is
deprecated from 2.24) or using signals like "activate-link".

One problem with the "activate-link" signal thought is that
we need to have a reference of an about dialog to pass to
g_signal_connect(). So instead of using gtk_show_about_dialog()
let's manage a dialog ourself with gtk_about_dialog_new(),
gtk_dialog_run(), gtk_widget_destroy().

Other changes:
- for GTK _bellow_ (but not including) 2.24 use
gtk_about_dialog_set_url_hook()
- use g_object_set() which is a convenient replacement for
the varargs list in gtk_show_about_dialog() (also makes the diff smaller).

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---

This an improvement over the previous fix for issue #67.

---
 gtk-gui.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gtk-gui.c b/gtk-gui.c
index d292e6d..0ee0e3e 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1047,19 +1047,19 @@ static void about_dialog(GtkWidget *w, gpointer data)
 {
 	const char *logo_property = NULL;
 	GdkPixbuf *logo = NULL;
-	GtkWidget * dialog;
+	GtkWidget *dialog;
 
 	if (need_icon) {
 		logo_property = "logo";
 		logo = gdk_pixbuf_from_pixdata(&subsurface_icon_pixbuf, TRUE, NULL);
 	}
 	dialog = gtk_about_dialog_new();
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION <= 24)
+#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 24)
 	gtk_about_dialog_set_url_hook(about_dialog_link_cb, NULL, NULL); /* deprecated since GTK 2.24 */
 #else
 	g_signal_connect(GTK_ABOUT_DIALOG(dialog), "activate-link", G_CALLBACK(about_dialog_link_cb), NULL);
 #endif
-	gtk_show_about_dialog(NULL,
+	g_object_set(GTK_OBJECT(dialog),
 		"title", _("About Subsurface"),
 		"program-name", "Subsurface",
 		"comments", _("Multi-platform divelog software in C"),
@@ -1073,6 +1073,10 @@ static void about_dialog(GtkWidget *w, gpointer data)
 		/* Must be last: */
 		logo_property, logo,
 		NULL);
+	if (logo)
+		g_object_unref(logo);
+	gtk_dialog_run(GTK_DIALOG(dialog));
+	gtk_widget_destroy(dialog);
 }
 
 static void view_list(GtkWidget *w, gpointer data)
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list