]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added functions ZakFormForm::clear and ZakFormElement::clear.
authorAndrea Zagli <azagli@libero.it>
Mon, 2 Nov 2015 20:41:40 +0000 (21:41 +0100)
committerAndrea Zagli <azagli@libero.it>
Mon, 2 Nov 2015 20:41:40 +0000 (21:41 +0100)
src/form.c
src/form.h
src/formelement.c
src/formelement.h

index 4ab5f9d6796056afa9731c528ab45379ebeb3c72..c66d673b498ecc93d24cccdf1eaeb33ad31fe21c 100644 (file)
@@ -89,6 +89,30 @@ zak_form_form_add_element (ZakFormForm *zakform, ZakFormElement *element)
        return ret;
 }
 
+/**
+ * zak_form_form_clear:
+ * @zakform: a #ZakFormForm object.
+ *
+ */
+void
+zak_form_form_clear (ZakFormForm *zakform)
+{
+       guint i;
+
+       ZakFormFormPrivate *priv;
+
+       g_return_if_fail (ZAK_FORM_IS_FORM (zakform));
+
+       priv = zak_form_form_get_instance_private (zakform);
+
+       for (i = 0; i < priv->ar_elements->len; i++)
+               {
+                       ZakFormElement *element = (ZakFormElement *)g_ptr_array_index (priv->ar_elements, i);
+
+                       zak_form_element_clear (element);
+               }
+}
+
 /**
  * zak_form_form_is_valid:
  * @zakform:
index c06f6becb25c51e87dff0da8a6acd1ba9a038e45..f1179b627437a5a5c1035c8943f07227676b8043 100644 (file)
@@ -41,6 +41,8 @@ struct _ZakFormFormClass
 
 gboolean zak_form_form_add_element (ZakFormForm *zakform, ZakFormElement *element);
 
+void zak_form_form_clear (ZakFormForm *zakform);
+
 gboolean zak_form_form_is_valid (ZakFormForm *zakform);
 
 
index fe688a0ec7ba4413bceecc11b75a6ba461a53877..93d6e82320e47d3b05cbc30f86b20cc446d898af 100644 (file)
@@ -223,6 +223,21 @@ gchar
        return g_strdup (priv->default_value);
 }
 
+/**
+ * zak_form_element_clear:
+ * @element:
+ *
+ */
+void
+zak_form_element_clear (ZakFormElement *element)
+{
+       ZakFormElementPrivate *priv;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       zak_form_element_set_value (element, priv->default_value);
+}
+
 /**
  * zak_form_element_add_validator:
  * @element:
index db6b32815aa61dbb7ebb8e1da977aa386d7b2a51..cef647dac6952da9943e1b836e710b01c6338012 100644 (file)
@@ -46,6 +46,8 @@ 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_clear (ZakFormElement *element);
+
 void zak_form_element_add_filter (ZakFormElement *element, ZakFormElementIFilter *filter);
 void zak_form_element_filter (ZakFormElement *element);