Fixed freeing data at stop & start. Previously the root window was set to NULL when...
[rodin/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         /* Font description of proportional font */
27         PangoFontDescription *default_font_desc;
28         /* Font description of monospace font */
29         PangoFontDescription *monospace_font_desc;
30         /* Spacing between Glk windows */
31         guint spacing;
32         /* The CSS file to read style defaults from */
33         gchar *css_file;
34         /* Hashtable containing the default and current style */
35         struct StyleSet *default_styles;
36         struct StyleSet *current_styles;
37
38         /* *** Threading data *** */
39         /* Whether program is running */
40         gboolean running;
41     /* Glk program loaded in widget */
42     GModule *program;
43     /* Thread in which Glk program is run */
44     GThread *thread;
45     /* Event queue and threading stuff */
46     GQueue *event_queue;
47     GMutex *event_lock;
48     GCond *event_queue_not_empty;
49     GCond *event_queue_not_full;
50     /* Abort mechanism */
51     GMutex *abort_lock;
52     gboolean abort_signalled;
53         /* Window arrangement locks */
54         GMutex *arrange_lock;
55         GCond *rearranged;
56         gboolean needs_rearrange;
57         gboolean ignore_next_arrange_event;
58         /* Input queues */
59         GAsyncQueue *char_input_queue;
60         GAsyncQueue *line_input_queue;
61
62         /* *** Glk library data *** */
63     /* User-defined interrupt handler */
64     void (*interrupt_handler)(void);
65     /* Global tree of all windows */
66     GNode *root_window;
67     /* List of filerefs currently in existence */
68     GList *fileref_list;
69     /* Current stream */
70     strid_t current_stream;
71     /* List of streams currently in existence */
72     GList *stream_list;
73         /* Current timer */
74         guint timer_id;
75         /* Current resource blorb map */
76         giblorb_map_t *resource_map;
77         /* File stream pointing to the blorb used as current resource map */
78         strid_t resource_file;
79         /* Callbacks for registering and unregistering dispatch objects */
80         gidispatch_rock_t (*register_obj)(void *, glui32);
81         void (*unregister_obj)(void *, glui32, gidispatch_rock_t);
82         gidispatch_rock_t (*register_arr)(void *, glui32, char *);
83         void (*unregister_arr)(void *, glui32, char *, gidispatch_rock_t);
84         /* Have styles been initialized */
85         gboolean style_initialized;
86         /* Is widget still displaying windows from last run */
87         gboolean needs_reset;
88
89         /* *** Platform-dependent Glk library data *** */
90         /* Flag for functions to find out if they are being called from startup code */
91         gboolean in_startup;
92         /* "Current directory" for creating filerefs */
93         gchar *current_dir;
94 };
95
96 #define CHIMARA_GLK_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHIMARA_TYPE_GLK, ChimaraGlkPrivate))
97 #define CHIMARA_GLK_USE_PRIVATE(o, n) ChimaraGlkPrivate *n = CHIMARA_GLK_PRIVATE(o)
98
99 G_GNUC_INTERNAL void _chimara_glk_free_nonwindow_private_data(ChimaraGlkPrivate *self);
100
101 G_END_DECLS
102
103 #endif /* __CHIMARA_GLK_PRIVATE_H__ */