1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Philip en Marijn 2008 <>
6 * iliad.c is free software copyrighted by Philip en Marijn.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
20 * main.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.
33 #include <sys/types.h>
40 #include <glib/gi18n.h>
44 #include <libchimara/chimara-glk.h>
45 #include <libchimara/chimara-if.h>
48 #include <liberdm/erdm.h>
49 #include <liberipc/eripcviewer.h>
50 #include <liberipc/eripctoolbar.h>
51 #include <liberipc/eripcbusyd.h>
53 /* Global pointers to widgets */
54 GtkWidget *window = NULL;
55 GtkWidget *glk = NULL;
57 static erClientChannel_t erbusyChannel;
58 static erClientChannel_t ertoolbarChannel;
61 on_started(ChimaraGlk *glk)
63 g_printerr("Started!\n");
67 on_stopped(ChimaraGlk *glk)
69 g_printerr("Stopped!\n");
75 chimara_glk_feed_line_input( CHIMARA_GLK(glk), "restore" );
81 chimara_glk_feed_line_input( CHIMARA_GLK(glk), "save" );
87 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
88 glk = chimara_if_new();
89 //chimara_if_set_preferred_interpreter( CHIMARA_IF(glk), CHIMARA_IF_FORMAT_Z8, CHIMARA_IF_INTERPRETER_NITFOL);
91 gtk_widget_set_size_request(window, 800, 800);
95 "ignore-errors", TRUE,
97 chimara_glk_set_default_font_string(CHIMARA_GLK(glk), "Serif 12");
98 chimara_glk_set_monospace_font_string(CHIMARA_GLK(glk), "Monospace 12");
99 g_signal_connect(glk, "started", G_CALLBACK(on_started), NULL);
100 g_signal_connect(glk, "stopped", G_CALLBACK(on_stopped), NULL);
102 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
103 GtkWidget *toolbar = gtk_toolbar_new();
105 GtkToolItem *restore_button = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
106 g_signal_connect(restore_button, "clicked", G_CALLBACK(on_restore), NULL);
107 gtk_toolbar_insert( GTK_TOOLBAR(toolbar), restore_button, 0 );
109 GtkToolItem *save_button = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
110 g_signal_connect(save_button, "clicked", G_CALLBACK(on_save), NULL);
111 gtk_toolbar_insert( GTK_TOOLBAR(toolbar), save_button, 0 );
113 GtkToolItem *quit_button = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
114 g_signal_connect(quit_button, "clicked", G_CALLBACK(gtk_main_quit), NULL);
115 gtk_toolbar_insert( GTK_TOOLBAR(toolbar), quit_button, 0 );
117 GtkWidget *spacer = gtk_vbox_new(FALSE, 0);
118 gtk_widget_set_size_request(spacer, -1, 250);
120 gtk_box_pack_start( GTK_BOX(vbox), toolbar, FALSE, FALSE, 0 );
121 gtk_box_pack_start( GTK_BOX(vbox), glk, TRUE, TRUE, 0 );
122 gtk_box_pack_end( GTK_BOX(vbox), spacer, FALSE, FALSE, 0 );
124 gtk_container_add( GTK_CONTAINER(window), vbox );
130 erIpcStartClient(ER_TOOLBAR_CHANNEL, &ertoolbarChannel);
131 tbSelectIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID);
132 tbClearIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID);
135 tbAppendPlatformIcon( ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_trashcan, -1);
136 tbSetStatePlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_trashcan, iconState_grey );
138 // Enable then pop up keyboard
139 tbAppendPlatformIcon( ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_keyboard, -1);
140 tbSetStatePlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_keyboard, iconState_selected);
144 iliad_clear_toolbar()
147 tbSetStatePlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_trashcan, iconState_normal );
149 // Disable the keyboard
150 tbSetStatePlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_keyboard, iconState_normal);
154 main(int argc, char *argv[])
156 GError *error = NULL;
159 bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
160 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
161 textdomain(GETTEXT_PACKAGE);
164 if( !g_thread_supported() )
167 gtk_init(&argc, &argv);
170 gtk_widget_show_all(window);
173 g_printerr("Must provide a game file\n");
177 if( !chimara_if_run_game(CHIMARA_IF(glk), argv[1], &error) ) {
178 g_printerr("Error starting Glk library: %s\n", error->message);
181 //chimara_glk_run( CHIMARA_GLK(glk), ".libs/multiwin.so", argc, argv, NULL);
183 iliad_init_toolbar();
189 chimara_glk_stop(CHIMARA_GLK(glk));
190 chimara_glk_wait(CHIMARA_GLK(glk));
192 iliad_clear_toolbar();