From: Andrea Zagli Date: Wed, 9 Aug 2017 13:47:52 +0000 (+0200) Subject: Added function ZakForm::remove_element_by_idx (closes #1104). X-Git-Tag: v0.1.0~1^2 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=a7a174c8ab3de9d6957fe71e3b99adae3fae4122;p=zakform%2Flibzakform Added function ZakForm::remove_element_by_idx (closes #1104). --- diff --git a/src/form.c b/src/form.c index 2ca0809..7358f1c 100644 --- a/src/form.c +++ b/src/form.c @@ -357,6 +357,23 @@ zak_form_form_remove_element_by_id (ZakFormForm *zakform, const gchar *id) return ret; } +/** + * zak_form_form_remove_element_by_idx: + * @zakform: + * @idx: + * + * Returns: #TRUE if @element is removed; FALSE otherwise. + */ +gboolean +zak_form_form_remove_element_by_idx (ZakFormForm *zakform, guint idx) +{ + ZakFormFormPrivate *priv; + + priv = zak_form_form_get_instance_private (zakform); + + return (g_ptr_array_remove_index (priv->ar_elements, idx) != NULL); +} + /** * zak_form_form_get_element_by_id: * @zakform: diff --git a/src/form.h b/src/form.h index e141b5f..9a6e90d 100644 --- a/src/form.h +++ b/src/form.h @@ -51,6 +51,7 @@ gboolean zak_form_form_load_from_file (ZakFormForm *zakform, const gchar *filena gboolean zak_form_form_add_element (ZakFormForm *zakform, ZakFormElement *element); gboolean zak_form_form_remove_element (ZakFormForm *zakform, ZakFormElement *element); gboolean zak_form_form_remove_element_by_id (ZakFormForm *zakform, const gchar *id); +gboolean zak_form_form_remove_element_by_idx (ZakFormForm *zakform, guint idx); ZakFormElement *zak_form_form_get_element_by_id (ZakFormForm *zakform, const gchar *id); guint zak_form_form_get_element_idx_by_id (ZakFormForm *zakform, const gchar *id); GPtrArray *zak_form_form_get_elements (ZakFormForm *zakform);