]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added property is-key to ZakFormElement.
authorAndrea Zagli <azagli@libero.it>
Tue, 1 Dec 2015 10:24:39 +0000 (11:24 +0100)
committerAndrea Zagli <azagli@libero.it>
Tue, 1 Dec 2015 10:24:39 +0000 (11:24 +0100)
src/formelement.c
src/formelement.h

index 67d874a3ed977de88e66c4016c2e3262e6d53f32..d55f3759874e81eaea89563ca553bc7529261163 100644 (file)
@@ -25,6 +25,7 @@
 enum
 {
        PROP_0,
+       PROP_IS_KEY,
        PROP_VALUE,
        PROP_DEFAULT_VALUE,
        PROP_ORIGINAL_VALUE,
@@ -59,6 +60,7 @@ static GPtrArray *zak_form_element_get_messages (ZakFormElement *element);
 
 typedef struct
        {
+               gboolean is_key;
                gchar *value;
                gchar *default_value;
                gchar *original_value;
@@ -87,6 +89,13 @@ zak_form_element_class_init (ZakFormElementClass *class)
        class->xml_parsing = zak_form_element_xml_parsing;
        class->get_messages = zak_form_element_get_messages;
 
+       g_object_class_install_property (object_class, PROP_IS_KEY,
+                                        g_param_spec_boolean ("is-key",
+                                                              "Is key",
+                                                              "Is key",
+                                                              TRUE,
+                                                              G_PARAM_READWRITE));
+
        g_object_class_install_property (object_class, PROP_VALUE,
                                         g_param_spec_string ("value",
                                                              "Value",
@@ -142,6 +151,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->value = g_strdup ("");
        priv->visible = TRUE;
        priv->editable = TRUE;
@@ -206,6 +216,37 @@ zak_form_element_filter (ZakFormElement *element)
                }
 }
 
+/**
+ * zak_form_element_set_is_key:
+ * @element:
+ * @is_key:
+ *
+ */
+void
+zak_form_element_set_is_key (ZakFormElement *element, gboolean is_key)
+{
+       ZakFormElementPrivate *priv;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       priv->is_key = is_key;
+}
+
+/**
+ * zak_form_element_get_is_key:
+ * @element:
+ *
+ */
+gboolean
+zak_form_element_get_is_key (ZakFormElement *element)
+{
+       ZakFormElementPrivate *priv;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       return priv->is_key;
+}
+
 /**
  * zak_form_element_set_value:
  * @element:
@@ -624,6 +665,10 @@ zak_form_element_set_property (GObject *object,
 
        switch (property_id)
                {
+               case PROP_IS_KEY:
+                   zak_form_element_set_is_key (zak_form_element, g_value_get_boolean (value));
+                       break;
+
                case PROP_VALUE:
                    zak_form_element_set_value (zak_form_element, g_value_dup_string (value));
                        break;
@@ -669,6 +714,10 @@ zak_form_element_get_property (GObject *object,
 
        switch (property_id)
                {
+               case PROP_IS_KEY:
+                       g_value_set_boolean (value, zak_form_element_get_is_key (zak_form_element));
+                       break;
+
                case PROP_VALUE:
                        g_value_set_string (value, zak_form_element_get_value (zak_form_element));
                        break;
index e4f47fb889a232dbc642cfee95ac1391c821c90d..db64302df0f8cb6a9e4b55100782d67bdc0744c3 100644 (file)
@@ -53,6 +53,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);
+
 gboolean zak_form_element_set_value (ZakFormElement *element, const gchar *value);
 gchar *zak_form_element_get_value (ZakFormElement *element);