/*
- * Copyright (C) 2017-2020 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2017-2021 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
G_DEFINE_TYPE_WITH_PRIVATE (ZakFormCgiFormElementRadio, zak_form_cgi_form_element_radio, ZAK_FORM_CGI_TYPE_FORM_ELEMENT)
-typedef struct
- {
- gchar *value;
- gchar *content;
- } Option;
-
static void
zak_form_cgi_form_element_radio_class_init (ZakFormCgiFormElementRadioClass *klass)
{
{
if (xmlStrcmp (xnode->name, (const xmlChar *)"option") == 0)
{
- Option *opt = g_new0 (Option, 1);
+ ZakFormCgiFormElementRadioOption *opt = g_new0 (ZakFormCgiFormElementRadioOption, 1);
opt->value = (gchar *)xmlGetProp (xnode, (const xmlChar *)"value");
opt->content = (gchar *)xmlGetProp (xnode, (const xmlChar *)"content");
g_free (attr_class);
}
- Option *opt = (Option *)g_ptr_array_index (priv->ar_options, idx);
+ ZakFormCgiFormElementRadioOption *opt = (ZakFormCgiFormElementRadioOption *)g_ptr_array_index (priv->ar_options, idx);
ht_attrs_option = g_hash_table_new (g_str_hash, g_str_equal);
zak_utils_ghashtable_copy (ht_attrs, ht_attrs_option);
return ret_value;
}
+GPtrArray
+*zak_form_cgi_form_element_radio_get_options (ZakFormCgiFormElement *element)
+{
+ GPtrArray *ret;
+ guint i;
+ ZakFormCgiFormElementRadioOption *opt;
+
+ ZakFormCgiFormElementRadioPrivate *priv = zak_form_cgi_form_element_radio_get_instance_private (ZAK_FORM_CGI_FORM_ELEMENT_RADIO (element));
+
+ ret = g_ptr_array_new ();
+
+ for (i = 0; i < priv->ar_options->len; i++)
+ {
+ ZakFormCgiFormElementRadioOption *new_opt;
+
+ opt = (ZakFormCgiFormElementRadioOption *)g_ptr_array_index (priv->ar_options, i);
+
+ new_opt = g_new0 (ZakFormCgiFormElementRadioOption, 1);
+ new_opt->value = g_strdup (opt->value);
+ new_opt->content = g_strdup (opt->content);
+
+ g_ptr_array_add (ret, new_opt);
+ }
+
+ return ret;
+
+}
+
+ZakFormCgiFormElementRadioOption
+*zak_form_cgi_form_element_radio_get_option (ZakFormCgiFormElement *element, guint idx)
+{
+ ZakFormCgiFormElementRadioOption *ret;
+ ZakFormCgiFormElementRadioOption *opt;
+
+ ZakFormCgiFormElementRadioPrivate *priv = zak_form_cgi_form_element_radio_get_instance_private (ZAK_FORM_CGI_FORM_ELEMENT_RADIO (element));
+
+ ret = g_new0 (ZakFormCgiFormElementRadioOption, 1);
+
+ opt = (ZakFormCgiFormElementRadioOption *)g_ptr_array_index (priv->ar_options, idx);
+ if (opt != NULL)
+ {
+ ret->value = g_strdup (opt->value);
+ ret->content = g_strdup (opt->content);
+ }
+
+ return ret;
+}
+
/* PRIVATE */
static void
zak_form_cgi_form_element_radio_set_property (GObject *object,
/*
- * Copyright (C) 2017-2020 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2017-2021 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
gchar *zak_form_cgi_form_element_radio_render_single (ZakFormCgiFormElement *element, guint idx);
+typedef struct
+ {
+ gchar *value;
+ gchar *content;
+ } ZakFormCgiFormElementRadioOption;
+
+GPtrArray *zak_form_cgi_form_element_radio_get_options (ZakFormCgiFormElement *element);
+ZakFormCgiFormElementRadioOption *zak_form_cgi_form_element_radio_get_option (ZakFormCgiFormElement *element, guint idx);
+
G_END_DECLS