gtkbuilder.h 9.74 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Johan Dahlin's avatar
Johan Dahlin committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15
 * Copyright (C) 2006-2007 Async Open Source,
 *                         Johan Dahlin <jdahlin@async.com.br>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
Javier Jardón's avatar
Javier Jardón committed
16
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
Johan Dahlin's avatar
Johan Dahlin committed
17
 */
18

19 20 21
#ifndef __GTK_BUILDER_H__
#define __GTK_BUILDER_H__

22
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23 24 25
#error "Only <gtk/gtk.h> can be included directly."
#endif

26
#include <gtk/gtkapplication.h>
Matthias Clasen's avatar
Matthias Clasen committed
27
#include <gtk/gtkwidget.h>
Johan Dahlin's avatar
Johan Dahlin committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

G_BEGIN_DECLS

#define GTK_TYPE_BUILDER                 (gtk_builder_get_type ())
#define GTK_BUILDER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUILDER, GtkBuilder))
#define GTK_BUILDER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BUILDER, GtkBuilderClass))
#define GTK_IS_BUILDER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUILDER))
#define GTK_IS_BUILDER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BUILDER))
#define GTK_BUILDER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUILDER, GtkBuilderClass))

#define GTK_BUILDER_ERROR                (gtk_builder_error_quark ())

typedef struct _GtkBuilderClass   GtkBuilderClass;
typedef struct _GtkBuilderPrivate GtkBuilderPrivate;

43 44
/**
 * GtkBuilderError:
45
 * @GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION: A type-func attribute didn’t name
46 47
 *  a function that returns a #GType.
 * @GTK_BUILDER_ERROR_UNHANDLED_TAG: The input contained a tag that #GtkBuilder
48
 *  can’t handle.
49 50 51
 * @GTK_BUILDER_ERROR_MISSING_ATTRIBUTE: An attribute that is required by
 *  #GtkBuilder was missing.
 * @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 56
 * @GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE: A required property value was
 *  missing.
57
 * @GTK_BUILDER_ERROR_INVALID_VALUE: #GtkBuilder couldn’t parse
58 59 60 61
 *  some attribute value.
 * @GTK_BUILDER_ERROR_VERSION_MISMATCH: The input file requires a newer version
 *  of GTK+.
 * @GTK_BUILDER_ERROR_DUPLICATE_ID: An object id occurred twice.
62 63
 * @GTK_BUILDER_ERROR_OBJECT_TYPE_REFUSED: A specified object type is of the same type or
 *  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 66
 * @GTK_BUILDER_ERROR_INVALID_PROPERTY: The specified property is unknown for the object class.
 * @GTK_BUILDER_ERROR_INVALID_SIGNAL: The specified signal is unknown for the object class.
67 68 69 70
 *
 * Error codes that identify various errors that can occur while using
 * #GtkBuilder.
 */
Johan Dahlin's avatar
Johan Dahlin committed
71 72 73 74 75 76
typedef enum
{
  GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION,
  GTK_BUILDER_ERROR_UNHANDLED_TAG,
  GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
  GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
77
  GTK_BUILDER_ERROR_INVALID_TAG,
78
  GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
79
  GTK_BUILDER_ERROR_INVALID_VALUE,
80
  GTK_BUILDER_ERROR_VERSION_MISMATCH,
81 82
  GTK_BUILDER_ERROR_DUPLICATE_ID,
  GTK_BUILDER_ERROR_OBJECT_TYPE_REFUSED,
83 84 85
  GTK_BUILDER_ERROR_TEMPLATE_MISMATCH,
  GTK_BUILDER_ERROR_INVALID_PROPERTY,
  GTK_BUILDER_ERROR_INVALID_SIGNAL
Johan Dahlin's avatar
Johan Dahlin committed
86 87
} GtkBuilderError;

88
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
89 90 91 92 93 94
GQuark gtk_builder_error_quark (void);

struct _GtkBuilder
{
  GObject parent_instance;

95
  GtkBuilderPrivate *priv;
Johan Dahlin's avatar
Johan Dahlin committed
96 97 98 99 100 101 102
};

struct _GtkBuilderClass
{
  GObjectClass parent_class;
  
  GType (* get_type_from_name) (GtkBuilder *builder,
103
                                const char *type_name);
Johan Dahlin's avatar
Johan Dahlin committed
104 105 106 107 108 109 110 111 112 113 114 115

  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
  void (*_gtk_reserved5) (void);
  void (*_gtk_reserved6) (void);
  void (*_gtk_reserved7) (void);
  void (*_gtk_reserved8) (void);
};

116
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
117
GType        gtk_builder_get_type                (void) G_GNUC_CONST;
118
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
119 120
GtkBuilder*  gtk_builder_new                     (void);

121
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
122 123 124
guint        gtk_builder_add_from_file           (GtkBuilder    *builder,
                                                  const gchar   *filename,
                                                  GError       **error);
125
GDK_AVAILABLE_IN_ALL
126 127 128
guint        gtk_builder_add_from_resource       (GtkBuilder    *builder,
                                                  const gchar   *resource_path,
                                                  GError       **error);
129
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
130 131 132 133
guint        gtk_builder_add_from_string         (GtkBuilder    *builder,
                                                  const gchar   *buffer,
                                                  gsize          length,
                                                  GError       **error);
134
GDK_AVAILABLE_IN_ALL
135 136 137 138
guint        gtk_builder_add_objects_from_file   (GtkBuilder    *builder,
                                                  const gchar   *filename,
                                                  gchar        **object_ids,
                                                  GError       **error);
139
GDK_AVAILABLE_IN_3_4
140 141 142 143
guint        gtk_builder_add_objects_from_resource(GtkBuilder    *builder,
                                                  const gchar   *resource_path,
                                                  gchar        **object_ids,
                                                  GError       **error);
144
GDK_AVAILABLE_IN_ALL
145 146 147 148 149
guint        gtk_builder_add_objects_from_string (GtkBuilder    *builder,
                                                  const gchar   *buffer,
                                                  gsize          length,
                                                  gchar        **object_ids,
                                                  GError       **error);
150
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
151 152
GObject*     gtk_builder_get_object              (GtkBuilder    *builder,
                                                  const gchar   *name);
153
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
154
GSList*      gtk_builder_get_objects             (GtkBuilder    *builder);
155
GDK_AVAILABLE_IN_3_8
156 157 158
void         gtk_builder_expose_object           (GtkBuilder    *builder,
                                                  const gchar   *name,
                                                  GObject       *object);
159
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
160 161
void         gtk_builder_connect_signals         (GtkBuilder    *builder,
						  gpointer       user_data);
162
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
163 164 165
void         gtk_builder_connect_signals_full    (GtkBuilder    *builder,
                                                  GtkBuilderConnectFunc func,
						  gpointer       user_data);
166
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
167 168
void         gtk_builder_set_translation_domain  (GtkBuilder   	*builder,
                                                  const gchar  	*domain);
169
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
170
const gchar* gtk_builder_get_translation_domain  (GtkBuilder   	*builder);
171
GDK_AVAILABLE_IN_ALL
Johan Dahlin's avatar
Johan Dahlin committed
172
GType        gtk_builder_get_type_from_name      (GtkBuilder   	*builder,
173
                                                  const char   	*type_name);
Johan Dahlin's avatar
Johan Dahlin committed
174

175
GDK_AVAILABLE_IN_ALL
176 177
gboolean     gtk_builder_value_from_string       (GtkBuilder    *builder,
						  GParamSpec   	*pspec,
Johan Dahlin's avatar
Johan Dahlin committed
178
                                                  const gchar  	*string,
179 180
                                                  GValue       	*value,
						  GError       **error);
181
GDK_AVAILABLE_IN_ALL
182 183
gboolean     gtk_builder_value_from_string_type  (GtkBuilder    *builder,
						  GType        	 type,
Johan Dahlin's avatar
Johan Dahlin committed
184
                                                  const gchar  	*string,
185 186
                                                  GValue       	*value,
						  GError       **error);
187 188 189 190 191 192 193
GDK_AVAILABLE_IN_3_10
GtkBuilder * gtk_builder_new_from_file           (const gchar   *filename);
GDK_AVAILABLE_IN_3_10
GtkBuilder * gtk_builder_new_from_resource       (const gchar   *resource_path);
GDK_AVAILABLE_IN_3_10
GtkBuilder * gtk_builder_new_from_string         (const gchar   *string,
                                                  gssize         length);
Johan Dahlin's avatar
Johan Dahlin committed
194

195 196 197 198 199 200 201 202 203 204 205 206 207
GDK_AVAILABLE_IN_3_10
void         gtk_builder_add_callback_symbol     (GtkBuilder    *builder,
						  const gchar   *callback_name,
						  GCallback      callback_symbol);
GDK_AVAILABLE_IN_3_10
void         gtk_builder_add_callback_symbols    (GtkBuilder    *builder,
						  const gchar   *first_callback_name,
						  GCallback      first_callback_symbol,
						  ...) G_GNUC_NULL_TERMINATED;
GDK_AVAILABLE_IN_3_10
GCallback    gtk_builder_lookup_callback_symbol  (GtkBuilder    *builder,
						  const gchar   *callback_name);

Matthias Clasen's avatar
Matthias Clasen committed
208
GDK_AVAILABLE_IN_3_12
209 210 211
void         gtk_builder_set_application         (GtkBuilder     *builder,
                                                  GtkApplication *application);

Matthias Clasen's avatar
Matthias Clasen committed
212
GDK_AVAILABLE_IN_3_12
213 214 215
GtkApplication * gtk_builder_get_application     (GtkBuilder     *builder);


216 217 218 219 220 221 222 223
/**
 * GTK_BUILDER_WARN_INVALID_CHILD_TYPE:
 * @object: the #GtkBuildable on which the warning ocurred
 * @type: the unexpected type value
 *
 * This macro should be used to emit a warning about and unexpected @type value
 * in a #GtkBuildable add_child implementation.
 */
Johan Dahlin's avatar
Johan Dahlin committed
224
#define GTK_BUILDER_WARN_INVALID_CHILD_TYPE(object, type) \
225
  g_warning ("'%s' is not a valid child type of '%s'", type, g_type_name (G_OBJECT_TYPE (object)))
Johan Dahlin's avatar
Johan Dahlin committed
226 227 228 229

G_END_DECLS

#endif /* __GTK_BUILDER_H__ */