]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added proprty long_name to ZakFormElement.
authorAndrea Zagli <azagli@libero.it>
Sat, 2 Jan 2016 16:31:48 +0000 (17:31 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 2 Jan 2016 16:31:48 +0000 (17:31 +0100)
src/formelement.c
src/formelement.h
src/formvalidatorcomparedate.c

index 26c601266ed459b5c35a22e08520f9ab824c3f45..56c7c7ba8b02a3e08287f684545afc804f1b4cf9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2016 Andrea Zagli <azagli@libero.it>
  *
  * 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;
index 8b87c1d8ffcdf86b40c7519e8157a1311f4b623e..2c17cf6bff19f7465c0d74ac77cd7bfdf226ab06 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2016 Andrea Zagli <azagli@libero.it>
  *
  * 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);
 
index e4cbd146d584b862f0dfa2d409d0c43c5df897b5..309f1477497f69dce15ddd4eab6c0dff93a525d1 100644 (file)
@@ -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);
                                }