From cd5c61e102dfd7cb1bfc5031e693b2dcd66bec9e Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Mon, 25 Feb 2013 20:56:50 +0200 Subject: Don't use gtk_show_about_dialog() for the about dialog 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 Signed-off-by: Dirk Hohndel --- gtk-gui.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gtk-gui.c') diff --git a/gtk-gui.c b/gtk-gui.c index d292e6db3..0ee0e3e23 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) -- cgit v1.2.3-70-g09d2