From: Andrea Zagli Date: Sun, 22 Nov 2015 15:19:40 +0000 (+0100) Subject: Added property editable to ZakFormElement. X-Git-Tag: debian/0.0.1-1~38 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=abac57626e92ba95b172fa01be930b0b7473f518;p=zakform%2Flibzakform Added property editable to ZakFormElement. --- diff --git a/src/formelement.c b/src/formelement.c index 0628775..00d0fc3 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -27,7 +27,8 @@ enum PROP_0, PROP_VALUE, PROP_DEFAULT_VALUE, - PROP_VISIBLE + PROP_VISIBLE, + PROP_EDITABLE }; static void zak_form_element_class_init (ZakFormElementClass *class); @@ -56,6 +57,7 @@ typedef struct gchar *value; gchar *default_value; gboolean visible; + gboolean editable; GPtrArray *pa_filters; GPtrArray *pa_validators; GPtrArray *pa_messages; @@ -89,12 +91,19 @@ zak_form_element_class_init (ZakFormElementClass *class) "", G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - g_object_class_install_property (object_class, PROP_DEFAULT_VALUE, + g_object_class_install_property (object_class, PROP_VISIBLE, g_param_spec_boolean ("visible", "Visible", "Visible", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, PROP_EDITABLE, + g_param_spec_boolean ("editable", + "Editable", + "Editable", + TRUE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } static void @@ -263,6 +272,37 @@ zak_form_element_get_visible (ZakFormElement *element) return priv->visible; } +/** + * zak_form_element_set_editable: + * @element: + * @editable: + * + */ +void +zak_form_element_set_editable (ZakFormElement *element, gboolean editable) +{ + ZakFormElementPrivate *priv; + + priv = zak_form_element_get_instance_private (element); + + priv->editable = editable; +} + +/** + * zak_form_element_get_editable: + * @element: + * + */ +gboolean +zak_form_element_get_editable (ZakFormElement *element) +{ + ZakFormElementPrivate *priv; + + priv = zak_form_element_get_instance_private (element); + + return priv->editable; +} + /** * zak_form_element_clear: * @element: @@ -369,6 +409,14 @@ zak_form_element_set_property (GObject *object, zak_form_element_set_default_value (zak_form_element, g_value_get_string (value)); break; + case PROP_VISIBLE: + zak_form_element_set_visible (zak_form_element, g_value_get_boolean (value)); + break; + + case PROP_EDITABLE: + zak_form_element_set_editable (zak_form_element, g_value_get_boolean (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -394,6 +442,14 @@ zak_form_element_get_property (GObject *object, g_value_set_string (value, zak_form_element_get_default_value (zak_form_element)); break; + case PROP_VISIBLE: + g_value_set_boolean (value, zak_form_element_get_visible (zak_form_element)); + break; + + case PROP_EDITABLE: + g_value_set_boolean (value, zak_form_element_get_editable (zak_form_element)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; diff --git a/src/formelement.h b/src/formelement.h index 41b63d0..842cf57 100644 --- a/src/formelement.h +++ b/src/formelement.h @@ -49,6 +49,9 @@ gchar *zak_form_element_get_default_value (ZakFormElement *element); void zak_form_element_set_visible (ZakFormElement *element, gboolean visible); gboolean zak_form_element_get_visible (ZakFormElement *element); +void zak_form_element_set_editable (ZakFormElement *element, gboolean editable); +gboolean zak_form_element_get_editable (ZakFormElement *element); + void zak_form_element_clear (ZakFormElement *element); void zak_form_element_add_filter (ZakFormElement *element, ZakFormElementFilter *filter);