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