new about dialog
authorJavier S. Pedro <maemo@javispedro.com>
Mon, 7 Sep 2009 17:00:33 +0000 (19:00 +0200)
committerJavier S. Pedro <maemo@javispedro.com>
Mon, 7 Sep 2009 17:00:33 +0000 (19:00 +0200)
gui/Makefile
gui/about.c [new file with mode: 0644]
gui/cellrendererkey.c
gui/plugin.c
gui/plugin.h
gui/state.c

index a0df652..a7501c6 100644 (file)
@@ -1,5 +1,5 @@
-PKGS:=gtk+-2.0 hildon-1 hildon-fm-2 gconf-2.0 gnome-vfs-2.0
-CPPFLAGS:=$(shell pkg-config --cflags $(PKGS)) 
+PKGS:=gtk+-2.0 hildon-1 hildon-fm-2 libhildonmime gconf-2.0 gnome-vfs-2.0
+CPPFLAGS:=$(shell pkg-config --cflags $(PKGS)) -DGAME_VERSION=$(GAME_VERSION)
 LDLIBS:=$(shell pkg-config --libs $(PKGS))
 
 ifdef GUI_CFLAGS
@@ -26,7 +26,7 @@ M4DEFS:= -DGAME_VERSION=$(GAME_VERSION) -DGAME_PLUGIN_PATH=$(GAME_PLUGIN_PATH)
 M4DEFS+= -DGAME_CONF_PATH=$(GAME_CONF_PATH) -DGAME_BIN_PATH=$(GAME_BIN_PATH)
 M4DEFS+= -DGAME_GAME_PATH=$(GAME_GAME_PATH) -DGAME_BANNER_PATH=$(GAME_BANNER_PATH)
 
-OBJS:=plugin.o state.o save.o controls.o cellrendererkey.o
+OBJS:=plugin.o state.o save.o controls.o cellrendererkey.o about.o
 
 DATA_FILES:=drnoksnes.conf drnoksnes.desktop drnoksnes.game 
 DATA_FILES+=drnoksnes.service drnoksnes.startup.service
diff --git a/gui/about.c b/gui/about.c
new file mode 100644 (file)
index 0000000..a8c28c1
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+* This file is part of DrNokSnes
+*
+* Copyright (C) 2009 Javier S. Pedro <maemo@javispedro.com>
+*
+* This software is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public License
+* as published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+
+#include <gtk/gtk.h>
+#include <hildon/hildon-helper.h>
+#include <hildon-mime.h>
+
+#include "plugin.h"
+
+static GtkDialog* dialog;
+
+static void cb_dialog_response(GtkWidget * button, gpointer data)
+{
+       gtk_widget_destroy(GTK_WIDGET(dialog));
+}
+
+static void cb_url_response(GtkWidget * button, gpointer data)
+{
+       GError* error;
+       const gchar * uri = gtk_link_button_get_uri(GTK_LINK_BUTTON(button));
+       HildonURIAction* action = hildon_uri_get_default_action(uri, &error);
+       hildon_uri_open(uri, action, &error);
+}
+
+void about_dialog(GtkWindow* parent)
+{
+       dialog = GTK_DIALOG(gtk_dialog_new_with_buttons("About",
+               parent, GTK_DIALOG_MODAL,
+               GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL));
+
+       GtkBox* caption_box = GTK_BOX(gtk_hbox_new(FALSE, HILDON_MARGIN_DEFAULT));
+       GtkWidget* logo = gtk_image_new_from_icon_name("drnoksnes",
+               GTK_ICON_SIZE_DIALOG);
+       GtkWidget* label = gtk_label_new(NULL);
+       gchar * label_caption = g_strdup_printf("<b>%s</b> %s",
+               "DrNokSnes", G_STRINGIFY(GAME_VERSION));
+       gtk_label_set_markup(GTK_LABEL(label), label_caption);
+       g_free(label_caption);
+       gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+
+       GtkWidget* separator1 = gtk_hseparator_new();
+       GtkWidget* separator2 = gtk_hseparator_new();
+       GtkWidget* url_label = gtk_link_button_new("http://drnoksnes.garage.maemo.org/");
+       GtkWidget* upstream_label = gtk_label_new("Many thanks to DrPocketSnes authors and contributors.");
+       GtkWidget* wazd_label = gtk_label_new("Thanks to wazd for artwork.");
+       GtkWidget* thanks_label = gtk_label_new("And, of course, thanks to all of maemo.org for their help.");
+
+       gtk_box_pack_start(caption_box, logo, FALSE, FALSE, HILDON_MARGIN_DEFAULT);
+       gtk_box_pack_start_defaults(caption_box, label);
+
+       gtk_box_pack_start_defaults(GTK_BOX(dialog->vbox), GTK_WIDGET(caption_box));
+       gtk_box_pack_start(GTK_BOX(dialog->vbox), separator1, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(dialog->vbox), url_label, FALSE, FALSE, HILDON_MARGIN_DEFAULT);
+       gtk_box_pack_start(GTK_BOX(dialog->vbox), separator2, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(dialog->vbox), upstream_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(dialog->vbox), wazd_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(dialog->vbox), thanks_label, FALSE, FALSE, 0);
+
+       g_signal_connect(G_OBJECT(dialog), "response",
+                                       G_CALLBACK (cb_dialog_response), NULL);
+       g_signal_connect(G_OBJECT(url_label), "clicked",
+                                       G_CALLBACK (cb_url_response), NULL);
+
+       gtk_widget_show_all(GTK_WIDGET(dialog));
+}
+
index ad1761f..fb47c64 100644 (file)
@@ -402,7 +402,7 @@ cell_renderer_key_start_editing (GtkCellRenderer      *cell,
   eventbox = g_object_new(pointless_eventbox_subclass_get_type(), NULL);
   key->edit_widget = eventbox;
   g_object_add_weak_pointer (G_OBJECT (key->edit_widget),
-                             (void**) &key->edit_widget);
+                             (gpointer*) &key->edit_widget);
 
 
   hbox = gtk_hbox_new(FALSE, 2);
index 90eccaf..28ac650 100644 (file)
@@ -143,6 +143,11 @@ static void controls_item_callback(GtkWidget * button, gpointer data)
        controls_dialog(get_parent_window());
 }
 
+static void about_item_callback(GtkWidget * button, gpointer data)
+{
+       about_dialog(get_parent_window());
+}
+
 static GtkWidget * load_plugin(void)
 {
        int i;
@@ -274,7 +279,8 @@ static void write_config(void)
 static GtkWidget **load_menu(guint *nitems)
 {
        menu_items[0] = gtk_menu_item_new_with_label("Settings");
-       *nitems = 1;
+       menu_items[1] = gtk_menu_item_new_with_label("About…");
+       *nitems = 2;
 
        GtkMenu* settings_menu = GTK_MENU(gtk_menu_new());
        GtkMenuItem* controls_item =
@@ -286,6 +292,8 @@ static GtkWidget **load_menu(guint *nitems)
 
        g_signal_connect(G_OBJECT(controls_item), "activate",
                                        G_CALLBACK(controls_item_callback), NULL);
+       g_signal_connect(G_OBJECT(menu_items[1]), "activate",
+                                       G_CALLBACK(about_item_callback), NULL);
 
        return menu_items;
 }
index 0fe6513..65d5795 100644 (file)
@@ -27,4 +27,7 @@ void save_save_as(GtkWindow* parent);
 void controls_setup();
 void controls_dialog(GtkWindow* parent);
 
+/* about.c */
+void about_dialog(GtkWindow* parent);
+
 #endif
index 23174dc..e158000 100644 (file)
@@ -61,7 +61,7 @@ static gboolean rom_get_freeze_file()
        }
 
        if (current_rom_file_exists) {
-               frz_file = g_strconcat(rom_base, FRZ_FILE_EXT);
+               frz_file = g_strconcat(rom_base, FRZ_FILE_EXT, NULL);
                frz_exists =
                        g_file_test(frz_file, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR);