return zak_form_iprovider_delete (provider, priv->ar_elements);
}
+/**
+ * zak_form_form_get_xml:
+ * @zakform:
+ * @version: not used.
+ *
+ * Returns: the xml fo the form.
+ */
+xmlDoc
+*zak_form_form_get_xml (ZakFormForm *zakform, const gchar *version)
+{
+ ZakFormFormPrivate *priv;
+
+ xmlDoc *xdoc;
+ xmlNode *xroot;
+ xmlNode *xnode;
+
+ gchar *_version;
+
+ guint i;
+
+ if (version == NULL)
+ {
+ _version = g_strdup ("1.0");
+ }
+ else
+ {
+ _version = g_strdup (version);
+ }
+
+ _version = g_strdup ("1.0");
+
+ priv = zak_form_form_get_instance_private (zakform);
+
+ xdoc = xmlNewDoc ((const xmlChar *)"1.0");
+
+ xroot = xmlNewNode (NULL, (const xmlChar *)"zakform");
+ xmlSetProp (xroot, (const xmlChar *)"version", (const xmlChar *)_version);
+ xmlDocSetRootElement (xdoc, xroot);
+
+ for (i = 0; i < priv->ar_elements->len; i++)
+ {
+ xnode = zak_form_element_get_xml ((ZakFormElement *)g_ptr_array_index (priv->ar_elements, i), _version);
+ xmlAddChild (xroot, xnode);
+ }
+
+ g_free (_version);
+
+ return xdoc;
+}
+
/* PRIVATE */
static void
zak_form_form_set_property (GObject *object,
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
gboolean zak_form_form_update (ZakFormForm *zakform, ZakFormIProvider *provider);
gboolean zak_form_form_delete (ZakFormForm *zakform, ZakFormIProvider *provider);
+xmlDoc *zak_form_form_get_xml (ZakFormForm *zakform, const gchar *version);
+
G_END_DECLS
ZAK_FORM_ELEMENT_GET_CLASS (element)->xml_parsing (element, xmlnode);
}
}
+
+xmlNode
+*zak_form_element_get_xml (ZakFormElement *element, const gchar *version)
+{
+ xmlNode *xroot;
+ xmlNode *xnode;
+
+ xroot = xmlNewNode (NULL, (xmlChar *)"element");
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"name");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_name (element));
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"long-name");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_long_name (element));
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"is-key");
+ xmlNodeSetContent (xnode, zak_form_element_get_is_key (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"type");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_provider_type (element));
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"default-value");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_default_value (element));
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"format");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_format (element));
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"visible");
+ xmlNodeSetContent (xnode, zak_form_element_get_visible (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"editable");
+ xmlNodeSetContent (xnode, zak_form_element_get_editable (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"to-load");
+ xmlNodeSetContent (xnode, zak_form_element_get_to_load (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"to-save");
+ xmlNodeSetContent (xnode, zak_form_element_get_to_save (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+
+ if (ZAK_FORM_ELEMENT_GET_CLASS (element)->get_xml != NULL)
+ {
+ ZAK_FORM_ELEMENT_GET_CLASS (element)->get_xml (element, xroot, version);
+ }
+
+ return xroot;
+}
gboolean (*is_valid) (ZakFormElement *element);
+ void (*get_xml) (ZakFormElement *element, xmlNode *xroot, const gchar *version);
+
guint before_validating_signal_id;
guint after_validating_signal_id;
};
ZakFormElementValidator *zak_form_element_get_validator_by_id (ZakFormElement *element, const gchar *id);
GPtrArray *zak_form_element_get_validators_by_type (ZakFormElement *element, GType type);
+xmlNode *zak_form_element_get_xml (ZakFormElement *element, const gchar *version);
+
G_END_DECLS