/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 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
return ret;
}
+static gpointer
+copy_ar_func (gconstpointer src, gpointer data)
+{
+ GPtrArray *ret;
+ GPtrArray *ar_src;
+
+ guint i;
+
+ ar_src = (GPtrArray *)src;
+
+ ret = g_ptr_array_new ();
+
+ for (i = 0; i < ar_src->len; i++)
+ {
+ g_ptr_array_add (ret, g_strdup ((gchar *)g_ptr_array_index (ar_src, i)));
+ }
+
+ return ret;
+}
+
/**
* zak_form_element_get_messages:
* @element:
{
ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element);
- return priv->pa_messages;
+ return g_ptr_array_copy (priv->pa_messages, copy_ar_func, NULL);
+}
+
+/**
+ * zak_form_element_set_messages:
+ * @element:
+ * @messages:
+ *
+ * Sets element's messages.
+ */
+void
+zak_form_element_set_messages (ZakFormElement *element, GPtrArray *messages)
+{
+ ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element);
+
+ if (priv->pa_messages != NULL)
+ {
+ g_ptr_array_free (priv->pa_messages, TRUE);
+ priv->pa_messages = g_ptr_array_copy (messages, copy_ar_func, NULL);
+ }
}
/**
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 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
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);
+void zak_form_element_set_messages (ZakFormElement *element, GPtrArray *messages);
GPtrArray *zak_form_element_get_validators (ZakFormElement *element);
ZakFormElementValidator *zak_form_element_get_validator_by_id (ZakFormElement *element, const gchar *id);