]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added property original-value to ZakFormElement.
authorAndrea Zagli <azagli@libero.it>
Sun, 22 Nov 2015 15:24:17 +0000 (16:24 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 22 Nov 2015 15:24:17 +0000 (16:24 +0100)
src/formelement.c
src/formelement.h

index 00d0fc3aaa30e49ee85cfb6e1f430a3136dc2fc1..b2db2b07e4718fb2a921131e17e7ee12ae787905 100644 (file)
@@ -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;
index 842cf57604b11a0bfe2c926f753e8dce8ea8dff8..a3855d655f016dad8efff97db74404c5b0eef215 100644 (file)
@@ -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);