/*
- * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2017-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
static void zak_form_element_array_clear (ZakFormElement *element);
static gboolean zak_form_element_array_is_valid (ZakFormElement *element);
+static void zak_form_element_array_get_xml (ZakFormElement *element, xmlNode *xnode, const gchar *version);
+
#define ZAK_FORM_ELEMENT_ARRAY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_TYPE_ELEMENT_ARRAY, ZakFormElementArrayPrivate))
typedef struct _ZakFormElementArrayPrivate ZakFormElementArrayPrivate;
struct _ZakFormElementArrayPrivate
{
+ gchar *handler_name;
GPtrArray *ar_elements;
};
elem_class->get_editable = zak_form_element_array_get_editable;
elem_class->clear = zak_form_element_array_clear;
elem_class->is_valid = zak_form_element_array_is_valid;
+ elem_class->get_xml = zak_form_element_array_get_xml;
g_type_class_add_private (object_class, sizeof (ZakFormElementArrayPrivate));
{
ZakFormElementArrayPrivate *priv = ZAK_FORM_ELEMENT_ARRAY_GET_PRIVATE (zak_form_element_array);
+ priv->handler_name = NULL;
priv->ar_elements = g_ptr_array_new ();
}
ZakFormElementConstructorFunc element_constructor;
+ ZakFormElementArrayPrivate *priv = ZAK_FORM_ELEMENT_ARRAY_GET_PRIVATE (element);
+
cur = xmlnode->children;
while (cur != NULL)
{
{
GModule *module;
GCallback func;
- gchar *handler_name;
module = g_module_open (NULL, G_MODULE_BIND_LAZY);
if (module != NULL)
{
- handler_name = (gchar *)xmlNodeGetContent (cur);
+ priv->handler_name = g_strdup ((gchar *)xmlNodeGetContent (cur));
- if (!g_module_symbol (module, handler_name, (gpointer)&func))
+ if (!g_module_symbol (module, priv->handler_name, (gpointer)&func))
{
- g_warning (_("Could not find signal handler '%s'."), handler_name);
+ g_warning (_("Could not find signal handler '%s'."), priv->handler_name);
+ g_free (priv->handler_name);
+ priv->handler_name = NULL;
}
else
{
g_signal_connect (element, "element-added", func, NULL);
}
-
- g_free (handler_name);
}
}
else if (xmlStrEqual (cur->name, (const xmlChar *)"element"))
return ret;
}
+
+static void
+zak_form_element_array_get_xml (ZakFormElement *element, xmlNode *xnode, const gchar *version)
+{
+ guint i;
+
+ xmlNode *cur;
+
+ ZakFormElementArrayPrivate *priv = ZAK_FORM_ELEMENT_ARRAY_GET_PRIVATE (element);
+
+ xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_element_array");
+
+ if (priv->handler_name != NULL
+ && g_strcmp0 (priv->handler_name, "") != 0)
+ {
+ cur = xmlNewNode (NULL, (const xmlChar *)"signal-element-added");
+ xmlNodeSetContent (cur, (xmlChar *)priv->handler_name);
+ xmlAddChild (xnode, cur);
+ }
+
+ for (i = 0; i < priv->ar_elements->len; i++)
+ {
+ cur = zak_form_element_get_xml ((ZakFormElement *)g_ptr_array_index (priv->ar_elements, i), version);
+ xmlAddChild (xnode, cur);
+ }
+}
if (ZAK_FORM_ELEMENT_FILTER_GET_CLASS (filter)->get_xml!= NULL)
{
- ZAK_FORM_ELEMENT_FILTER_GET_CLASS (filter)->get_xml (filter, version, xnode);
+ ZAK_FORM_ELEMENT_FILTER_GET_CLASS (filter)->get_xml (filter, xnode, version);
}
return xnode;
gboolean (*xml_parsing) (ZakFormElementFilter *filter, xmlNode *xnode);
gchar *(*filter) (ZakFormElementFilter *self, const gchar *value);
- void (*get_xml) (ZakFormElementFilter *self, const gchar *version, xmlNode *xnode);
+ void (*get_xml) (ZakFormElementFilter *self, xmlNode *xnode, const gchar *version);
};
gboolean zak_form_element_filter_xml_parsing (ZakFormElementFilter *filter, xmlNode *xnode);
static gboolean zak_form_element_filter_luc_xml_parsing (ZakFormElementFilter *filter, xmlNode *xnode);
static gchar *zak_form_element_filter_luc_filter (ZakFormElementFilter *filter_luc, const gchar *value);
-static void zak_form_element_filter_luc_get_xml (ZakFormElementFilter *filter, const gchar *version, xmlNode *xnode);
+static void zak_form_element_filter_luc_get_xml (ZakFormElementFilter *filter, xmlNode *xnode, const gchar *version);
enum
{
}
static void
-zak_form_element_filter_luc_get_xml (ZakFormElementFilter *filter, const gchar *version, xmlNode *xnode)
+zak_form_element_filter_luc_get_xml (ZakFormElementFilter *filter, xmlNode *xnode, const gchar *version)
{
ZakFormElementFilterLuc *zak_form_element = ZAK_FORM_ELEMENT_FILTER_LUC (filter);
ZakFormElementFilterLucPrivate *priv = ZAK_FORM_ELEMENT_FILTER_LUC_GET_PRIVATE (zak_form_element);
static gboolean zak_form_element_filter_trim_xml_parsing (ZakFormElementFilter *filter, xmlNode *xnode);
static gchar *zak_form_element_filter_trim_filter (ZakFormElementFilter *filter_trim, const gchar *value);
-static void zak_form_element_filter_trim_get_xml (ZakFormElementFilter *filter, const gchar *version, xmlNode *xnode);
+static void zak_form_element_filter_trim_get_xml (ZakFormElementFilter *filter, xmlNode *xnode, const gchar *version);
struct _ZakFormElementFilterTrim
{
}
static void
-zak_form_element_filter_trim_get_xml (ZakFormElementFilter *filter, const gchar *version, xmlNode *xnode)
+zak_form_element_filter_trim_get_xml (ZakFormElementFilter *filter, xmlNode *xnode, const gchar *version)
{
ZakFormElementFilterTrim *zak_form_element = ZAK_FORM_ELEMENT_FILTER_TRIM (filter);
ZakFormElementFilterTrimPrivate *priv = ZAK_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE (zak_form_element);
if (ZAK_FORM_ELEMENT_VALIDATOR_GET_CLASS (validator)->get_xml!= NULL)
{
- ZAK_FORM_ELEMENT_VALIDATOR_GET_CLASS (validator)->get_xml (validator, version, xnode);
+ ZAK_FORM_ELEMENT_VALIDATOR_GET_CLASS (validator)->get_xml (validator, xnode, version);
}
return xnode;
gboolean (*xml_parsing) (ZakFormElementValidator *self, xmlNode *xnode);
gboolean (*validate) (ZakFormElementValidator *self, const gchar *value);
- void (*get_xml) (ZakFormElementValidator *self, const gchar *version, xmlNode *xnode);
+ void (*get_xml) (ZakFormElementValidator *self, xmlNode *xnode, const gchar *version);
};
gboolean zak_form_element_validator_xml_parsing (ZakFormElementValidator *self, xmlNode *xnode);
static gboolean zak_form_element_validator_date_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
static gboolean zak_form_element_validator_date_validate (ZakFormElementValidator *validator_date, const gchar *value);
-static void zak_form_element_validator_date_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode);
+static void zak_form_element_validator_date_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorDate
{
}
static void
-zak_form_element_validator_date_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode)
+zak_form_element_validator_date_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version)
{
ZakFormElementValidatorDate *validator_date = ZAK_FORM_ELEMENT_VALIDATOR_DATE (validator);
ZakFormElementValidatorDatePrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_DATE_GET_PRIVATE (validator_date);
static gboolean zak_form_element_validator_is_number_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
static gboolean zak_form_element_validator_is_number_validate (ZakFormElementValidator *validator_is_number, const gchar *value);
-static void zak_form_element_validator_is_number_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode);
+static void zak_form_element_validator_is_number_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorIsNumber
{
}
static void
-zak_form_element_validator_is_number_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode)
+zak_form_element_validator_is_number_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version)
{
ZakFormElementValidatorIsNumber *validator_isnumber = ZAK_FORM_ELEMENT_VALIDATOR_IS_NUMBER (validator);
ZakFormElementValidatorIsNumberPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_IS_NUMBER_GET_PRIVATE (validator_isnumber);
static gboolean zak_form_element_validator_notempty_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
static gboolean zak_form_element_validator_notempty_validate (ZakFormElementValidator *validator_notempty, const gchar *value);
-static void zak_form_element_validator_notempty_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode);
+static void zak_form_element_validator_notempty_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorNotempty
{
}
static void
-zak_form_element_validator_notempty_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode)
+zak_form_element_validator_notempty_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version)
{
ZakFormElementValidatorNotempty *validator_notempty = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY (validator);
ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (validator_notempty);
static gboolean zak_form_element_validator_number_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
static gboolean zak_form_element_validator_number_validate (ZakFormElementValidator *validator_number, const gchar *value);
-static void zak_form_element_validator_number_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode);
+static void zak_form_element_validator_number_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorNumber
{
}
static void
-zak_form_element_validator_number_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode)
+zak_form_element_validator_number_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version)
{
ZakFormElementValidatorNumber *validator_number = ZAK_FORM_ELEMENT_VALIDATOR_NUMBER (validator);
ZakFormElementValidatorNumberPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NUMBER_GET_PRIVATE (validator_number);
static gboolean zak_form_element_validator_regex_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
static gboolean zak_form_element_validator_regex_validate (ZakFormElementValidator *validator_regex, const gchar *value);
-static void zak_form_element_validator_regex_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode);
+static void zak_form_element_validator_regex_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorRegex
{
}
static void
-zak_form_element_validator_regex_get_xml (ZakFormElementValidator *validator, const gchar *version, xmlNode *xnode)
+zak_form_element_validator_regex_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version)
{
ZakFormElementValidatorRegex *validator_regex = ZAK_FORM_ELEMENT_VALIDATOR_REGEX (validator);
ZakFormElementValidatorRegexPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (validator_regex);
if (ZAK_FORM_VALIDATOR_GET_CLASS (validator)->get_xml!= NULL)
{
- ZAK_FORM_VALIDATOR_GET_CLASS (validator)->get_xml (validator, version, xnode);
+ ZAK_FORM_VALIDATOR_GET_CLASS (validator)->get_xml (validator, xnode, version);
}
return xnode;
static gboolean zak_form_validator_compare_xml_parsing (ZakFormValidator *validator, xmlNode *xnode, gpointer form);
static gboolean zak_form_validator_compare_validate (ZakFormValidator *validator_notempty);
-static void zak_form_validator_compare_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode);
+static void zak_form_validator_compare_get_xml (ZakFormValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormValidatorCompare
{
}
static void
-zak_form_validator_compare_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode)
+zak_form_validator_compare_get_xml (ZakFormValidator *validator, xmlNode *xnode, const gchar *version)
{
ZakFormValidatorCompare *validator_compare = ZAK_FORM_VALIDATOR_COMPARE (validator);
ZakFormValidatorComparePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_GET_PRIVATE (validator_compare);
static gboolean zak_form_validator_compare_date_xml_parsing (ZakFormValidator *validator, xmlNode *xnode, gpointer form);
static gboolean zak_form_validator_compare_date_validate (ZakFormValidator *validator_notempty);
-static void zak_form_validator_compare_date_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode);
+static void zak_form_validator_compare_date_get_xml (ZakFormValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormValidatorCompareDate
{
}
static void
-zak_form_validator_compare_date_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode)
+zak_form_validator_compare_date_get_xml (ZakFormValidator *validator, xmlNode *xnode, const gchar *version)
{
ZakFormValidatorCompareDate *validator_compare_date = ZAK_FORM_VALIDATOR_COMPARE_DATE (validator);
ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator_compare_date);
static gboolean zak_form_validator_compare_number_xml_parsing (ZakFormValidator *validator, xmlNode *xnode, gpointer form);
static gboolean zak_form_validator_compare_number_validate (ZakFormValidator *validator_notempty);
-static void zak_form_validator_compare_number_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode);
+static void zak_form_validator_compare_number_get_xml (ZakFormValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormValidatorCompareNumber
{
}
static void
-zak_form_validator_compare_number_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode)
+zak_form_validator_compare_number_get_xml (ZakFormValidator *validator, xmlNode *xnode, const gchar *version)
{
ZakFormValidatorCompareNumber *validator_compare_number = ZAK_FORM_VALIDATOR_COMPARE_NUMBER (validator);
ZakFormValidatorCompareNumberPrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_NUMBER_GET_PRIVATE (validator_compare_number);