glade-xml-utils.h 15.2 KB
Newer Older
Chema Celorio's avatar
Chema Celorio committed
1
/* TODO : s/glade_xml_get_/glade_xml_node_get/g */
Jose Maria Celorio's avatar
Jose Maria Celorio committed
2 3 4
#ifndef __GLADE_XML_UTILS_H__
#define __GLADE_XML_UTILS_H__

5
#include <glib.h>
6
#include <glib-object.h>
7 8
#include <gmodule.h>

9

Jose Maria Celorio's avatar
Jose Maria Celorio committed
10 11
G_BEGIN_DECLS

Chema Celorio's avatar
Chema Celorio committed
12 13 14
#define GLADE_XML_CONTEXT(c)    ((GladeXmlContext *)c)
#define GLADE_XML_IS_CONTEXT(c) (c != NULL)

15 16 17
#define CAST_BAD (gchar *)


Tristan Van Berkom's avatar
Tristan Van Berkom committed
18 19 20 21
typedef struct _GladeXmlContext GladeXmlContext;
typedef struct _GladeXmlNode    GladeXmlNode;
typedef struct _GladeXmlDoc     GladeXmlDoc;

22 23
/* FIXME: forward declarations to get around circular header dependencies.
 */
24 25 26 27
typedef struct _GladeWidget         GladeWidget;
typedef struct _GladeWidgetAdaptor  GladeWidgetAdaptor;
typedef struct _GladeProperty       GladeProperty;
typedef struct _GladeProject        GladeProject;
28

29

30 31
#define GLADE_GTKBUILDER_VERSIONING_BASE_MAJOR    2
#define GLADE_GTKBUILDER_VERSIONING_BASE_MINOR    14
32 33 34 35
#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))
36

37

38
/* Used for catalog tags and attributes */
39 40
#define GLADE_XML_TAG_PROJECT                     "interface"
#define GLADE_XML_TAG_WIDGET                      "object"
41
#define GLADE_XML_TAG_TEMPLATE                    "template"
42

43
#define GLADE_XML_TAG_VERSION                     "version"
44
#define GLADE_XML_TAG_REQUIRES                    "requires"
45
#define GLADE_XML_TAG_LIB                         "lib"
46 47 48 49 50
#define GLADE_XML_TAG_PROPERTY                    "property"
#define GLADE_XML_TAG_CLASS                       "class"
#define GLADE_XML_TAG_ID                          "id"
#define GLADE_XML_TAG_SIGNAL                      "signal"
#define GLADE_XML_TAG_HANDLER                     "handler"
51
#define GLADE_XML_TAG_AFTER                       "after"
52
#define GLADE_XML_TAG_SWAPPED                     "swapped"
53
#define GLADE_XML_TAG_OBJECT                      "object"
54 55 56 57 58
#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"
59 60
#define GLADE_XML_TAG_I18N_TRUE                   "yes"
#define GLADE_XML_TAG_SIGNAL_TRUE                 "yes"
61
#define GLADE_XML_TAG_SIGNAL_FALSE                "no"
62
#define GLADE_XML_TAG_TYPE                        "type"
63 64 65 66
#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"
67 68 69 70

#define GLADE_TAG_VERSION                         "version"
#define GLADE_TAG_TARGETABLE                      "targetable"
#define GLADE_TAG_VERSION_SINCE                   "since"
71
#define GLADE_TAG_BUILDER_SINCE                   "gtkbuilder-since"
72
#define GLADE_TAG_DEPRECATED                      "deprecated"
73
#define GLADE_TAG_DEPRECATED_SINCE                "deprecated-since"
74

75 76 77 78 79 80 81 82 83 84
#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"
85 86
#define GLADE_TAG_SIGNALS                         "signals"
#define GLADE_TAG_SIGNAL                          "signal"
87 88
#define GLADE_TAG_INTERNAL_CHILDREN               "internal-children"
#define GLADE_TAG_ANARCHIST                       "anarchist"
89
#define GLADE_TAG_DEFAULT                         "default"
90
#define GLADE_TAG_PARENTLESS_WIDGET               "parentless-widget"
91
#define GLADE_TAG_DISABLED                        "disabled"
92
#define GLADE_TAG_CONSTRUCT_ONLY                  "construct-only"
93
#define GLADE_TAG_NEEDS_SYNC                      "needs-sync"
94 95
#define GLADE_TAG_DEFAULT_PALETTE_STATE           "default-palette-state"
#define GLADE_TAG_REPLACE_CHILD_FUNCTION          "replace-child-function"
96
#define GLADE_TAG_CREATE_WIDGET_FUNCTION          "create-widget-function"
97
#define GLADE_TAG_CONSTRUCT_OBJECT_FUNCTION       "construct-object-function"
98
#define GLADE_TAG_DESTROY_OBJECT_FUNCTION         "destroy-object-function"
99
#define GLADE_TAG_DEEP_POST_CREATE_FUNCTION       "deep-post-create-function"
100 101 102
#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"
103
#define GLADE_TAG_ADD_CHILD_VERIFY_FUNCTION       "add-child-verify-function"
104 105 106 107 108
#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"
109 110
#define GLADE_TAG_CONSTRUCTOR_FUNCTION            "constructor-function"
#define GLADE_TAG_ACTION_ACTIVATE_FUNCTION        "action-activate-function"
111
#define GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION  "child-action-activate-function"
Tristan Van Berkom's avatar
Tristan Van Berkom committed
112
#define GLADE_TAG_ACTION_SUBMENU_FUNCTION         "action-submenu-function"
113
#define GLADE_TAG_DEPENDS_FUNCTION                "depends-function"
114 115
#define GLADE_TAG_READ_WIDGET_FUNCTION            "read-widget-function"
#define GLADE_TAG_WRITE_WIDGET_FUNCTION           "write-widget-function"
116
#define GLADE_TAG_WRITE_WIDGET_AFTER_FUNCTION     "write-widget-after-function"
117 118
#define GLADE_TAG_READ_CHILD_FUNCTION             "read-child-function"
#define GLADE_TAG_WRITE_CHILD_FUNCTION            "write-child-function"
119 120
#define GLADE_TAG_CREATE_EPROP_FUNCTION           "create-editor-property-function"
#define GLADE_TAG_STRING_FROM_VALUE_FUNCTION      "string-from-value-function"
121
#define GLADE_TAG_CREATE_EDITABLE_FUNCTION        "create-editable-function"
122 123 124
#define GLADE_TAG_PROPERTIES                      "properties"
#define GLADE_TAG_PACKING_PROPERTIES              "packing-properties"
#define GLADE_TAG_PROPERTY                        "property"
125 126 127
#define GLADE_TAG_ACTIONS                         "actions"
#define GLADE_TAG_PACKING_ACTIONS                 "packing-actions"
#define GLADE_TAG_ACTION                          "action"
128 129
#define GLADE_TAG_TYPE                            "type"
#define GLADE_TAG_SPEC                            "spec"
130 131 132 133
#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"
134 135 136 137 138 139 140 141 142
#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"
Tristan Van Berkom's avatar
Tristan Van Berkom committed
143
#define GLADE_TAG_CUSTOM_LAYOUT                   "custom-layout"
144 145 146
#define GLADE_TAG_EXPANDED                        "expanded"
#define GLADE_TAG_GENERIC_NAME                    "generic-name"
#define GLADE_TAG_NAME                            "name"
147
#define GLADE_TAG_PARENT                          "parent"
148 149 150 151 152
#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"
153
#define GLADE_TAG_HAS_CONTEXT                     "context"
154
#define GLADE_TAG_CONTEXT                         "context"
155
#define GLADE_TAG_COMMENT                         "comments"
156 157 158 159 160 161 162
#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"
163
#define GLADE_TAG_SAVE_ALWAYS                     "save-always"
164 165
#define GLADE_TAG_EDITABLE                        "editable"
#define GLADE_TAG_IGNORE                          "ignore"
166
#define GLADE_TAG_MULTILINE                       "multiline"
167
#define GLADE_TAG_RESOURCE                        "resource"
168 169
#define GLADE_TAG_STOCK                           "stock"
#define GLADE_TAG_STOCK_ICON                      "stock-icon"
170
#define GLADE_TAG_THEMED_ICON                     "themed-icon"
171 172 173 174 175 176
#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"
177
#define GLADE_TAG_USE_PLACEHOLDERS                "use-placeholders"
178 179
#define GLADE_TAG_DEFAULT_WIDTH                   "default-width"
#define GLADE_TAG_DEFAULT_HEIGHT                  "default-height"
180 181 182 183 184
#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"
Vincent Geddes's avatar
Vincent Geddes committed
185 186
#define GLADE_TAG_ICON_PREFIX                     "icon-prefix"
#define GLADE_TAG_ICON_NAME                       "icon-name"
187
#define GLADE_TAG_IMPORTANT                       "important"
188
#define GLADE_TAG_CREATE_TYPE                     "create-type"
189
#define GLADE_TAG_TEMPLATE_PREFIX                 "template-prefix"
Chema Celorio's avatar
Chema Celorio committed
190

191

192
/* search child */
193 194
GladeXmlNode *   glade_xml_search_child          (GladeXmlNode *node, const gchar *name);
GladeXmlNode *   glade_xml_search_child_required (GladeXmlNode *tree, const gchar *name);
195 196 197

/* content */

198
gchar *      glade_xml_get_content (GladeXmlNode *node_in); /* Get the content of the node */
Chema Celorio's avatar
Chema Celorio committed
199
void         glade_xml_set_content (GladeXmlNode *node_in, const gchar *content);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
200

201 202
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);
Chema Celorio's avatar
Chema Celorio committed
203

204 205 206 207
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);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
208

209
gboolean glade_xml_get_boolean (GladeXmlNode *node, const gchar *name, gboolean _default);
Chema Celorio's avatar
Chema Celorio committed
210

211
void         glade_xml_set_value (GladeXmlNode *node_in, const gchar *name, const gchar *val);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
212

Chema Celorio's avatar
Chema Celorio committed
213
/* Properties */ 
214 215
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);
216
gboolean glade_xml_get_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean _default);
217
gdouble  glade_xml_get_property_double (GladeXmlNode *node_in, const gchar *name, gdouble _default);
218
gint     glade_xml_get_property_int (GladeXmlNode *node_in, const gchar *name, gint _default);
Tristan Van Berkom's avatar
Tristan Van Berkom committed
219
gboolean glade_xml_get_property_version (GladeXmlNode *node_in, const gchar *name, guint16 *major, guint16 *minor);
220 221
GList   *glade_xml_get_property_targetable_versions (GladeXmlNode *node_in, const gchar *name);

222

Chema Celorio's avatar
Chema Celorio committed
223
void glade_xml_node_set_property_string (GladeXmlNode *node_in, const gchar *name, const gchar *string);
224
void glade_xml_node_set_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean value);
Jose Maria Celorio's avatar
Jose Maria Celorio committed
225

Chema Celorio's avatar
Chema Celorio committed
226 227
/* Node operations */
GladeXmlNode * glade_xml_node_new (GladeXmlContext *context, const gchar *name);
228
GladeXmlNode * glade_xml_node_new_comment (GladeXmlContext *context, const gchar *comment);
229
GladeXmlNode * glade_xml_node_copy (GladeXmlNode *node);
230
void           glade_xml_node_delete (GladeXmlNode *node);
Chema Celorio's avatar
Chema Celorio committed
231
GladeXmlNode * glade_xml_node_get_children (GladeXmlNode *node);
232
GladeXmlNode * glade_xml_node_get_parent (GladeXmlNode *node_in);
Chema Celorio's avatar
Chema Celorio committed
233
GladeXmlNode * glade_xml_node_next (GladeXmlNode *node_in);
234
gboolean       glade_xml_node_verify (GladeXmlNode *node_in, const gchar *name);
235 236
gboolean       glade_xml_node_verify_silent (GladeXmlNode *node_in, const gchar *name);
const gchar *  glade_xml_node_get_name (GladeXmlNode *node_in);
237
void           glade_xml_node_append_child (GladeXmlNode * node, GladeXmlNode *child);
238
void           glade_xml_node_remove (GladeXmlNode *node_in);
239 240
gboolean       glade_xml_node_is_comment (GladeXmlNode *node_in);
GladeXmlNode * glade_xml_node_next_with_comments (GladeXmlNode *node_in);
241
GladeXmlNode * glade_xml_node_prev_with_comments (GladeXmlNode *node_in);
242
GladeXmlNode * glade_xml_node_get_children_with_comments (GladeXmlNode *node);
243 244
GladeXmlNode * glade_xml_node_add_prev_sibling (GladeXmlNode *node, GladeXmlNode *new_node);
GladeXmlNode * glade_xml_node_add_next_sibling (GladeXmlNode *node, GladeXmlNode *new_node);
245
GType          glade_xml_node_get_type (void) G_GNUC_CONST;
Jose Maria Celorio's avatar
Jose Maria Celorio committed
246

Chema Celorio's avatar
Chema Celorio committed
247 248
/* Document Operatons */
GladeXmlNode * glade_xml_doc_get_root (GladeXmlDoc *doc);
249 250 251 252
GladeXmlDoc *  glade_xml_doc_new (void);
void           glade_xml_doc_set_root (GladeXmlDoc *doc, GladeXmlNode *node);
void           glade_xml_doc_free (GladeXmlDoc *doc_in);
gint           glade_xml_doc_save (GladeXmlDoc *doc_in, const gchar *full_path);
253
GladeXmlNode * glade_xml_doc_new_comment (GladeXmlDoc *doc, const gchar *comment);
254

255 256 257 258 259
/* Parse Context */
GladeXmlContext * glade_xml_context_new     (GladeXmlDoc *doc, const gchar *name_space);
void              glade_xml_context_destroy (GladeXmlContext *context);
void              glade_xml_context_free    (GladeXmlContext *context);
GladeXmlContext * glade_xml_context_new_from_path (const gchar *full_path,
260 261
                                                   const gchar *nspace,
                                                   const gchar *root_name);
262
GladeXmlDoc *     glade_xml_context_get_doc (GladeXmlContext *context);
263

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

Juan Pablo Ugarte's avatar
Juan Pablo Ugarte committed
267
gboolean        glade_xml_load_sym_from_node (GladeXmlNode     *node_in,
268 269 270
                                              GModule          *module,
                                              gchar            *tagname,
                                              gpointer         *sym_location);
271

Jose Maria Celorio's avatar
Jose Maria Celorio committed
272 273 274
G_END_DECLS

#endif /* __GLADE_XML_UTILS_H__ */