]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added property format to ZakFormElement.
authorAndrea Zagli <azagli@libero.it>
Mon, 7 Dec 2015 09:40:50 +0000 (10:40 +0100)
committerAndrea Zagli <azagli@libero.it>
Mon, 7 Dec 2015 09:40:50 +0000 (10:40 +0100)
src/formelement.c
src/formelement.h

index 604577f5d8d3e26f679f4b7d00bc7013ed4da5d0..d7c856ee4515b573ca19dea12bb66d2fe727b3bd 100644 (file)
@@ -31,6 +31,7 @@ enum
        PROP_VALUE,
        PROP_DEFAULT_VALUE,
        PROP_ORIGINAL_VALUE,
+       PROP_FORMAT,
        PROP_VISIBLE,
        PROP_EDITABLE,
        PROP_TO_LOAD,
@@ -66,6 +67,7 @@ typedef struct
                gchar *value;
                gchar *default_value;
                gchar *original_value;
+               gchar *format;
                gboolean visible;
                gboolean editable;
                gboolean to_load;
@@ -132,6 +134,13 @@ zak_form_element_class_init (ZakFormElementClass *class)
                                                              "",
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
+       g_object_class_install_property (object_class, PROP_FORMAT,
+                                        g_param_spec_string ("format",
+                                                             "Format",
+                                                             "Format",
+                                                             "",
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
        g_object_class_install_property (object_class, PROP_VISIBLE,
                                         g_param_spec_boolean ("visible",
                                                               "Visible",
@@ -508,6 +517,48 @@ zak_form_element_is_changed (ZakFormElement *element)
        return (g_strcmp0 (zak_form_element_get_original_value (element), zak_form_element_get_value (element)) != 0);
 }
 
+/**
+ * zak_form_element_set_format:
+ * @element:
+ * @format:
+ *
+ */
+gboolean
+zak_form_element_set_format (ZakFormElement *element, const gchar *format)
+{
+       ZakFormElementPrivate *priv;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       if (priv->format != NULL)
+               {
+                       g_free (priv->format);
+               }
+
+       priv->format = g_strdup (format);
+
+       return TRUE;
+}
+
+/**
+ * zak_form_element_get_format:
+ * @element:
+ *
+ */
+gchar
+*zak_form_element_get_format (ZakFormElement *element)
+{
+       ZakFormElementPrivate *priv;
+
+       gchar *ret;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       ret = g_strdup (priv->format);
+
+       return ret;
+}
+
 /**
  * zak_form_element_set_visible:
  * @element:
@@ -799,6 +850,10 @@ zak_form_element_set_property (GObject *object,
                    zak_form_element_set_original_value (zak_form_element, g_value_get_string (value));
                        break;
 
+               case PROP_FORMAT:
+                   zak_form_element_set_format (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;
@@ -856,6 +911,10 @@ zak_form_element_get_property (GObject *object,
                        g_value_set_string (value, zak_form_element_get_original_value (zak_form_element));
                        break;
 
+               case PROP_FORMAT:
+                       g_value_set_string (value, zak_form_element_get_format (zak_form_element));
+                       break;
+
                case PROP_VISIBLE:
                        g_value_set_boolean (value, zak_form_element_get_visible (zak_form_element));
                        break;
@@ -926,6 +985,10 @@ zak_form_element_xml_parsing (ZakFormElement *element, xmlNode *xmlnode)
                                {
                                        zak_form_element_set_default_value (element, (const gchar *)xmlNodeGetContent (cur));
                                }
+                   else if (xmlStrcmp (cur->name, (const xmlChar *)"format") == 0)
+                               {
+                                       zak_form_element_set_format (element, (const gchar *)xmlNodeGetContent (cur));
+                               }
                    else if (xmlStrcmp (cur->name, (const xmlChar *)"visible") == 0)
                                {
                                        zak_form_element_set_visible (element, xmlStrEqual ((const gchar *)xmlNodeGetContent (cur), "TRUE"));
index ebfb9f1df8fc318ad7b83bbef389d31af6f67b28..ab776f95b4861d820dfe381079c8aa8361c3d7a6 100644 (file)
@@ -70,6 +70,9 @@ gchar *zak_form_element_get_original_value (ZakFormElement *element);
 void zak_form_element_set_as_original_value (ZakFormElement *element);
 gboolean zak_form_element_is_changed (ZakFormElement *element);
 
+gboolean zak_form_element_set_format (ZakFormElement *element, const gchar *format);
+gchar *zak_form_element_get_format (ZakFormElement *element);
+
 void zak_form_element_set_visible (ZakFormElement *element, gboolean visible);
 gboolean zak_form_element_get_visible (ZakFormElement *element);