]> saetta.ns0.it Git - zakform/cgi/commitdiff
Use of ::new_attrs on ::new (closes #1119).
authorAndrea Zagli <azagli@libero.it>
Tue, 10 Sep 2019 08:54:07 +0000 (10:54 +0200)
committerAndrea Zagli <azagli@libero.it>
Tue, 10 Sep 2019 08:54:07 +0000 (10:54 +0200)
src/formelement.c
src/formelementcheck.c
src/formelementemail.c
src/formelementfile.c
src/formelementhidden.c
src/formelementpassword.c
src/formelementradio.c
src/formelementselect.c
src/formelementsubmit.c
src/formelementtext.c
src/formelementtextarea.c

index 218bad7d8dc0046f95cdf0082705e9476d9b5ff1..5aa90462082a5f66b42398ad0f6478f6cddfbf7a 100644 (file)
@@ -133,7 +133,12 @@ zak_form_cgi_form_element_set_id (ZakFormCgiFormElement *element, const gchar *i
                }
 
        priv->id = g_strdup (_id);
-       g_hash_table_replace (priv->ht_label_attrs, "for", g_strdup (priv->id));
+
+       if (priv->ht_label_attrs == NULL)
+               {
+                       priv->ht_label_attrs = g_hash_table_new (g_str_hash, g_str_equal);
+               }
+       g_hash_table_replace (priv->ht_label_attrs, g_strdup ("for"), g_strdup (priv->id));
 
        g_free (_id);
 }
@@ -165,9 +170,9 @@ zak_form_cgi_form_element_set_label (ZakFormCgiFormElement *element, const gchar
                        va_start (ap, label);
                        priv->ht_label_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
 
-                       g_hash_table_replace (priv->ht_label_attrs, "zak-cgi-content", g_strdup (label));
-                       g_hash_table_replace (priv->ht_label_attrs, "for", priv->id != NULL  ? g_strdup (priv->id) : g_strdup (""));
-                       g_hash_table_replace (priv->ht_label_attrs, "class", g_strdup ("control-label"));
+                       g_hash_table_replace (priv->ht_label_attrs, g_strdup ("zak-cgi-content"), g_strdup (label));
+                       g_hash_table_replace (priv->ht_label_attrs, g_strdup ("for"), priv->id != NULL  ? g_strdup (priv->id) : g_strdup (""));
+                       g_hash_table_replace (priv->ht_label_attrs, g_strdup ("class"), g_strdup ("control-label"));
 
                        if (zak_form_element_get_long_name (ZAK_FORM_ELEMENT (element)) == NULL)
                                {
@@ -217,7 +222,7 @@ gchar
        if (priv->id == NULL
            || g_strcmp0 (g_strstrip (priv->id), "") == 0)
                {
-                       priv->id = g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT));
+                       zak_form_cgi_form_element_set_id (element, g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)));
                }
 
        str = g_string_new ("<div class=\"form-group");
@@ -248,25 +253,16 @@ gchar
                                        priv->ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
                                }
 
-                       name = g_hash_table_lookup (priv->ht_attrs, "name");
-                       if (name == NULL
-                           || g_strcmp0 (g_strstrip (name), "") == 0)
+                       name = zak_form_element_get_name (ZAK_FORM_ELEMENT (element));
+                       if (name != NULL
+                           && g_strcmp0 (g_strstrip (name), "") != 0)
                                {
-                                       if (name != NULL)
-                                               {
-                                                       g_free (name);
-                                               }
+                                       g_hash_table_replace (priv->ht_attrs, g_strdup ("name"), g_strdup (name));
+                               }
 
-                                       name = zak_form_element_get_name (ZAK_FORM_ELEMENT (element));
-                                       if (name != NULL
-                                           && g_strcmp0 (g_strstrip (name), "") != 0)
-                                               {
-                                                       g_hash_table_insert (priv->ht_attrs, g_strdup ("name"), g_strdup (name));
-                                               }
-                                       if (name != NULL)
-                                               {
-                                                       g_free (name);
-                                               }
+                       if (name != NULL)
+                               {
+                                       g_free (name);
                                }
 
                        attr_class = g_hash_table_lookup (priv->ht_attrs, "class");
@@ -274,18 +270,17 @@ gchar
                                {
                                        if (g_strstr_len (attr_class, -1, "form-control") == NULL)
                                                {
-                                                       g_hash_table_insert (priv->ht_attrs, "class", g_strdup_printf ("%s form-control", attr_class));
-                                                       g_free (attr_class);
+                                                       g_hash_table_insert (priv->ht_attrs, g_strdup ("class"), g_strdup_printf ("%s form-control", attr_class));
                                                }
                                }
                        else
                                {
-                                       g_hash_table_insert (priv->ht_attrs, "class", g_strdup ("form-control"));
+                                       g_hash_table_insert (priv->ht_attrs, g_strdup ("class"), g_strdup ("form-control"));
                                }
 
                        if (!zak_form_element_get_editable (ZAK_FORM_ELEMENT (element)))
                                {
-                                       g_hash_table_insert (priv->ht_attrs, (gpointer)"readonly", (gpointer)"readonly");
+                                       g_hash_table_insert (priv->ht_attrs, (gpointer)g_strdup ("readonly"), (gpointer)g_strdup ("readonly"));
                                }
 
                        g_string_append (str, ZAK_FORM_CGI_FORM_ELEMENT_GET_CLASS (element)->render (element));
@@ -329,13 +324,14 @@ gchar
 
        str = NULL;
 
-       if (priv->ht_label_attrs != NULL)
+       if (priv->ht_label_attrs != NULL
+           && g_hash_table_lookup (priv->ht_label_attrs, "zak-cgi-content") != NULL)
                {
                        str = g_string_new ("");
 
                        if (g_strcmp0 (g_hash_table_lookup (priv->ht_label_attrs, "for"), "") == 0)
                                {
-                                       g_hash_table_replace (priv->ht_label_attrs, "for", g_strdup (priv->id));
+                                       g_hash_table_replace (priv->ht_label_attrs, g_strdup ("for"), g_strdup (priv->id));
                                }
 
                        lbl_id = g_strdup_printf ("lbl_%s", priv->id);
@@ -368,13 +364,13 @@ zak_form_cgi_form_element_construct (ZakFormCgiFormElement *element,
 
        priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
 
-       priv->id = g_strdup (id);
+       zak_form_cgi_form_element_set_id (element, id);
 
        priv->ht_attrs = ht_attrs;
 
        if (g_hash_table_lookup (priv->ht_attrs, "name") == NULL)
                {
-                       g_hash_table_insert (priv->ht_attrs, "name", g_strdup (id));
+                       g_hash_table_insert (priv->ht_attrs, g_strdup ("name"), g_strdup (id));
                }
        zak_form_element_set_name (ZAK_FORM_ELEMENT (element), g_hash_table_lookup (priv->ht_attrs, "name"));
 
index 157b23bf24e999cb69de4cac7a4336c9987c9b7b..466d93b0a8af8852775fa800252e0e8a72b50c74 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -89,11 +89,7 @@ zak_form_cgi_form_element_check_init (ZakFormCgiFormElementCheck *zak_form_cgi_f
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_check_new ()
 {
-       ZakFormCgiFormElementCheck *zak_form_cgi_form_element_check;
-
-       zak_form_cgi_form_element_check = ZAK_FORM_CGI_FORM_ELEMENT_CHECK (g_object_new (zak_form_cgi_form_element_check_get_type (), NULL));
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_check);
+       return zak_form_cgi_form_element_check_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -113,12 +109,12 @@ ZakFormCgiFormElement
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_check;
 
-       zak_form_cgi_form_element_check = zak_form_cgi_form_element_check_new ();
+       zak_form_cgi_form_element_check = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_check_get_type (), NULL));
 
        va_start (ap, id);
 
        ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
-       g_hash_table_replace (ht_attrs, "type", "checkbox");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("checkbox"));
 
        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_check_parent_class)->construct (zak_form_cgi_form_element_check,
                                     id,
@@ -180,7 +176,7 @@ zak_form_cgi_form_element_check_xml_parsing (ZakFormElement *element, xmlNodePtr
        id = NULL;
 
        ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
-       g_hash_table_replace (ht_attrs, "type", "checkbox");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("checkbox"));
 
        cur = xmlnode->children;
        while (cur != NULL)
@@ -243,7 +239,8 @@ static gchar
        ht_attrs = klass->get_ht_attrs (element);
        ht_label_attrs = klass->get_ht_label_attrs (element);
 
-       if (ht_label_attrs != NULL)
+       if (ht_label_attrs != NULL
+           && g_hash_table_lookup (ht_label_attrs, "zak-cgi-content") != NULL)
                {
                        str = g_string_new ("<br/>\n");
                }
@@ -256,13 +253,13 @@ static gchar
        if (value != NULL
                && zak_utils_string_to_boolean (value))
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"checked", (gpointer)"checked");
+                       g_hash_table_insert (ht_attrs, g_strdup ("checked"), g_strdup ("checked"));
                }
 
        attr_class = g_hash_table_lookup (ht_attrs, "class");
        if (attr_class != NULL)
                {
-                       g_hash_table_insert (ht_attrs, "class", g_strjoinv ("", g_strsplit (attr_class, "form-control", -1)));
+                       g_hash_table_insert (ht_attrs, g_strdup ("class"), g_strjoinv ("", g_strsplit (attr_class, "form-control", -1)));
                        g_free (attr_class);
                }
 
@@ -273,7 +270,8 @@ static gchar
                                zak_form_cgi_form_element_check_get_text (ZAK_FORM_CGI_FORM_ELEMENT_CHECK (element)),
                                priv->in_line ? "" : "\n</div><br/>");
 
-       if (ht_label_attrs != NULL)
+       if (ht_label_attrs != NULL
+           && g_hash_table_lookup (ht_label_attrs, "zak-cgi-content") != NULL)
                {
                        g_string_append (str, "<br/><br/>\n");
                }
index 96160e08bc03183dff982c67c1048b1ab2862d8a..067052cf801455dfac78d2c0e5eb230546a3da48 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -29,13 +29,13 @@ static void zak_form_cgi_form_element_email_init (ZakFormCgiFormElementEmail *za
 static gchar *zak_form_cgi_form_element_email_render (ZakFormCgiFormElement *element);
 
 static void zak_form_cgi_form_element_email_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                                          guint property_id,
+                                                          const GValue *value,
+                                                          GParamSpec *pspec);
 static void zak_form_cgi_form_element_email_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                                          guint property_id,
+                                                          GValue *value,
+                                                          GParamSpec *pspec);
 
 static void zak_form_cgi_form_element_email_dispose (GObject *gobject);
 static void zak_form_cgi_form_element_email_finalize (GObject *gobject);
@@ -84,11 +84,7 @@ zak_form_cgi_form_element_email_init (ZakFormCgiFormElementEmail *zak_form_cgi_f
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_email_new ()
 {
-       ZakFormCgiFormElementEmail *zak_form_cgi_form_element_email;
-
-       zak_form_cgi_form_element_email = ZAK_FORM_CGI_FORM_ELEMENT_EMAIL (g_object_new (zak_form_cgi_form_element_email_get_type (), NULL));
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_email);
+       return zak_form_cgi_form_element_email_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -100,7 +96,7 @@ ZakFormCgiFormElement
  */
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_email_new_attrs (const gchar *id,
-                                                                                 ...)
+                                            ...)
 {
        va_list ap;
 
@@ -108,16 +104,16 @@ ZakFormCgiFormElement
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_email;
 
-       zak_form_cgi_form_element_email = zak_form_cgi_form_element_email_new ();
+       zak_form_cgi_form_element_email = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_email_get_type (), NULL));
 
        va_start (ap, id);
 
        ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
-       g_hash_table_replace (ht_attrs, "type", "email");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("email"));
 
        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_email_parent_class)->construct (zak_form_cgi_form_element_email,
-                                                                                                                                                                               id,
-                                                                                                                                                                               ht_attrs);
+                                    id,
+                                    ht_attrs);
 
        return zak_form_cgi_form_element_email;
 }
@@ -134,7 +130,7 @@ zak_form_cgi_form_element_email_xml_parsing (ZakFormElement *element, xmlNodePtr
        id = NULL;
 
        ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
-       g_hash_table_replace (ht_attrs, "type", "email");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("email"));
 
        cur = xmlnode->children;
        while (cur != NULL)
@@ -152,7 +148,7 @@ zak_form_cgi_form_element_email_xml_parsing (ZakFormElement *element, xmlNodePtr
                                }
                        else
                                {
-                                       g_hash_table_replace (ht_attrs, g_strdup (cur->name), (gchar *)xmlNodeGetContent (cur));
+                                       g_hash_table_replace (ht_attrs, g_strdup ((gchar *)cur->name), (gchar *)xmlNodeGetContent (cur));
                                }
 
                        cur = cur->next;
@@ -161,8 +157,8 @@ zak_form_cgi_form_element_email_xml_parsing (ZakFormElement *element, xmlNodePtr
        if (id != NULL)
                {
                        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_email_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
-                                                                                                                                                                                               id,
-                                                                                                                                                                                               ht_attrs);
+                                                    id,
+                                                    ht_attrs);
                }
 }
 
@@ -184,7 +180,7 @@ static gchar
        value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("value"), (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_tag_ht ("input", zak_form_cgi_form_element_get_id (element), ht_attrs);
@@ -195,9 +191,9 @@ static gchar
 /* PRIVATE */
 static void
 zak_form_cgi_form_element_email_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
+                                              guint property_id,
+                                              const GValue *value,
+                                              GParamSpec *pspec)
 {
        ZakFormCgiFormElementEmail *zak_form_cgi_form_element_email = (ZakFormCgiFormElementEmail *)object;
        ZakFormCgiFormElementEmailPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_EMAIL_GET_PRIVATE (zak_form_cgi_form_element_email);
@@ -212,9 +208,9 @@ zak_form_cgi_form_element_email_set_property (GObject *object,
 
 static void
 zak_form_cgi_form_element_email_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
+                                              guint property_id,
+                                              GValue *value,
+                                              GParamSpec *pspec)
 {
        ZakFormCgiFormElementEmail *zak_form_cgi_form_element_email = (ZakFormCgiFormElementEmail *)object;
        ZakFormCgiFormElementEmailPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_EMAIL_GET_PRIVATE (zak_form_cgi_form_element_email);
index caa1d4f0baf592253e10d1eb3e8d1b03a835c28e..72924094612b4dbbbd7878fe6cfe691e8d26da55 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -95,14 +95,7 @@ zak_form_cgi_form_element_file_init (ZakFormCgiFormElementFile *zak_form_cgi_for
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_file_new ()
 {
-       ZakFormCgiFormElementFile *zak_form_cgi_form_element_file;
-
-       zak_form_cgi_form_element_file = ZAK_FORM_CGI_FORM_ELEMENT_FILE (g_object_new (zak_form_cgi_form_element_file_get_type (), NULL));
-
-       g_signal_connect (G_OBJECT (zak_form_cgi_form_element_file), "after-validating",
-                         G_CALLBACK (zak_form_cgi_form_element_file_after_validating), NULL);
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_file);
+       return  zak_form_cgi_form_element_file_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -120,7 +113,10 @@ ZakFormCgiFormElement
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_file;
 
-       zak_form_cgi_form_element_file = zak_form_cgi_form_element_file_new ();
+       zak_form_cgi_form_element_file = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_file_get_type (), NULL));
+
+       g_signal_connect (G_OBJECT (zak_form_cgi_form_element_file), "after-validating",
+                         G_CALLBACK (zak_form_cgi_form_element_file_after_validating), NULL);
 
        va_start (ap, id);
 
index 1e1b7285b3d28404d943488d23a9c9f44421d85c..6a5599ccfa9518e46f31332fdbc978c3c631c8b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -21,6 +21,7 @@
 #endif
 
 #include <libzakcgi/libzakcgi.h>
+
 #include "formelementhidden.h"
 
 static void zak_form_cgi_form_element_hidden_class_init (ZakFormCgiFormElementHiddenClass *class);
@@ -29,13 +30,13 @@ static void zak_form_cgi_form_element_hidden_init (ZakFormCgiFormElementHidden *
 static gchar *zak_form_cgi_form_element_hidden_render (ZakFormCgiFormElement *element);
 
 static void zak_form_cgi_form_element_hidden_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                                           guint property_id,
+                                                           const GValue *value,
+                                                           GParamSpec *pspec);
 static void zak_form_cgi_form_element_hidden_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                                           guint property_id,
+                                                           GValue *value,
+                                                           GParamSpec *pspec);
 
 static void zak_form_cgi_form_element_hidden_dispose (GObject *gobject);
 static void zak_form_cgi_form_element_hidden_finalize (GObject *gobject);
@@ -84,11 +85,7 @@ zak_form_cgi_form_element_hidden_init (ZakFormCgiFormElementHidden *zak_form_cgi
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_hidden_new ()
 {
-       ZakFormCgiFormElementHidden *zak_form_cgi_form_element_hidden;
-
-       zak_form_cgi_form_element_hidden = ZAK_FORM_CGI_FORM_ELEMENT_HIDDEN (g_object_new (zak_form_cgi_form_element_hidden_get_type (), NULL));
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_hidden);
+       return  zak_form_cgi_form_element_hidden_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -100,7 +97,7 @@ ZakFormCgiFormElement
  */
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_hidden_new_attrs (const gchar *id,
-                                                                               ...)
+                                             ...)
 {
        va_list ap;
 
@@ -108,16 +105,16 @@ ZakFormCgiFormElement
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_hidden;
 
-       zak_form_cgi_form_element_hidden = zak_form_cgi_form_element_hidden_new ();
+       zak_form_cgi_form_element_hidden = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_hidden_get_type (), NULL));
 
        va_start (ap, id);
 
        ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
-       g_hash_table_replace (ht_attrs, "type", "hidden");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("hidden"));
 
        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_hidden_parent_class)->construct (zak_form_cgi_form_element_hidden,
-                                                                                                                                                                         id,
-                                                                                                                                                                         ht_attrs);
+                                     id,
+                                     ht_attrs);
 
        return zak_form_cgi_form_element_hidden;
 }
@@ -134,7 +131,7 @@ zak_form_cgi_form_element_hidden_xml_parsing (ZakFormElement *element, xmlNodePt
        id = NULL;
 
        ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
-       g_hash_table_replace (ht_attrs, "type", "hidden");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("hidden"));
 
        cur = xmlnode->children;
        while (cur != NULL)
@@ -148,7 +145,7 @@ zak_form_cgi_form_element_hidden_xml_parsing (ZakFormElement *element, xmlNodePt
                                }
                        else
                                {
-                                       g_hash_table_replace (ht_attrs, g_strdup (cur->name), (gchar *)xmlNodeGetContent (cur));
+                                       g_hash_table_replace (ht_attrs, g_strdup ((gchar *)cur->name), (gchar *)xmlNodeGetContent (cur));
                                }
 
                        cur = cur->next;
@@ -157,8 +154,8 @@ zak_form_cgi_form_element_hidden_xml_parsing (ZakFormElement *element, xmlNodePt
        if (id != NULL)
                {
                        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_hidden_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
-                                                                                                                                                                                         id,
-                                                                                                                                                                                         ht_attrs);
+                                                     id,
+                                                     ht_attrs);
                }
 }
 
@@ -180,7 +177,7 @@ static gchar
        value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("value"), (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_tag_ht ("input", zak_form_cgi_form_element_get_id (element), ht_attrs);
@@ -191,9 +188,9 @@ static gchar
 /* PRIVATE */
 static void
 zak_form_cgi_form_element_hidden_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
+                                               guint property_id,
+                                               const GValue *value,
+                                               GParamSpec *pspec)
 {
        ZakFormCgiFormElementHidden *zak_form_cgi_form_element_hidden = (ZakFormCgiFormElementHidden *)object;
        ZakFormCgiFormElementHiddenPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_HIDDEN_GET_PRIVATE (zak_form_cgi_form_element_hidden);
@@ -208,9 +205,9 @@ zak_form_cgi_form_element_hidden_set_property (GObject *object,
 
 static void
 zak_form_cgi_form_element_hidden_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
+                                               guint property_id,
+                                               GValue *value,
+                                               GParamSpec *pspec)
 {
        ZakFormCgiFormElementHidden *zak_form_cgi_form_element_hidden = (ZakFormCgiFormElementHidden *)object;
        ZakFormCgiFormElementHiddenPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_HIDDEN_GET_PRIVATE (zak_form_cgi_form_element_hidden);
index 8a21d2dfc38b6d66441bdf902fe24c8958760496..291e916b77d96cf06010b9733724053f65686f3d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -21,6 +21,7 @@
 #endif
 
 #include <libzakcgi/libzakcgi.h>
+
 #include "formelementpassword.h"
 
 static void zak_form_cgi_form_element_password_class_init (ZakFormCgiFormElementPasswordClass *class);
@@ -29,13 +30,13 @@ static void zak_form_cgi_form_element_password_init (ZakFormCgiFormElementPasswo
 static gchar *zak_form_cgi_form_element_password_render (ZakFormCgiFormElement *element);
 
 static void zak_form_cgi_form_element_password_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                                             guint property_id,
+                                                             const GValue *value,
+                                                             GParamSpec *pspec);
 static void zak_form_cgi_form_element_password_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                                             guint property_id,
+                                                             GValue *value,
+                                                             GParamSpec *pspec);
 
 static void zak_form_cgi_form_element_password_dispose (GObject *gobject);
 static void zak_form_cgi_form_element_password_finalize (GObject *gobject);
@@ -84,11 +85,7 @@ zak_form_cgi_form_element_password_init (ZakFormCgiFormElementPassword *zak_form
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_password_new ()
 {
-       ZakFormCgiFormElementPassword *zak_form_cgi_form_element_password;
-
-       zak_form_cgi_form_element_password = ZAK_FORM_CGI_FORM_ELEMENT_PASSWORD (g_object_new (zak_form_cgi_form_element_password_get_type (), NULL));
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_password);
+       return  zak_form_cgi_form_element_password_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -100,7 +97,7 @@ ZakFormCgiFormElement
  */
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_password_new_attrs (const gchar *id,
-                                                                                 ...)
+                                               ...)
 {
        va_list ap;
 
@@ -108,16 +105,16 @@ ZakFormCgiFormElement
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_password;
 
-       zak_form_cgi_form_element_password = zak_form_cgi_form_element_password_new ();
+       zak_form_cgi_form_element_password = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_password_get_type (), NULL));
 
        va_start (ap, id);
 
        ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
-       g_hash_table_replace (ht_attrs, "type", "password");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("password"));
 
        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_password_parent_class)->construct (zak_form_cgi_form_element_password,
-                                                                                                                                                                               id,
-                                                                                                                                                                               ht_attrs);
+                                       id,
+                                       ht_attrs);
 
        return zak_form_cgi_form_element_password;
 }
@@ -134,7 +131,7 @@ zak_form_cgi_form_element_password_xml_parsing (ZakFormElement *element, xmlNode
        id = NULL;
 
        ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
-       g_hash_table_replace (ht_attrs, "type", "password");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("password"));
 
        cur = xmlnode->children;
        while (cur != NULL)
@@ -152,7 +149,7 @@ zak_form_cgi_form_element_password_xml_parsing (ZakFormElement *element, xmlNode
                                }
                        else
                                {
-                                       g_hash_table_replace (ht_attrs, g_strdup (cur->name), (gchar *)xmlNodeGetContent (cur));
+                                       g_hash_table_replace (ht_attrs, g_strdup ((gchar *)cur->name), (gchar *)xmlNodeGetContent (cur));
                                }
 
                        cur = cur->next;
@@ -161,8 +158,8 @@ zak_form_cgi_form_element_password_xml_parsing (ZakFormElement *element, xmlNode
        if (id != NULL)
                {
                        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_password_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
-                                                                                                                                                                                               id,
-                                                                                                                                                                                               ht_attrs);
+                                                       id,
+                                                       ht_attrs);
                }
 }
 
@@ -184,7 +181,7 @@ static gchar
        value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("value"), (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_tag_ht ("input", zak_form_cgi_form_element_get_id (element), ht_attrs);
index 49c18ce4a04f893cf956e0bd1abd5820a81f98e6..6340bdce7ebe451a7f0e8e61dba063a4324d389c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -23,6 +23,7 @@
 #include <libzakutils/libzakutils.h>
 
 #include <libzakcgi/libzakcgi.h>
+
 #include "formelementradio.h"
 
 static void zak_form_cgi_form_element_radio_class_init (ZakFormCgiFormElementRadioClass *class);
@@ -95,11 +96,7 @@ zak_form_cgi_form_element_radio_init (ZakFormCgiFormElementRadio *zak_form_cgi_f
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_radio_new ()
 {
-       ZakFormCgiFormElementRadio *zak_form_cgi_form_element_radio;
-
-       zak_form_cgi_form_element_radio = ZAK_FORM_CGI_FORM_ELEMENT_RADIO (g_object_new (zak_form_cgi_form_element_radio_get_type (), NULL));
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_radio);
+       return zak_form_cgi_form_element_radio_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -119,12 +116,12 @@ ZakFormCgiFormElement
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_radio;
 
-       zak_form_cgi_form_element_radio = zak_form_cgi_form_element_radio_new ();
+       zak_form_cgi_form_element_radio = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_radio_get_type (), NULL));
 
        va_start (ap, id);
 
        ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
-       g_hash_table_replace (ht_attrs, "type", "radio");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("radio"));
 
        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_radio_parent_class)->construct (zak_form_cgi_form_element_radio,
                                     id,
@@ -163,7 +160,7 @@ zak_form_cgi_form_element_radio_xml_parsing (ZakFormElement *element, xmlNodePtr
        id = NULL;
 
        ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
-       g_hash_table_replace (ht_attrs, "type", "radio");
+       g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("radio"));
 
        cur = xmlnode->children;
        while (cur != NULL)
@@ -263,7 +260,7 @@ static gchar
        attr_class = g_hash_table_lookup (ht_attrs, "class");
        if (attr_class != NULL)
                {
-                       g_hash_table_insert (ht_attrs, "class", g_strjoinv ("", g_strsplit (attr_class, "form-control", -1)));
+                       g_hash_table_insert (ht_attrs, g_strdup ("class"), g_strjoinv ("", g_strsplit (attr_class, "form-control", -1)));
                        g_free (attr_class);
                }
 
@@ -274,12 +271,12 @@ static gchar
                        ht_attrs_option = g_hash_table_new (g_str_hash, g_str_equal);
                        zak_utils_ghashtable_copy (ht_attrs, ht_attrs_option);
 
-                       g_hash_table_insert (ht_attrs_option, (gpointer)"value", (gpointer)g_strdup (opt->value));
+                       g_hash_table_insert (ht_attrs_option, (gpointer)g_strdup ("value"), (gpointer)g_strdup (opt->value));
 
                        if (element_value != NULL
                            && g_strcmp0 (element_value, opt->value) == 0)
                                {
-                                       g_hash_table_insert (ht_attrs_option, (gpointer)"checked", (gpointer)"checked");
+                                       g_hash_table_insert (ht_attrs_option, (gpointer)g_strdup ("checked"), (gpointer)g_strdup ("checked"));
                                }
 
                        g_string_append_printf (ret, "\n%s<label%s>\n%s %s</label>%s",
index 3cb9d0e7400ee550813e255b5008943e2eb820ae..1e7cbf3842d97fd2967b17a38112186fed1730db 100644 (file)
@@ -21,6 +21,7 @@
 #endif
 
 #include <libzakcgi/libzakcgi.h>
+
 #include "formelementselect.h"
 
 static void zak_form_cgi_form_element_select_class_init (ZakFormCgiFormElementSelectClass *class);
@@ -85,11 +86,7 @@ zak_form_cgi_form_element_select_init (ZakFormCgiFormElementSelect *zak_form_cgi
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_select_new ()
 {
-       ZakFormCgiFormElementSelect *zak_form_cgi_form_element_select;
-
-       zak_form_cgi_form_element_select = ZAK_FORM_CGI_FORM_ELEMENT_SELECT (g_object_new (zak_form_cgi_form_element_select_get_type (), NULL));
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_select);
+       return  zak_form_cgi_form_element_select_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -107,7 +104,7 @@ ZakFormCgiFormElement
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_select;
 
-       zak_form_cgi_form_element_select = zak_form_cgi_form_element_select_new ();
+       zak_form_cgi_form_element_select = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_select_get_type (), NULL));
 
        va_start (ap, id);
 
@@ -143,8 +140,8 @@ zak_form_cgi_form_element_select_add_option (ZakFormCgiFormElementSelect *elemen
                {
                        ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
                }
-       g_hash_table_replace (ht_attrs, "zak-cgi-content", g_strdup (content));
-       g_hash_table_replace (ht_attrs, "value", g_strdup (value));
+       g_hash_table_replace (ht_attrs, g_strdup ("zak-cgi-content"), g_strdup (content));
+       g_hash_table_replace (ht_attrs, g_strdup ("value"), g_strdup (value));
 
        g_ptr_array_add (priv->ar_options, ht_attrs);
 }
@@ -229,7 +226,7 @@ static gchar
                                {
                                        if (g_strcmp0 (gval, (gchar *)g_hash_table_lookup (ht_options_attrs, "value")) == 0)
                                                {
-                                                       g_hash_table_replace (ht_options_attrs, "selected", g_strdup ("selected"));
+                                                       g_hash_table_replace (ht_options_attrs, g_strdup ("selected"), g_strdup ("selected"));
                                                }
                                }
 
@@ -242,10 +239,10 @@ static gchar
 
        if (!zak_form_element_get_editable (ZAK_FORM_ELEMENT (element)))
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"disabled", (gpointer)"disabled");
+                       g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("disabled"), (gpointer)g_strdup ("disabled"));
                }
 
-       g_hash_table_replace (ht_attrs, "zak-cgi-content", g_strdup (options->str));
+       g_hash_table_replace (ht_attrs, g_strdup ("zak-cgi-content"), g_strdup (options->str));
        ret = zak_cgi_tag_tag_ht ("select", zak_form_cgi_form_element_get_id (element), ht_attrs);
 
        g_string_free (options, TRUE);
index 67f091d14a480ce3efc089d5dd079e41d73112b9..5a326133fac4a0eaa99629ee9d9d73e0f3e0c699 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -21,6 +21,7 @@
 #endif
 
 #include <libzakcgi/libzakcgi.h>
+
 #include "formelementsubmit.h"
 
 static void zak_form_cgi_form_element_submit_class_init (ZakFormCgiFormElementSubmitClass *class);
@@ -29,13 +30,13 @@ static void zak_form_cgi_form_element_submit_init (ZakFormCgiFormElementSubmit *
 static gchar *zak_form_cgi_form_element_submit_render (ZakFormCgiFormElement *element);
 
 static void zak_form_cgi_form_element_submit_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                                           guint property_id,
+                                                           const GValue *value,
+                                                           GParamSpec *pspec);
 static void zak_form_cgi_form_element_submit_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                                           guint property_id,
+                                                           GValue *value,
+                                                           GParamSpec *pspec);
 
 static void zak_form_cgi_form_element_submit_dispose (GObject *gobject);
 static void zak_form_cgi_form_element_submit_finalize (GObject *gobject);
@@ -84,11 +85,7 @@ zak_form_cgi_form_element_submit_init (ZakFormCgiFormElementSubmit *zak_form_cgi
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_submit_new ()
 {
-       ZakFormCgiFormElementSubmit *zak_form_cgi_form_element_submit;
-
-       zak_form_cgi_form_element_submit = ZAK_FORM_CGI_FORM_ELEMENT_SUBMIT (g_object_new (zak_form_cgi_form_element_submit_get_type (), NULL));
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_submit);
+       return zak_form_cgi_form_element_submit_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -100,19 +97,19 @@ ZakFormCgiFormElement
  */
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_submit_new_attrs (const gchar *id,
-                                                                               ...)
+                                             ...)
 {
        va_list ap;
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_submit;
 
-       zak_form_cgi_form_element_submit = zak_form_cgi_form_element_submit_new ();
+       zak_form_cgi_form_element_submit = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_submit_get_type (), NULL));
 
        va_start (ap, id);
 
        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_submit_parent_class)->construct (zak_form_cgi_form_element_submit,
-                                                                                                                                                                         id,
-                                                                                                                                                                         zak_cgi_commons_valist_to_ghashtable (ap));
+                                     id,
+                                     zak_cgi_commons_valist_to_ghashtable (ap));
 
        return zak_form_cgi_form_element_submit;
 }
@@ -155,8 +152,8 @@ zak_form_cgi_form_element_submit_xml_parsing (ZakFormElement *element, xmlNodePt
        if (id != NULL)
                {
                        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_submit_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
-                                                                                                                                                                                         id,
-                                                                                                                                                                                         ht_attrs);
+                                                     id,
+                                                     ht_attrs);
                }
 }
 
index abb771286d288b33ccd4e48d8b2aea211e676f79..2d6003b07999ac4b002aeef02cf39b6c0e9d1a9b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -21,6 +21,7 @@
 #endif
 
 #include <libzakcgi/libzakcgi.h>
+
 #include "formelementtext.h"
 
 static void zak_form_cgi_form_element_text_class_init (ZakFormCgiFormElementTextClass *class);
@@ -29,13 +30,13 @@ static void zak_form_cgi_form_element_text_init (ZakFormCgiFormElementText *zak_
 static gchar *zak_form_cgi_form_element_text_render (ZakFormCgiFormElement *element);
 
 static void zak_form_cgi_form_element_text_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                                         guint property_id,
+                                                         const GValue *value,
+                                                         GParamSpec *pspec);
 static void zak_form_cgi_form_element_text_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                                         guint property_id,
+                                                         GValue *value,
+                                                         GParamSpec *pspec);
 
 static void zak_form_cgi_form_element_text_dispose (GObject *gobject);
 static void zak_form_cgi_form_element_text_finalize (GObject *gobject);
@@ -84,11 +85,8 @@ zak_form_cgi_form_element_text_init (ZakFormCgiFormElementText *zak_form_cgi_for
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_text_new ()
 {
-       ZakFormCgiFormElementText *zak_form_cgi_form_element_text;
-
-       zak_form_cgi_form_element_text = ZAK_FORM_CGI_FORM_ELEMENT_TEXT (g_object_new (zak_form_cgi_form_element_text_get_type (), NULL));
 
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_text);
+       return zak_form_cgi_form_element_text_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -100,19 +98,19 @@ ZakFormCgiFormElement
  */
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_text_new_attrs (const gchar *id,
-                                                                         ...)
+                                           ...)
 {
        va_list ap;
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_text;
 
-       zak_form_cgi_form_element_text = zak_form_cgi_form_element_text_new ();
+       zak_form_cgi_form_element_text = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_text_get_type (), NULL));
 
        va_start (ap, id);
 
        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_text_parent_class)->construct (zak_form_cgi_form_element_text,
-                                                                                                                                                                       id,
-                                                                                                                                                                       zak_cgi_commons_valist_to_ghashtable (ap));
+                                   id,
+                                   zak_cgi_commons_valist_to_ghashtable (ap));
 
        return zak_form_cgi_form_element_text;
 }
@@ -155,8 +153,8 @@ zak_form_cgi_form_element_text_xml_parsing (ZakFormElement *element, xmlNodePtr
        if (id != NULL)
                {
                        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_text_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
-                                                                                                                                                                                       id,
-                                                                                                                                                                                       ht_attrs);
+                                                   id,
+                                                   ht_attrs);
                }
 }
 
@@ -178,7 +176,7 @@ static gchar
        value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("value"), (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_text_ht (zak_form_cgi_form_element_get_id (element), ht_attrs);
index a41efcdd379f78ded825c826e0a040b852b0a304..e7703f1e280c8020e008b3c9fce52c7207bb8854 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -21,6 +21,7 @@
 #endif
 
 #include <libzakcgi/libzakcgi.h>
+
 #include "formelementtextarea.h"
 
 static void zak_form_cgi_form_element_text_area_class_init (ZakFormCgiFormElementTextAreaClass *class);
@@ -29,13 +30,13 @@ static void zak_form_cgi_form_element_text_area_init (ZakFormCgiFormElementTextA
 static gchar *zak_form_cgi_form_element_text_area_render (ZakFormCgiFormElement *element);
 
 static void zak_form_cgi_form_element_text_area_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                                              guint property_id,
+                                                              const GValue *value,
+                                                              GParamSpec *pspec);
 static void zak_form_cgi_form_element_text_area_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                                              guint property_id,
+                                                              GValue *value,
+                                                              GParamSpec *pspec);
 
 static void zak_form_cgi_form_element_text_area_dispose (GObject *gobject);
 static void zak_form_cgi_form_element_text_area_finalize (GObject *gobject);
@@ -84,11 +85,7 @@ zak_form_cgi_form_element_text_area_init (ZakFormCgiFormElementTextArea *zak_for
 ZakFormCgiFormElement
 *zak_form_cgi_form_element_text_area_new ()
 {
-       ZakFormCgiFormElementTextArea *zak_form_cgi_form_element_text_area;
-
-       zak_form_cgi_form_element_text_area = ZAK_FORM_CGI_FORM_ELEMENT_TEXT_AREA (g_object_new (zak_form_cgi_form_element_text_area_get_type (), NULL));
-
-       return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_text_area);
+       return zak_form_cgi_form_element_text_area_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
 }
 
 /**
@@ -106,13 +103,13 @@ ZakFormCgiFormElement
 
        ZakFormCgiFormElement *zak_form_cgi_form_element_text_area;
 
-       zak_form_cgi_form_element_text_area = zak_form_cgi_form_element_text_area_new ();
+       zak_form_cgi_form_element_text_area = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_text_area_get_type (), NULL));
 
        va_start (ap, id);
 
        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_text_area_parent_class)->construct (zak_form_cgi_form_element_text_area,
-                                                                                                                                                                                id,
-                                                                                                                                                                                zak_cgi_commons_valist_to_ghashtable (ap));
+                                        id,
+                                        zak_cgi_commons_valist_to_ghashtable (ap));
 
        return zak_form_cgi_form_element_text_area;
 }
@@ -155,8 +152,8 @@ zak_form_cgi_form_element_text_area_xml_parsing (ZakFormElement *element, xmlNod
        if (id != NULL)
                {
                        ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_text_area_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
-                                                                                                                                                                                                id,
-                                                                                                                                                                                                ht_attrs);
+                                                        id,
+                                                        ht_attrs);
                }
 }
 
@@ -178,7 +175,7 @@ static gchar
        value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"zak-cgi-content", (gpointer)g_strdup (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("zak-cgi-content"), (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_tag_ht ("textarea", zak_form_cgi_form_element_get_id (element), ht_attrs);