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 <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Lubomir I. Ivanov 2013-02-25 20:56:50 +02:00 committed by Dirk Hohndel
parent 9f8bbeb0cf
commit cd5c61e102

View file

@ -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)