summaryrefslogtreecommitdiff
path: root/gladeui/glade-xml-utils.h
blob: 3a88aceffe7b539d143c0cb792e28fc98849daa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/* TODO : s/glade_xml_get_/glade_xml_node_get/g */
#ifndef __GLADE_XML_UTILS_H__
#define __GLADE_XML_UTILS_H__

#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>


G_BEGIN_DECLS

#define GLADE_XML_CONTEXT(c)    ((GladeXmlContext *)c)
#define GLADE_XML_IS_CONTEXT(c) (c != NULL)

#define CAST_BAD (gchar *)


typedef struct _GladeXmlContext GladeXmlContext;
typedef struct _GladeXmlNode    GladeXmlNode;
typedef struct _GladeXmlDoc     GladeXmlDoc;

/* FIXME: forward declarations to get around circular header dependencies.
 */
typedef struct _GladeWidget         GladeWidget;
typedef struct _GladeWidgetAdaptor  GladeWidgetAdaptor;
typedef struct _GladeProperty       GladeProperty;
typedef struct _GladeProject        GladeProject;


#define GLADE_GTKBUILDER_VERSIONING_BASE_MAJOR    2
#define GLADE_GTKBUILDER_VERSIONING_BASE_MINOR    14
#define GLADE_GTKBUILDER_HAS_VERSIONING(maj, min)      \
  ((maj) > GLADE_GTKBUILDER_VERSIONING_BASE_MAJOR ||   \
   ((maj) == GLADE_GTKBUILDER_VERSIONING_BASE_MAJOR && \
    (min) >= GLADE_GTKBUILDER_VERSIONING_BASE_MINOR))


/* Used for catalog tags and attributes */
#define GLADE_XML_TAG_PROJECT                     "interface"
#define GLADE_XML_TAG_WIDGET                      "object"
#define GLADE_XML_TAG_TEMPLATE                    "template"

#define GLADE_XML_TAG_VERSION                     "version"
#define GLADE_XML_TAG_REQUIRES                    "requires"
#define GLADE_XML_TAG_LIB                         "lib"
#define GLADE_XML_TAG_PROPERTY                    "property"
#define GLADE_XML_TAG_CLASS                       "class"
#define GLADE_XML_TAG_TYPE_FUNC                   "type-func"
#define GLADE_XML_TAG_ID                          "id"
#define GLADE_XML_TAG_SIGNAL                      "signal"
#define GLADE_XML_TAG_HANDLER                     "handler"
#define GLADE_XML_TAG_AFTER                       "after"
#define GLADE_XML_TAG_SWAPPED                     "swapped"
#define GLADE_XML_TAG_OBJECT                      "object"
#define GLADE_XML_TAG_NAME                        "name"
#define GLADE_XML_TAG_CHILD                       "child"
#define GLADE_XML_TAG_PACKING                     "packing"
#define GLADE_XML_TAG_PLACEHOLDER                 "placeholder"
#define GLADE_XML_TAG_INTERNAL_CHILD              "internal-child"
#define GLADE_XML_TAG_I18N_TRUE                   "yes"
#define GLADE_XML_TAG_SIGNAL_TRUE                 "yes"
#define GLADE_XML_TAG_SIGNAL_FALSE                "no"
#define GLADE_XML_TAG_TYPE                        "type"
#define GLADE_XML_TAG_SOURCES                     "sources"
#define GLADE_XML_TAG_SOURCE                      "source"
#define GLADE_XML_TAG_FILENAME                    "filename"
#define GLADE_XML_TAG_STOCK_ID                    "stock-id"

#define GLADE_TAG_VERSION                         "version"
#define GLADE_TAG_TARGETABLE                      "targetable"
#define GLADE_TAG_VERSION_SINCE                   "since"
#define GLADE_TAG_BUILDER_SINCE                   "gtkbuilder-since"
#define GLADE_TAG_DEPRECATED                      "deprecated"
#define GLADE_TAG_DEPRECATED_SINCE                "deprecated-since"

#define GLADE_TAG_GLADE_CATALOG                   "glade-catalog"
#define GLADE_TAG_GLADE_WIDGET_CLASSES            "glade-widget-classes"
#define GLADE_TAG_GLADE_WIDGET_CLASS              "glade-widget-class"
#define GLADE_TAG_GLADE_WIDGET_GROUP              "glade-widget-group"
#define GLADE_TAG_GLADE_WIDGET_CLASS_REF          "glade-widget-class-ref"
#define GLADE_TAG_ADAPTOR                         "adaptor"
#define GLADE_TAG_LIBRARY                         "library"
#define GLADE_TAG_DEPENDS                         "depends"
#define GLADE_TAG_DOMAIN                          "domain"
#define GLADE_TAG_BOOK                            "book"
#define GLADE_TAG_SIGNALS                         "signals"
#define GLADE_TAG_SIGNAL                          "signal"
#define GLADE_TAG_INTERNAL_CHILDREN               "internal-children"
#define GLADE_TAG_ANARCHIST                       "anarchist"
#define GLADE_TAG_DEFAULT                         "default"
#define GLADE_TAG_PARENTLESS_WIDGET               "parentless-widget"
#define GLADE_TAG_DISABLED                        "disabled"
#define GLADE_TAG_CONSTRUCT_ONLY                  "construct-only"
#define GLADE_TAG_NEEDS_SYNC                      "needs-sync"
#define GLADE_TAG_DEFAULT_PALETTE_STATE           "default-palette-state"
#define GLADE_TAG_REPLACE_CHILD_FUNCTION          "replace-child-function"
#define GLADE_TAG_CREATE_WIDGET_FUNCTION          "create-widget-function"
#define GLADE_TAG_CONSTRUCT_OBJECT_FUNCTION       "construct-object-function"
#define GLADE_TAG_DESTROY_OBJECT_FUNCTION         "destroy-object-function"
#define GLADE_TAG_DEEP_POST_CREATE_FUNCTION       "deep-post-create-function"
#define GLADE_TAG_POST_CREATE_FUNCTION            "post-create-function"
#define GLADE_TAG_GET_INTERNAL_CHILD_FUNCTION     "get-internal-child-function"
#define GLADE_TAG_ADD_CHILD_FUNCTION              "add-child-function"
#define GLADE_TAG_ADD_CHILD_VERIFY_FUNCTION       "add-child-verify-function"
#define GLADE_TAG_REMOVE_CHILD_FUNCTION           "remove-child-function"
#define GLADE_TAG_GET_CHILDREN_FUNCTION           "get-children-function"
#define GLADE_TAG_CHILD_SET_PROP_FUNCTION         "child-set-property-function"
#define GLADE_TAG_CHILD_GET_PROP_FUNCTION         "child-get-property-function"
#define GLADE_TAG_CHILD_VERIFY_FUNCTION           "child-verify-function"
#define GLADE_TAG_CONSTRUCTOR_FUNCTION            "constructor-function"
#define GLADE_TAG_ACTION_ACTIVATE_FUNCTION        "action-activate-function"
#define GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION  "child-action-activate-function"
#define GLADE_TAG_ACTION_SUBMENU_FUNCTION         "action-submenu-function"
#define GLADE_TAG_DEPENDS_FUNCTION                "depends-function"
#define GLADE_TAG_READ_WIDGET_FUNCTION            "read-widget-function"
#define GLADE_TAG_WRITE_WIDGET_FUNCTION           "write-widget-function"
#define GLADE_TAG_WRITE_WIDGET_AFTER_FUNCTION     "write-widget-after-function"
#define GLADE_TAG_READ_CHILD_FUNCTION             "read-child-function"
#define GLADE_TAG_WRITE_CHILD_FUNCTION            "write-child-function"
#define GLADE_TAG_CREATE_EPROP_FUNCTION           "create-editor-property-function"
#define GLADE_TAG_STRING_FROM_VALUE_FUNCTION      "string-from-value-function"
#define GLADE_TAG_CREATE_EDITABLE_FUNCTION        "create-editable-function"
#define GLADE_TAG_PROPERTIES                      "properties"
#define GLADE_TAG_PACKING_PROPERTIES              "packing-properties"
#define GLADE_TAG_PROPERTY                        "property"
#define GLADE_TAG_ACTIONS                         "actions"
#define GLADE_TAG_PACKING_ACTIONS                 "packing-actions"
#define GLADE_TAG_ACTION                          "action"
#define GLADE_TAG_TYPE                            "type"
#define GLADE_TAG_SPEC                            "spec"
#define GLADE_TAG_SPECIFICATIONS                  "parameter-spec"
#define GLADE_TAG_MAX_VALUE                       "max"
#define GLADE_TAG_MIN_VALUE                       "min"
#define GLADE_TAG_VALUE_TYPE                      "value-type"
#define GLADE_TAG_TOOLTIP                         "tooltip"
#define GLADE_TAG_SET_FUNCTION                    "set-property-function"
#define GLADE_TAG_GET_FUNCTION                    "get-property-function"
#define GLADE_TAG_VERIFY_FUNCTION                 "verify-function"
#define GLADE_TAG_QUERY                           "query"
#define GLADE_TAG_COMMON                          "common"
#define GLADE_TAG_OPTIONAL                        "optional"
#define GLADE_TAG_OPTIONAL_DEFAULT                "optional-default"
#define GLADE_TAG_VISIBLE                         "visible"
#define GLADE_TAG_CUSTOM_LAYOUT                   "custom-layout"
#define GLADE_TAG_EXPANDED                        "expanded"
#define GLADE_TAG_GENERIC_NAME                    "generic-name"
#define GLADE_TAG_NAME                            "name"
#define GLADE_TAG_PARENT                          "parent"
#define GLADE_TAG_TITLE                           "title"
#define GLADE_TAG_ID                              "id"
#define GLADE_TAG_KEY                             "key"
#define GLADE_TAG_VALUE                           "value"
#define GLADE_TAG_TRANSLATABLE                    "translatable"
#define GLADE_TAG_HAS_CONTEXT                     "context"
#define GLADE_TAG_CONTEXT                         "context"
#define GLADE_TAG_COMMENT                         "comments"
#define GLADE_TAG_PACKING_DEFAULTS                "packing-defaults"
#define GLADE_TAG_PARENT_CLASS                    "parent-class"
#define GLADE_TAG_CHILD_PROPERTY                  "child-property"
#define GLADE_TAG_DISPLAYABLE_VALUES              "displayable-values"
#define GLADE_TAG_NICK                            "nick"
#define GLADE_TAG_SPECIAL_CHILD_TYPE              "special-child-type"
#define GLADE_TAG_SAVE                            "save"
#define GLADE_TAG_SAVE_ALWAYS                     "save-always"
#define GLADE_TAG_EDITABLE                        "editable"
#define GLADE_TAG_IGNORE                          "ignore"
#define GLADE_TAG_MULTILINE                       "multiline"
#define GLADE_TAG_RESOURCE                        "resource"
#define GLADE_TAG_STOCK                           "stock"
#define GLADE_TAG_STOCK_ICON                      "stock-icon"
#define GLADE_TAG_THEMED_ICON                     "themed-icon"
#define GLADE_TAG_INIT_FUNCTION                   "init-function"
#define GLADE_TAG_ATK_PROPERTY                    "atk-property"
#define GLADE_TAG_TRANSFER_ON_PASTE               "transfer-on-paste"
#define GLADE_TAG_WEIGHT                          "weight"
#define GLADE_TAG_GET_TYPE_FUNCTION               "get-type-function"
#define GLADE_TAG_TOPLEVEL                        "toplevel"
#define GLADE_TAG_USE_PLACEHOLDERS                "use-placeholders"
#define GLADE_TAG_DEFAULT_WIDTH                   "default-width"
#define GLADE_TAG_DEFAULT_HEIGHT                  "default-height"
#define GLADE_TAG_EVENT_HANDLER_CONNECTED         "EventHandlerConnected"
#define GLADE_TAG_FALSE                           "False"
#define GLADE_TAG_TRUE                            "True"
#define GLADE_TAG_YES                             "Yes"
#define GLADE_TAG_NO                              "No"
#define GLADE_TAG_ICON_PREFIX                     "icon-prefix"
#define GLADE_TAG_ICON_NAME                       "icon-name"
#define GLADE_TAG_IMPORTANT                       "important"
#define GLADE_TAG_CREATE_TYPE                     "create-type"
#define GLADE_TAG_TEMPLATE_PREFIX                 "template-prefix"
#define GLADE_TAG_BIND_SOURCE                     "bind-source"
#define GLADE_TAG_BIND_PROPERTY                   "bind-property"
#define GLADE_TAG_BIND_FLAGS                      "bind-flags"


/* search child */
GladeXmlNode *   glade_xml_search_child          (GladeXmlNode *node, const gchar *name);
GladeXmlNode *   glade_xml_search_child_required (GladeXmlNode *tree, const gchar *name);

/* content */

gchar *      glade_xml_get_content (GladeXmlNode *node_in); /* Get the content of the node */
void         glade_xml_set_content (GladeXmlNode *node_in, const gchar *content);

gboolean     glade_xml_get_value_int          (GladeXmlNode *node_in, const gchar *name, int *val);
gboolean     glade_xml_get_value_int_required (GladeXmlNode *node, const gchar *name, int *val);

gchar *      glade_xml_get_value_string          (GladeXmlNode *node, const gchar *name);
gchar *      glade_xml_get_value_string_required (GladeXmlNode *node,
                                                  const gchar *name,
                                                  const gchar *xtra_info);

gboolean glade_xml_get_boolean (GladeXmlNode *node, const gchar *name, gboolean _default);

void         glade_xml_set_value (GladeXmlNode *node_in, const gchar *name, const gchar *val);

/* Properties */ 
gchar   *glade_xml_get_property_string_required (GladeXmlNode *node_in, const gchar *name, const gchar *xtra);
gchar   *glade_xml_get_property_string (GladeXmlNode *node_in, const gchar *name);
gboolean glade_xml_get_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean _default);
gdouble  glade_xml_get_property_double (GladeXmlNode *node_in, const gchar *name, gdouble _default);
gint     glade_xml_get_property_int (GladeXmlNode *node_in, const gchar *name, gint _default);
gboolean glade_xml_get_property_version (GladeXmlNode *node_in, const gchar *name, guint16 *major, guint16 *minor);
GList   *glade_xml_get_property_targetable_versions (GladeXmlNode *node_in, const gchar *name);


void glade_xml_node_set_property_string (GladeXmlNode *node_in, const gchar *name, const gchar *string);
void glade_xml_node_set_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean value);

/* Node operations */
GladeXmlNode * glade_xml_node_new (GladeXmlContext *context, const gchar *name);
GladeXmlNode * glade_xml_node_new_comment (GladeXmlContext *context, const gchar *comment);
GladeXmlNode * glade_xml_node_copy (GladeXmlNode *node);
void           glade_xml_node_delete (GladeXmlNode *node);
GladeXmlNode * glade_xml_node_get_children (GladeXmlNode *node);
GladeXmlNode * glade_xml_node_get_parent (GladeXmlNode *node_in);
GladeXmlNode * glade_xml_node_next (GladeXmlNode *node_in);
gboolean       glade_xml_node_verify (GladeXmlNode *node_in, const gchar *name);
gboolean       glade_xml_node_verify_silent (GladeXmlNode *node_in, const gchar *name);
const gchar *  glade_xml_node_get_name (GladeXmlNode *node_in);
void           glade_xml_node_append_child (GladeXmlNode * node, GladeXmlNode *child);
void           glade_xml_node_remove (GladeXmlNode *node_in);
gboolean       glade_xml_node_is_comment (GladeXmlNode *node_in);
GladeXmlNode * glade_xml_node_next_with_comments (GladeXmlNode *node_in);
GladeXmlNode * glade_xml_node_prev_with_comments (GladeXmlNode *node_in);
GladeXmlNode * glade_xml_node_get_children_with_comments (GladeXmlNode *node);
GladeXmlNode * glade_xml_node_add_prev_sibling (GladeXmlNode *node, GladeXmlNode *new_node);
GladeXmlNode * glade_xml_node_add_next_sibling (GladeXmlNode *node, GladeXmlNode *new_node);
GType          glade_xml_node_get_type (void) G_GNUC_CONST;

/* Document Operations */
GladeXmlNode * glade_xml_doc_get_root (GladeXmlDoc *doc);
GladeXmlDoc *  glade_xml_doc_new (void);
GladeXmlDoc *  glade_xml_doc_ref (GladeXmlDoc *doc);
void           glade_xml_doc_unref (GladeXmlDoc *doc);
void           glade_xml_doc_set_root (GladeXmlDoc *doc, GladeXmlNode *node);
gint           glade_xml_doc_save (GladeXmlDoc *doc_in, const gchar *full_path);
GladeXmlNode * glade_xml_doc_new_comment (GladeXmlDoc *doc, const gchar *comment);
GType          glade_xml_doc_get_type (void) G_GNUC_CONST;

/* Parse Context */
GladeXmlContext * glade_xml_context_new     (GladeXmlDoc *doc, const gchar *name_space);
GladeXmlContext * glade_xml_context_copy    (GladeXmlContext *context);
void              glade_xml_context_free    (GladeXmlContext *context);
GladeXmlContext * glade_xml_context_new_from_path (const gchar *full_path,
                                                   const gchar *nspace,
                                                   const gchar *root_name);
GladeXmlDoc *     glade_xml_context_get_doc (GladeXmlContext *context);
GType             glade_xml_context_get_type (void) G_GNUC_CONST;

/* Dumps an xml string from a context */
gchar * glade_xml_dump_from_context (GladeXmlContext *context);

gboolean        glade_xml_load_sym_from_node (GladeXmlNode     *node_in,
                                              GModule          *module,
                                              gchar            *tagname,
                                              gpointer         *sym_location);

G_DEFINE_AUTOPTR_CLEANUP_FUNC (GladeXmlDoc, glade_xml_doc_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GladeXmlContext, glade_xml_context_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GladeXmlNode, glade_xml_node_delete)

G_END_DECLS

#endif /* __GLADE_XML_UTILS_H__ */