From 40cf50b43f824311d7f14893ed1193bb5642741a Mon Sep 17 00:00:00 2001 From: rodin Date: Sun, 18 Apr 2010 14:04:40 +0000 Subject: [PATCH] Iliad port --- Makefile.am | 4 ++++ configure.ac | 4 ++-- interpreters/frotz/Makefile.am | 10 +++++++++- libchimara/Makefile.am | 8 +++++++- libchimara/abort.c | 8 +++++++- libchimara/chimara-glk.c | 17 ++++++++++++++--- libchimara/chimara-if.c | 9 ++++++++- libchimara/fileref.c | 4 ++++ libchimara/input.c | 4 ++++ libchimara/pager.c | 5 +++++ player/iliad.c | 28 +++++++++++++++++++++++++++- tests/styletest.c | 2 +- 12 files changed, 92 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 445af84..9cac9d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,11 @@ ## Process this file with automake to produce Makefile.in ## Created by Anjuta +if TARGET_ILIAD +SUBDIRS = libchimara interpreters player po +else SUBDIRS = libchimara interpreters player tests docs po +endif chimaradocdir = $(datadir)/doc/chimara dist_chimaradoc_DATA = \ diff --git a/configure.ac b/configure.ac index 9b0ebb0..18e630a 100644 --- a/configure.ac +++ b/configure.ac @@ -25,8 +25,8 @@ LT_VERSION_INFO="$CHIMARA_CURRENT:$CHIMARA_REVISION:$CHIMARA_AGE" AC_SUBST(LT_VERSION_INFO) ### REQUIREMENTS ############################################################## -GTK_REQUIRED_VERSION=2.12 -GLIB_REQUIRED_VERSION=2.16 +GTK_REQUIRED_VERSION=2.6 +GLIB_REQUIRED_VERSION=2.6 GTK_DOC_REQUIRED_VERSION=1.9 AC_SUBST(GTK_REQUIRED_VERSION) AC_SUBST(GLIB_REQUIRED_VERSION) diff --git a/interpreters/frotz/Makefile.am b/interpreters/frotz/Makefile.am index f1a0100..f72505c 100644 --- a/interpreters/frotz/Makefile.am +++ b/interpreters/frotz/Makefile.am @@ -3,7 +3,15 @@ frotz_la_SOURCES = buffer.c err.c fastmem.c files.c input.c main.c math.c \ object.c process.c quetzal.c random.c redirect.c sound.c stream.c table.c \ text.c variable.c glkscreen.c glkmisc.c frotz.h glkfrotz.h glkio.h setup.h frotz_la_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/libchimara -frotz_la_CFLAGS = -Wno-pointer-sign $(AM_CFLAGS) + +if TARGET_ILIAD +no_pointer_sign = +else +no_pointer_sign = -Wno-pointer-sign +endif + +frotz_la_CFLAGS = $(no_pointer_sign) $(AM_CFLAGS) + frotz_la_LDFLAGS = -module $(PLUGIN_LIBTOOL_FLAGS) frotzdocdir = $(datadir)/doc/$(PACKAGE)/frotz diff --git a/libchimara/Makefile.am b/libchimara/Makefile.am index 5fb89bf..ff634e4 100644 --- a/libchimara/Makefile.am +++ b/libchimara/Makefile.am @@ -4,6 +4,12 @@ AM_CFLAGS = -Wall lib_LTLIBRARIES = libchimara.la +if TARGET_ILIAD + plugindir = "../interpreters" +else + plugindir = $(pkglibdir) +endif + libchimara_la_SOURCES = \ abort.c abort.h \ case.c \ @@ -38,7 +44,7 @@ libchimara_la_SOURCES = \ libchimara_la_CPPFLAGS = \ -DG_LOG_DOMAIN=\"Chimara\" \ -DLOCALEDIR=\""$(datadir)/locale"\" \ - -DPLUGINDIR=\""$(pkglibdir)"\" \ + -DPLUGINDIR=\""$(plugindir)"\" \ -DPLUGINSOURCEDIR=\""$(abs_builddir)/../interpreters"\" \ -I$(top_srcdir) libchimara_la_CFLAGS = @CHIMARA_CFLAGS@ $(AM_CFLAGS) diff --git a/libchimara/abort.c b/libchimara/abort.c index 28e33fa..8eb21da 100644 --- a/libchimara/abort.c +++ b/libchimara/abort.c @@ -143,7 +143,13 @@ shutdown_glk_post(void) /* Empty the event queue */ g_mutex_lock(glk_data->event_lock); g_queue_foreach(glk_data->event_queue, (GFunc)g_free, NULL); - g_queue_clear(glk_data->event_queue); + + /* COMPAT: g_queue_clear could be used here, but only appeared in 2.14 */ + // g_queue_clear(glk_data->event_queue); + g_list_free(glk_data->event_queue->head); + glk_data->event_queue->head = glk_data->event_queue->tail = NULL; + glk_data->event_queue->length = 0; + g_mutex_unlock(glk_data->event_lock); /* Reset the abort signaling mechanism */ diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 982b39f..e585165 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -617,9 +617,16 @@ chimara_glk_text_buffer_output(ChimaraGlk *self, guint window_rock, gchar *text) /* Default signal handler */ } -/* G_PARAM_STATIC_STRINGS only appeared in GTK 2.13.0 */ +/* COMPAT: G_PARAM_STATIC_STRINGS only appeared in GTK 2.13.0 */ #ifndef G_PARAM_STATIC_STRINGS + +/* COMPAT: G_PARAM_STATIC_NAME and friends only appeared in GTK 2.8 */ +#if GTK_CHECK_VERSION(2,8,0) #define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) +#else +#define G_PARAM_STATIC_STRINGS (0) +#endif + #endif static void @@ -1107,7 +1114,9 @@ glk_enter(struct StartupData *startup) /* Run main function */ glk_main_t glk_main = startup->glk_main; - g_slice_free(struct StartupData, startup); + + /* COMPAT: avoid usage of slices */ + g_free(startup); g_signal_emit_by_name(startup->glk_data->self, "started"); glk_main(); glk_exit(); /* Run shutdown code in glk_exit() even if glk_main() returns normally */ @@ -1146,7 +1155,9 @@ chimara_glk_run(ChimaraGlk *glk, const gchar *plugin, int argc, char *argv[], GE } ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); - struct StartupData *startup = g_slice_new0(struct StartupData); + + /* COMPAT: avoid usage of slices */ + struct StartupData *startup = g_new0(struct StartupData,1); /* Open the module to run */ g_assert( g_module_supported() ); diff --git a/libchimara/chimara-if.c b/libchimara/chimara-if.c index c7e4575..be9fc20 100644 --- a/libchimara/chimara-if.c +++ b/libchimara/chimara-if.c @@ -248,9 +248,16 @@ chimara_if_command(ChimaraIF *self, gchar *input, gchar *response) /* Default signal handler */ } -/* G_PARAM_STATIC_STRINGS only appeared in GTK 2.13.0 */ +/* COMPAT: G_PARAM_STATIC_STRINGS only appeared in GTK 2.13.0 */ #ifndef G_PARAM_STATIC_STRINGS + +/* COMPAT: G_PARAM_STATIC_NAME and friends only appeared in GTK 2.8 */ +#if GTK_CHECK_VERSION(2,8,0) #define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) +#else +#define G_PARAM_STATIC_STRINGS (0) +#endif + #endif static void diff --git a/libchimara/fileref.c b/libchimara/fileref.c index 937933c..d0cee08 100644 --- a/libchimara/fileref.c +++ b/libchimara/fileref.c @@ -233,7 +233,11 @@ glk_fileref_create_by_prompt(glui32 usage, glui32 fmode, glui32 rock) GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_action(GTK_FILE_CHOOSER(chooser), GTK_FILE_CHOOSER_ACTION_SAVE); + + /* COMPAT: */ +#if GTK_CHECK_VERSION(2,8,0) gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(chooser), TRUE); +#endif break; case filemode_ReadWrite: case filemode_WriteAppend: diff --git a/libchimara/input.c b/libchimara/input.c index ddc41d8..8b6d4c2 100644 --- a/libchimara/input.c +++ b/libchimara/input.c @@ -127,7 +127,11 @@ text_grid_request_line_event_common(winid_t win, glui32 maxlen, gboolean insert, /* Make the entry as small as possible to fit with the text */ gtk_entry_set_has_frame(GTK_ENTRY(win->input_entry), FALSE); GtkBorder border = { 0, 0, 0, 0 }; + + /* COMPAT: */ +#if GTK_CHECK_VERSION(2,10,0) gtk_entry_set_inner_border(GTK_ENTRY(win->input_entry), &border); +#endif gtk_entry_set_max_length(GTK_ENTRY(win->input_entry), win->input_length); gtk_entry_set_width_chars(GTK_ENTRY(win->input_entry), win->input_length); diff --git a/libchimara/pager.c b/libchimara/pager.c index e00daf9..1fdbf46 100644 --- a/libchimara/pager.c +++ b/libchimara/pager.c @@ -75,7 +75,12 @@ pager_after_size_allocate(GtkTextView *view, GtkAllocation *allocation, winid_t if(scroll_distance > view_height) { start_paging(win); /* Seriously... */ + /* COMPAT: */ +#if GTK_CHECK_VERSION(2,14,0) gdk_window_invalidate_rect(gtk_widget_get_window(win->widget), NULL, TRUE); +#else + gdk_window_invalidate_rect(win->widget->window, NULL, TRUE); +#endif } else if(scroll_distance > 0) { GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(win->widget)); diff --git a/player/iliad.c b/player/iliad.c index ee9d7f5..6433e82 100644 --- a/player/iliad.c +++ b/player/iliad.c @@ -44,10 +44,19 @@ #include #include +/* Iliad includes */ +#include +#include +#include +#include + /* Global pointers to widgets */ GtkWidget *window = NULL; GtkWidget *glk = NULL; +static erClientChannel_t erbusyChannel; +static erClientChannel_t ertoolbarChannel; + static void on_started(ChimaraGlk *glk) { @@ -115,6 +124,22 @@ create_window(void) gtk_container_add( GTK_CONTAINER(window), vbox ); } +static void +iliad_popup_keyboard() +{ + erIpcStartClient(ER_TOOLBAR_CHANNEL, &ertoolbarChannel); + tbSelectIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID); + tbClearIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID); + + // Turn off trashcan + tbAppendPlatformIcon( ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_trashcan, -1); + tbSetStatePlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_trashcan, iconState_grey ); + + // Enable then pop up keyboard + tbAppendPlatformIcon( ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_keyboard, -1); + tbSetStatePlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_keyboard, iconState_selected); +} + int main(int argc, char *argv[]) { @@ -144,7 +169,8 @@ main(int argc, char *argv[]) return 1; } //chimara_glk_run( CHIMARA_GLK(glk), ".libs/multiwin.so", argc, argv, NULL); - + + iliad_popup_keyboard(); gdk_threads_enter(); gtk_main(); diff --git a/tests/styletest.c b/tests/styletest.c index 0ed73cc..7b976d0 100644 --- a/tests/styletest.c +++ b/tests/styletest.c @@ -28,7 +28,7 @@ void glk_main(void) assert(buffer); glk_put_string("Welcome to the style test\n"); - + glk_put_string("int finish_text_grid_line_input(winid_t win, gboolean\n 11 static void cancel_old_input_request(winid_t win);\n 12 \n 13 /* Internal function: code common to both flavors of char ev\n 14 void\n 15 request_char_event_common(winid_t win, gboolean unicode)\n 16 {\n 17 VALID_WINDOW(win, return);\n 18 g_return_if_fail(win->type != wintype_TextBuffer || win-\n 19 \n 20 cancel_old_input_request(win);\n 21 \n 22 flush_window_buffer(win);\n 23 \n 24 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key\n 25 \n 26 win->input_request_type = unicode? INPUT_REQUEST_CHARACT\n 27 g_signal_handler_unblock( win->widget, win->char_input_k\n 28 \n 29 gdk_threads_enter();\n 30 \n 31 /*\n 32 if(win->type == wintype_TextBuffer)\n 33 {\n 34 GtkTextBuffer *buffer = gtk_text_view_get_buffer( GT\n 35 GtkTextIter iter;\n 36 gtk_text_buffer_get_end_iter(buffer, &iter);\n 37 gtk_text_buffer_place_cursor(buffer, &iter);\n 38 gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(win\n 39 // Why doesn't this always work?? \n 40 } */\n 41 \n 42 gtk_widget_grab_focus( GTK_WIDGET(win->widget) );\n 43 gdk_threads_leave();\n 44 \n 47 }\n 48 \n 49 /**\n 50 * glk_request_char_event:\n 51 * @win: A window to request char events from.\n 52 *\n 53 * Request input of a Latin-1 character or special key. A wi\n 54 * requests for both character and line input at the same ti\n 55 * requests for character input of both types (Latin-1 and U\n 56 * illegal to call glk_request_char_event() if the window al\n 57 * request for either character or\n"); glk_request_line_event(mainwin, buffer, 255, 0); while(strncmp(buffer, "quit", 4)) { -- 2.30.2