]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Aded member function ZakFormElement::xml_parsing.
authorAndrea Zagli <azagli@libero.it>
Sat, 28 Nov 2015 12:34:40 +0000 (13:34 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 28 Nov 2015 12:34:40 +0000 (13:34 +0100)
src/formelement.c
src/formelement.h

index 855c5df94f2d1cc2f61bf419db2cec3e4677c6f9..da9775a054f41ba2a070779f6fab5694aefd39e0 100644 (file)
@@ -51,6 +51,8 @@ static void zak_form_element_get_property (GObject *object,
 static void zak_form_element_dispose (GObject *gobject);
 static void zak_form_element_finalize (GObject *gobject);
 
+static void zak_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmlnode);
+
 static GPtrArray *zak_form_element_get_messages (ZakFormElement *element);
 
 typedef struct
@@ -77,6 +79,7 @@ zak_form_element_class_init (ZakFormElementClass *class)
        object_class->dispose = zak_form_element_dispose;
        object_class->finalize = zak_form_element_finalize;
 
+       class->xml_parsing = zak_form_element_xml_parsing;
        class->get_messages = zak_form_element_get_messages;
 
        g_object_class_install_property (object_class, PROP_VALUE,
@@ -624,6 +627,23 @@ zak_form_element_finalize (GObject *gobject)
        parent_class->finalize (gobject);
 }
 
+static void
+zak_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmlnode)
+{
+       xmlNode *cur;
+
+       cur = xmlnode->children;
+       while (cur)
+               {
+                   if (xmlStrcmp (cur->name, (const xmlChar *)"default-value") == 0)
+                               {
+                                       zak_form_element_set_default_value (element, (const gchar *)xmlNodeGetContent (cur));
+                               }
+
+                       cur = cur->next;
+               }
+}
+
 static GPtrArray
 *zak_form_element_get_messages (ZakFormElement *element)
 {
index 4f3dc31a133e84fc2450dddca8aa531cbadefbf5..6640edb7c1c6c2291178e2ca5120f69244d9f7f9 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <glib-object.h>
 
+#include <libxml/tree.h>
+
 #include "formelementfilter.h"
 #include "formelementvalidator.h"
 
@@ -36,6 +38,8 @@ struct _ZakFormElementClass
        {
                GObjectClass parent_class;
 
+               void (*xml_parsing) (ZakFormElement *element, xmlNode *xmlnode);
+
                gboolean (*set_value) (ZakFormElement *element, const gchar *value);
                gchar *(*get_value) (ZakFormElement *element);