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