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_BUILDABLE_H__
20#define __GTK_BUILDABLE_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/gtkbuilder.h>
27
28G_BEGIN_DECLS
29
30#define GTK_TYPE_BUILDABLE (gtk_buildable_get_type ())
31#define GTK_BUILDABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUILDABLE, GtkBuildable))
32#define GTK_BUILDABLE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GTK_TYPE_BUILDABLE, GtkBuildableIface))
33#define GTK_IS_BUILDABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUILDABLE))
34#define GTK_BUILDABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_BUILDABLE, GtkBuildableIface))
35
36
37typedef struct _GtkBuildable GtkBuildable; /* Dummy typedef */
38typedef struct _GtkBuildableIface GtkBuildableIface;
39
40/**
41 * GtkBuildableIface:
42 * @g_iface: the parent class
43 * @set_name: Stores the name attribute given in the GtkBuilder UI definition.
44 * #GtkWidget stores the name as object data. Implement this method if your
45 * object has some notion of “name” and it makes sense to map the XML name
46 * attribute to it.
47 * @get_name: The getter corresponding to @set_name. Implement this
48 * if you implement @set_name.
49 * @add_child: Adds a child. The @type parameter can be used to
50 * differentiate the kind of child. #GtkContainer implements this
51 * to add add a child widget to the container, #GtkNotebook uses
52 * the @type to distinguish between page labels (of type "page-label")
53 * and normal children.
54 * @set_buildable_property: Sets a property of a buildable object.
55 * It is normally not necessary to implement this, g_object_set_property()
56 * is used by default. #GtkWindow implements this to delay showing itself
57 * (i.e. setting the #GtkWidget:visible property) until the whole interface
58 * is created.
59 * @construct_child: Constructs a child of a buildable that has been
60 * specified as “constructor” in the UI definition. #GtkUIManager implements
61 * this to reference to a widget created in a <ui> tag which is outside
62 * of the normal GtkBuilder UI definition hierarchy. A reference to the
63 * constructed object is returned and becomes owned by the caller.
64 * @custom_tag_start: Implement this if the buildable needs to parse
65 * content below <child>. To handle an element, the implementation
66 * must fill in the @parser and @user_data and return %TRUE.
67 * #GtkWidget implements this to parse keyboard accelerators specified
68 * in <accelerator> elements. #GtkContainer implements it to map
69 * properties defined via <packing> elements to child properties.
70 * Note that @user_data must be freed in @custom_tag_end or @custom_finished.
71 * @custom_tag_end: Called for the end tag of each custom element that is
72 * handled by the buildable (see @custom_tag_start).
73 * @custom_finished: Called for each custom tag handled by the buildable
74 * when the builder finishes parsing (see @custom_tag_start)
75 * @parser_finished: Called when a builder finishes the parsing
76 * of a UI definition. It is normally not necessary to implement this,
77 * unless you need to perform special cleanup actions. #GtkWindow sets
78 * the #GtkWidget:visible property here.
79 * @get_internal_child: Returns an internal child of a buildable.
80 * #GtkDialog implements this to give access to its @vbox, making
81 * it possible to add children to the vbox in a UI definition.
82 * Implement this if the buildable has internal children that may
83 * need to be accessed from a UI definition.
84 *
85 * The #GtkBuildableIface interface contains method that are
86 * necessary to allow #GtkBuilder to construct an object from
87 * a #GtkBuilder UI definition.
88 */
89struct _GtkBuildableIface
90{
91 GTypeInterface g_iface;
92
93 /* virtual table */
94 void (* set_name) (GtkBuildable *buildable,
95 const gchar *name);
96 const gchar * (* get_name) (GtkBuildable *buildable);
97 void (* add_child) (GtkBuildable *buildable,
98 GtkBuilder *builder,
99 GObject *child,
100 const gchar *type);
101 void (* set_buildable_property) (GtkBuildable *buildable,
102 GtkBuilder *builder,
103 const gchar *name,
104 const GValue *value);
105 GObject * (* construct_child) (GtkBuildable *buildable,
106 GtkBuilder *builder,
107 const gchar *name);
108 gboolean (* custom_tag_start) (GtkBuildable *buildable,
109 GtkBuilder *builder,
110 GObject *child,
111 const gchar *tagname,
112 GMarkupParser *parser,
113 gpointer *data);
114 void (* custom_tag_end) (GtkBuildable *buildable,
115 GtkBuilder *builder,
116 GObject *child,
117 const gchar *tagname,
118 gpointer *data);
119 void (* custom_finished) (GtkBuildable *buildable,
120 GtkBuilder *builder,
121 GObject *child,
122 const gchar *tagname,
123 gpointer data);
124 void (* parser_finished) (GtkBuildable *buildable,
125 GtkBuilder *builder);
126
127 GObject * (* get_internal_child) (GtkBuildable *buildable,
128 GtkBuilder *builder,
129 const gchar *childname);
130};
131
132
133GDK_AVAILABLE_IN_ALL
134GType gtk_buildable_get_type (void) G_GNUC_CONST;
135
136GDK_AVAILABLE_IN_ALL
137void gtk_buildable_set_name (GtkBuildable *buildable,
138 const gchar *name);
139GDK_AVAILABLE_IN_ALL
140const gchar * gtk_buildable_get_name (GtkBuildable *buildable);
141GDK_AVAILABLE_IN_ALL
142void gtk_buildable_add_child (GtkBuildable *buildable,
143 GtkBuilder *builder,
144 GObject *child,
145 const gchar *type);
146GDK_AVAILABLE_IN_ALL
147void gtk_buildable_set_buildable_property (GtkBuildable *buildable,
148 GtkBuilder *builder,
149 const gchar *name,
150 const GValue *value);
151GDK_AVAILABLE_IN_ALL
152GObject * gtk_buildable_construct_child (GtkBuildable *buildable,
153 GtkBuilder *builder,
154 const gchar *name);
155GDK_AVAILABLE_IN_ALL
156gboolean gtk_buildable_custom_tag_start (GtkBuildable *buildable,
157 GtkBuilder *builder,
158 GObject *child,
159 const gchar *tagname,
160 GMarkupParser *parser,
161 gpointer *data);
162GDK_AVAILABLE_IN_ALL
163void gtk_buildable_custom_tag_end (GtkBuildable *buildable,
164 GtkBuilder *builder,
165 GObject *child,
166 const gchar *tagname,
167 gpointer *data);
168GDK_AVAILABLE_IN_ALL
169void gtk_buildable_custom_finished (GtkBuildable *buildable,
170 GtkBuilder *builder,
171 GObject *child,
172 const gchar *tagname,
173 gpointer data);
174GDK_AVAILABLE_IN_ALL
175void gtk_buildable_parser_finished (GtkBuildable *buildable,
176 GtkBuilder *builder);
177GDK_AVAILABLE_IN_ALL
178GObject * gtk_buildable_get_internal_child (GtkBuildable *buildable,
179 GtkBuilder *builder,
180 const gchar *childname);
181
182G_END_DECLS
183
184#endif /* __GTK_BUILDABLE_H__ */
185