From: Andrea Zagli Date: Sun, 16 Apr 2017 07:58:57 +0000 (+0200) Subject: FormElement doesn't take into account editable property. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=0e6b88e0d399eaa36d37e49e78ec9d367e6e11a5;p=zakform%2Fcgi FormElement doesn't take into account editable property. --- diff --git a/src/formelement.c b/src/formelement.c index 7f219bf..47c742a 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2016 Andrea Zagli + * Copyright (C) 2015-2017 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,19 +32,19 @@ static void zak_form_cgi_form_element_class_init (ZakFormCgiFormElementClass *cl static void zak_form_cgi_form_element_init (ZakFormCgiFormElement *zak_form_cgi_form_element); static void zak_form_cgi_form_element_construct (ZakFormCgiFormElement *element, - const gchar *id, - GHashTable *ht_attrs); + const gchar *id, + GHashTable *ht_attrs); static GHashTable *zak_form_cgi_form_element_get_ht_attrs (ZakFormCgiFormElement *element); static void zak_form_cgi_form_element_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_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_dispose (GObject *gobject); static void zak_form_cgi_form_element_finalize (GObject *gobject); @@ -212,6 +212,11 @@ gchar g_hash_table_replace (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_string_append (str, ZAK_FORM_CGI_FORM_ELEMENT_GET_CLASS (element)->render (element)); } @@ -222,10 +227,10 @@ gchar for (i = 0; i < messages->len; i++) { g_string_append_printf (str, - "\n%s", - priv->id, - i + 1, - (gchar *)g_ptr_array_index (messages, i)); + "\n%s", + priv->id, + i + 1, + (gchar *)g_ptr_array_index (messages, i)); } } @@ -240,8 +245,8 @@ gchar /* PRIVATE */ static void zak_form_cgi_form_element_construct (ZakFormCgiFormElement *element, - const gchar *id, - GHashTable *ht_attrs) + const gchar *id, + GHashTable *ht_attrs) { ZakFormCgiFormElementPrivate *priv; @@ -300,9 +305,9 @@ zak_form_cgi_form_element_set_value (ZakFormCgiFormElement *element, const gchar static void zak_form_cgi_form_element_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { ZakFormCgiFormElement *zak_form_cgi_form_element = (ZakFormCgiFormElement *)object; ZakFormCgiFormElementPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (zak_form_cgi_form_element); @@ -317,9 +322,9 @@ zak_form_cgi_form_element_set_property (GObject *object, static void zak_form_cgi_form_element_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { ZakFormCgiFormElement *zak_form_cgi_form_element = (ZakFormCgiFormElement *)object; ZakFormCgiFormElementPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (zak_form_cgi_form_element);