refraction part 7
authorReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 26 Dec 2009 14:12:28 +0000 (16:12 +0200)
committerReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 26 Dec 2009 14:12:28 +0000 (16:12 +0200)
src/callbacks.c
src/play.c
src/plugin/mancala-ui-plugin.c

index 3b38a9b..70215ed 100644 (file)
@@ -38,7 +38,7 @@ int exit_callback(int errcode) {
 //             fwrite(car, sizeof(struct CAR), cars, han);
 //             fclose(han);
 //     }
-    fprintf("exit_callback called...\n");
+    fprintf(stderr, "exit_callback called...\n");
 
        return 0;
 }
@@ -46,13 +46,13 @@ int exit_callback(int errcode) {
 // Quit game
 int quit_callback(int errcode) {
 //     remove("/tmp/.crazyparking-save");
-    fprintf("quit_callback called...\n");
+    fprintf(stderr, "quit_callback called...\n");
        hgw_context_compat_destroy_quit(hgw_context);
        return 0;
 }
 
 int flush_callback(int errcode) {
 //     remove("/tmp/.crazyparking-save");
-    fprintf("quit_callback called...\n");
+    fprintf(stderr, "quit_callback called...\n");
        return 0;
 }
index fc81a95..dda0f19 100644 (file)
@@ -441,7 +441,6 @@ int main(int argc, char **argv) {
     play();
     
     hgw_context_compat_destroy_deinit(hgw_context);
-    hgw_context_destroy(hgw_context);
     
     return 0;
 }
index 2e23565..528b9d6 100644 (file)
@@ -26,7 +26,7 @@
 #include <hildon/hildon.h>
 #include <gtk/gtk.h>
 #include <startup_plugin.h>
-
+#include <startup_app.h>
 
 static GtkWidget *load_plugin               (void);
 static void       unload_plugin             (void);
@@ -46,14 +46,25 @@ static StartupPluginInfo plugin_info = {
 
 STARTUP_INIT_PLUGIN(plugin_info, gs, FALSE, FALSE)
 
-static GtkWidget *load_plugin (void)
+static void destroy_help_subwindow (void)
+{
+    StartupApp *app = gs.ui->app;
+    osso_application_top(app->osso, app->path, NULL);
+}
+
+static void show_help_subwindow (void)
 {
+    GtkWidget *win;
     GtkWidget *textbox;
     GtkTextBuffer *textbox_buffer;
     gchar *textbox_text;
     PangoFontDescription *font_desc;
     GtkWidget *pannable_text;
     
+    /* Create the subwindow (a stackable window) */
+    win = hildon_stackable_window_new();
+    gtk_window_set_title ( GTK_WINDOW (win), "Help");
+
     /* Create and pack labels */     
     textbox_text = g_strdup_printf("Welcome to Mancala, the ancient African game of skill!\n\nMancala is a very simple, easy-to-learn game. Each player begins with a horizontal row of holes or pits filled with a certain number of stones. At either end of the board are the players' home pits, which are used to keep score. In this case, the human player has the left home pit and the upper row holes. A move is made by clicking into the hole you wish to move from. The stones are then picked up and distributed, one to each hole, moving toward your home pit is reached, and then moving through your opponent's row, bypassing his/her home, and moving back towards in a circle (counterclockwise), until all the stones have been distributed.\n\nIf the last stone is placed in your home, you receive an extra turn. If the last stone lands in an empty hole on your side, you 'capture' the stones in the opposite hole on your opponent's side, moving them to your home.\n\nThe game ends when one player cannot play (ie. there are no stones on his/her side of the board.  The player who has the most stones on his/her *side* wins.");
     
@@ -79,7 +90,26 @@ static GtkWidget *load_plugin (void)
     pannable_text = hildon_pannable_area_new();
     hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA(pannable_text), textbox);
     
-    return GTK_WIDGET(pannable_text);
+    gtk_container_add (GTK_CONTAINER (win), pannable_text);
+    
+    g_signal_connect (win, "destroy", destroy_help_subwindow, NULL);
+    
+
+    /* This call show the window and also add the window to the stack */
+    gtk_widget_show_all (win);
+}
+
+
+
+static GtkWidget *load_plugin (void)
+{
+    GtkWidget *button;
+    button =  gtk_button_new_with_label ("Instuctions");
+    
+    g_signal_connect (button, "clicked", G_CALLBACK (show_help_subwindow), NULL);
+    
+    return GTK_WIDGET(button);
+    
 }
 
 static void