Use init and clear for GMutex and GCond
[projects/chimara/chimara.git] / libchimara / chimara-glk-private.h
1 #ifndef __CHIMARA_GLK_PRIVATE_H__
2 #define __CHIMARA_GLK_PRIVATE_H__
3
4 #include <glib.h>
5 #include <gmodule.h>
6 #include <pango/pango.h>
7 #include "glk.h"
8 #include "style.h"
9 #include "gi_blorb.h"
10 #include "gi_dispa.h"
11 #include "chimara-glk.h"
12
13 G_BEGIN_DECLS
14
15 typedef struct _ChimaraGlkPrivate ChimaraGlkPrivate;
16
17 struct _ChimaraGlkPrivate {
18     /* Pointer back to the widget itself for use in thread */
19     ChimaraGlk *self;
20
21         /* *** Widget properties *** */
22     /* Whether user input is expected */
23     gboolean interactive;
24     /* Whether file operations are allowed */
25     gboolean protect;
26         /* Spacing between Glk windows */
27         guint spacing;
28         /* The CSS file to read style defaults from */
29         gchar *css_file;
30         /* Hashtable containing the current styles set by CSS and GLK */
31         struct StyleSet *styles;
32         struct StyleSet *glk_styles;
33         PangoAttrList *pager_attr_list;
34         /* Final message displayed when game exits */
35         gchar *final_message;
36         /* Image cache */
37         GSList *image_cache;
38
39         /* *** Threading data *** */
40         /* Whether program is running */
41         gboolean running;
42         /* Whether widget has been finalized */
43         gboolean after_finalize;
44     /* Glk program loaded in widget */
45     GModule *program;
46     /* Thread in which Glk program is run */
47     GThread *thread;
48     /* Event queue and threading stuff */
49     GQueue *event_queue;
50         GMutex event_lock;
51         GCond event_queue_not_empty;
52         GCond event_queue_not_full;
53     /* Abort mechanism */
54         GMutex abort_lock;
55     gboolean abort_signalled;
56         /* Key press after shutdown mechanism */
57         GMutex shutdown_lock;
58         GCond shutdown_key_pressed;
59         /* Window arrangement locks */
60         GMutex arrange_lock;
61         GCond rearranged;
62         gboolean needs_rearrange;
63         gboolean ignore_next_arrange_event;
64         /* Input queues */
65         GAsyncQueue *char_input_queue;
66         GAsyncQueue *line_input_queue;
67         /* Resource loading locks */
68         GMutex resource_lock;
69         GCond resource_loaded;
70         GCond resource_info_available;
71         guint32 resource_available;
72
73         /* *** Glk library data *** */
74         /* Info about current plugin */
75         gchar *program_name;
76         gchar *program_info;
77         gchar *story_name;
78     /* User-defined interrupt handler */
79     void (*interrupt_handler)(void);
80     /* Global tree of all windows */
81     GNode *root_window;
82     /* List of filerefs currently in existence */
83     GList *fileref_list;
84     /* Current stream */
85     strid_t current_stream;
86     /* List of streams currently in existence */
87     GList *stream_list;
88         /* List of sound channels currently in existence */
89         GList *schannel_list;
90         /* Current timer */
91         guint timer_id;
92         /* Current resource blorb map */
93         giblorb_map_t *resource_map;
94         /* File stream pointing to the blorb used as current resource map */
95         strid_t resource_file;
96         /* Optional callback for loading resource data */
97         ChimaraResourceLoadFunc resource_load_callback;
98         gpointer resource_load_callback_data;
99         GDestroyNotify resource_load_callback_destroy_data;
100         /* Callbacks for registering and unregistering dispatch objects */
101         gidispatch_rock_t (*register_obj)(void *, glui32);
102         void (*unregister_obj)(void *, glui32, gidispatch_rock_t);
103         gidispatch_rock_t (*register_arr)(void *, glui32, char *);
104         void (*unregister_arr)(void *, glui32, char *, gidispatch_rock_t);
105
106         /* *** Platform-dependent Glk library data *** */
107         /* Flag for functions to find out if they are being called from startup code */
108         gboolean in_startup;
109         /* "Current directory" for creating filerefs */
110         gchar *current_dir;
111 };
112
113 #define CHIMARA_GLK_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHIMARA_TYPE_GLK, ChimaraGlkPrivate))
114 #define CHIMARA_GLK_USE_PRIVATE(o, n) ChimaraGlkPrivate *n = CHIMARA_GLK_PRIVATE(o)
115
116 G_END_DECLS
117
118 #endif /* __CHIMARA_GLK_PRIVATE_H__ */