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 
24 typedef struct {
25   const gchar *name;
26 } TagInfo;
27 
28 typedef struct {
29   TagInfo tag;
30 } CommonInfo;
31 
32 typedef struct {
33   TagInfo tag;
34   GType type;
35   GObjectClass *oclass;
36   gchar *id;
37   gchar *constructor;
38   GSList *properties;
39   gsize n_properties;
40   GSList *signals;
41   GSList *bindings;
42   GObject *object;
43   CommonInfo *parent;
44   gboolean applied_properties;
45 } ObjectInfo;
46 
47 typedef struct {
48   TagInfo tag;
49   gchar *id;
50   GHashTable *objects;
51 } MenuInfo;
52 
53 typedef struct {
54   TagInfo tag;
55   GSList *packing_properties;
56   GObject *object;
57   CommonInfo *parent;
58   gchar *type;
59   gchar *internal_child;
60   gboolean added;
61 } ChildInfo;
62 
63 typedef struct {
64   TagInfo tag;
65   GParamSpec *pspec;
66   GString *text;
67   gboolean translatable:1;
68   gboolean bound:1;
69   gchar *context;
70   gint line;
71   gint col;
72 } PropertyInfo;
73 
74 typedef struct {
75   TagInfo tag;
76   gchar *object_name;
77   guint  id;
78   GQuark detail;
79   gchar *handler;
80   GConnectFlags flags;
81   gchar *connect_object_name;
82 } SignalInfo;
83 
84 typedef struct
85 {
86   GObject *target;
87   GParamSpec *target_pspec;
88   gchar *source;
89   gchar *source_property;
90   GBindingFlags flags;
91   gint line;
92   gint col;
93 } BindingInfo;
94 
95 typedef struct {
96   TagInfo  tag;
97   gchar   *library;
98   gint     major;
99   gint     minor;
100 } RequiresInfo;
101 
102 typedef struct {
103   GMarkupParser *parser;
104   gchar *tagname;
105   const gchar *start;
106   gpointer data;
107   GObject *object;
108   GObject *child;
109 } SubParser;
110 
111 typedef struct {
112   const gchar *last_element;
113   GtkBuilder *builder;
114   gchar *domain;
115   GSList *stack;
116   SubParser *subparser;
117   GMarkupParseContext *ctx;
118   const gchar *filename;
119   GSList *finalizers;
120   GSList *custom_finalizers;
121 
122   GSList *requested_objects; /* NULL if all the objects are requested */
123   gboolean inside_requested_object;
124   gint requested_object_level;
125   gint cur_object_level;
126 
127   gint object_counter;
128 
129   GHashTable *object_ids;
130 } ParserData;
131 
132 typedef GType (*GTypeGetFunc) (void);
133 
134 /* Things only GtkBuilder should use */
135 void _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
136                                        const gchar *filename,
137                                        const gchar *buffer,
138                                        gsize length,
139                                        gchar **requested_objs,
140                                        GError **error);
141 GObject * _gtk_builder_construct (GtkBuilder *builder,
142                                   ObjectInfo *info,
143 				  GError    **error);
144 void      _gtk_builder_apply_properties (GtkBuilder *builder,
145 					 ObjectInfo *info,
146 					 GError **error);
147 void      _gtk_builder_add_object (GtkBuilder  *builder,
148                                    const gchar *id,
149                                    GObject     *object);
150 void      _gtk_builder_add (GtkBuilder *builder,
151                             ChildInfo *child_info);
152 void      _gtk_builder_add_signals (GtkBuilder *builder,
153 				    GSList     *signals);
154 void      _gtk_builder_finish (GtkBuilder *builder);
155 void _free_signal_info (SignalInfo *info,
156                         gpointer user_data);
157 
158 /* Internal API which might be made public at some point */
159 gboolean _gtk_builder_boolean_from_string (const gchar  *string,
160 					   gboolean     *value,
161 					   GError      **error);
162 gboolean _gtk_builder_enum_from_string (GType         type,
163                                         const gchar  *string,
164                                         gint         *enum_value,
165                                         GError      **error);
166 gboolean  _gtk_builder_flags_from_string (GType         type,
167                                           GFlagsValue  *aliases,
168 					  const char   *string,
169 					  guint        *value,
170 					  GError      **error);
171 const gchar * _gtk_builder_parser_translate (const gchar *domain,
172                                              const gchar *context,
173                                              const gchar *text);
174 gchar *   _gtk_builder_get_resource_path (GtkBuilder *builder,
175 					  const gchar *string);
176 gchar *   _gtk_builder_get_absolute_filename (GtkBuilder *builder,
177 					      const gchar *string);
178 
179 void      _gtk_builder_menu_start (ParserData   *parser_data,
180                                    const gchar  *element_name,
181                                    const gchar **attribute_names,
182                                    const gchar **attribute_values,
183                                    GError      **error);
184 void      _gtk_builder_menu_end   (ParserData  *parser_data);
185 
186 GType     _gtk_builder_get_template_type (GtkBuilder *builder);
187 
188 void _gtk_builder_prefix_error            (GtkBuilder           *builder,
189                                            GMarkupParseContext  *context,
190                                            GError              **error);
191 void _gtk_builder_error_unhandled_tag     (GtkBuilder           *builder,
192                                            GMarkupParseContext  *context,
193                                            const gchar          *object,
194                                            const gchar          *element_name,
195                                            GError              **error);
196 gboolean _gtk_builder_check_parent        (GtkBuilder           *builder,
197                                            GMarkupParseContext  *context,
198                                            const gchar          *parent_name,
199                                            GError              **error);
200 GObject * _gtk_builder_lookup_object      (GtkBuilder           *builder,
201                                            const gchar          *name,
202                                            gint                  line,
203                                            gint                  col);
204 gboolean _gtk_builder_lookup_failed       (GtkBuilder           *builder,
205                                            GError              **error);
206 
207 
208 #endif /* __GTK_BUILDER_PRIVATE_H__ */
209