]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added function ZakFormForm::get_validators and ::get_validators_by_type (refs #1103).
authorAndrea Zagli <azagli@libero.it>
Sat, 28 Jan 2017 09:59:00 +0000 (10:59 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 28 Jan 2017 09:59:00 +0000 (10:59 +0100)
src/form.c
src/form.h
src/libzakform.h

index f9d2c81928b1c5b5414e937c973482fdc1de8932..65d27d87b9ffd0ed73e504f0083960a96b05b043 100644 (file)
@@ -573,6 +573,50 @@ zak_form_form_add_validator (ZakFormForm *zakform, ZakFormValidator *validator)
        return ret;
 }
 
+/**
+ * zak_form_form_get_validators:
+ * @zakform:
+ *
+ * Returns: a #GPtrArray with the list of ZakFormValidator's in the form.
+ */
+GPtrArray
+*zak_form_form_get_validators (ZakFormForm *zakform)
+{
+       ZakFormFormPrivate *priv = zak_form_form_get_instance_private (zakform);
+
+       return priv->ar_validators;
+}
+
+/**
+ * zak_form_form_get_validators_by_type:
+ * @zakform:
+ * @type:
+ *
+ * Returns: a #GPtrArray with the list of ZakFormValidator's in the form filtered by @type.
+ */
+GPtrArray
+*zak_form_form_get_validators_by_type (ZakFormForm *zakform, GType type)
+{
+       GPtrArray *ar;
+       ZakFormValidator *validator;
+
+       guint i;
+
+       ZakFormFormPrivate *priv = zak_form_form_get_instance_private (zakform);
+
+       ar = g_ptr_array_new ();
+       for (i = 0; i < priv->ar_validators->len; i++)
+               {
+                       validator = (ZakFormValidator *)g_ptr_array_index (priv->ar_validators, i);
+                       if (G_OBJECT_TYPE (validator) == type)
+                               {
+                                       g_ptr_array_add (ar, validator);
+                               }
+               }
+
+       return ar;
+}
+
 /**
  * zak_form_form_clear:
  * @zakform: a #ZakFormForm object.
index 88c4cfd6459a93283a18493def04b047a0fcd530..33b65ea5257fdb0fa44bf6f675b61e1555872eb2 100644 (file)
@@ -54,6 +54,8 @@ GPtrArray *zak_form_form_get_elements (ZakFormForm *zakform);
 GPtrArray *zak_form_form_get_elements_by_type (ZakFormForm *zakform, GType type);
 
 gboolean zak_form_form_add_validator (ZakFormForm *zakform, ZakFormValidator *validator);
+GPtrArray *zak_form_form_get_validators (ZakFormForm *zakform);
+GPtrArray *zak_form_form_get_validators_by_type (ZakFormForm *zakform, GType type);
 
 void zak_form_form_clear (ZakFormForm *zakform);
 
index b5aaf419d50e774e0c9aa4599a4b39d9165f46f6..e3ba88adb693e851d72708f9b8ea5a8e7e267dc1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 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
@@ -36,6 +36,8 @@
 #include <libzakform/formiprovider.h>
 
 #include <libzakform/formvalidator.h>
+#include <libzakform/formvalidatorcompare.h>
+#include <libzakform/formvalidatorcomparedate.h>
 
 
 #endif /* __LIBZAKFORM_H__ */