]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added function ZakFormElement::get_validator_by_id.
authorAndrea Zagli <azagli@libero.it>
Sun, 16 Apr 2017 11:23:50 +0000 (13:23 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 16 Apr 2017 11:23:50 +0000 (13:23 +0200)
src/formelement.c
src/formelement.h

index 9e6db5e54da0a3f4ab73056c5ea7f2e7b4a8d912..bac1f7ecceaace4b692f45acf55d1d83bd3379ee 100644 (file)
@@ -47,17 +47,17 @@ static void zak_form_element_class_init (ZakFormElementClass *class);
 static void zak_form_element_init (ZakFormElement *zak_form_element);
 
 static void zak_form_element_construct (ZakFormElement *element,
-                                                                                       const gchar *id,
-                                                                                       GHashTable *ht_attrs);
+                                        const gchar *id,
+                                        GHashTable *ht_attrs);
 
 static void zak_form_element_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                           guint property_id,
+                                           const GValue *value,
+                                           GParamSpec *pspec);
 static void zak_form_element_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                           guint property_id,
+                                           GValue *value,
+                                           GParamSpec *pspec);
 
 static void zak_form_element_dispose (GObject *gobject);
 static void zak_form_element_finalize (GObject *gobject);
@@ -1100,6 +1100,37 @@ zak_form_element_add_validator (ZakFormElement *element, ZakFormElementValidator
        g_ptr_array_add (priv->pa_validators, validator);
 }
 
+/**
+ * zak_form_element_get_validator_by_id:
+ * @element:
+ * @id:
+ *
+ */
+ZakFormElementValidator
+*zak_form_element_get_validator_by_id (ZakFormElement *element, const gchar *id)
+{
+       ZakFormElementValidator *validator;
+
+       guint i;
+
+       ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element);
+
+       validator = NULL;
+
+       for (i = 0; i < priv->pa_validators->len; i++)
+               {
+                       if (g_strcmp0 (zak_form_element_validator_get_id ((ZakFormElementValidator *)g_ptr_array_index (priv->pa_validators, i)), id) == 0)
+                               {
+                                       validator = (ZakFormElementValidator *)g_ptr_array_index (priv->pa_validators, i);
+                                       break;
+                               }
+               }
+
+       return validator;
+
+
+}
+
 /**
  * zak_form_element_is_valid:
  * @element:
index d68f6a518e3b48626ca47fabdc12a53cde25dbbe..bf15098231231c2f0634961b19869e5d7b76ff9f 100644 (file)
@@ -109,6 +109,7 @@ gboolean zak_form_element_is_valid (ZakFormElement *element);
 GPtrArray *zak_form_element_get_messages (ZakFormElement *element);
 
 GPtrArray *zak_form_element_get_validators (ZakFormElement *element);
+ZakFormElementValidator *zak_form_element_get_validator_by_id (ZakFormElement *element, const gchar *id);
 GPtrArray *zak_form_element_get_validators_by_type (ZakFormElement *element, GType type);