From b5ea235366659b91fdc246e807995201d766eadb Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sun, 22 Nov 2015 16:14:42 +0100 Subject: [PATCH] Added property visible to ZakFormElement. --- docs/notes.txt | 6 +++++- src/formelement.c | 42 +++++++++++++++++++++++++++++++++++++++++- src/formelement.h | 3 +++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/docs/notes.txt b/docs/notes.txt index f111d71..c3ad23d 100644 --- a/docs/notes.txt +++ b/docs/notes.txt @@ -15,8 +15,11 @@ ELEMENT - implement html and gtk - properties: - default (OK did it) + - is editable + - is visible - to-load - to-save + - original value - each element must parse own definition from xml - each element is bounded to a db field - each element could have specifics properties/methods @@ -29,8 +32,9 @@ ELEMENT VALIDATOR - to be transformed from interface to abstract (OK did it) -FIELD/DB +FIELD/DB (LOADERS AND SAVERS) - boolean, integer, float, string, datetime +- load from xml GROUP OF ELEMENTS ??? diff --git a/src/formelement.c b/src/formelement.c index 98f2909..0628775 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -26,7 +26,8 @@ enum { PROP_0, PROP_VALUE, - PROP_DEFAULT_VALUE + PROP_DEFAULT_VALUE, + PROP_VISIBLE }; static void zak_form_element_class_init (ZakFormElementClass *class); @@ -54,6 +55,7 @@ typedef struct { gchar *value; gchar *default_value; + gboolean visible; GPtrArray *pa_filters; GPtrArray *pa_validators; GPtrArray *pa_messages; @@ -86,6 +88,13 @@ zak_form_element_class_init (ZakFormElementClass *class) "Default value", "", G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, PROP_DEFAULT_VALUE, + g_param_spec_boolean ("visible", + "Visible", + "Visible", + TRUE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } static void @@ -223,6 +232,37 @@ gchar return g_strdup (priv->default_value); } +/** + * zak_form_element_set_visible: + * @element: + * @visible: + * + */ +void +zak_form_element_set_visible (ZakFormElement *element, gboolean visible) +{ + ZakFormElementPrivate *priv; + + priv = zak_form_element_get_instance_private (element); + + priv->visible = visible; +} + +/** + * zak_form_element_get_visible: + * @element: + * + */ +gboolean +zak_form_element_get_visible (ZakFormElement *element) +{ + ZakFormElementPrivate *priv; + + priv = zak_form_element_get_instance_private (element); + + return priv->visible; +} + /** * zak_form_element_clear: * @element: diff --git a/src/formelement.h b/src/formelement.h index 4acc228..41b63d0 100644 --- a/src/formelement.h +++ b/src/formelement.h @@ -46,6 +46,9 @@ gchar *zak_form_element_get_value (ZakFormElement *element); void zak_form_element_set_default_value (ZakFormElement *element, const gchar *value); 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_clear (ZakFormElement *element); void zak_form_element_add_filter (ZakFormElement *element, ZakFormElementFilter *filter); -- 2.49.0