Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
gtkbuildable.h
Go to the documentation of this file.
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#pragma once
20
21#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22#error "Only <gtk/gtk.h> can be included directly."
23#endif
24
25#include <gtk/gtkbuilder.h>
26
28
29#define GTK_TYPE_BUILDABLE (gtk_buildable_get_type ())
30#define GTK_BUILDABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUILDABLE, GtkBuildable))
31#define GTK_IS_BUILDABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUILDABLE))
32#define GTK_BUILDABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_BUILDABLE, GtkBuildableIface))
33
34typedef struct _GtkBuildable GtkBuildable; /* Dummy typedef */
36
37typedef struct _GtkBuildableParseContext GtkBuildableParseContext;
39
40/**
41 * GtkBuildableParseContext:
42 *
43 * An opaque context struct for `GtkBuildableParser`.
44 */
45
46/**
47 * GtkBuildableParser:
48 * @start_element: function called for open elements
49 * @end_element: function called for close elements
50 * @text: function called for character data
51 * @error: function called on error
52 *
53 * A sub-parser for `GtkBuildable` implementations.
54 */
56{
57 /* Called for open tags <foo bar="baz"> */
59 const char *element_name,
60 const char **attribute_names,
61 const char **attribute_values,
62 gpointer user_data,
63 GError **error);
64
65 /* Called for close tags </foo> */
67 const char *element_name,
68 gpointer user_data,
69 GError **error);
70
71 /* Called for character data */
72 /* text is not nul-terminated */
73 void (*text) (GtkBuildableParseContext *context,
74 const char *text,
75 gsize text_len,
76 gpointer user_data,
77 GError **error);
78
79 /* Called on error, including one set by other
80 * methods in the vtable. The GError should not be freed.
81 */
83 GError *error,
84 gpointer user_data);
85
86 /*< private >*/
88};
89
90/**
91 * GtkBuildableIface:
92 * @g_iface: the parent class
93 * @set_id: Stores the id attribute given in the `GtkBuilder` UI definition.
94 * `GtkWidget` stores the name as object data. Implement this method if your
95 * object has some notion of “ID” and it makes sense to map the XML id
96 * attribute to it.
97 * @get_id: The getter corresponding to @set_id. Implement this
98 * if you implement @set_id.
99 * @add_child: Adds a child. The @type parameter can be used to
100 * differentiate the kind of child. `GtkWidget` implements this
101 * to add event controllers to the widget, `GtkNotebook` uses
102 * the @type to distinguish between page labels (of type "page-label")
103 * and normal children.
104 * @set_buildable_property: Sets a property of a buildable object.
105 * It is normally not necessary to implement this, g_object_set_property()
106 * is used by default. `GtkWindow` implements this to delay showing itself
107 * (i.e. setting the [property@Gtk.Widget:visible] property) until the whole
108 * interface is created.
109 * @construct_child: Constructs a child of a buildable that has been
110 * specified as “constructor” in the UI definition. This can be used to
111 * reference a widget created in a `<ui>` tag which is outside
112 * of the normal GtkBuilder UI definition hierarchy. A reference to the
113 * constructed object is returned and becomes owned by the caller.
114 * @custom_tag_start: Implement this if the buildable needs to parse
115 * content below `<child>`. To handle an element, the implementation
116 * must fill in the @parser and @user_data and return %TRUE.
117 * `GtkWidget` implements this to parse accessible attributes specified
118 * in `<accessibility>` elements.
119 * Note that @user_data must be freed in @custom_tag_end or @custom_finished.
120 * @custom_tag_end: Called for the end tag of each custom element that is
121 * handled by the buildable (see @custom_tag_start).
122 * @custom_finished: Called for each custom tag handled by the buildable
123 * when the builder finishes parsing (see @custom_tag_start)
124 * @parser_finished: Called when a builder finishes the parsing
125 * of a UI definition. It is normally not necessary to implement this,
126 * unless you need to perform special cleanup actions. `GtkWindow` sets
127 * the `GtkWidget:visible` property here.
128 * @get_internal_child: Returns an internal child of a buildable.
129 * `GtkDialog` implements this to give access to its @vbox, making
130 * it possible to add children to the vbox in a UI definition.
131 * Implement this if the buildable has internal children that may
132 * need to be accessed from a UI definition.
133 *
134 * The `GtkBuildableIface` interface contains methods that are
135 * necessary to allow `GtkBuilder` to construct an object from
136 * a `GtkBuilder` UI definition.
137 */
139{
141
142 /* virtual table */
143 void (* set_id) (GtkBuildable *buildable,
144 const char *id);
145 const char * (* get_id) (GtkBuildable *buildable);
146
147 /**
148 * GtkBuildableIface::add_child:
149 * @buildable: a `GtkBuildable`
150 * @builder: a `GtkBuilder`
151 * @child: child to add
152 * @type: (nullable): kind of child or %NULL
153 *
154 * Adds a child to @buildable. @type is an optional string
155 * describing how the child should be added.
156 */
157 void (* add_child) (GtkBuildable *buildable,
158 GtkBuilder *builder,
159 GObject *child,
160 const char *type);
162 GtkBuilder *builder,
163 const char *name,
164 const GValue *value);
165 GObject * (* construct_child) (GtkBuildable *buildable,
166 GtkBuilder *builder,
167 const char *name);
168
169 /**
170 * GtkBuildableIface::custom_tag_start:
171 * @buildable: a `GtkBuildable`
172 * @builder: a `GtkBuilder` used to construct this object
173 * @child: (nullable): child object or %NULL for non-child tags
174 * @tagname: name of tag
175 * @parser: (out): a `GtkBuildableParser` to fill in
176 * @data: (out): return location for user data that will be passed in
177 * to parser functions
178 *
179 * Called for each unknown element under `<child>`.
180 *
181 * Returns: %TRUE if an object has a custom implementation, %FALSE
182 * if it doesn't.
183 */
185 GtkBuilder *builder,
186 GObject *child,
187 const char *tagname,
188 GtkBuildableParser *parser,
189 gpointer *data);
190 /**
191 * GtkBuildableIface::custom_tag_end:
192 * @buildable: A `GtkBuildable`
193 * @builder: `GtkBuilder` used to construct this object
194 * @child: (nullable): child object or %NULL for non-child tags
195 * @tagname: name of tag
196 * @data: user data that will be passed in to parser functions
197 *
198 * Called at the end of each custom element handled by
199 * the buildable.
200 */
201 void (* custom_tag_end) (GtkBuildable *buildable,
202 GtkBuilder *builder,
203 GObject *child,
204 const char *tagname,
205 gpointer data);
206 /**
207 * GtkBuildableIface::custom_finished:
208 * @buildable: a `GtkBuildable`
209 * @builder: a `GtkBuilder`
210 * @child: (nullable): child object or %NULL for non-child tags
211 * @tagname: the name of the tag
212 * @data: user data created in custom_tag_start
213 *
214 * Similar to gtk_buildable_parser_finished() but is
215 * called once for each custom tag handled by the @buildable.
216 */
217 void (* custom_finished) (GtkBuildable *buildable,
218 GtkBuilder *builder,
219 GObject *child,
220 const char *tagname,
221 gpointer data);
222 void (* parser_finished) (GtkBuildable *buildable,
223 GtkBuilder *builder);
224
225 /**
226 * GtkBuildableIface::get_internal_child:
227 * @buildable: a `GtkBuildable`
228 * @builder: a `GtkBuilder`
229 * @childname: name of child
230 *
231 * Retrieves the internal child called @childname of the @buildable object.
232 *
233 * Returns: (transfer none): the internal child of the buildable object
234 */
235 GObject * (* get_internal_child) (GtkBuildable *buildable,
236 GtkBuilder *builder,
237 const char *childname);
238};
239
240
243
246
249 const GtkBuildableParser *parser,
250 gpointer user_data);
259 int *line_number,
260 int *char_number);
261
263
265
#define GDK_AVAILABLE_IN_ALL
unsigned long gsize
Definition glibconfig.h:83
#define G_END_DECLS
Definition gmacros.h:910
#define G_BEGIN_DECLS
Definition gmacros.h:909
#define G_GNUC_CONST
Definition gmacros.h:637
#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func)
Definition gmacros.h:1400
GOBJECT_AVAILABLE_IN_ALL void g_object_unref(gpointer object)
struct _GtkBuildable GtkBuildable
GDK_AVAILABLE_IN_ALL GType gtk_buildable_get_type(void) G_GNUC_CONST
GDK_AVAILABLE_IN_ALL void gtk_buildable_parse_context_push(GtkBuildableParseContext *context, const GtkBuildableParser *parser, gpointer user_data)
struct _GtkBuildableParseContext GtkBuildableParseContext
GDK_AVAILABLE_IN_ALL gpointer gtk_buildable_parse_context_pop(GtkBuildableParseContext *context)
GDK_AVAILABLE_IN_ALL const char * gtk_buildable_get_buildable_id(GtkBuildable *buildable)
GDK_AVAILABLE_IN_ALL GPtrArray * gtk_buildable_parse_context_get_element_stack(GtkBuildableParseContext *context)
GDK_AVAILABLE_IN_ALL void gtk_buildable_parse_context_get_position(GtkBuildableParseContext *context, int *line_number, int *char_number)
GDK_AVAILABLE_IN_ALL const char * gtk_buildable_parse_context_get_element(GtkBuildableParseContext *context)
struct _GtkBuilder GtkBuilder
Definition gtktypes.h:38
gsize GType
Definition gtype.h:427
gint gboolean
Definition gtypes.h:56
void * gpointer
Definition gtypes.h:109
const char * name
Definition lsqlite3.c:2154
int value
Definition lsqlite3.c:2155
gboolean(* custom_tag_start)(GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const char *tagname, GtkBuildableParser *parser, gpointer *data)
GTypeInterface g_iface
void(* custom_tag_end)(GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const char *tagname, gpointer data)
void(* add_child)(GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const char *type)
void(* custom_finished)(GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const char *tagname, gpointer data)
void(* set_id)(GtkBuildable *buildable, const char *id)
void(* parser_finished)(GtkBuildable *buildable, GtkBuilder *builder)
void(* set_buildable_property)(GtkBuildable *buildable, GtkBuilder *builder, const char *name, const GValue *value)
void(* text)(GtkBuildableParseContext *context, const char *text, gsize text_len, gpointer user_data, GError **error)
void(* end_element)(GtkBuildableParseContext *context, const char *element_name, gpointer user_data, GError **error)
gpointer padding[4]
void(* start_element)(GtkBuildableParseContext *context, const char *element_name, const char **attribute_names, const char **attribute_values, gpointer user_data, GError **error)
void(* error)(GtkBuildableParseContext *context, GError *error, gpointer user_data)