1 /* Copyright / licensing information here. */
3 #ifndef __CHIMARA_GLK_H__
4 #define __CHIMARA_GLK_H__
8 #include <pango/pango.h>
12 #define CHIMARA_TYPE_GLK (chimara_glk_get_type())
13 #define CHIMARA_GLK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CHIMARA_TYPE_GLK, ChimaraGlk))
14 #define CHIMARA_GLK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CHIMARA_TYPE_GLK, ChimaraGlkClass))
15 #define CHIMARA_IS_GLK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CHIMARA_TYPE_GLK))
16 #define CHIMARA_IS_GLK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), CHIMARA_TYPE_GLK))
17 #define CHIMARA_GLK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHIMARA_TYPE_GLK, ChimaraGlkClass))
22 * This structure contains no public members.
24 typedef struct _ChimaraGlk {
25 GtkContainer parent_instance;
30 typedef struct _ChimaraGlkClass {
31 GtkContainerClass parent_class;
33 void(* stopped) (ChimaraGlk *self);
34 void(* started) (ChimaraGlk *self);
35 void(* waiting) (ChimaraGlk *self);
36 void(* char_input) (ChimaraGlk *self, guint32 window_rock, guint keysym);
37 void(* line_input) (ChimaraGlk *self, guint32 window_rock, gchar *text);
38 void(* text_buffer_output) (ChimaraGlk *self, guint32 window_rock, gchar *text);
39 void(* iliad_screen_update) (ChimaraGlk *self, gboolean typing);
43 * ChimaraGlkWindowType:
44 * @CHIMARA_GLK_TEXT_BUFFER: The styles for text buffer windows.
45 * @CHIMARA_GLK_TEXT_GRID: The styles for text grid windows.
47 * Specifies the type of windows for which to retrieve the style tag with
48 * chimara_glk_get_tag().
51 CHIMARA_GLK_TEXT_BUFFER,
53 } ChimaraGlkWindowType;
57 * @CHIMARA_LOAD_MODULE_ERROR: There was an error opening the plugin containing
58 * the Glk program. The error message from <link
59 * linkend="g-module-error">g_module_error()</link> is appended to the <link
60 * linkend="GError">GError</link> message.
61 * @CHIMARA_NO_GLK_MAIN: The plugin containing the Glk program did not export a
62 * glk_main() function.
63 * @CHIMARA_PLUGIN_NOT_FOUND: An appropriate interpreter plugin for the
64 * autodetected game file type could not be found.
65 * @CHIMARA_PLUGIN_ALREADY_RUNNING: A plugin was opened while there was already
66 * another plugin running in the widget.
68 * Error codes returned by #ChimaraGlk widgets and subclasses.
70 typedef enum _ChimaraError {
71 CHIMARA_LOAD_MODULE_ERROR,
73 CHIMARA_PLUGIN_NOT_FOUND,
74 CHIMARA_PLUGIN_ALREADY_RUNNING
78 * ChimaraResourceType:
79 * @CHIMARA_RESOURCE_SOUND: A sound file.
80 * @CHIMARA_RESOURCE_IMAGE: An image file.
82 * The type of resource that the Glk program is requesting, passed to a
83 * #ChimaraResourceLoadFunc.
85 typedef enum _ChimaraResourceType {
86 CHIMARA_RESOURCE_SOUND,
87 CHIMARA_RESOURCE_IMAGE
88 } ChimaraResourceType;
91 * ChimaraResourceLoadFunc:
92 * @usage: A #ChimaraResourceType constant.
93 * @resnum: The resource number to look for.
94 * @user_data: A pointer to provide to the callback.
96 * The type of function passed to chimara_glk_set_resource_load_callback(). It
97 * takes a #ChimaraResourceType constant, @usage, to indicate what sort of
98 * resource to look for; @resnum is the resource number to look for, and
99 * @user_data is the user data provided along with the callback. The function
100 * must return an allocated string containing the filename where the resource
103 typedef gchar * (*ChimaraResourceLoadFunc)(ChimaraResourceType usage, guint32 resnum, gpointer user_data);
108 * The domain of errors raised by Chimara widgets.
110 #define CHIMARA_ERROR chimara_error_quark()
112 GQuark chimara_error_quark(void);
113 GType chimara_glk_get_type(void) G_GNUC_CONST;
114 GtkWidget *chimara_glk_new(void);
115 void chimara_glk_set_interactive(ChimaraGlk *glk, gboolean interactive);
116 gboolean chimara_glk_get_interactive(ChimaraGlk *glk);
117 void chimara_glk_set_protect(ChimaraGlk *glk, gboolean protect);
118 gboolean chimara_glk_get_protect(ChimaraGlk *glk);
119 void chimara_glk_set_css_to_default(ChimaraGlk *glk);
120 gboolean chimara_glk_set_css_from_file(ChimaraGlk *glk, const gchar *filename, GError **error);
121 void chimara_glk_set_css_from_string(ChimaraGlk *glk, const gchar *css);
122 void chimara_glk_set_spacing(ChimaraGlk *glk, guint spacing);
123 guint chimara_glk_get_spacing(ChimaraGlk *glk);
124 gboolean chimara_glk_run(ChimaraGlk *glk, const gchar *plugin, int argc, char *argv[], GError **error);
125 void chimara_glk_stop(ChimaraGlk *glk);
126 void chimara_glk_wait(ChimaraGlk *glk);
127 gboolean chimara_glk_get_running(ChimaraGlk *glk);
128 void chimara_glk_feed_char_input(ChimaraGlk *glk, guint32 keyval);
129 void chimara_glk_feed_line_input(ChimaraGlk *glk, const gchar *text);
130 gboolean chimara_glk_is_char_input_pending(ChimaraGlk *glk);
131 gboolean chimara_glk_is_line_input_pending(ChimaraGlk *glk);
132 GtkTextTag *chimara_glk_get_tag(ChimaraGlk *glk, ChimaraGlkWindowType window, const gchar *name);
133 const gchar **chimara_glk_get_tag_names(unsigned int *num_tags);
134 void chimara_glk_update_style(ChimaraGlk *glk);
135 void chimara_glk_set_resource_load_callback(ChimaraGlk *glk, ChimaraResourceLoadFunc func, gpointer user_data, GDestroyNotify destroy_user_data);
139 #endif /* __CHIMARA_GLK_H__ */