1 /* TODO : s/glade_xml_get_/glade_xml_node_get/g */
2 #ifndef __GLADE_XML_UTILS_H__
3 #define __GLADE_XML_UTILS_H__
4 
5 #include <glib.h>
6 #include <gmodule.h>
7 
8 
9 G_BEGIN_DECLS
10 
11 #define GLADE_XML_CONTEXT(c)    ((GladeXmlContext *)c)
12 #define GLADE_XML_IS_CONTEXT(c) (c != NULL)
13 
14 #define CAST_BAD (gchar *)
15 
16 
17 typedef struct _GladeXmlContext GladeXmlContext;
18 typedef struct _GladeXmlNode    GladeXmlNode;
19 typedef struct _GladeXmlDoc     GladeXmlDoc;
20 
21 /* FIXME: forward declarations to get around circular header dependencies.
22  */
23 typedef struct _GladeWidget         GladeWidget;
24 typedef struct _GladeWidgetAdaptor  GladeWidgetAdaptor;
25 typedef struct _GladeProperty       GladeProperty;
26 typedef struct _GladeProject        GladeProject;
27 
28 
29 #define GLADE_GTKBUILDER_VERSIONING_BASE_MAJOR    2
30 #define GLADE_GTKBUILDER_VERSIONING_BASE_MINOR    14
31 #define GLADE_GTKBUILDER_HAS_VERSIONING(maj, min) \
32 	((maj) > GLADE_GTKBUILDER_VERSIONING_BASE_MAJOR || \
33 	 ((maj) == GLADE_GTKBUILDER_VERSIONING_BASE_MAJOR && \
34 	  (min) >= GLADE_GTKBUILDER_VERSIONING_BASE_MINOR))
35 
36 
37 /* Used for catalog tags and attributes */
38 #define GLADE_XML_TAG_PROJECT                     "interface"
39 #define GLADE_XML_TAG_WIDGET                      "object"
40 #define GLADE_XML_TAG_TEMPLATE                    "template"
41 
42 #define GLADE_XML_TAG_VERSION                     "version"
43 #define GLADE_XML_TAG_REQUIRES                    "requires"
44 #define GLADE_XML_TAG_LIB                         "lib"
45 #define GLADE_XML_TAG_PROPERTY                    "property"
46 #define GLADE_XML_TAG_CLASS                       "class"
47 #define GLADE_XML_TAG_ID                          "id"
48 #define GLADE_XML_TAG_SIGNAL                      "signal"
49 #define GLADE_XML_TAG_HANDLER                     "handler"
50 #define GLADE_XML_TAG_AFTER                       "after"
51 #define GLADE_XML_TAG_SWAPPED                     "swapped"
52 #define GLADE_XML_TAG_OBJECT                      "object"
53 #define GLADE_XML_TAG_NAME                        "name"
54 #define GLADE_XML_TAG_CHILD                       "child"
55 #define GLADE_XML_TAG_PACKING                     "packing"
56 #define GLADE_XML_TAG_PLACEHOLDER                 "placeholder"
57 #define GLADE_XML_TAG_INTERNAL_CHILD              "internal-child"
58 #define GLADE_XML_TAG_I18N_TRUE                   "yes"
59 #define GLADE_XML_TAG_SIGNAL_TRUE                 "yes"
60 #define GLADE_XML_TAG_SIGNAL_FALSE                "no"
61 #define GLADE_XML_TAG_TYPE                        "type"
62 #define GLADE_XML_TAG_SOURCES                     "sources"
63 #define GLADE_XML_TAG_SOURCE                      "source"
64 #define GLADE_XML_TAG_FILENAME                    "filename"
65 #define GLADE_XML_TAG_STOCK_ID                    "stock-id"
66 
67 #define GLADE_TAG_VERSION                         "version"
68 #define GLADE_TAG_TARGETABLE                      "targetable"
69 #define GLADE_TAG_VERSION_SINCE                   "since"
70 #define GLADE_TAG_BUILDER_SINCE                   "gtkbuilder-since"
71 #define GLADE_TAG_DEPRECATED                      "deprecated"
72 
73 #define GLADE_TAG_GLADE_CATALOG                   "glade-catalog"
74 #define GLADE_TAG_GLADE_WIDGET_CLASSES            "glade-widget-classes"
75 #define GLADE_TAG_GLADE_WIDGET_CLASS              "glade-widget-class"
76 #define GLADE_TAG_GLADE_WIDGET_GROUP              "glade-widget-group"
77 #define GLADE_TAG_GLADE_WIDGET_CLASS_REF          "glade-widget-class-ref"
78 #define GLADE_TAG_ADAPTOR                         "adaptor"
79 #define GLADE_TAG_LIBRARY                         "library"
80 #define GLADE_TAG_DEPENDS                         "depends"
81 #define GLADE_TAG_DOMAIN                          "domain"
82 #define GLADE_TAG_BOOK                            "book"
83 #define GLADE_TAG_SIGNALS                         "signals"
84 #define GLADE_TAG_SIGNAL                          "signal"
85 #define GLADE_TAG_INTERNAL_CHILDREN               "internal-children"
86 #define GLADE_TAG_ANARCHIST                       "anarchist"
87 #define GLADE_TAG_DEFAULT                         "default"
88 #define GLADE_TAG_PARENTLESS_WIDGET               "parentless-widget"
89 #define GLADE_TAG_DISABLED                        "disabled"
90 #define GLADE_TAG_CONSTRUCT_ONLY                  "construct-only"
91 #define GLADE_TAG_NEEDS_SYNC                      "needs-sync"
92 #define GLADE_TAG_DEFAULT_PALETTE_STATE           "default-palette-state"
93 #define GLADE_TAG_REPLACE_CHILD_FUNCTION          "replace-child-function"
94 #define GLADE_TAG_CREATE_WIDGET_FUNCTION          "create-widget-function"
95 #define GLADE_TAG_CONSTRUCT_OBJECT_FUNCTION       "construct-object-function"
96 #define GLADE_TAG_DESTROY_OBJECT_FUNCTION         "destroy-object-function"
97 #define GLADE_TAG_DEEP_POST_CREATE_FUNCTION       "deep-post-create-function"
98 #define GLADE_TAG_POST_CREATE_FUNCTION            "post-create-function"
99 #define GLADE_TAG_GET_INTERNAL_CHILD_FUNCTION     "get-internal-child-function"
100 #define GLADE_TAG_ADD_CHILD_FUNCTION              "add-child-function"
101 #define GLADE_TAG_ADD_CHILD_VERIFY_FUNCTION       "add-child-verify-function"
102 #define GLADE_TAG_REMOVE_CHILD_FUNCTION           "remove-child-function"
103 #define GLADE_TAG_GET_CHILDREN_FUNCTION           "get-children-function"
104 #define GLADE_TAG_CHILD_SET_PROP_FUNCTION         "child-set-property-function"
105 #define GLADE_TAG_CHILD_GET_PROP_FUNCTION         "child-get-property-function"
106 #define GLADE_TAG_CHILD_VERIFY_FUNCTION           "child-verify-function"
107 #define GLADE_TAG_CONSTRUCTOR_FUNCTION            "constructor-function"
108 #define GLADE_TAG_ACTION_ACTIVATE_FUNCTION        "action-activate-function"
109 #define GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION  "child-action-activate-function"
110 #define GLADE_TAG_ACTION_SUBMENU_FUNCTION         "action-submenu-function"
111 #define GLADE_TAG_DEPENDS_FUNCTION                "depends-function"
112 #define GLADE_TAG_READ_WIDGET_FUNCTION            "read-widget-function"
113 #define GLADE_TAG_WRITE_WIDGET_FUNCTION           "write-widget-function"
114 #define GLADE_TAG_WRITE_WIDGET_AFTER_FUNCTION     "write-widget-after-function"
115 #define GLADE_TAG_READ_CHILD_FUNCTION             "read-child-function"
116 #define GLADE_TAG_WRITE_CHILD_FUNCTION            "write-child-function"
117 #define GLADE_TAG_CREATE_EPROP_FUNCTION           "create-editor-property-function"
118 #define GLADE_TAG_STRING_FROM_VALUE_FUNCTION      "string-from-value-function"
119 #define GLADE_TAG_CREATE_EDITABLE_FUNCTION        "create-editable-function"
120 #define GLADE_TAG_PROPERTIES                      "properties"
121 #define GLADE_TAG_PACKING_PROPERTIES              "packing-properties"
122 #define GLADE_TAG_PROPERTY                        "property"
123 #define GLADE_TAG_ACTIONS                         "actions"
124 #define GLADE_TAG_PACKING_ACTIONS                 "packing-actions"
125 #define GLADE_TAG_ACTION                          "action"
126 #define GLADE_TAG_TYPE                            "type"
127 #define GLADE_TAG_SPEC                            "spec"
128 #define GLADE_TAG_SPECIFICATIONS                  "parameter-spec"
129 #define GLADE_TAG_MAX_VALUE                       "max"
130 #define GLADE_TAG_MIN_VALUE                       "min"
131 #define GLADE_TAG_VALUE_TYPE                      "value-type"
132 #define GLADE_TAG_TOOLTIP                         "tooltip"
133 #define GLADE_TAG_SET_FUNCTION                    "set-property-function"
134 #define GLADE_TAG_GET_FUNCTION                    "get-property-function"
135 #define GLADE_TAG_VERIFY_FUNCTION                 "verify-function"
136 #define GLADE_TAG_QUERY                           "query"
137 #define GLADE_TAG_COMMON                          "common"
138 #define GLADE_TAG_OPTIONAL                        "optional"
139 #define GLADE_TAG_OPTIONAL_DEFAULT                "optional-default"
140 #define GLADE_TAG_VISIBLE                         "visible"
141 #define GLADE_TAG_CUSTOM_LAYOUT                   "custom-layout"
142 #define GLADE_TAG_EXPANDED                        "expanded"
143 #define GLADE_TAG_GENERIC_NAME                    "generic-name"
144 #define GLADE_TAG_NAME                            "name"
145 #define GLADE_TAG_PARENT                          "parent"
146 #define GLADE_TAG_TITLE                           "title"
147 #define GLADE_TAG_ID                              "id"
148 #define GLADE_TAG_KEY                             "key"
149 #define GLADE_TAG_VALUE                           "value"
150 #define GLADE_TAG_TRANSLATABLE                    "translatable"
151 #define GLADE_TAG_HAS_CONTEXT                     "context"
152 #define GLADE_TAG_CONTEXT                         "context"
153 #define GLADE_TAG_COMMENT                         "comments"
154 #define GLADE_TAG_PACKING_DEFAULTS                "packing-defaults"
155 #define GLADE_TAG_PARENT_CLASS                    "parent-class"
156 #define GLADE_TAG_CHILD_PROPERTY                  "child-property"
157 #define GLADE_TAG_DISPLAYABLE_VALUES              "displayable-values"
158 #define GLADE_TAG_NICK                            "nick"
159 #define GLADE_TAG_SPECIAL_CHILD_TYPE              "special-child-type"
160 #define GLADE_TAG_SAVE                            "save"
161 #define GLADE_TAG_SAVE_ALWAYS                     "save-always"
162 #define GLADE_TAG_EDITABLE                        "editable"
163 #define GLADE_TAG_IGNORE                          "ignore"
164 #define GLADE_TAG_MULTILINE                       "multiline"
165 #define GLADE_TAG_RESOURCE                        "resource"
166 #define GLADE_TAG_STOCK                           "stock"
167 #define GLADE_TAG_STOCK_ICON                      "stock-icon"
168 #define GLADE_TAG_THEMED_ICON                     "themed-icon"
169 #define GLADE_TAG_INIT_FUNCTION                   "init-function"
170 #define GLADE_TAG_ATK_PROPERTY                    "atk-property"
171 #define GLADE_TAG_TRANSFER_ON_PASTE               "transfer-on-paste"
172 #define GLADE_TAG_WEIGHT                          "weight"
173 #define GLADE_TAG_GET_TYPE_FUNCTION               "get-type-function"
174 #define GLADE_TAG_TOPLEVEL                        "toplevel"
175 #define GLADE_TAG_USE_PLACEHOLDERS                "use-placeholders"
176 #define GLADE_TAG_DEFAULT_WIDTH                   "default-width"
177 #define GLADE_TAG_DEFAULT_HEIGHT                  "default-height"
178 #define GLADE_TAG_EVENT_HANDLER_CONNECTED         "EventHandlerConnected"
179 #define GLADE_TAG_FALSE                           "False"
180 #define GLADE_TAG_TRUE                            "True"
181 #define GLADE_TAG_YES                             "Yes"
182 #define GLADE_TAG_NO                              "No"
183 #define GLADE_TAG_ICON_PREFIX                     "icon-prefix"
184 #define GLADE_TAG_ICON_NAME                       "icon-name"
185 #define GLADE_TAG_IMPORTANT                       "important"
186 #define GLADE_TAG_CREATE_TYPE                     "create-type"
187 
188 
189 /* search child */
190 GladeXmlNode *   glade_xml_search_child          (GladeXmlNode * node, const gchar *name);
191 GladeXmlNode *   glade_xml_search_child_required (GladeXmlNode * tree, const gchar* name);
192 
193 /* content */
194 
195 gchar *      glade_xml_get_content (GladeXmlNode * node_in); /* Get the content of the node */
196 void         glade_xml_set_content (GladeXmlNode *node_in, const gchar *content);
197 
198 gboolean     glade_xml_get_value_int          (GladeXmlNode * node_in, const gchar *name, int *val);
199 gboolean     glade_xml_get_value_int_required (GladeXmlNode * node, const gchar *name, int *val);
200 
201 gchar *      glade_xml_get_value_string          (GladeXmlNode * node, const gchar *name);
202 gchar *      glade_xml_get_value_string_required (GladeXmlNode * node,
203 					    const gchar *name,
204 					    const gchar *xtra_info);
205 
206 gboolean glade_xml_get_boolean (GladeXmlNode * node, const gchar *name, gboolean _default);
207 
208 void         glade_xml_set_value (GladeXmlNode * node_in, const gchar *name, const gchar *val);
209 
210 /* Properties */
211 gchar *  glade_xml_get_property_string_required (GladeXmlNode *node_in, const gchar *name, const gchar *xtra);
212 gchar *  glade_xml_get_property_string (GladeXmlNode *node_in, const gchar *name);
213 gboolean glade_xml_get_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean _default);
214 gdouble  glade_xml_get_property_double (GladeXmlNode *node_in, const gchar *name, gdouble _default);
215 gint     glade_xml_get_property_int (GladeXmlNode *node_in, const gchar *name, gint _default);
216 gboolean glade_xml_get_property_version (GladeXmlNode *node_in, const gchar *name, guint16 *major, guint16 *minor);
217 GList   *glade_xml_get_property_targetable_versions (GladeXmlNode *node_in, const gchar *name);
218 
219 
220 void glade_xml_node_set_property_string (GladeXmlNode *node_in, const gchar *name, const gchar *string);
221 void glade_xml_node_set_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean value);
222 
223 /* Node operations */
224 GladeXmlNode * glade_xml_node_new (GladeXmlContext *context, const gchar *name);
225 GladeXmlNode * glade_xml_node_new_comment (GladeXmlContext *context, const gchar *comment);
226 GladeXmlNode * glade_xml_node_copy (GladeXmlNode *node);
227 void           glade_xml_node_delete (GladeXmlNode *node);
228 GladeXmlNode * glade_xml_node_get_children (GladeXmlNode *node);
229 GladeXmlNode * glade_xml_node_get_parent (GladeXmlNode *node_in);
230 GladeXmlNode * glade_xml_node_next (GladeXmlNode *node_in);
231 gboolean       glade_xml_node_verify (GladeXmlNode * node_in, const gchar *name);
232 gboolean       glade_xml_node_verify_silent (GladeXmlNode *node_in, const gchar *name);
233 const gchar *  glade_xml_node_get_name (GladeXmlNode *node_in);
234 void           glade_xml_node_append_child (GladeXmlNode * node, GladeXmlNode * child);
235 void           glade_xml_node_remove (GladeXmlNode *node_in);
236 gboolean       glade_xml_node_is_comment (GladeXmlNode *node_in);
237 GladeXmlNode * glade_xml_node_next_with_comments (GladeXmlNode *node_in);
238 GladeXmlNode * glade_xml_node_prev_with_comments (GladeXmlNode * node_in);
239 GladeXmlNode * glade_xml_node_get_children_with_comments (GladeXmlNode *node);
240 GladeXmlNode * glade_xml_node_add_prev_sibling (GladeXmlNode *node, GladeXmlNode *new_node);
241 GladeXmlNode * glade_xml_node_add_next_sibling (GladeXmlNode *node, GladeXmlNode *new_node);
242 
243 /* Document Operatons */
244 GladeXmlNode * glade_xml_doc_get_root (GladeXmlDoc *doc);
245 GladeXmlDoc *  glade_xml_doc_new (void);
246 void           glade_xml_doc_set_root (GladeXmlDoc *doc, GladeXmlNode *node);
247 void           glade_xml_doc_free (GladeXmlDoc *doc_in);
248 gint           glade_xml_doc_save (GladeXmlDoc *doc_in, const gchar *full_path);
249 GladeXmlNode * glade_xml_doc_new_comment (GladeXmlDoc *doc, const gchar *comment);
250 
251 /* Parse Context */
252 GladeXmlContext * glade_xml_context_new     (GladeXmlDoc *doc, const gchar *name_space);
253 void              glade_xml_context_destroy (GladeXmlContext *context);
254 void              glade_xml_context_free    (GladeXmlContext *context);
255 GladeXmlContext * glade_xml_context_new_from_path (const gchar *full_path,
256 						   const gchar *nspace,
257 						   const gchar *root_name);
258 GladeXmlDoc *     glade_xml_context_get_doc (GladeXmlContext *context);
259 
260 /* Dumps an xml string from a context */
261 gchar * glade_xml_dump_from_context (GladeXmlContext *context);
262 
263 gboolean        glade_xml_load_sym_from_node (GladeXmlNode     *node_in,
264 					      GModule          *module,
265 					      gchar            *tagname,
266 					      gpointer         *sym_location);
267 
268 G_END_DECLS
269 
270 #endif /* __GLADE_XML_UTILS_H__ */
271