From 8b08f87b96d7144c515bf5b2e242b7ef1955ed4c Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sun, 22 Nov 2015 16:24:17 +0100 Subject: [PATCH] Added property original-value to ZakFormElement. --- src/formelement.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ src/formelement.h | 3 +++ 2 files changed, 56 insertions(+) diff --git a/src/formelement.c b/src/formelement.c index 00d0fc3..b2db2b0 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -27,6 +27,7 @@ enum PROP_0, PROP_VALUE, PROP_DEFAULT_VALUE, + PROP_ORIGINAL_VALUE, PROP_VISIBLE, PROP_EDITABLE }; @@ -56,6 +57,7 @@ typedef struct { gchar *value; gchar *default_value; + gchar *original_value; gboolean visible; gboolean editable; GPtrArray *pa_filters; @@ -91,6 +93,13 @@ zak_form_element_class_init (ZakFormElementClass *class) "", G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, PROP_ORIGINAL_VALUE, + g_param_spec_string ("original-value", + "Original value", + "Original value", + "", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, PROP_VISIBLE, g_param_spec_boolean ("visible", "Visible", @@ -241,6 +250,42 @@ gchar return g_strdup (priv->default_value); } +/** + * zak_form_element_set_original_value: + * @element: + * @value: + * + */ +void +zak_form_element_set_original_value (ZakFormElement *element, const gchar *value) +{ + ZakFormElementPrivate *priv; + + priv = zak_form_element_get_instance_private (element); + + if (priv->original_value != NULL) + { + g_free (priv->original_value); + } + + priv->original_value = g_strdup (value); +} + +/** + * zak_form_element_get_original_value: + * @element: + * + */ +gchar +*zak_form_element_get_original_value (ZakFormElement *element) +{ + ZakFormElementPrivate *priv; + + priv = zak_form_element_get_instance_private (element); + + return g_strdup (priv->original_value); +} + /** * zak_form_element_set_visible: * @element: @@ -409,6 +454,10 @@ zak_form_element_set_property (GObject *object, zak_form_element_set_default_value (zak_form_element, g_value_get_string (value)); break; + case PROP_ORIGINAL_VALUE: + zak_form_element_set_original_value (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; @@ -442,6 +491,10 @@ zak_form_element_get_property (GObject *object, g_value_set_string (value, zak_form_element_get_default_value (zak_form_element)); break; + case PROP_ORIGINAL_VALUE: + g_value_set_string (value, zak_form_element_get_original_value (zak_form_element)); + break; + case PROP_VISIBLE: g_value_set_boolean (value, zak_form_element_get_visible (zak_form_element)); break; diff --git a/src/formelement.h b/src/formelement.h index 842cf57..a3855d6 100644 --- a/src/formelement.h +++ b/src/formelement.h @@ -46,6 +46,9 @@ gchar *zak_form_element_get_value (ZakFormElement *element); void zak_form_element_set_default_value (ZakFormElement *element, const gchar *value); gchar *zak_form_element_get_default_value (ZakFormElement *element); +void zak_form_element_set_original_value (ZakFormElement *element, const gchar *value); +gchar *zak_form_element_get_original_value (ZakFormElement *element); + void zak_form_element_set_visible (ZakFormElement *element, gboolean visible); gboolean zak_form_element_get_visible (ZakFormElement *element); -- 2.49.0