gtkbuilderprivate.h 6.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* gtkbuilderprivate.h
 * Copyright (C) 2006-2007 Async Open Source,
 *                         Johan Dahlin <jdahlin@async.com.br>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
Javier Jardón's avatar
Javier Jardón committed
16
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
 */

#ifndef __GTK_BUILDER_PRIVATE_H__
#define __GTK_BUILDER_PRIVATE_H__

#include "gtkbuilder.h"

typedef struct {
  const gchar *name;
} TagInfo;

typedef struct {
  TagInfo tag;
} CommonInfo;

typedef struct {
  TagInfo tag;
34
  GType type;
35 36 37 38
  gchar *id;
  gchar *constructor;
  GSList *properties;
  GSList *signals;
39
  GSList *bindings;
40 41
  GObject *object;
  CommonInfo *parent;
42
  gboolean applied_properties;
43 44
} ObjectInfo;

Matthias Clasen's avatar
Matthias Clasen committed
45 46 47 48 49 50
typedef struct {
  TagInfo tag;
  gchar *id;
  GHashTable *objects;
} MenuInfo;

51 52 53 54 55 56 57 58 59 60 61 62
typedef struct {
  TagInfo tag;
  GSList *packing_properties;
  GObject *object;
  CommonInfo *parent;
  gchar *type;
  gchar *internal_child;
  gboolean added;
} ChildInfo;

typedef struct {
  TagInfo tag;
63
  GParamSpec *pspec;
Matthias Clasen's avatar
Matthias Clasen committed
64
  GString *text;
65 66
  gboolean translatable:1;
  gboolean bound:1;
67
  gchar *context;
68 69
  gint line;
  gint col;
70 71 72 73 74
} PropertyInfo;

typedef struct {
  TagInfo tag;
  gchar *object_name;
75 76
  guint  id;
  GQuark detail;
77 78 79 80 81
  gchar *handler;
  GConnectFlags flags;
  gchar *connect_object_name;
} SignalInfo;

82 83 84
typedef struct
{
  GObject *target;
85
  GParamSpec *target_pspec;
86 87 88
  gchar *source;
  gchar *source_property;
  GBindingFlags flags;
89 90
  gint line;
  gint col;
91 92
} BindingInfo;

93 94 95 96 97 98 99
typedef struct {
  TagInfo  tag;
  gchar   *library;
  gint     major;
  gint     minor;
} RequiresInfo;

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
typedef struct {
  GMarkupParser *parser;
  gchar *tagname;
  const gchar *start;
  gpointer data;
  GObject *object;
  GObject *child;
} SubParser;

typedef struct {
  const gchar *last_element;
  GtkBuilder *builder;
  gchar *domain;
  GSList *stack;
  SubParser *subparser;
  GMarkupParseContext *ctx;
  const gchar *filename;
  GSList *finalizers;
  GSList *custom_finalizers;
119 120 121 122 123

  GSList *requested_objects; /* NULL if all the objects are requested */
  gboolean inside_requested_object;
  gint requested_object_level;
  gint cur_object_level;
124

125 126
  gint object_counter;

127
  GHashTable *object_ids;
128 129 130 131
} ParserData;

typedef GType (*GTypeGetFunc) (void);

132
/* Things only GtkBuilder should use */
133 134 135 136
void _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
                                       const gchar *filename,
                                       const gchar *buffer,
                                       gsize length,
137
                                       gchar **requested_objs,
138 139
                                       GError **error);
GObject * _gtk_builder_construct (GtkBuilder *builder,
140 141
                                  ObjectInfo *info,
				  GError    **error);
142 143 144
void      _gtk_builder_apply_properties (GtkBuilder *builder,
					 ObjectInfo *info,
					 GError **error);
145 146 147
void      _gtk_builder_add_object (GtkBuilder  *builder,
                                   const gchar *id,
                                   GObject     *object);
148 149
void      _gtk_builder_add (GtkBuilder *builder,
                            ChildInfo *child_info);
150 151
void      _gtk_builder_add_signals (GtkBuilder *builder,
				    GSList     *signals);
152 153 154
void      _gtk_builder_finish (GtkBuilder *builder);
void _free_signal_info (SignalInfo *info,
                        gpointer user_data);
155 156

/* Internal API which might be made public at some point */
157 158 159
gboolean _gtk_builder_boolean_from_string (const gchar  *string,
					   gboolean     *value,
					   GError      **error);
160 161 162 163
gboolean _gtk_builder_enum_from_string (GType         type,
                                        const gchar  *string,
                                        gint         *enum_value,
                                        GError      **error);
164 165
gboolean  _gtk_builder_flags_from_string (GType       type,
					  const char *string,
166
					  guint      *value,
167
					  GError    **error);
168 169 170
const gchar * _gtk_builder_parser_translate (const gchar *domain,
                                             const gchar *context,
                                             const gchar *text);
171 172
gchar *   _gtk_builder_get_resource_path (GtkBuilder *builder,
					  const gchar *string);
173 174
gchar *   _gtk_builder_get_absolute_filename (GtkBuilder *builder,
					      const gchar *string);
175

176 177 178 179 180 181 182
void      _gtk_builder_menu_start (ParserData   *parser_data,
                                   const gchar  *element_name,
                                   const gchar **attribute_names,
                                   const gchar **attribute_values,
                                   GError      **error);
void      _gtk_builder_menu_end   (ParserData  *parser_data);

183
GType     _gtk_builder_get_template_type (GtkBuilder *builder);
184 185 186 187 188 189
GDK_AVAILABLE_IN_3_18
guint     gtk_builder_extend_with_template  (GtkBuilder    *builder,
                                             GtkWidget     *widget,
                                             GType          template_type,                                                          const gchar   *buffer,
                                             gsize          length,
                                             GError       **error);
190

191 192 193 194 195 196 197 198 199 200 201 202
void _gtk_builder_prefix_error            (GtkBuilder           *builder,
                                           GMarkupParseContext  *context,
                                           GError              **error);
void _gtk_builder_error_unhandled_tag     (GtkBuilder           *builder,
                                           GMarkupParseContext  *context,
                                           const gchar          *object,
                                           const gchar          *element_name,
                                           GError              **error);
gboolean _gtk_builder_check_parent        (GtkBuilder           *builder,
                                           GMarkupParseContext  *context,
                                           const gchar          *parent_name,
                                           GError              **error);
203 204 205 206
GObject * _gtk_builder_lookup_object      (GtkBuilder           *builder,
                                           const gchar          *name,
                                           gint                  line,
                                           gint                  col);
207 208
gboolean _gtk_builder_lookup_failed       (GtkBuilder           *builder,
                                           GError              **error);
209

210

211
#endif /* __GTK_BUILDER_PRIVATE_H__ */