]> saetta.ns0.it Git - zakform/cgi/commitdiff
Migration to GValue for element value.
authorAndrea Zagli <azagli@libero.it>
Sat, 13 May 2017 09:28:12 +0000 (11:28 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 13 May 2017 09:28:12 +0000 (11:28 +0200)
src/form.c
src/formelement.c
src/formelement.h

index d2005d6b986d2efb46f65fa9e2db52439820ce38..9cf7abc6ccac0ce610b2eb3ff519a2ae6ecab58a 100644 (file)
@@ -152,7 +152,7 @@ zak_form_cgi_form_bind (ZakFormCgiForm *zakcgiform)
                                        gval = zak_cgi_main_get_stdin_field (priv->zakcgimain, zak_form_cgi_form_element_get_id (element));
                                        if (gval != NULL)
                                                {
-                                                       zak_form_cgi_form_element_bind (element, g_value_get_string (gval));
+                                                       zak_form_cgi_form_element_bind (element, gval);
                                                }
                                }
                }
index b3a790a1308500fdc84cc201bd24f0023a989aa9..ce1415756096a6ff514b40819cd37a450f781179 100644 (file)
@@ -20,7 +20,9 @@
        #include <config.h>
 #endif
 
+#include <libzakutils/libzakutils.h>
 #include <libzakcgi/libzakcgi.h>
+
 #include "formelement.h"
 
 enum
@@ -50,8 +52,8 @@ static void zak_form_cgi_form_element_get_property (GObject *object,
 static void zak_form_cgi_form_element_dispose (GObject *gobject);
 static void zak_form_cgi_form_element_finalize (GObject *gobject);
 
-static gchar *zak_form_cgi_form_element_get_value (ZakFormCgiFormElement *element);
-static gboolean zak_form_cgi_form_element_set_value (ZakFormCgiFormElement *element, const gchar *value);
+static GValue *zak_form_cgi_form_element_get_value (ZakFormCgiFormElement *element);
+static gboolean zak_form_cgi_form_element_set_value (ZakFormCgiFormElement *element, GValue *value);
 static void zak_form_cgi_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmlnode);
 
 #define ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_CGI_TYPE_FORM_ELEMENT, ZakFormCgiFormElementPrivate))
@@ -62,7 +64,7 @@ struct _ZakFormCgiFormElementPrivate
                gchar *id;
                GHashTable *ht_attrs;
                GHashTable *ht_label_attrs;
-               gchar *value;
+               GValue *value;
        };
 
 G_DEFINE_TYPE (ZakFormCgiFormElement, zak_form_cgi_form_element, ZAK_FORM_TYPE_ELEMENT)
@@ -154,13 +156,13 @@ zak_form_cgi_form_element_set_label (ZakFormCgiFormElement *element, const gchar
  *
  */
 void
-zak_form_cgi_form_element_bind (ZakFormCgiFormElement *element, const gchar *value)
+zak_form_cgi_form_element_bind (ZakFormCgiFormElement *element, GValue *value)
 {
        ZakFormCgiFormElementPrivate *priv;
 
        priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
 
-       priv->value = g_strdup (value);
+       priv->value = value;
 }
 
 /**
@@ -330,28 +332,28 @@ static GHashTable
        return priv->ht_label_attrs;
 }
 
-static gchar
+static GValue
 *zak_form_cgi_form_element_get_value (ZakFormCgiFormElement *element)
 {
-       gchar *ret;
+       GValue *ret;
 
        ZakFormCgiFormElementPrivate *priv;
 
        priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
 
-       ret = g_strdup (priv->value);
+       ret = priv->value;
 
        return ret;
 }
 
 static gboolean
-zak_form_cgi_form_element_set_value (ZakFormCgiFormElement *element, const gchar *value)
+zak_form_cgi_form_element_set_value (ZakFormCgiFormElement *element, GValue *value)
 {
        ZakFormCgiFormElementPrivate *priv;
 
        priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
 
-       priv->value = g_strdup (value);
+       priv->value = value;
 
        return TRUE;
 }
index 23c3de81a3f665559f7a4d2110a849e265229c27..79085710218308e7e5c31ce2ba2fb3167fa1510a 100644 (file)
@@ -50,7 +50,7 @@ gchar *zak_form_cgi_form_element_get_id (ZakFormCgiFormElement *element);
 
 void zak_form_cgi_form_element_set_label (ZakFormCgiFormElement *element, const gchar *label, ...);
 
-void zak_form_cgi_form_element_bind (ZakFormCgiFormElement *element, const gchar *value);
+void zak_form_cgi_form_element_bind (ZakFormCgiFormElement *element, GValue *value);
 
 gchar *zak_form_cgi_form_element_render (ZakFormCgiFormElement *element);
 gchar *zak_form_cgi_form_element_render_label (ZakFormCgiFormElement *element);