* On a second thought: rename client to player
authorrodin <rodin@ddfedd41-794f-dd11-ae45-00112f111e67>
Mon, 30 Nov 2009 13:25:39 +0000 (13:25 +0000)
committerrodin <rodin@ddfedd41-794f-dd11-ae45-00112f111e67>
Mon, 30 Nov 2009 13:25:39 +0000 (13:25 +0000)
 * Added the player to the RPM and DEB packages
 * Added out patch to Froz to the repository

25 files changed:
Makefile.am
chimara.spec.in
client/.svnignore [deleted file]
client/Makefile.am [deleted file]
client/callbacks.c [deleted file]
client/chimara.menus [deleted file]
client/chimara.ui [deleted file]
client/error.c [deleted file]
client/error.h [deleted file]
client/iliad.c [deleted file]
client/main.c [deleted file]
configure.ac
debian/control
debian/copyright
debian/libchimara-player.install [new file with mode: 0644]
interpreters/frotz.patch [new file with mode: 0644]
player/.svnignore [new file with mode: 0644]
player/Makefile.am [new file with mode: 0644]
player/callbacks.c [new file with mode: 0644]
player/chimara.menus [new file with mode: 0644]
player/chimara.ui [new file with mode: 0644]
player/error.c [new file with mode: 0644]
player/error.h [new file with mode: 0644]
player/iliad.c [new file with mode: 0644]
player/main.c [new file with mode: 0644]

index 2ce4185ca0c7f52af5269093b720fda3f400d69a..ac912e7a8bbbedaf0f35a433b24cfc2294d5d415 100644 (file)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 ## Created by Anjuta
 
-SUBDIRS = libchimara interpreters tests docs po
+SUBDIRS = libchimara interpreters tests docs po player
 
 chimaradocdir = ${prefix}/doc/chimara
 dist_chimaradoc_DATA = \
@@ -35,4 +35,4 @@ rpm:
        @$(ECHO) \
        "To build an RPM package, you must run configure with --enable-rpm."; \
        exit 1
-endif
\ No newline at end of file
+endif
index cd41347dc540bd2ef6f652ca492c4ac2ce78d33c..fbde4061811fcf5312e999cf36eb684d087642fa 100644 (file)
@@ -40,6 +40,15 @@ Requires:       %{name} = %{version}-%{release}
 The %{name}-devel package contains libraries and header files for
 developing applications that use %{name}.
 
+%package        player
+Summary:        The default IF player using %{name}
+Group:          Games
+Requires:       %{name} = %{version}-%{release}
+
+%description    player
+The %{name}-player package contains the default interactive fiction player using %{name}.
+developing applications that use %{name}.
+
 %prep
 %setup -q
 
@@ -77,6 +86,11 @@ rm -rf $RPM_BUILD_ROOT
 %{_includedir}/chimara/libchimara/*.h
 %{_libdir}/pkgconfig/*.pc
 
+%files player
+%{_bindir}/chimara
+
 %changelog
+* Mon Nov 30 2009 W. M. van Vliet <w.m.vanvliet@student.utwente.nl>
+- Added Chimara player to the package.
 * Wed Nov 25 2009 P. F. Chimento <philip.chimento@gmail.com>
 - Created specfile.
diff --git a/client/.svnignore b/client/.svnignore
deleted file mode 100644 (file)
index c413f5d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-chimara
-iliad
diff --git a/client/Makefile.am b/client/Makefile.am
deleted file mode 100644 (file)
index af25af5..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-AM_CFLAGS = -Wall
-AM_CPPFLAGS = -I$(top_srcdir)
-
-PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk_main$$"
-
-if TARGET_ILIAD
-
-chimara_iliad_SOURCES = iliad.c
-chimara_iliad_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS)
-chimara_iliad_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la
-
-bin_PROGRAMS = chimara_iliad
-
-else
-
-dist_data_DATA = chimara.ui chimara.menus 
-bin_PROGRAMS = chimara
-
-chimara_SOURCES = main.c callbacks.c error.c error.h
-chimara_CPPFLAGS = $(AM_CPPFLAGS) \
-       -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-       -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
-       -DPACKAGE_DATA_DIR=\""$(datadir)"\"
-chimara_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS)
-chimara_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la
-
-endif
diff --git a/client/callbacks.c b/client/callbacks.c
deleted file mode 100644 (file)
index 479a5ce..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
-/*
- * callbacks.c
- * Copyright (C) Philip en Marijn 2008 <>
- * 
- * callbacks.c is free software copyrighted by Philip en Marijn.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Philip en Marijn'' nor the name of any other
- *    contributor may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- * 
- * callbacks.c IS PROVIDED BY Philip en Marijn ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL Philip en Marijn OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <gdk/gdkkeysyms.h>
-#include <libchimara/chimara-glk.h>
-#include "error.h"
-
-void on_save(GtkAction *action, ChimaraGlk *glk) {
-       chimara_glk_feed_line_input(glk, "save");
-}
-
-void on_restore(GtkAction *action, ChimaraGlk *glk) {
-       chimara_glk_feed_line_input(glk, "restore");
-}
-
-gboolean on_window_delete_event(GtkWidget *widget, GdkEvent *event, ChimaraGlk *glk) {
-       gtk_main_quit();
-       return TRUE;
-}
-
-void on_quit(GtkAction *action, ChimaraGlk *glk) {
-       gtk_main_quit();
-}
diff --git a/client/chimara.menus b/client/chimara.menus
deleted file mode 100644 (file)
index e7ead1e..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0"?>
-<ui>
-  <menubar>
-    <menu action="game">
-      <menuitem action="open"/>
-      <menuitem action="restore"/>
-      <menuitem action="save"/>
-      <separator/>
-      <menuitem action="quit"/>
-    </menu>
-  </menubar>
-  <toolbar>
-    <toolitem action="open"/>
-    <toolitem action="restore"/>
-    <toolitem action="save"/>
-    <separator/>
-    <toolitem action="quit"/>
-  </toolbar>
-</ui>
diff --git a/client/chimara.ui b/client/chimara.ui
deleted file mode 100644 (file)
index 2519722..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0"?>
-<interface>
-  <!-- interface-requires gtk+ 2.12 -->
-  <!-- interface-naming-policy toplevel-contextual -->
-  <object class="GtkWindow" id="chimara">
-    <property name="title" translatable="yes">Chimara</property>
-    <property name="default_width">800</property>
-    <property name="default_height">800</property>
-    <signal name="delete_event" handler="on_window_delete_event"/>
-    <child>
-      <object class="GtkVBox" id="vbox">
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-    </child>
-  </object>
-  <object class="GtkActionGroup" id="actiongroup"/>
-  <object class="GtkAction" id="game">
-    <property name="label">_Game</property>
-  </object>
-  <object class="GtkAction" id="open">
-    <property name="label">_Open...</property>
-    <property name="short_label">_Open</property>
-    <property name="tooltip">Quit the current game and load a new one</property>
-    <property name="stock_id">gtk-media-play</property>
-  </object>
-  <object class="GtkAction" id="restore">
-    <property name="label">_Restore...</property>
-    <property name="short_label">_Restore</property>
-    <property name="tooltip">Restore a previously saved game</property>
-    <property name="stock_id">gtk-open</property>
-    <signal name="activate" handler="on_restore"/>
-  </object>
-  <object class="GtkAction" id="save">
-    <property name="label">_Save</property>
-    <property name="tooltip">Save the game</property>
-    <property name="stock_id">gtk-save</property>
-    <signal name="activate" handler="on_save"/>
-  </object>
-  <object class="GtkAction" id="quit">
-    <property name="label">_Quit</property>
-    <property name="tooltip">Exit Chimara</property>
-    <property name="stock_id">gtk-quit</property>
-    <signal name="activate" handler="on_quit"/>
-  </object>
-</interface>
diff --git a/client/error.c b/client/error.c
deleted file mode 100644 (file)
index c9b6f08..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*  Copyright 2006 P.F. Chimento
- *  This file is part of GNOME Inform 7.
- * 
- *  GNOME Inform 7 is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  GNOME Inform 7 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 General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GNOME Inform 7; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-#include <gtk/gtk.h>
-#include <stdarg.h>
-
-#include "error.h"
-
-/* Create and display an error dialog box, with parent window parent, and
-message format string msg. If err is not NULL, tack the error message on to the
-end of the format string. */
-void 
-error_dialog(GtkWindow *parent, GError *err, const gchar *msg, ...) 
-{
-    va_list ap;
-    
-    va_start(ap, msg);
-    gchar buffer[1024];
-    g_vsnprintf(buffer, 1024, msg, ap);
-    va_end(ap);
-    
-    gchar *message;
-    if(err) {
-        message = g_strconcat(buffer, err->message, NULL);
-        g_error_free(err);
-    } else
-        message = g_strdup(buffer);
-    
-    GtkWidget *dialog = gtk_message_dialog_new(parent,
-          parent? GTK_DIALOG_DESTROY_WITH_PARENT : 0,
-          GTK_MESSAGE_ERROR,
-          GTK_BUTTONS_OK,
-          message);
-    gtk_dialog_run(GTK_DIALOG(dialog));
-    gtk_widget_destroy(dialog);
-    g_free(message);
-}
diff --git a/client/error.h b/client/error.h
deleted file mode 100644 (file)
index bb05fbe..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*  Copyright 2006 P.F. Chimento
- *  This file is part of GNOME Inform 7.
- * 
- *  GNOME Inform 7 is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  GNOME Inform 7 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 General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GNOME Inform 7; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-#ifndef ERROR_H
-#define ERROR_H
-
-#include <stdarg.h>
-#include <gtk/gtk.h>
-
-void error_dialog(GtkWindow *parent, GError *err, const gchar *msg, ...);
-
-#endif
diff --git a/client/iliad.c b/client/iliad.c
deleted file mode 100644 (file)
index ee9d7f5..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
-/*
- * iliad.c
- * Copyright (C) Philip en Marijn 2008 <>
- * 
- * iliad.c is free software copyrighted by Philip en Marijn.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Philip en Marijn'' nor the name of any other
- *    contributor may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- * 
- * main.c IS PROVIDED BY Philip en Marijn ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL Philip en Marijn OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-
-#include "error.h"
-#include <libchimara/chimara-glk.h>
-#include <libchimara/chimara-if.h>
-
-/* Global pointers to widgets */
-GtkWidget *window = NULL;
-GtkWidget *glk = NULL;
-
-static void
-on_started(ChimaraGlk *glk)
-{
-    g_printerr("Started!\n");
-}
-
-static void
-on_stopped(ChimaraGlk *glk)
-{
-    g_printerr("Stopped!\n");
-}
-
-static void
-on_restore()
-{
-       chimara_glk_feed_line_input( CHIMARA_GLK(glk), "restore" );
-}
-
-static void
-on_save()
-{
-       chimara_glk_feed_line_input( CHIMARA_GLK(glk), "save" );
-}
-
-static void
-create_window(void)
-{
-       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-       glk = chimara_if_new();
-       //chimara_if_set_preferred_interpreter( CHIMARA_IF(glk), CHIMARA_IF_FORMAT_Z8, CHIMARA_IF_INTERPRETER_NITFOL);
-
-       gtk_widget_set_size_request(window, 800, 800);
-       g_object_set(glk, 
-               "border-width", 6, 
-               "spacing", 6,
-               "ignore-errors", TRUE,
-               NULL);
-       chimara_glk_set_default_font_string(CHIMARA_GLK(glk), "Serif 12");
-       chimara_glk_set_monospace_font_string(CHIMARA_GLK(glk), "Monospace 12");
-       g_signal_connect(glk, "started", G_CALLBACK(on_started), NULL);
-       g_signal_connect(glk, "stopped", G_CALLBACK(on_stopped), NULL);
-       
-       GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
-       GtkWidget *toolbar = gtk_toolbar_new();
-
-       GtkToolItem *restore_button = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
-       g_signal_connect(restore_button, "clicked", G_CALLBACK(on_restore), NULL);
-       gtk_toolbar_insert( GTK_TOOLBAR(toolbar), restore_button, 0 );
-
-       GtkToolItem *save_button = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
-       g_signal_connect(save_button, "clicked", G_CALLBACK(on_save), NULL);
-       gtk_toolbar_insert( GTK_TOOLBAR(toolbar), save_button, 0 );
-
-       GtkToolItem *quit_button = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
-       g_signal_connect(quit_button, "clicked", G_CALLBACK(gtk_main_quit), NULL);
-       gtk_toolbar_insert( GTK_TOOLBAR(toolbar), quit_button, 0 );
-
-       GtkWidget *spacer = gtk_vbox_new(FALSE, 0);
-       gtk_widget_set_size_request(spacer, -1, 250);
-
-       gtk_box_pack_start( GTK_BOX(vbox), toolbar, FALSE, FALSE, 0 );
-       gtk_box_pack_start( GTK_BOX(vbox), glk, TRUE, TRUE, 0 );
-       gtk_box_pack_end( GTK_BOX(vbox), spacer, FALSE, FALSE, 0 );
-
-       gtk_container_add( GTK_CONTAINER(window), vbox );
-}
-
-int
-main(int argc, char *argv[])
-{
-       GError *error = NULL;
-
-#ifdef ENABLE_NLS
-       bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
-       bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-       textdomain(GETTEXT_PACKAGE);
-#endif
-
-       if( !g_thread_supported() )
-               g_thread_init(NULL);
-       gdk_threads_init();
-       gtk_init(&argc, &argv);
-
-       create_window();
-       gtk_widget_show_all(window);
-
-       if(argc < 2) {
-               g_printerr("Must provide a game file\n");
-               return 1;
-       }
-       
-       if( !chimara_if_run_game(CHIMARA_IF(glk), argv[1], &error) ) {
-               g_printerr("Error starting Glk library: %s\n", error->message);
-               return 1;
-       }
-       //chimara_glk_run( CHIMARA_GLK(glk), ".libs/multiwin.so", argc, argv, NULL);
-
-
-       gdk_threads_enter();
-       gtk_main();
-       gdk_threads_leave();
-
-       chimara_glk_stop(CHIMARA_GLK(glk));
-       chimara_glk_wait(CHIMARA_GLK(glk));
-
-       return 0;
-}
diff --git a/client/main.c b/client/main.c
deleted file mode 100644 (file)
index b86badd..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
-/*
- * main.c
- * Copyright (C) Philip en Marijn 2008 <>
- * 
- * main.c is free software copyrighted by Philip en Marijn.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Philip en Marijn'' nor the name of any other
- *    contributor may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- * 
- * main.c IS PROVIDED BY Philip en Marijn ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL Philip en Marijn OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-
-#include "error.h"
-#include <libchimara/chimara-glk.h>
-#include <libchimara/chimara-if.h>
-
-/* Global pointers to widgets */
-GtkBuilder *builder = NULL;
-GtkUIManager *uimanager = NULL;
-GtkWidget *window = NULL;
-GtkWidget *glk = NULL;
-
-static GObject *
-load_object(const gchar *name)
-{
-       GObject *retval;
-       if( (retval = gtk_builder_get_object(builder, name)) == NULL) {
-               error_dialog(NULL, NULL, "Error while getting object '%s'", name);
-               g_error("Error while getting object '%s'", name);
-       }
-       return retval;
-}
-
-static void
-create_window(void)
-{
-       GError *error = NULL;
-
-       builder = gtk_builder_new();
-       if( !gtk_builder_add_from_file(builder, PACKAGE_SRC_DIR "/chimara.ui", &error) ) {
-               error_dialog(NULL, error, "Error while building interface: ");  
-               return;
-       }
-
-       window = GTK_WIDGET(load_object("chimara"));
-       GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup"));
-
-       /* Add all the actions to the action group. This for-loop is a temporary fix
-       and can be removed once Glade supports adding actions and accelerators to an
-       action group. */
-       const gchar *actions[] = { 
-               "game", "",
-               "open", "<ctrl>F7", 
-               "save", NULL, /* NULL means use stock accelerator */
-               "quit", NULL,
-               "hint", "",
-               "char_input", "",
-               "char_input2", "",
-               NULL
-       };
-       const gchar **ptr;
-       for(ptr = actions; *ptr; ptr += 2)
-               gtk_action_group_add_action_with_accel(actiongroup, GTK_ACTION(load_object(ptr[0])), ptr[1]);
-
-       uimanager = gtk_ui_manager_new();
-       if( !gtk_ui_manager_add_ui_from_file(uimanager, PACKAGE_SRC_DIR "/chimara.menus", &error) ) {
-               error_dialog(NULL, error, "Error while building interface: ");
-               return;
-       }
-       
-       glk = chimara_if_new();
-       //chimara_if_set_preferred_interpreter( CHIMARA_IF(glk), CHIMARA_IF_FORMAT_Z8, CHIMARA_IF_INTERPRETER_NITFOL);
-
-       g_object_set(glk, 
-               "border-width", 6, 
-               "spacing", 6,
-               "ignore-errors", TRUE,
-               NULL);
-       chimara_glk_set_default_font_string(CHIMARA_GLK(glk), "Serif 12");
-       chimara_glk_set_monospace_font_string(CHIMARA_GLK(glk), "Monospace 12");
-       
-       GtkBox *vbox = GTK_BOX( gtk_builder_get_object(builder, "vbox") );                      
-       if(vbox == NULL)
-       {
-               error_dialog(NULL, NULL, "Could not find vbox");
-               return;
-       }
-
-       gtk_ui_manager_insert_action_group(uimanager, actiongroup, 0);
-       GtkWidget *menubar = gtk_ui_manager_get_widget(uimanager, "/menubar");
-       GtkWidget *toolbar = gtk_ui_manager_get_widget(uimanager, "/toolbar");
-
-       gtk_box_pack_end(vbox, glk, TRUE, TRUE, 0);
-       gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 0);
-       gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0);
-       
-       gtk_builder_connect_signals(builder, glk);
-}
-
-int
-main(int argc, char *argv[])
-{
-       GError *error = NULL;
-
-#ifdef ENABLE_NLS
-       bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
-       bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-       textdomain(GETTEXT_PACKAGE);
-#endif
-
-       if( !g_thread_supported() )
-               g_thread_init(NULL);
-       gdk_threads_init();
-       gtk_init(&argc, &argv);
-
-       create_window();
-       gtk_widget_show_all(window);
-
-       g_object_unref( G_OBJECT(builder) );
-       g_object_unref( G_OBJECT(uimanager) );
-
-       if(argc < 2) {
-               error_dialog(GTK_WINDOW(window), NULL, "Must provide a game file");
-               return 1;
-       }
-       
-    if( !chimara_if_run_game(CHIMARA_IF(glk), argv[1], &error) ) {
-               error_dialog(GTK_WINDOW(window), error, "Error starting Glk library: ");
-               return 1;
-       }
-
-    gdk_threads_enter();
-       gtk_main();
-       gdk_threads_leave();
-
-       chimara_glk_stop(CHIMARA_GLK(glk));
-       chimara_glk_wait(CHIMARA_GLK(glk));
-
-       return 0;
-}
index 5b2501dcf6c836b4ad4be920a62142d4590e6457..787fef9f241a6d42f000f057182ea7383fe3ece8 100644 (file)
@@ -147,6 +147,7 @@ interpreters/nitfol/Makefile
 interpreters/glulxe/Makefile
 interpreters/git/Makefile
 tests/Makefile
+player/Makefile
 docs/Makefile
 docs/reference/Makefile
 docs/reference/version.xml
index 2cdf3079b25ea21270e97cf45a8029cdc3301262..8070f2472a62036b52b205d64fc6061b21215277 100644 (file)
@@ -46,4 +46,16 @@ Description: Documentation for the Chimara Glk library
  .
  This package contains the Chimara reference manual.
 
+Package: libchimara-player
+Section: games
+Architecture: any
+Depends: ${misc:Depends}
+         libchimara0 (= ${binary:Version}),
+         libglib2.0-dev,
+         libgtk2.0-dev
+Description: Interactive fiction player using the Chimara Glk library
+ Chimara is a GTK+ widget that loads and runs Glk programs as plugins. Glk is an
+ input/output specification specifically designed for interactive fiction.
+ .
+ This package contains a default interactive fiction player that uses Chimara.
 
index 0087586c013615825a95129d5b6bd26c9126ffcd..31b5d854bd5713af70bca02adcd145a2b72e640f 100644 (file)
@@ -5,7 +5,7 @@ It was downloaded from <url://example.com>
 
 Upstream Author(s):
 
-    Marijn van Vliet <whatever>
+    Marijn van Vliet <w.m.vanvliet@student.utwente.nl>
     Philip Chimento <philip.chimento@gmail.com>
 
 Copyright:
diff --git a/debian/libchimara-player.install b/debian/libchimara-player.install
new file mode 100644 (file)
index 0000000..0e4f65a
--- /dev/null
@@ -0,0 +1 @@
+debian/tmp/usr/bin/chimara
diff --git a/interpreters/frotz.patch b/interpreters/frotz.patch
new file mode 100644 (file)
index 0000000..a40dcec
--- /dev/null
@@ -0,0 +1,33 @@
+--- frotz/glkscreen.c  2009-11-14 17:44:15.617976131 +0100
++++ frotz/glkscreen.c.new      2009-11-14 17:44:10.367194781 +0100
+@@ -305,13 +305,6 @@
+                       return;
+       }
+-      if (gos_upper && gos_curwin == gos_upper) {
+-              if (cury > mach_status_ht) {
+-                      mach_status_ht = cury;
+-                      reset_status_ht();
+-              }
+-      }
+-
+       /* check fixed flag in header, game can change it at whim */
+       if (gos_curwin == gos_lower)
+       {
+@@ -583,8 +576,15 @@
+ {
+       cury = zargs[0];
+       curx = zargs[1];
+-      if (gos_upper)
++
++      if (gos_upper) {
++              if (cury > mach_status_ht) {
++                      mach_status_ht = cury;
++                      reset_status_ht();
++              }
++
+               glk_window_move_cursor(gos_upper, curx - 1, cury - 1);
++      }
+ }
+ /*
diff --git a/player/.svnignore b/player/.svnignore
new file mode 100644 (file)
index 0000000..c413f5d
--- /dev/null
@@ -0,0 +1,6 @@
+.deps
+.libs
+Makefile
+Makefile.in
+chimara
+iliad
diff --git a/player/Makefile.am b/player/Makefile.am
new file mode 100644 (file)
index 0000000..af25af5
--- /dev/null
@@ -0,0 +1,27 @@
+AM_CFLAGS = -Wall
+AM_CPPFLAGS = -I$(top_srcdir)
+
+PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk_main$$"
+
+if TARGET_ILIAD
+
+chimara_iliad_SOURCES = iliad.c
+chimara_iliad_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS)
+chimara_iliad_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la
+
+bin_PROGRAMS = chimara_iliad
+
+else
+
+dist_data_DATA = chimara.ui chimara.menus 
+bin_PROGRAMS = chimara
+
+chimara_SOURCES = main.c callbacks.c error.c error.h
+chimara_CPPFLAGS = $(AM_CPPFLAGS) \
+       -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+       -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
+       -DPACKAGE_DATA_DIR=\""$(datadir)"\"
+chimara_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS)
+chimara_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la
+
+endif
diff --git a/player/callbacks.c b/player/callbacks.c
new file mode 100644 (file)
index 0000000..479a5ce
--- /dev/null
@@ -0,0 +1,52 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * callbacks.c
+ * Copyright (C) Philip en Marijn 2008 <>
+ * 
+ * callbacks.c is free software copyrighted by Philip en Marijn.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Philip en Marijn'' nor the name of any other
+ *    contributor may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ * 
+ * callbacks.c IS PROVIDED BY Philip en Marijn ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL Philip en Marijn OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <gdk/gdkkeysyms.h>
+#include <libchimara/chimara-glk.h>
+#include "error.h"
+
+void on_save(GtkAction *action, ChimaraGlk *glk) {
+       chimara_glk_feed_line_input(glk, "save");
+}
+
+void on_restore(GtkAction *action, ChimaraGlk *glk) {
+       chimara_glk_feed_line_input(glk, "restore");
+}
+
+gboolean on_window_delete_event(GtkWidget *widget, GdkEvent *event, ChimaraGlk *glk) {
+       gtk_main_quit();
+       return TRUE;
+}
+
+void on_quit(GtkAction *action, ChimaraGlk *glk) {
+       gtk_main_quit();
+}
diff --git a/player/chimara.menus b/player/chimara.menus
new file mode 100644 (file)
index 0000000..e7ead1e
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<ui>
+  <menubar>
+    <menu action="game">
+      <menuitem action="open"/>
+      <menuitem action="restore"/>
+      <menuitem action="save"/>
+      <separator/>
+      <menuitem action="quit"/>
+    </menu>
+  </menubar>
+  <toolbar>
+    <toolitem action="open"/>
+    <toolitem action="restore"/>
+    <toolitem action="save"/>
+    <separator/>
+    <toolitem action="quit"/>
+  </toolbar>
+</ui>
diff --git a/player/chimara.ui b/player/chimara.ui
new file mode 100644 (file)
index 0000000..2519722
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="GtkWindow" id="chimara">
+    <property name="title" translatable="yes">Chimara</property>
+    <property name="default_width">800</property>
+    <property name="default_height">800</property>
+    <signal name="delete_event" handler="on_window_delete_event"/>
+    <child>
+      <object class="GtkVBox" id="vbox">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkActionGroup" id="actiongroup"/>
+  <object class="GtkAction" id="game">
+    <property name="label">_Game</property>
+  </object>
+  <object class="GtkAction" id="open">
+    <property name="label">_Open...</property>
+    <property name="short_label">_Open</property>
+    <property name="tooltip">Quit the current game and load a new one</property>
+    <property name="stock_id">gtk-media-play</property>
+  </object>
+  <object class="GtkAction" id="restore">
+    <property name="label">_Restore...</property>
+    <property name="short_label">_Restore</property>
+    <property name="tooltip">Restore a previously saved game</property>
+    <property name="stock_id">gtk-open</property>
+    <signal name="activate" handler="on_restore"/>
+  </object>
+  <object class="GtkAction" id="save">
+    <property name="label">_Save</property>
+    <property name="tooltip">Save the game</property>
+    <property name="stock_id">gtk-save</property>
+    <signal name="activate" handler="on_save"/>
+  </object>
+  <object class="GtkAction" id="quit">
+    <property name="label">_Quit</property>
+    <property name="tooltip">Exit Chimara</property>
+    <property name="stock_id">gtk-quit</property>
+    <signal name="activate" handler="on_quit"/>
+  </object>
+</interface>
diff --git a/player/error.c b/player/error.c
new file mode 100644 (file)
index 0000000..c9b6f08
--- /dev/null
@@ -0,0 +1,52 @@
+/*  Copyright 2006 P.F. Chimento
+ *  This file is part of GNOME Inform 7.
+ * 
+ *  GNOME Inform 7 is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GNOME Inform 7 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GNOME Inform 7; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#include <gtk/gtk.h>
+#include <stdarg.h>
+
+#include "error.h"
+
+/* Create and display an error dialog box, with parent window parent, and
+message format string msg. If err is not NULL, tack the error message on to the
+end of the format string. */
+void 
+error_dialog(GtkWindow *parent, GError *err, const gchar *msg, ...) 
+{
+    va_list ap;
+    
+    va_start(ap, msg);
+    gchar buffer[1024];
+    g_vsnprintf(buffer, 1024, msg, ap);
+    va_end(ap);
+    
+    gchar *message;
+    if(err) {
+        message = g_strconcat(buffer, err->message, NULL);
+        g_error_free(err);
+    } else
+        message = g_strdup(buffer);
+    
+    GtkWidget *dialog = gtk_message_dialog_new(parent,
+          parent? GTK_DIALOG_DESTROY_WITH_PARENT : 0,
+          GTK_MESSAGE_ERROR,
+          GTK_BUTTONS_OK,
+          message);
+    gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_widget_destroy(dialog);
+    g_free(message);
+}
diff --git a/player/error.h b/player/error.h
new file mode 100644 (file)
index 0000000..bb05fbe
--- /dev/null
@@ -0,0 +1,27 @@
+/*  Copyright 2006 P.F. Chimento
+ *  This file is part of GNOME Inform 7.
+ * 
+ *  GNOME Inform 7 is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GNOME Inform 7 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GNOME Inform 7; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#ifndef ERROR_H
+#define ERROR_H
+
+#include <stdarg.h>
+#include <gtk/gtk.h>
+
+void error_dialog(GtkWindow *parent, GError *err, const gchar *msg, ...);
+
+#endif
diff --git a/player/iliad.c b/player/iliad.c
new file mode 100644 (file)
index 0000000..ee9d7f5
--- /dev/null
@@ -0,0 +1,157 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * iliad.c
+ * Copyright (C) Philip en Marijn 2008 <>
+ * 
+ * iliad.c is free software copyrighted by Philip en Marijn.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Philip en Marijn'' nor the name of any other
+ *    contributor may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ * 
+ * main.c IS PROVIDED BY Philip en Marijn ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL Philip en Marijn OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "error.h"
+#include <libchimara/chimara-glk.h>
+#include <libchimara/chimara-if.h>
+
+/* Global pointers to widgets */
+GtkWidget *window = NULL;
+GtkWidget *glk = NULL;
+
+static void
+on_started(ChimaraGlk *glk)
+{
+    g_printerr("Started!\n");
+}
+
+static void
+on_stopped(ChimaraGlk *glk)
+{
+    g_printerr("Stopped!\n");
+}
+
+static void
+on_restore()
+{
+       chimara_glk_feed_line_input( CHIMARA_GLK(glk), "restore" );
+}
+
+static void
+on_save()
+{
+       chimara_glk_feed_line_input( CHIMARA_GLK(glk), "save" );
+}
+
+static void
+create_window(void)
+{
+       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       glk = chimara_if_new();
+       //chimara_if_set_preferred_interpreter( CHIMARA_IF(glk), CHIMARA_IF_FORMAT_Z8, CHIMARA_IF_INTERPRETER_NITFOL);
+
+       gtk_widget_set_size_request(window, 800, 800);
+       g_object_set(glk, 
+               "border-width", 6, 
+               "spacing", 6,
+               "ignore-errors", TRUE,
+               NULL);
+       chimara_glk_set_default_font_string(CHIMARA_GLK(glk), "Serif 12");
+       chimara_glk_set_monospace_font_string(CHIMARA_GLK(glk), "Monospace 12");
+       g_signal_connect(glk, "started", G_CALLBACK(on_started), NULL);
+       g_signal_connect(glk, "stopped", G_CALLBACK(on_stopped), NULL);
+       
+       GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
+       GtkWidget *toolbar = gtk_toolbar_new();
+
+       GtkToolItem *restore_button = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
+       g_signal_connect(restore_button, "clicked", G_CALLBACK(on_restore), NULL);
+       gtk_toolbar_insert( GTK_TOOLBAR(toolbar), restore_button, 0 );
+
+       GtkToolItem *save_button = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
+       g_signal_connect(save_button, "clicked", G_CALLBACK(on_save), NULL);
+       gtk_toolbar_insert( GTK_TOOLBAR(toolbar), save_button, 0 );
+
+       GtkToolItem *quit_button = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
+       g_signal_connect(quit_button, "clicked", G_CALLBACK(gtk_main_quit), NULL);
+       gtk_toolbar_insert( GTK_TOOLBAR(toolbar), quit_button, 0 );
+
+       GtkWidget *spacer = gtk_vbox_new(FALSE, 0);
+       gtk_widget_set_size_request(spacer, -1, 250);
+
+       gtk_box_pack_start( GTK_BOX(vbox), toolbar, FALSE, FALSE, 0 );
+       gtk_box_pack_start( GTK_BOX(vbox), glk, TRUE, TRUE, 0 );
+       gtk_box_pack_end( GTK_BOX(vbox), spacer, FALSE, FALSE, 0 );
+
+       gtk_container_add( GTK_CONTAINER(window), vbox );
+}
+
+int
+main(int argc, char *argv[])
+{
+       GError *error = NULL;
+
+#ifdef ENABLE_NLS
+       bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+       bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+       textdomain(GETTEXT_PACKAGE);
+#endif
+
+       if( !g_thread_supported() )
+               g_thread_init(NULL);
+       gdk_threads_init();
+       gtk_init(&argc, &argv);
+
+       create_window();
+       gtk_widget_show_all(window);
+
+       if(argc < 2) {
+               g_printerr("Must provide a game file\n");
+               return 1;
+       }
+       
+       if( !chimara_if_run_game(CHIMARA_IF(glk), argv[1], &error) ) {
+               g_printerr("Error starting Glk library: %s\n", error->message);
+               return 1;
+       }
+       //chimara_glk_run( CHIMARA_GLK(glk), ".libs/multiwin.so", argc, argv, NULL);
+
+
+       gdk_threads_enter();
+       gtk_main();
+       gdk_threads_leave();
+
+       chimara_glk_stop(CHIMARA_GLK(glk));
+       chimara_glk_wait(CHIMARA_GLK(glk));
+
+       return 0;
+}
diff --git a/player/main.c b/player/main.c
new file mode 100644 (file)
index 0000000..b86badd
--- /dev/null
@@ -0,0 +1,170 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * main.c
+ * Copyright (C) Philip en Marijn 2008 <>
+ * 
+ * main.c is free software copyrighted by Philip en Marijn.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Philip en Marijn'' nor the name of any other
+ *    contributor may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ * 
+ * main.c IS PROVIDED BY Philip en Marijn ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL Philip en Marijn OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "error.h"
+#include <libchimara/chimara-glk.h>
+#include <libchimara/chimara-if.h>
+
+/* Global pointers to widgets */
+GtkBuilder *builder = NULL;
+GtkUIManager *uimanager = NULL;
+GtkWidget *window = NULL;
+GtkWidget *glk = NULL;
+
+static GObject *
+load_object(const gchar *name)
+{
+       GObject *retval;
+       if( (retval = gtk_builder_get_object(builder, name)) == NULL) {
+               error_dialog(NULL, NULL, "Error while getting object '%s'", name);
+               g_error("Error while getting object '%s'", name);
+       }
+       return retval;
+}
+
+static void
+create_window(void)
+{
+       GError *error = NULL;
+
+       builder = gtk_builder_new();
+       if( !gtk_builder_add_from_file(builder, PACKAGE_SRC_DIR "/chimara.ui", &error) ) {
+               error_dialog(NULL, error, "Error while building interface: ");  
+               return;
+       }
+
+       window = GTK_WIDGET(load_object("chimara"));
+       GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup"));
+
+       /* Add all the actions to the action group. This for-loop is a temporary fix
+       and can be removed once Glade supports adding actions and accelerators to an
+       action group. */
+       const gchar *actions[] = { 
+               "game", "",
+               "open", "<ctrl>F7", 
+               "save", NULL, /* NULL means use stock accelerator */
+               "quit", NULL,
+               "hint", "",
+               "char_input", "",
+               "char_input2", "",
+               NULL
+       };
+       const gchar **ptr;
+       for(ptr = actions; *ptr; ptr += 2)
+               gtk_action_group_add_action_with_accel(actiongroup, GTK_ACTION(load_object(ptr[0])), ptr[1]);
+
+       uimanager = gtk_ui_manager_new();
+       if( !gtk_ui_manager_add_ui_from_file(uimanager, PACKAGE_SRC_DIR "/chimara.menus", &error) ) {
+               error_dialog(NULL, error, "Error while building interface: ");
+               return;
+       }
+       
+       glk = chimara_if_new();
+       //chimara_if_set_preferred_interpreter( CHIMARA_IF(glk), CHIMARA_IF_FORMAT_Z8, CHIMARA_IF_INTERPRETER_NITFOL);
+
+       g_object_set(glk, 
+               "border-width", 6, 
+               "spacing", 6,
+               "ignore-errors", TRUE,
+               NULL);
+       chimara_glk_set_default_font_string(CHIMARA_GLK(glk), "Serif 12");
+       chimara_glk_set_monospace_font_string(CHIMARA_GLK(glk), "Monospace 12");
+       
+       GtkBox *vbox = GTK_BOX( gtk_builder_get_object(builder, "vbox") );                      
+       if(vbox == NULL)
+       {
+               error_dialog(NULL, NULL, "Could not find vbox");
+               return;
+       }
+
+       gtk_ui_manager_insert_action_group(uimanager, actiongroup, 0);
+       GtkWidget *menubar = gtk_ui_manager_get_widget(uimanager, "/menubar");
+       GtkWidget *toolbar = gtk_ui_manager_get_widget(uimanager, "/toolbar");
+
+       gtk_box_pack_end(vbox, glk, TRUE, TRUE, 0);
+       gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 0);
+       gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0);
+       
+       gtk_builder_connect_signals(builder, glk);
+}
+
+int
+main(int argc, char *argv[])
+{
+       GError *error = NULL;
+
+#ifdef ENABLE_NLS
+       bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+       bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+       textdomain(GETTEXT_PACKAGE);
+#endif
+
+       if( !g_thread_supported() )
+               g_thread_init(NULL);
+       gdk_threads_init();
+       gtk_init(&argc, &argv);
+
+       create_window();
+       gtk_widget_show_all(window);
+
+       g_object_unref( G_OBJECT(builder) );
+       g_object_unref( G_OBJECT(uimanager) );
+
+       if(argc < 2) {
+               error_dialog(GTK_WINDOW(window), NULL, "Must provide a game file");
+               return 1;
+       }
+       
+    if( !chimara_if_run_game(CHIMARA_IF(glk), argv[1], &error) ) {
+               error_dialog(GTK_WINDOW(window), error, "Error starting Glk library: ");
+               return 1;
+       }
+
+    gdk_threads_enter();
+       gtk_main();
+       gdk_threads_leave();
+
+       chimara_glk_stop(CHIMARA_GLK(glk));
+       chimara_glk_wait(CHIMARA_GLK(glk));
+
+       return 0;
+}