Created open game functionality in the player. Fix #37.
[rodin/chimara.git] / tests / callbacks.c
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  * callbacks.c
4  * Copyright (C) Philip en Marijn 2008 <>
5  * 
6  * callbacks.c is free software copyrighted by Philip en Marijn.
7  * 
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name ``Philip en Marijn'' nor the name of any other
17  *    contributor may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  * 
20  * callbacks.c IS PROVIDED BY Philip en Marijn ``AS IS'' AND ANY EXPRESS
21  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL Philip en Marijn OR ANY OTHER CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #include <gdk/gdkkeysyms.h>
34 #include <libchimara/chimara-glk.h>
35 #include "error.h"
36
37 void on_save(GtkAction *action, ChimaraGlk *glk) {
38         chimara_glk_feed_line_input(glk, "save");
39 }
40
41 void on_restore(GtkAction *action, ChimaraGlk *glk) {
42         chimara_glk_feed_line_input(glk, "restore");
43 }
44
45 gboolean on_window_delete_event(GtkWidget *widget, GdkEvent *event, ChimaraGlk *glk) {
46         gtk_main_quit();
47         return TRUE;
48 }
49
50 void on_quit(GtkAction *action, ChimaraGlk *glk) {
51         gtk_main_quit();
52 }
53
54 void on_hint(GtkAction *action, ChimaraGlk *glk) {
55         chimara_glk_feed_line_input(glk, "se");
56         chimara_glk_feed_line_input(glk, "push cans to window");
57         chimara_glk_feed_line_input(glk, "stand on cans");
58         chimara_glk_feed_line_input(glk, "open window");
59         chimara_glk_feed_line_input(glk, "enter window");
60 }
61
62 void on_press_r(GtkAction *action, ChimaraGlk *glk) {
63         chimara_glk_feed_char_input(glk, GDK_R);
64 }
65
66 void on_press_enter(GtkAction *action, ChimaraGlk *glk) {
67         chimara_glk_feed_char_input(glk, GDK_Return);
68         chimara_glk_feed_char_input(glk, GDK_Return);
69         chimara_glk_feed_char_input(glk, GDK_Return);
70 }