]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added property type to ZakFormElement.
authorAndrea Zagli <azagli@libero.it>
Tue, 1 Dec 2015 14:07:55 +0000 (15:07 +0100)
committerAndrea Zagli <azagli@libero.it>
Tue, 1 Dec 2015 14:07:55 +0000 (15:07 +0100)
src/formelement.c
src/formelement.h

index d55f3759874e81eaea89563ca553bc7529261163..b68fe0c91f0080dce58c9749e409f0042ea0b4a0 100644 (file)
@@ -26,6 +26,7 @@ enum
 {
        PROP_0,
        PROP_IS_KEY,
+       PROP_TYPE,
        PROP_VALUE,
        PROP_DEFAULT_VALUE,
        PROP_ORIGINAL_VALUE,
@@ -61,6 +62,7 @@ static GPtrArray *zak_form_element_get_messages (ZakFormElement *element);
 typedef struct
        {
                gboolean is_key;
+               gchar *type;
                gchar *value;
                gchar *default_value;
                gchar *original_value;
@@ -96,6 +98,13 @@ zak_form_element_class_init (ZakFormElementClass *class)
                                                               TRUE,
                                                               G_PARAM_READWRITE));
 
+       g_object_class_install_property (object_class, PROP_TYPE,
+                                        g_param_spec_string ("type",
+                                                             "Type",
+                                                             "Type",
+                                                             "",
+                                                             G_PARAM_READWRITE));
+
        g_object_class_install_property (object_class, PROP_VALUE,
                                         g_param_spec_string ("value",
                                                              "Value",
@@ -152,6 +161,7 @@ zak_form_element_init (ZakFormElement *zak_form_element)
        ZakFormElementPrivate *priv = zak_form_element_get_instance_private (zak_form_element);
 
        priv->is_key = TRUE;
+       priv->type = g_strdup ("");
        priv->value = g_strdup ("");
        priv->visible = TRUE;
        priv->editable = TRUE;
@@ -247,6 +257,46 @@ zak_form_element_get_is_key (ZakFormElement *element)
        return priv->is_key;
 }
 
+/**
+ * zak_form_element_set_provider_type:
+ * @element:
+ * @type:
+ *
+ */
+void
+zak_form_element_set_provider_type (ZakFormElement *element, const gchar *type)
+{
+       ZakFormElementPrivate *priv;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       if (priv->type != NULL)
+               {
+                       g_free (priv->type);
+               }
+
+       priv->type = g_strdup (type);
+}
+
+/**
+ * zak_form_element_get_type:
+ * @element:
+ *
+ */
+gchar
+*zak_form_element_get_provider_type (ZakFormElement *element)
+{
+       ZakFormElementPrivate *priv;
+
+       gchar *ret;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       ret = g_strdup (priv->type);
+
+       return ret;
+}
+
 /**
  * zak_form_element_set_value:
  * @element:
@@ -669,6 +719,10 @@ zak_form_element_set_property (GObject *object,
                    zak_form_element_set_is_key (zak_form_element, g_value_get_boolean (value));
                        break;
 
+               case PROP_TYPE:
+                   zak_form_element_set_provider_type (zak_form_element, g_value_dup_string (value));
+                       break;
+
                case PROP_VALUE:
                    zak_form_element_set_value (zak_form_element, g_value_dup_string (value));
                        break;
@@ -718,6 +772,10 @@ zak_form_element_get_property (GObject *object,
                        g_value_set_boolean (value, zak_form_element_get_is_key (zak_form_element));
                        break;
 
+               case PROP_TYPE:
+                       g_value_set_string (value, zak_form_element_get_provider_type (zak_form_element));
+                       break;
+
                case PROP_VALUE:
                        g_value_set_string (value, zak_form_element_get_value (zak_form_element));
                        break;
index db64302df0f8cb6a9e4b55100782d67bdc0744c3..02917b83b1307c4cfa4286d33fad106dab60f86f 100644 (file)
@@ -56,6 +56,9 @@ struct _ZakFormElementClass
 void zak_form_element_set_to_is_key (ZakFormElement *element, gboolean is_key);
 gboolean zak_form_element_get_is_key (ZakFormElement *element);
 
+void zak_form_element_set_provider_type (ZakFormElement *element, const gchar *type);
+gchar *zak_form_element_get_provider_type (ZakFormElement *element);
+
 gboolean zak_form_element_set_value (ZakFormElement *element, const gchar *value);
 gchar *zak_form_element_get_value (ZakFormElement *element);