1 | /* gtkbuilderprivate.h |
2 | * Copyright (C) 2006-2007 Async Open Source, |
3 | * Johan Dahlin <jdahlin@async.com.br> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | #ifndef __GTK_BUILDER_PRIVATE_H__ |
20 | #define __GTK_BUILDER_PRIVATE_H__ |
21 | |
22 | #include "gtkbuilder.h" |
23 | #include "gtkbuildable.h" |
24 | #include "gtkexpression.h" |
25 | |
26 | enum { |
27 | TAG_PROPERTY, |
28 | TAG_BINDING, |
29 | TAG_BINDING_EXPRESSION, |
30 | TAG_REQUIRES, |
31 | TAG_OBJECT, |
32 | TAG_CHILD, |
33 | TAG_SIGNAL, |
34 | TAG_INTERFACE, |
35 | TAG_TEMPLATE, |
36 | TAG_EXPRESSION, |
37 | }; |
38 | |
39 | typedef struct { |
40 | guint tag_type; |
41 | } CommonInfo; |
42 | |
43 | typedef struct { |
44 | guint tag_type; |
45 | GType type; |
46 | GObjectClass *oclass; |
47 | char *id; |
48 | char *constructor; |
49 | |
50 | GPtrArray *properties; |
51 | GPtrArray *signals; |
52 | GSList *bindings; |
53 | |
54 | GObject *object; |
55 | CommonInfo *parent; |
56 | } ObjectInfo; |
57 | |
58 | typedef struct { |
59 | guint tag_type; |
60 | GSList *packing_properties; |
61 | GObject *object; |
62 | CommonInfo *parent; |
63 | char *type; |
64 | char *internal_child; |
65 | gboolean added; |
66 | } ChildInfo; |
67 | |
68 | typedef struct { |
69 | guint tag_type; |
70 | GParamSpec *pspec; |
71 | gpointer value; |
72 | GString *text; |
73 | gboolean translatable : 1; |
74 | gboolean bound : 1; |
75 | gboolean applied : 1; |
76 | char *context; |
77 | int line; |
78 | int col; |
79 | } PropertyInfo; |
80 | |
81 | typedef struct _ExpressionInfo ExpressionInfo; |
82 | struct _ExpressionInfo { |
83 | guint tag_type; |
84 | enum { |
85 | EXPRESSION_EXPRESSION, |
86 | EXPRESSION_CONSTANT, |
87 | EXPRESSION_CLOSURE, |
88 | EXPRESSION_PROPERTY |
89 | } expression_type; |
90 | union { |
91 | GtkExpression *expression; |
92 | struct { |
93 | GType type; |
94 | GString *text; |
95 | } constant; |
96 | struct { |
97 | GType type; |
98 | char *function_name; |
99 | char *object_name; |
100 | gboolean swapped; |
101 | GSList *params; |
102 | } closure; |
103 | struct { |
104 | GType this_type; |
105 | char *property_name; |
106 | ExpressionInfo *expression; |
107 | } property; |
108 | }; |
109 | }; |
110 | |
111 | typedef struct { |
112 | guint tag_type; |
113 | char *object_name; |
114 | guint id; |
115 | GQuark detail; |
116 | char *handler; |
117 | GConnectFlags flags; |
118 | char *connect_object_name; |
119 | } SignalInfo; |
120 | |
121 | typedef struct |
122 | { |
123 | guint tag_type; |
124 | GObject *target; |
125 | GParamSpec *target_pspec; |
126 | char *source; |
127 | char *source_property; |
128 | GBindingFlags flags; |
129 | int line; |
130 | int col; |
131 | } BindingInfo; |
132 | |
133 | typedef struct |
134 | { |
135 | guint tag_type; |
136 | GObject *target; |
137 | GParamSpec *target_pspec; |
138 | char *object_name; |
139 | ExpressionInfo *expr; |
140 | int line; |
141 | int col; |
142 | } BindingExpressionInfo; |
143 | |
144 | typedef struct { |
145 | guint tag_type; |
146 | char *library; |
147 | int major; |
148 | int minor; |
149 | } RequiresInfo; |
150 | |
151 | struct _GtkBuildableParseContext { |
152 | const GMarkupParser *internal_callbacks; |
153 | GMarkupParseContext *ctx; |
154 | |
155 | const GtkBuildableParser *parser; |
156 | gpointer user_data; |
157 | |
158 | GPtrArray *tag_stack; |
159 | |
160 | GArray *subparser_stack; |
161 | gpointer held_user_data; |
162 | gboolean awaiting_pop; |
163 | }; |
164 | |
165 | typedef struct { |
166 | GtkBuildableParser *parser; |
167 | char *tagname; |
168 | const char *start; |
169 | gpointer data; |
170 | GObject *object; |
171 | GObject *child; |
172 | } SubParser; |
173 | |
174 | typedef struct { |
175 | const char *last_element; |
176 | GtkBuilder *builder; |
177 | char *domain; |
178 | GPtrArray *stack; |
179 | SubParser *subparser; |
180 | GtkBuildableParseContext ctx; |
181 | const char *filename; |
182 | GPtrArray *finalizers; |
183 | GSList *custom_finalizers; |
184 | |
185 | const char **requested_objects; /* NULL if all the objects are requested */ |
186 | gboolean inside_requested_object; |
187 | int requested_object_level; |
188 | int cur_object_level; |
189 | |
190 | int object_counter; |
191 | |
192 | GHashTable *object_ids; |
193 | } ParserData; |
194 | |
195 | /* Things only GtkBuilder should use */ |
196 | GBytes * _gtk_buildable_parser_precompile (const char *text, |
197 | gssize text_len, |
198 | GError **error); |
199 | gboolean _gtk_buildable_parser_is_precompiled (const char *data, |
200 | gssize data_len); |
201 | gboolean _gtk_buildable_parser_replay_precompiled (GtkBuildableParseContext *context, |
202 | const char *data, |
203 | gssize data_len, |
204 | GError **error); |
205 | void _gtk_builder_parser_parse_buffer (GtkBuilder *builder, |
206 | const char *filename, |
207 | const char *buffer, |
208 | gssize length, |
209 | const char **requested_objs, |
210 | GError **error); |
211 | GObject * _gtk_builder_construct (GtkBuilder *builder, |
212 | ObjectInfo *info, |
213 | GError **error); |
214 | void _gtk_builder_apply_properties (GtkBuilder *builder, |
215 | ObjectInfo *info, |
216 | GError **error); |
217 | void _gtk_builder_add_object (GtkBuilder *builder, |
218 | const char *id, |
219 | GObject *object); |
220 | void _gtk_builder_add (GtkBuilder *builder, |
221 | ChildInfo *child_info); |
222 | void _gtk_builder_add_signals (GtkBuilder *builder, |
223 | GPtrArray *signals); |
224 | void gtk_builder_take_bindings (GtkBuilder *builder, |
225 | GObject *target, |
226 | GSList *bindings); |
227 | |
228 | gboolean _gtk_builder_finish (GtkBuilder *builder, |
229 | GError **error); |
230 | void _free_signal_info (SignalInfo *info, |
231 | gpointer user_data); |
232 | void _free_binding_info (BindingInfo *info, |
233 | gpointer user_data); |
234 | void free_binding_expression_info (BindingExpressionInfo *info); |
235 | GtkExpression * expression_info_construct (GtkBuilder *builder, |
236 | ExpressionInfo *info, |
237 | GError **error); |
238 | |
239 | /* Internal API which might be made public at some point */ |
240 | gboolean _gtk_builder_enum_from_string (GType type, |
241 | const char *string, |
242 | int *enum_value, |
243 | GError **error); |
244 | gboolean _gtk_builder_flags_from_string (GType type, |
245 | const char *string, |
246 | guint *value, |
247 | GError **error); |
248 | gboolean _gtk_builder_boolean_from_string (const char *string, |
249 | gboolean *value, |
250 | GError **error); |
251 | |
252 | const char * _gtk_builder_parser_translate (const char *domain, |
253 | const char *context, |
254 | const char *text); |
255 | char * _gtk_builder_get_resource_path (GtkBuilder *builder, |
256 | const char *string) G_GNUC_MALLOC; |
257 | char * _gtk_builder_get_absolute_filename (GtkBuilder *builder, |
258 | const char *string) G_GNUC_MALLOC; |
259 | |
260 | void (ParserData *parser_data, |
261 | const char *element_name, |
262 | const char **attribute_names, |
263 | const char **attribute_values, |
264 | GError **error); |
265 | void (ParserData *parser_data); |
266 | |
267 | GType _gtk_builder_get_template_type (GtkBuilder *builder); |
268 | |
269 | void _gtk_builder_prefix_error (GtkBuilder *builder, |
270 | GtkBuildableParseContext *context, |
271 | GError **error); |
272 | void _gtk_builder_error_unhandled_tag (GtkBuilder *builder, |
273 | GtkBuildableParseContext *context, |
274 | const char *object, |
275 | const char *element_name, |
276 | GError **error); |
277 | gboolean _gtk_builder_check_parent (GtkBuilder *builder, |
278 | GtkBuildableParseContext *context, |
279 | const char *parent_name, |
280 | GError **error); |
281 | GObject *gtk_builder_lookup_object (GtkBuilder *builder, |
282 | const char *name, |
283 | int line, |
284 | int col, |
285 | GError **error); |
286 | GObject *_gtk_builder_lookup_object (GtkBuilder *builder, |
287 | const char *name, |
288 | int line, |
289 | int col); |
290 | gboolean _gtk_builder_lookup_failed (GtkBuilder *builder, |
291 | GError **error); |
292 | |
293 | #endif /* __GTK_BUILDER_PRIVATE_H__ */ |
294 | |