From: Andrea Zagli Date: Sat, 28 Jan 2017 10:36:46 +0000 (+0100) Subject: Added functions ZakFormElement::get_filters and ::get_element_filters_by_type (refs... X-Git-Tag: v0.1.0~6 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=9ff8f83bd4cdf96074882711b8856fca1aadfd3c;p=zakform%2Flibzakform Added functions ZakFormElement::get_filters and ::get_element_filters_by_type (refs #1103). --- diff --git a/src/formelement.c b/src/formelement.c index 447bc33..52efa66 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2016 Andrea Zagli + * Copyright (C) 2015-2017 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -257,6 +257,50 @@ zak_form_element_filter (ZakFormElement *element) } } +/** + * zak_form_element_get_filters: + * @zakform: + * + * Returns: a #GPtrArray with the list of ZakFormElement's in the form. + */ +GPtrArray +*zak_form_element_get_filters (ZakFormElement *element) +{ + ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element); + + return priv->pa_filters; +} + +/** + * zak_form_element_get_filters_by_type: + * @element: + * @type: + * + * Returns: a #GPtrArray with the list of ZakFormElementFilter's in the form element filtered by @type. + */ +GPtrArray +*zak_form_element_get_filters_by_type (ZakFormElement *element, GType type) +{ + GPtrArray *ar; + ZakFormElementFilter *filter; + + guint i; + + ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element); + + ar = g_ptr_array_new (); + for (i = 0; i < priv->pa_filters->len; i++) + { + filter = (ZakFormElementFilter *)g_ptr_array_index (priv->pa_filters, i); + if (G_OBJECT_TYPE (filter) == type) + { + g_ptr_array_add (ar, filter); + } + } + + return ar; +} + /** * zak_form_element_set_name: * @element: diff --git a/src/formelement.h b/src/formelement.h index a3489d4..ebf9df8 100644 --- a/src/formelement.h +++ b/src/formelement.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2016 Andrea Zagli + * Copyright (C) 2015-2017 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -96,11 +96,13 @@ void zak_form_element_clear (ZakFormElement *element); void zak_form_element_add_filter (ZakFormElement *element, ZakFormElementFilter *filter); void zak_form_element_filter (ZakFormElement *element); +GPtrArray *zak_form_element_get_filters (ZakFormElement *element); +GPtrArray *zak_form_element_get_filters_by_type (ZakFormElement *element, GType type); + void zak_form_element_add_validator (ZakFormElement *element, ZakFormElementValidator *validator); gboolean zak_form_element_is_valid (ZakFormElement *element); GPtrArray *zak_form_element_get_messages (ZakFormElement *element); - G_END_DECLS