From: Andrea Zagli Date: Sat, 2 Jan 2016 16:31:48 +0000 (+0100) Subject: Added proprty long_name to ZakFormElement. X-Git-Tag: debian/0.0.1-1~12 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=0b7caaa99fec70a60213de2eb0aac5d3f29c3c3a;p=zakform%2Flibzakform Added proprty long_name to ZakFormElement. --- diff --git a/src/formelement.c b/src/formelement.c index 26c6012..56c7c7b 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Andrea Zagli + * Copyright (C) 2015-2016 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,6 +28,7 @@ enum { PROP_0, PROP_NAME, + PROP_LONG_NAME, PROP_IS_KEY, PROP_TYPE, PROP_VALUE, @@ -64,6 +65,7 @@ static void zak_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmln typedef struct { gchar *name; + gchar *long_name; gboolean is_key; gchar *type; gchar *value; @@ -101,6 +103,13 @@ zak_form_element_class_init (ZakFormElementClass *class) "", G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_LONG_NAME, + g_param_spec_string ("long-name", + "Long name", + "Long name", + NULL, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_IS_KEY, g_param_spec_boolean ("is-key", "Is key", @@ -178,6 +187,7 @@ zak_form_element_init (ZakFormElement *zak_form_element) ZakFormElementPrivate *priv = zak_form_element_get_instance_private (zak_form_element); priv->name = g_strdup (""); + priv->long_name = NULL; priv->is_key = FALSE; priv->type = g_strdup (""); priv->value = g_strdup (""); @@ -285,6 +295,53 @@ gchar return ret; } +/** + * zak_form_element_set_long_name: + * @element: + * @long_name: + * + */ +void +zak_form_element_set_long_name (ZakFormElement *element, const gchar *long_name) +{ + ZakFormElementPrivate *priv; + + priv = zak_form_element_get_instance_private (element); + + if (priv->long_name != NULL) + { + g_free (priv->long_name); + } + + priv->long_name = g_strdup (long_name); +} + +/** + * zak_form_element_get_long_name: + * @element: + * + */ +gchar +*zak_form_element_get_long_name (ZakFormElement *element) +{ + ZakFormElementPrivate *priv; + + gchar *ret; + + priv = zak_form_element_get_instance_private (element); + + if (priv->long_name == NULL) + { + ret = zak_form_element_get_name (element); + } + else + { + ret = g_strdup (priv->long_name); + } + + return ret; +} + /** * zak_form_element_set_is_key: * @element: @@ -905,6 +962,10 @@ zak_form_element_set_property (GObject *object, zak_form_element_set_name (zak_form_element, g_value_dup_string (value)); break; + case PROP_LONG_NAME: + zak_form_element_set_long_name (zak_form_element, g_value_dup_string (value)); + break; + case PROP_IS_KEY: zak_form_element_set_is_key (zak_form_element, g_value_get_boolean (value)); break; @@ -966,6 +1027,10 @@ zak_form_element_get_property (GObject *object, g_value_set_string (value, zak_form_element_get_name (zak_form_element)); break; + case PROP_LONG_NAME: + g_value_set_string (value, zak_form_element_get_long_name (zak_form_element)); + break; + case PROP_IS_KEY: g_value_set_boolean (value, zak_form_element_get_is_key (zak_form_element)); break; diff --git a/src/formelement.h b/src/formelement.h index 8b87c1d..2c17cf6 100644 --- a/src/formelement.h +++ b/src/formelement.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Andrea Zagli + * Copyright (C) 2015-2016 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -53,6 +53,9 @@ struct _ZakFormElementClass void zak_form_element_set_name (ZakFormElement *element, const gchar *name); gchar *zak_form_element_get_name (ZakFormElement *element); +void zak_form_element_set_long_name (ZakFormElement *element, const gchar *long_name); +gchar *zak_form_element_get_long_name (ZakFormElement *element); + void zak_form_element_set_to_is_key (ZakFormElement *element, gboolean is_key); gboolean zak_form_element_get_is_key (ZakFormElement *element); diff --git a/src/formvalidatorcomparedate.c b/src/formvalidatorcomparedate.c index e4cbd14..309f147 100644 --- a/src/formvalidatorcomparedate.c +++ b/src/formvalidatorcomparedate.c @@ -262,7 +262,7 @@ zak_form_validator_compare_date_validate (ZakFormValidator *validator, { gdt1 = zak_utils_get_gdatetime_from_string (zak_form_element_get_value (priv->v1), priv->format1); gdt2 = zak_utils_get_gdatetime_from_string (zak_form_element_get_value (priv->v2), priv->format2); - g_warning ("gdt1 %s; gdt2 %s",g_date_time_format(gdt1,"%d/%m/%Y"),g_date_time_format(gdt2,"%d/%m/%Y")); + if (gdt1 == NULL || gdt2 == NULL) { @@ -312,9 +312,9 @@ zak_form_validator_compare_date_validate (ZakFormValidator *validator, if (!ret) { msg = g_strdup_printf ("«%s» must be %s «%s»", - zak_form_element_get_name (priv->v1), + zak_form_element_get_long_name (priv->v1), msgs[priv->type], - zak_form_element_get_name (priv->v2)); + zak_form_element_get_long_name (priv->v2)); zak_form_validator_set_message (validator, msg); g_free (msg); }