]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added ZakForm::get_validator_by_id.
authorAndrea Zagli <azagli@libero.it>
Sun, 16 Apr 2017 09:05:10 +0000 (11:05 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 16 Apr 2017 09:05:10 +0000 (11:05 +0200)
src/form.c
src/form.h

index f87771ba0e63bf9371c4c8d5f6e7b3bf26415dcf..181fe1b3ea4aee480b590bba7c14ad845dd3bcdd 100644 (file)
@@ -605,6 +605,36 @@ zak_form_form_add_validator (ZakFormForm *zakform, ZakFormValidator *validator)
        return ret;
 }
 
+/**
+ * zak_form_form_get_validator_by_id:
+ * @zakform:
+ * @id:
+ *
+ * Returns: a #ZakFormValidator.
+ */
+ZakFormValidator
+*zak_form_form_get_validator_by_id (ZakFormForm *zakform, const gchar *id)
+{
+       ZakFormValidator *validator;
+
+       guint i;
+
+       ZakFormFormPrivate *priv = zak_form_form_get_instance_private (zakform);
+
+       validator = NULL;
+
+       for (i = 0; i < priv->ar_validators->len; i++)
+               {
+                       if (g_strcmp0 (zak_form_validator_get_id ((ZakFormValidator *)g_ptr_array_index (priv->ar_validators, i)), id) == 0)
+                               {
+                                       validator = (ZakFormValidator *)g_ptr_array_index (priv->ar_validators, i);
+                                       break;
+                               }
+               }
+
+       return validator;
+}
+
 /**
  * zak_form_form_get_validators:
  * @zakform:
index 33b65ea5257fdb0fa44bf6f675b61e1555872eb2..ee783171337c2fbced20a64e1c8cf6494292d938 100644 (file)
@@ -54,6 +54,7 @@ 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);
+ZakFormValidator *zak_form_form_get_validator_by_id (ZakFormForm *zakform, const gchar *id);
 GPtrArray *zak_form_form_get_validators (ZakFormForm *zakform);
 GPtrArray *zak_form_form_get_validators_by_type (ZakFormForm *zakform, GType type);