From: Andrea Zagli Date: Mon, 7 Dec 2015 09:40:50 +0000 (+0100) Subject: Added property format to ZakFormElement. X-Git-Tag: debian/0.0.1-1~22 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=3cc91c6803d3e48d447847922ce7a7086eaadd19;p=zakform%2Flibzakform Added property format to ZakFormElement. --- diff --git a/src/formelement.c b/src/formelement.c index 604577f..d7c856e 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -31,6 +31,7 @@ enum PROP_VALUE, PROP_DEFAULT_VALUE, PROP_ORIGINAL_VALUE, + PROP_FORMAT, PROP_VISIBLE, PROP_EDITABLE, PROP_TO_LOAD, @@ -66,6 +67,7 @@ typedef struct gchar *value; gchar *default_value; gchar *original_value; + gchar *format; gboolean visible; gboolean editable; gboolean to_load; @@ -132,6 +134,13 @@ zak_form_element_class_init (ZakFormElementClass *class) "", G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, PROP_FORMAT, + g_param_spec_string ("format", + "Format", + "Format", + "", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, PROP_VISIBLE, g_param_spec_boolean ("visible", "Visible", @@ -508,6 +517,48 @@ zak_form_element_is_changed (ZakFormElement *element) return (g_strcmp0 (zak_form_element_get_original_value (element), zak_form_element_get_value (element)) != 0); } +/** + * zak_form_element_set_format: + * @element: + * @format: + * + */ +gboolean +zak_form_element_set_format (ZakFormElement *element, const gchar *format) +{ + ZakFormElementPrivate *priv; + + priv = zak_form_element_get_instance_private (element); + + if (priv->format != NULL) + { + g_free (priv->format); + } + + priv->format = g_strdup (format); + + return TRUE; +} + +/** + * zak_form_element_get_format: + * @element: + * + */ +gchar +*zak_form_element_get_format (ZakFormElement *element) +{ + ZakFormElementPrivate *priv; + + gchar *ret; + + priv = zak_form_element_get_instance_private (element); + + ret = g_strdup (priv->format); + + return ret; +} + /** * zak_form_element_set_visible: * @element: @@ -799,6 +850,10 @@ zak_form_element_set_property (GObject *object, zak_form_element_set_original_value (zak_form_element, g_value_get_string (value)); break; + case PROP_FORMAT: + zak_form_element_set_format (zak_form_element, g_value_get_string (value)); + break; + case PROP_VISIBLE: zak_form_element_set_visible (zak_form_element, g_value_get_boolean (value)); break; @@ -856,6 +911,10 @@ zak_form_element_get_property (GObject *object, g_value_set_string (value, zak_form_element_get_original_value (zak_form_element)); break; + case PROP_FORMAT: + g_value_set_string (value, zak_form_element_get_format (zak_form_element)); + break; + case PROP_VISIBLE: g_value_set_boolean (value, zak_form_element_get_visible (zak_form_element)); break; @@ -926,6 +985,10 @@ zak_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmlnode) { zak_form_element_set_default_value (element, (const gchar *)xmlNodeGetContent (cur)); } + else if (xmlStrcmp (cur->name, (const xmlChar *)"format") == 0) + { + zak_form_element_set_format (element, (const gchar *)xmlNodeGetContent (cur)); + } else if (xmlStrcmp (cur->name, (const xmlChar *)"visible") == 0) { zak_form_element_set_visible (element, xmlStrEqual ((const gchar *)xmlNodeGetContent (cur), "TRUE")); diff --git a/src/formelement.h b/src/formelement.h index ebfb9f1..ab776f9 100644 --- a/src/formelement.h +++ b/src/formelement.h @@ -70,6 +70,9 @@ gchar *zak_form_element_get_original_value (ZakFormElement *element); void zak_form_element_set_as_original_value (ZakFormElement *element); gboolean zak_form_element_is_changed (ZakFormElement *element); +gboolean zak_form_element_set_format (ZakFormElement *element, const gchar *format); +gchar *zak_form_element_get_format (ZakFormElement *element); + void zak_form_element_set_visible (ZakFormElement *element, gboolean visible); gboolean zak_form_element_get_visible (ZakFormElement *element);