X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fchimara-glk.h;h=953f84ee0eddd6f63b2af2fa0e89090708435ba0;hb=17743f862a0295c3b9bdead66d05a74deaddea0e;hp=8713efe46ef2887c6ba4f2791bd5413d84d2d954;hpb=5f15de94ee255dd55c3e2916a3387bdb158d3a80;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/chimara-glk.h b/libchimara/chimara-glk.h index 8713efe..953f84e 100644 --- a/libchimara/chimara-glk.h +++ b/libchimara/chimara-glk.h @@ -21,53 +21,87 @@ G_BEGIN_DECLS * * This structure contains no public members. */ -typedef struct _ChimaraGlk { +typedef struct { GtkContainer parent_instance; /*< public >*/ } ChimaraGlk; -typedef struct _ChimaraGlkClass { +typedef struct { GtkContainerClass parent_class; /* Signals */ void(* stopped) (ChimaraGlk *self); void(* started) (ChimaraGlk *self); void(* waiting) (ChimaraGlk *self); - void(* char_input) (ChimaraGlk *self, guint32 window_rock, guint keysym); - void(* line_input) (ChimaraGlk *self, guint32 window_rock, gchar *text); - void(* text_buffer_output) (ChimaraGlk *self, guint32 window_rock, gchar *text); + void(* char_input) (ChimaraGlk *self, guint32 window_rock, char *string_id, unsigned keysym); + void(* line_input) (ChimaraGlk *self, guint32 window_rock, char *string_id, char *text); + void(* text_buffer_output) (ChimaraGlk *self, guint32 window_rock, char *string_id, char *text); + void(* iliad_screen_update) (ChimaraGlk *self, gboolean typing); } ChimaraGlkClass; +/** + * ChimaraGlkWindowType: + * @CHIMARA_GLK_TEXT_BUFFER: The styles for text buffer windows. + * @CHIMARA_GLK_TEXT_GRID: The styles for text grid windows. + * + * Specifies the type of windows for which to retrieve the style tag with + * chimara_glk_get_tag(). + */ +typedef enum { + CHIMARA_GLK_TEXT_BUFFER, + CHIMARA_GLK_TEXT_GRID +} ChimaraGlkWindowType; + /** * ChimaraError: + * @CHIMARA_LOAD_MODULE_ERROR: There was an error opening the plugin containing + * the Glk program. The error message from g_module_error() is appended to the GError message. + * @CHIMARA_NO_GLK_MAIN: The plugin containing the Glk program did not export a + * glk_main() function. + * @CHIMARA_PLUGIN_NOT_FOUND: An appropriate interpreter plugin for the + * autodetected game file type could not be found. + * @CHIMARA_PLUGIN_ALREADY_RUNNING: A plugin was opened while there was already + * another plugin running in the widget. * * Error codes returned by #ChimaraGlk widgets and subclasses. - * - * - * CHIMARA_LOAD_MODULE_ERROR - * There was an error opening the plugin containing the Glk - * program. The error message from g_module_error() is appended to the GError message. - * - * - * CHIMARA_NO_GLK_MAIN - * The plugin containing the Glk program did not export a - * glk_main() function. - * - * - * CHIMARA_PLUGIN_NOT_FOUND - * An appropriate interpreter plugin for the autodetected - * game file type could not be found. - * - * */ typedef enum _ChimaraError { CHIMARA_LOAD_MODULE_ERROR, CHIMARA_NO_GLK_MAIN, - CHIMARA_PLUGIN_NOT_FOUND + CHIMARA_PLUGIN_NOT_FOUND, + CHIMARA_PLUGIN_ALREADY_RUNNING } ChimaraError; +/** + * ChimaraResourceType: + * @CHIMARA_RESOURCE_SOUND: A sound file. + * @CHIMARA_RESOURCE_IMAGE: An image file. + * + * The type of resource that the Glk program is requesting, passed to a + * #ChimaraResourceLoadFunc. + */ +typedef enum _ChimaraResourceType { + CHIMARA_RESOURCE_SOUND, + CHIMARA_RESOURCE_IMAGE +} ChimaraResourceType; + +/** + * ChimaraResourceLoadFunc: + * @usage: A #ChimaraResourceType constant. + * @resnum: The resource number to look for. + * @user_data: A pointer to provide to the callback. + * + * The type of function passed to chimara_glk_set_resource_load_callback(). It + * takes a #ChimaraResourceType constant, @usage, to indicate what sort of + * resource to look for; @resnum is the resource number to look for, and + * @user_data is the user data provided along with the callback. The function + * must return an allocated string containing the filename where the resource + * can be found. + */ +typedef gchar * (*ChimaraResourceLoadFunc)(ChimaraResourceType usage, guint32 resnum, gpointer user_data); + /** * CHIMARA_ERROR: * @@ -82,21 +116,25 @@ void chimara_glk_set_interactive(ChimaraGlk *glk, gboolean interactive); gboolean chimara_glk_get_interactive(ChimaraGlk *glk); void chimara_glk_set_protect(ChimaraGlk *glk, gboolean protect); gboolean chimara_glk_get_protect(ChimaraGlk *glk); -void chimara_glk_set_default_font_description(ChimaraGlk *glk, PangoFontDescription *font); -void chimara_glk_set_default_font_string(ChimaraGlk *glk, const gchar *font); -PangoFontDescription *chimara_glk_get_default_font_description(ChimaraGlk *glk); -void chimara_glk_set_monospace_font_description(ChimaraGlk *glk, PangoFontDescription *font); -void chimara_glk_set_monospace_font_string(ChimaraGlk *glk, const gchar *font); -PangoFontDescription *chimara_glk_get_monospace_font_description(ChimaraGlk *glk); +void chimara_glk_set_css_to_default(ChimaraGlk *glk); +gboolean chimara_glk_set_css_from_file(ChimaraGlk *glk, const gchar *filename, GError **error); +void chimara_glk_set_css_from_string(ChimaraGlk *glk, const gchar *css); void chimara_glk_set_spacing(ChimaraGlk *glk, guint spacing); guint chimara_glk_get_spacing(ChimaraGlk *glk); gboolean chimara_glk_run(ChimaraGlk *glk, const gchar *plugin, int argc, char *argv[], GError **error); +gboolean chimara_glk_run_file(ChimaraGlk *self, GFile *plugin_file, int argc, char *argv[], GError **error); void chimara_glk_stop(ChimaraGlk *glk); void chimara_glk_wait(ChimaraGlk *glk); +void chimara_glk_unload_plugin(ChimaraGlk *glk); gboolean chimara_glk_get_running(ChimaraGlk *glk); -void chimara_glk_feed_char_input(ChimaraGlk *glk, guint32 keycode); +void chimara_glk_feed_char_input(ChimaraGlk *glk, guint32 keyval); void chimara_glk_feed_line_input(ChimaraGlk *glk, const gchar *text); -void chimara_glk_reset(ChimaraGlk *self); +gboolean chimara_glk_is_char_input_pending(ChimaraGlk *glk); +gboolean chimara_glk_is_line_input_pending(ChimaraGlk *glk); +GtkTextTag *chimara_glk_get_tag(ChimaraGlk *glk, ChimaraGlkWindowType window, const gchar *name); +const gchar **chimara_glk_get_tag_names(ChimaraGlk *glk, unsigned int *num_tags); +void chimara_glk_update_style(ChimaraGlk *glk); +void chimara_glk_set_resource_load_callback(ChimaraGlk *glk, ChimaraResourceLoadFunc func, gpointer user_data, GDestroyNotify destroy_user_data); G_END_DECLS