2 * This file is part of DrNokSnes
4 * Copyright (C) 2009 Javier S. Pedro <maemo@javispedro.com>
6 * This software is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * This software is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this software; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <hildon/hildon-helper.h>
25 #include <hildon-mime.h>
29 static GtkDialog* dialog;
31 static void cb_dialog_response(GtkWidget * button, gpointer data)
33 gtk_widget_destroy(GTK_WIDGET(dialog));
36 static void cb_url_response(GtkWidget * button, gpointer data)
39 const gchar * uri = gtk_link_button_get_uri(GTK_LINK_BUTTON(button));
40 HildonURIAction* action = hildon_uri_get_default_action(uri, &error);
41 hildon_uri_open(uri, action, &error);
44 void about_dialog(GtkWindow* parent)
46 dialog = GTK_DIALOG(gtk_dialog_new_with_buttons("About",
47 parent, GTK_DIALOG_MODAL,
48 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL));
50 GtkBox* caption_box = GTK_BOX(gtk_hbox_new(FALSE, HILDON_MARGIN_DEFAULT));
51 GtkWidget* logo = gtk_image_new_from_icon_name("drnoksnes",
52 GTK_ICON_SIZE_DIALOG);
53 GtkWidget* label = gtk_label_new(NULL);
54 gchar * label_caption = g_strdup_printf("<b>%s</b> %s",
55 "DrNokSnes", G_STRINGIFY(GAME_VERSION));
56 gtk_label_set_markup(GTK_LABEL(label), label_caption);
57 g_free(label_caption);
58 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
60 GtkWidget* separator1 = gtk_hseparator_new();
61 GtkWidget* separator2 = gtk_hseparator_new();
62 GtkWidget* url_label = gtk_link_button_new("http://drnoksnes.garage.maemo.org/");
63 GtkWidget* upstream_label = gtk_label_new("Many thanks to DrPocketSnes authors and contributors.");
64 GtkWidget* wazd_label = gtk_label_new("Thanks to wazd for artwork.");
65 GtkWidget* thanks_label = gtk_label_new("And, of course, thanks to all of maemo.org for their help.");
67 gtk_box_pack_start(caption_box, logo, FALSE, FALSE, HILDON_MARGIN_DEFAULT);
68 gtk_box_pack_start_defaults(caption_box, label);
70 gtk_box_pack_start_defaults(GTK_BOX(dialog->vbox), GTK_WIDGET(caption_box));
71 gtk_box_pack_start(GTK_BOX(dialog->vbox), separator1, FALSE, FALSE, 0);
72 gtk_box_pack_start(GTK_BOX(dialog->vbox), url_label, FALSE, FALSE, HILDON_MARGIN_DEFAULT);
73 gtk_box_pack_start(GTK_BOX(dialog->vbox), separator2, FALSE, FALSE, 0);
74 gtk_box_pack_start(GTK_BOX(dialog->vbox), upstream_label, FALSE, FALSE, 0);
75 gtk_box_pack_start(GTK_BOX(dialog->vbox), wazd_label, FALSE, FALSE, 0);
76 gtk_box_pack_start(GTK_BOX(dialog->vbox), thanks_label, FALSE, FALSE, 0);
78 g_signal_connect(G_OBJECT(dialog), "response",
79 G_CALLBACK (cb_dialog_response), NULL);
80 g_signal_connect(G_OBJECT(url_label), "clicked",
81 G_CALLBACK (cb_url_response), NULL);
83 gtk_widget_show_all(GTK_WIDGET(dialog));