gtkbuilderprivate.h 5.19 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 34 35 36 37 38 39 40
 */

#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;
  gchar *class_name;
  gchar *id;
  gchar *constructor;
  GSList *properties;
  GSList *signals;
  GObject *object;
  CommonInfo *parent;
41
  gboolean applied_properties;
42 43
} ObjectInfo;

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

50 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;
  gchar *name;
Matthias Clasen's avatar
Matthias Clasen committed
63
  GString *text;
64 65
  gchar *data;
  gboolean translatable;
66
  gchar *context;
67 68 69 70 71 72 73 74 75 76 77
} PropertyInfo;

typedef struct {
  TagInfo tag;
  gchar *object_name;
  gchar *name;
  gchar *handler;
  GConnectFlags flags;
  gchar *connect_object_name;
} SignalInfo;

78 79 80 81 82 83 84
typedef struct {
  TagInfo  tag;
  gchar   *library;
  gint     major;
  gint     minor;
} RequiresInfo;

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
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;
104 105 106 107 108

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

  GHashTable *object_ids;
111 112 113 114
} ParserData;

typedef GType (*GTypeGetFunc) (void);

115
/* Things only GtkBuilder should use */
116 117 118 119
void _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
                                       const gchar *filename,
                                       const gchar *buffer,
                                       gsize length,
120
                                       gchar **requested_objs,
121 122
                                       GError **error);
GObject * _gtk_builder_construct (GtkBuilder *builder,
123 124
                                  ObjectInfo *info,
				  GError    **error);
125 126 127
void      _gtk_builder_apply_properties (GtkBuilder *builder,
					 ObjectInfo *info,
					 GError **error);
128 129 130
void      _gtk_builder_add_object (GtkBuilder  *builder,
                                   const gchar *id,
                                   GObject     *object);
131 132
void      _gtk_builder_add (GtkBuilder *builder,
                            ChildInfo *child_info);
133 134
void      _gtk_builder_add_signals (GtkBuilder *builder,
				    GSList     *signals);
135 136 137
void      _gtk_builder_finish (GtkBuilder *builder);
void _free_signal_info (SignalInfo *info,
                        gpointer user_data);
138 139

/* Internal API which might be made public at some point */
140 141 142
gboolean _gtk_builder_boolean_from_string (const gchar  *string,
					   gboolean     *value,
					   GError      **error);
143 144 145 146
gboolean _gtk_builder_enum_from_string (GType         type,
                                        const gchar  *string,
                                        gint         *enum_value,
                                        GError      **error);
147 148
gboolean  _gtk_builder_flags_from_string (GType       type,
					  const char *string,
149
					  guint      *value,
150
					  GError    **error);
151 152 153
const gchar * _gtk_builder_parser_translate (const gchar *domain,
                                             const gchar *context,
                                             const gchar *text);
154 155
gchar *   _gtk_builder_get_resource_path (GtkBuilder *builder,
					  const gchar *string);
156 157
gchar *   _gtk_builder_get_absolute_filename (GtkBuilder *builder,
					      const gchar *string);
158

159 160 161 162 163 164 165
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);

166 167 168 169 170 171 172
GType     _gtk_builder_get_template_type (GtkBuilder *builder);
guint     _gtk_builder_extend_with_template (GtkBuilder    *builder,
					     GtkWidget     *widget,
					     GType          template_type,
					     const gchar   *buffer,
					     gsize          length,
					     GError       **error);
173

174
#endif /* __GTK_BUILDER_PRIVATE_H__ */