1/* GTK - The GIMP Toolkit
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_H__
20#define __GTK_BUILDER_H__
21
22#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23#error "Only <gtk/gtk.h> can be included directly."
24#endif
25
26#include <gtk/gtkapplication.h>
27#include <gtk/gtkwidget.h>
28
29G_BEGIN_DECLS
30
31#define GTK_TYPE_BUILDER (gtk_builder_get_type ())
32#define GTK_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUILDER, GtkBuilder))
33#define GTK_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BUILDER, GtkBuilderClass))
34#define GTK_IS_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUILDER))
35#define GTK_IS_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BUILDER))
36#define GTK_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUILDER, GtkBuilderClass))
37
38#define GTK_BUILDER_ERROR (gtk_builder_error_quark ())
39
40typedef struct _GtkBuilderClass GtkBuilderClass;
41typedef struct _GtkBuilderPrivate GtkBuilderPrivate;
42
43/**
44 * GtkBuilderError:
45 * @GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION: A type-func attribute didn’t name
46 * a function that returns a #GType.
47 * @GTK_BUILDER_ERROR_UNHANDLED_TAG: The input contained a tag that #GtkBuilder
48 * can’t handle.
49 * @GTK_BUILDER_ERROR_MISSING_ATTRIBUTE: An attribute that is required by
50 * #GtkBuilder was missing.
51 * @GTK_BUILDER_ERROR_INVALID_ATTRIBUTE: #GtkBuilder found an attribute that
52 * it doesn’t understand.
53 * @GTK_BUILDER_ERROR_INVALID_TAG: #GtkBuilder found a tag that
54 * it doesn’t understand.
55 * @GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE: A required property value was
56 * missing.
57 * @GTK_BUILDER_ERROR_INVALID_VALUE: #GtkBuilder couldn’t parse
58 * some attribute value.
59 * @GTK_BUILDER_ERROR_VERSION_MISMATCH: The input file requires a newer version
60 * of GTK+.
61 * @GTK_BUILDER_ERROR_DUPLICATE_ID: An object id occurred twice.
62 * @GTK_BUILDER_ERROR_OBJECT_TYPE_REFUSED: A specified object type is of the same type or
63 * derived from the type of the composite class being extended with builder XML.
64 * @GTK_BUILDER_ERROR_TEMPLATE_MISMATCH: The wrong type was specified in a composite class’s template XML
65 * @GTK_BUILDER_ERROR_INVALID_PROPERTY: The specified property is unknown for the object class.
66 * @GTK_BUILDER_ERROR_INVALID_SIGNAL: The specified signal is unknown for the object class.
67 * @GTK_BUILDER_ERROR_INVALID_ID: An object id is unknown
68 *
69 * Error codes that identify various errors that can occur while using
70 * #GtkBuilder.
71 */
72typedef enum
73{
74 GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION,
75 GTK_BUILDER_ERROR_UNHANDLED_TAG,
76 GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
77 GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
78 GTK_BUILDER_ERROR_INVALID_TAG,
79 GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
80 GTK_BUILDER_ERROR_INVALID_VALUE,
81 GTK_BUILDER_ERROR_VERSION_MISMATCH,
82 GTK_BUILDER_ERROR_DUPLICATE_ID,
83 GTK_BUILDER_ERROR_OBJECT_TYPE_REFUSED,
84 GTK_BUILDER_ERROR_TEMPLATE_MISMATCH,
85 GTK_BUILDER_ERROR_INVALID_PROPERTY,
86 GTK_BUILDER_ERROR_INVALID_SIGNAL,
87 GTK_BUILDER_ERROR_INVALID_ID
88} GtkBuilderError;
89
90GDK_AVAILABLE_IN_ALL
91GQuark gtk_builder_error_quark (void);
92
93struct _GtkBuilder
94{
95 GObject parent_instance;
96
97 GtkBuilderPrivate *priv;
98};
99
100struct _GtkBuilderClass
101{
102 GObjectClass parent_class;
103
104 GType (* get_type_from_name) (GtkBuilder *builder,
105 const char *type_name);
106
107 /* Padding for future expansion */
108 void (*_gtk_reserved1) (void);
109 void (*_gtk_reserved2) (void);
110 void (*_gtk_reserved3) (void);
111 void (*_gtk_reserved4) (void);
112 void (*_gtk_reserved5) (void);
113 void (*_gtk_reserved6) (void);
114 void (*_gtk_reserved7) (void);
115 void (*_gtk_reserved8) (void);
116};
117
118GDK_AVAILABLE_IN_ALL
119GType gtk_builder_get_type (void) G_GNUC_CONST;
120GDK_AVAILABLE_IN_ALL
121GtkBuilder* gtk_builder_new (void);
122
123GDK_AVAILABLE_IN_ALL
124guint gtk_builder_add_from_file (GtkBuilder *builder,
125 const gchar *filename,
126 GError **error);
127GDK_AVAILABLE_IN_ALL
128guint gtk_builder_add_from_resource (GtkBuilder *builder,
129 const gchar *resource_path,
130 GError **error);
131GDK_AVAILABLE_IN_ALL
132guint gtk_builder_add_from_string (GtkBuilder *builder,
133 const gchar *buffer,
134 gsize length,
135 GError **error);
136GDK_AVAILABLE_IN_ALL
137guint gtk_builder_add_objects_from_file (GtkBuilder *builder,
138 const gchar *filename,
139 gchar **object_ids,
140 GError **error);
141GDK_AVAILABLE_IN_3_4
142guint gtk_builder_add_objects_from_resource(GtkBuilder *builder,
143 const gchar *resource_path,
144 gchar **object_ids,
145 GError **error);
146GDK_AVAILABLE_IN_ALL
147guint gtk_builder_add_objects_from_string (GtkBuilder *builder,
148 const gchar *buffer,
149 gsize length,
150 gchar **object_ids,
151 GError **error);
152GDK_AVAILABLE_IN_ALL
153GObject* gtk_builder_get_object (GtkBuilder *builder,
154 const gchar *name);
155GDK_AVAILABLE_IN_ALL
156GSList* gtk_builder_get_objects (GtkBuilder *builder);
157GDK_AVAILABLE_IN_3_8
158void gtk_builder_expose_object (GtkBuilder *builder,
159 const gchar *name,
160 GObject *object);
161GDK_AVAILABLE_IN_ALL
162void gtk_builder_connect_signals (GtkBuilder *builder,
163 gpointer user_data);
164GDK_AVAILABLE_IN_ALL
165void gtk_builder_connect_signals_full (GtkBuilder *builder,
166 GtkBuilderConnectFunc func,
167 gpointer user_data);
168GDK_AVAILABLE_IN_ALL
169void gtk_builder_set_translation_domain (GtkBuilder *builder,
170 const gchar *domain);
171GDK_AVAILABLE_IN_ALL
172const gchar* gtk_builder_get_translation_domain (GtkBuilder *builder);
173GDK_AVAILABLE_IN_ALL
174GType gtk_builder_get_type_from_name (GtkBuilder *builder,
175 const char *type_name);
176
177GDK_AVAILABLE_IN_ALL
178gboolean gtk_builder_value_from_string (GtkBuilder *builder,
179 GParamSpec *pspec,
180 const gchar *string,
181 GValue *value,
182 GError **error);
183GDK_AVAILABLE_IN_ALL
184gboolean gtk_builder_value_from_string_type (GtkBuilder *builder,
185 GType type,
186 const gchar *string,
187 GValue *value,
188 GError **error);
189GDK_AVAILABLE_IN_3_10
190GtkBuilder * gtk_builder_new_from_file (const gchar *filename);
191GDK_AVAILABLE_IN_3_10
192GtkBuilder * gtk_builder_new_from_resource (const gchar *resource_path);
193GDK_AVAILABLE_IN_3_10
194GtkBuilder * gtk_builder_new_from_string (const gchar *string,
195 gssize length);
196
197GDK_AVAILABLE_IN_3_10
198void gtk_builder_add_callback_symbol (GtkBuilder *builder,
199 const gchar *callback_name,
200 GCallback callback_symbol);
201GDK_AVAILABLE_IN_3_10
202void gtk_builder_add_callback_symbols (GtkBuilder *builder,
203 const gchar *first_callback_name,
204 GCallback first_callback_symbol,
205 ...) G_GNUC_NULL_TERMINATED;
206GDK_AVAILABLE_IN_3_10
207GCallback gtk_builder_lookup_callback_symbol (GtkBuilder *builder,
208 const gchar *callback_name);
209
210GDK_AVAILABLE_IN_3_12
211void gtk_builder_set_application (GtkBuilder *builder,
212 GtkApplication *application);
213
214GDK_AVAILABLE_IN_3_12
215GtkApplication * gtk_builder_get_application (GtkBuilder *builder);
216
217
218/**
219 * GTK_BUILDER_WARN_INVALID_CHILD_TYPE:
220 * @object: the #GtkBuildable on which the warning ocurred
221 * @type: the unexpected type value
222 *
223 * This macro should be used to emit a warning about and unexpected @type value
224 * in a #GtkBuildable add_child implementation.
225 */
226#define GTK_BUILDER_WARN_INVALID_CHILD_TYPE(object, type) \
227 g_warning ("'%s' is not a valid child type of '%s'", type, g_type_name (G_OBJECT_TYPE (object)))
228
229GDK_AVAILABLE_IN_3_18
230guint gtk_builder_extend_with_template (GtkBuilder *builder,
231 GtkWidget *widget,
232 GType template_type, const gchar *buffer,
233 gsize length,
234 GError **error);
235
236G_END_DECLS
237
238#endif /* __GTK_BUILDER_H__ */
239

source code of include/gtk-3.0/gtk/gtkbuilder.h