From 009ba43d6e4e4167a7c575c9eb79164c55ab6f45 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 13 Mar 2011 00:29:50 +0000 Subject: fix gtk about dialog to use about: to display credits and licence svn path=/trunk/netsurf/; revision=12006 --- gtk/dialogs/about.c | 149 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 56 deletions(-) (limited to 'gtk/dialogs') diff --git a/gtk/dialogs/about.c b/gtk/dialogs/about.c index 14ddf624c..e3886e973 100644 --- a/gtk/dialogs/about.c +++ b/gtk/dialogs/about.c @@ -20,66 +20,103 @@ #include "gtk/dialogs/about.h" #include "desktop/browser.h" -GtkAboutDialog* about_dialog; - -static const gchar *authors[] = { - "John-Mark Bell", "James Bursa", "Michael Drake", - "Rob Kendrick", "Adrian Lees", "Vincent Sanders", - "Daniel Silverstone", "Richard Wilson", - "\nContributors:", "Kevin Bagust", "Stefaan Claes", - "Matthew Hambley", "Rob Jackson", "Jeffrey Lee", "Phil Mellor", - "Philip Pemberton", "Darren Salt", "Andrew Timmins", - "John Tytgat", "Chris Williams", - "\nGoogle Summer of Code Contributors:", "Mark Benjamin", - "Adam Blokus", "Paul Blokus", "Sean Fox", - "Michael Lester", "Andrew Sidwell", "Bo Yang", NULL -}; - -static const gchar *translators = "Sebastian Barthel\nBruno D'Arcangeli\n" - "Gerard van Katwijk\nJérôme Mathevet\nSimon Voortman."; -static const gchar *artists[] = { - "Michael Drake", "\nContributors:", "Andrew Duffell", - "John Duffell", "Richard Hallas", "Phil Mellor", NULL -}; - -static const gchar *documenters[] = { - "John-Mark Bell", "James Bursa", "Michael Drake", - "Richard Wilson", "\nContributors:", "James Shaw", NULL -}; - -static const gchar *name = "NetSurf"; -static const gchar *description = - "Small as a mouse, fast as a cheetah, and available for free.\n" - "NetSurf is a portable web browser for RISC OS, AmigaOS, BeOS " - "and UNIX-like platforms."; -static const gchar *url = "http://www.netsurf-browser.org/"; -static const gchar *url_label = "NetSurf Website"; -static const gchar *copyright = - "Copyright © 2003 - 2010 The NetSurf Developers"; - -static void launch_url (GtkAboutDialog *about_dialog, const gchar *url, - gpointer data) + +static void +nsgtk_about_dialog_credits(GtkWidget *button, gpointer data) { struct browser_window *bw = data; - browser_window_go(bw, url, 0, true); + browser_window_go(bw, "about:credits", 0, true); + gtk_widget_destroy(gtk_widget_get_toplevel(button)); } -void nsgtk_about_dialog_init(GtkWindow *parent, struct browser_window *bw, - const char *version) +static void +nsgtk_about_dialog_licence(GtkWidget *button, gpointer data) { - gchar *licence_text; - gchar *licence_location = g_strconcat(res_dir_location, "licence", NULL); - - g_file_get_contents(licence_location, &licence_text, NULL, NULL); - free(licence_location); - gtk_about_dialog_set_url_hook (launch_url, (gpointer) bw, NULL); - - gtk_show_about_dialog(parent, "artists", artists, "authors", authors, - "comments", description,"copyright", copyright, - "documenters", documenters, "license", licence_text, - "program-name", name, "translator-credits", translators, - "version", version, "website", url, - "website-label", url_label, - "wrap-license", FALSE, NULL); + struct browser_window *bw = data; + browser_window_go(bw, "about:licence", 0, true); + gtk_widget_destroy(gtk_widget_get_toplevel(button)); } +void nsgtk_about_dialog_init(GtkWindow *parent, + struct browser_window *bw, + const char *version) +{ + GtkWidget *dialog, *vbox, *button, *image, *label; + gchar *name_string; + GList *pixbufs = gtk_window_get_default_icon_list(); + + name_string = g_markup_printf_escaped ("NetSurf %s", version); + + + /* Create the widgets */ + dialog = gtk_dialog_new_with_buttons("About NetSurf", + parent, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CLOSE, + GTK_RESPONSE_NONE, + NULL); + + vbox = gtk_vbox_new (FALSE, 8); + + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, TRUE, TRUE, 0); + + if (pixbufs != NULL) { + GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(GDK_PIXBUF(g_list_nth_data(pixbufs, 0))); + + image = gtk_image_new(); + + gtk_image_set_from_icon_set (GTK_IMAGE (image), + icon_set, GTK_ICON_SIZE_DIALOG); + + gtk_icon_set_unref (icon_set); + g_list_free (pixbufs); + + gtk_box_pack_start(GTK_BOX (vbox), image, FALSE, FALSE, 0); + } + + + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (label), name_string); + g_free (name_string); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + label = gtk_label_new("NetSurf is a small fast web browser"); + gtk_label_set_selectable(GTK_LABEL (label), TRUE); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + label = gtk_label_new("Copyright © 2003 - 2011 The NetSurf Developers"); + gtk_label_set_selectable(GTK_LABEL(label), TRUE); + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); + gtk_box_pack_start(GTK_BOX (vbox), label, FALSE, FALSE, 0); + + + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + + /* Add the credits button */ + button = gtk_button_new_from_stock ("Credits"); + gtk_box_pack_end(GTK_BOX (GTK_DIALOG (dialog)->action_area), + button, FALSE, TRUE, 0); + gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE); + g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_credits), (gpointer)bw); + + /* Add the Licence button */ + button = gtk_button_new_from_stock ("Licence"); + gtk_box_pack_end(GTK_BOX (GTK_DIALOG (dialog)->action_area), + button, FALSE, TRUE, 0); + gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE); + g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_licence), (gpointer)bw); + + + /* Ensure that the dialog box is destroyed when the user responds. */ + g_signal_connect_swapped(dialog, + "response", + G_CALLBACK (gtk_widget_destroy), + dialog); + + /* Add the label, and show everything we've added to the dialog. */ + gtk_widget_show_all(dialog); +} -- cgit v1.2.3