]> saetta.ns0.it Git - libzakcgi/commitdiff
Added function ZakCgiFormElement::bind (closes #1021).
authorAndrea Zagli <azagli@libero.it>
Mon, 16 May 2016 14:52:15 +0000 (16:52 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 16 May 2016 14:52:15 +0000 (16:52 +0200)
src/form.c
src/formelement.c
src/formelement.h

index 6b9852d5f60ba92374a5a8c2091dc449842a559e..03c584aee4f3edbb97edf5cce314b4073ccdc58f 100644 (file)
@@ -138,7 +138,6 @@ zak_cgi_form_bind (ZakCgiForm *zakcgiform)
        guint i;
 
        GValue *gval;
-       gchar *value;
 
        ZakCgiFormPrivate *priv;
 
@@ -154,8 +153,7 @@ zak_cgi_form_bind (ZakCgiForm *zakcgiform)
                                        gval = zak_cgi_main_get_stdin_field (priv->zakcgimain, zak_cgi_form_element_get_id (element));
                                        if (gval != NULL)
                                                {
-                                                       value = zak_form_element_unformat (ZAK_FORM_ELEMENT (element), g_value_get_string (gval));
-                                                       zak_form_element_set_value (ZAK_FORM_ELEMENT (element), value);
+                                                       zak_cgi_form_element_bind (element, g_value_get_string (gval));
                                                }
                                }
                }
index f2f07fb9f095bf57c7d0deb5ee2e39275a851bca..6e079be96bd9dda41c03f25a066015fc6731a56b 100644 (file)
@@ -50,6 +50,8 @@ static void zak_cgi_form_element_get_property (GObject *object,
 static void zak_cgi_form_element_dispose (GObject *gobject);
 static void zak_cgi_form_element_finalize (GObject *gobject);
 
+static gchar *zak_cgi_form_element_get_value (ZakCgiFormElement *element);
+static gboolean zak_cgi_form_element_set_value (ZakCgiFormElement *element, const gchar *value);
 static void zak_cgi_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmlnode);
 
 #define ZAK_CGI_FORM_ELEMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CGI_TYPE_FORM_ELEMENT, ZakCgiFormElementPrivate))
@@ -60,6 +62,7 @@ struct _ZakCgiFormElementPrivate
                gchar *id;
                GHashTable *ht_attrs;
                GHashTable *ht_label_attrs;
+               gchar *value;
        };
 
 G_DEFINE_TYPE (ZakCgiFormElement, zak_cgi_form_element, ZAK_FORM_TYPE_ELEMENT)
@@ -68,6 +71,7 @@ static void
 zak_cgi_form_element_class_init (ZakCgiFormElementClass *class)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (class);
+       ZakFormElementClass *elem_class = ZAK_FORM_ELEMENT_CLASS (class);
 
        object_class->set_property = zak_cgi_form_element_set_property;
        object_class->get_property = zak_cgi_form_element_get_property;
@@ -76,6 +80,9 @@ zak_cgi_form_element_class_init (ZakCgiFormElementClass *class)
 
        class->xml_parsing = zak_cgi_form_element_xml_parsing;
 
+       elem_class->get_value = zak_cgi_form_element_get_value;
+       elem_class->set_value = zak_cgi_form_element_set_value;
+
        g_type_class_add_private (object_class, sizeof (ZakCgiFormElementPrivate));
 
        class->construct = zak_cgi_form_element_construct;
@@ -132,6 +139,22 @@ zak_cgi_form_element_set_label (ZakCgiFormElement *element, const gchar *label,
        zak_form_element_set_long_name (ZAK_FORM_ELEMENT (element), label);
 }
 
+/**
+ * zak_cgi_form_element_bind:
+ * @element:
+ * @value:
+ *
+ */
+void
+zak_cgi_form_element_bind (ZakCgiFormElement *element, const gchar *value)
+{
+       ZakCgiFormElementPrivate *priv;
+
+       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+       priv->value = g_strdup (value);
+}
+
 /**
  * zak_cgi_form_element_render:
  * @element:
@@ -250,6 +273,32 @@ static GHashTable
        return priv->ht_attrs;
 }
 
+static gchar
+*zak_cgi_form_element_get_value (ZakCgiFormElement *element)
+{
+       gchar *ret;
+
+       ZakCgiFormElementPrivate *priv;
+
+       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+       ret = g_strdup (priv->value);
+
+       return ret;
+}
+
+static gboolean
+zak_cgi_form_element_set_value (ZakCgiFormElement *element, const gchar *value)
+{
+       ZakCgiFormElementPrivate *priv;
+
+       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+       priv->value = g_strdup (value);
+
+       return TRUE;
+}
+
 static void
 zak_cgi_form_element_set_property (GObject *object,
                    guint property_id,
index 804021c285079fb920d9f0876c0d395f0bfca3c7..50d5822bec178cd7f03e41de558b476571eae56c 100644 (file)
@@ -50,6 +50,8 @@ gchar *zak_cgi_form_element_get_id (ZakCgiFormElement *element);
 
 void zak_cgi_form_element_set_label (ZakCgiFormElement *element, const gchar *label, ...);
 
+void zak_cgi_form_element_bind (ZakCgiFormElement *element, const gchar *value);
+
 gchar *zak_cgi_form_element_render (ZakCgiFormElement *element);