const gchar *id,
GHashTable *ht_attrs);
-static GHashTable *zak_form_cgi_form_element_get_ht_attrs (ZakFormCgiFormElement *element);
static GHashTable *zak_form_cgi_form_element_get_ht_label_attrs (ZakFormCgiFormElement *element);
static void zak_form_cgi_form_element_set_property (GObject *object,
g_type_class_add_private (object_class, sizeof (ZakFormCgiFormElementPrivate));
class->construct = zak_form_cgi_form_element_construct;
- class->get_ht_attrs = zak_form_cgi_form_element_get_ht_attrs;
class->get_ht_label_attrs = zak_form_cgi_form_element_get_ht_label_attrs;
}
}
}
+GHashTable
+*zak_form_cgi_form_element_get_attrs (ZakFormCgiFormElement *element)
+{
+ ZakFormCgiFormElementPrivate *priv;
+
+ priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+ return priv->ht_attrs;
+}
+
+void
+zak_form_cgi_form_element_set_attrs (ZakFormCgiFormElement *element, GHashTable *ht_attrs)
+{
+ ZakFormCgiFormElementPrivate *priv;
+
+ priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+ if (priv->ht_attrs != NULL)
+ {
+ g_hash_table_destroy (priv->ht_attrs);
+ }
+
+ priv->ht_attrs = g_hash_table_ref (ht_attrs);
+}
+
+gchar
+*zak_form_cgi_form_element_get_attr (ZakFormCgiFormElement *element, const gchar *attr)
+{
+ gchar *ret;
+
+ ZakFormCgiFormElementPrivate *priv;
+
+ priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+ ret = NULL;
+ if (priv->ht_attrs != NULL)
+ {
+ ret = g_hash_table_lookup (priv->ht_attrs, attr);
+ }
+
+ return ret;
+}
+
+void
+zak_form_cgi_form_element_set_attr (ZakFormCgiFormElement *element, const gchar *attr, const gchar *value)
+{
+ ZakFormCgiFormElementPrivate *priv;
+
+ g_return_if_fail (attr != NULL);
+ g_return_if_fail (value != NULL);
+
+ priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+ g_hash_table_replace (priv->ht_attrs, (gpointer)g_strdup (attr), (gpointer)g_strdup (value));
+}
+
/**
* zak_form_cgi_form_element_bind:
* @element:
return;
}
-static GHashTable
-*zak_form_cgi_form_element_get_ht_attrs (ZakFormCgiFormElement *element)
-{
- ZakFormCgiFormElementPrivate *priv;
-
- priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
-
- return priv->ht_attrs;
-}
-
static GHashTable
*zak_form_cgi_form_element_get_ht_label_attrs (ZakFormCgiFormElement *element)
{
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
ZakFormElementClass parent_class;
void (*construct) (ZakFormCgiFormElement *element, const gchar *id, GHashTable *ht_attrs);
- GHashTable *(*get_ht_attrs) (ZakFormCgiFormElement *element);
GHashTable *(*get_ht_label_attrs) (ZakFormCgiFormElement *element);
void zak_form_cgi_form_element_set_label (ZakFormCgiFormElement *element, const gchar *label, ...);
+GHashTable *zak_form_cgi_form_element_get_attrs (ZakFormCgiFormElement *element);
+void zak_form_cgi_form_element_set_attrs (ZakFormCgiFormElement *element, GHashTable *ht_attrs);
+
+gchar *zak_form_cgi_form_element_get_attr (ZakFormCgiFormElement *element, const gchar *attr);
+void zak_form_cgi_form_element_set_attr (ZakFormCgiFormElement *element, const gchar *attr, const gchar *value);
+
void zak_form_cgi_form_element_bind (ZakFormCgiFormElement *element, GValue *value);
gchar *zak_form_cgi_form_element_render (ZakFormCgiFormElement *element);
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_CHECK_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_CHECK (element)));
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
ht_label_attrs = klass->get_ht_label_attrs (element);
if (ht_label_attrs != NULL)
/*
- * Copyright (C) 2016-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2016-2019 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 *value;
- ZakFormCgiFormElementClass *klass;
-
- klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_EMAIL_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_EMAIL (element)));
-
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
/*
- * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2017-2019 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 *value;
- ZakFormCgiFormElementClass *klass;
-
- klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_FILE_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_FILE (element)));
-
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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 *value;
- ZakFormCgiFormElementClass *klass;
-
- klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_HIDDEN_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_HIDDEN (element)));
-
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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 *value;
- ZakFormCgiFormElementClass *klass;
-
- klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_PASSWORD_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_PASSWORD (element)));
-
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
/*
- * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2017-2019 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
klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_RADIO_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_RADIO (element)));
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
ht_label_attrs = klass->get_ht_label_attrs (element);
if (ht_label_attrs != NULL)
gchar *gval;
- ZakFormCgiFormElementClass *klass;
-
ZakFormCgiFormElementSelectPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_SELECT_GET_PRIVATE (element);
- klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_SELECT_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_SELECT (element)));
-
gval = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
/* list options */
g_string_append (options, "\n");
}
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
if (!zak_form_element_get_editable (ZAK_FORM_ELEMENT (element)))
{
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
GString *str_attr_class;
gchar *form_control;
- ZakFormCgiFormElementClass *klass;
-
- klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_SUBMIT_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_SUBMIT (element)));
-
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
attr_class = g_hash_table_lookup (ht_attrs, "class");
if (attr_class != NULL)
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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 *value;
- ZakFormCgiFormElementClass *klass;
-
- klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_TEXT_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_TEXT (element)));
-
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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 *value;
- ZakFormCgiFormElementClass *klass;
-
- klass = (ZakFormCgiFormElementClass *)g_type_class_peek_parent (ZAK_FORM_CGI_FORM_ELEMENT_TEXT_AREA_GET_CLASS (ZAK_FORM_CGI_FORM_ELEMENT_TEXT_AREA (element)));
-
- ht_attrs = klass->get_ht_attrs (element);
+ ht_attrs = zak_form_cgi_form_element_get_attrs (ZAK_FORM_CGI_FORM_ELEMENT (element));
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)