]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added property editable to ZakFormElement.
authorAndrea Zagli <azagli@libero.it>
Sun, 22 Nov 2015 15:19:40 +0000 (16:19 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 22 Nov 2015 15:19:40 +0000 (16:19 +0100)
src/formelement.c
src/formelement.h

index 06287753888b8570972075656285f93784699fa9..00d0fc3aaa30e49ee85cfb6e1f430a3136dc2fc1 100644 (file)
@@ -27,7 +27,8 @@ enum
        PROP_0,
        PROP_VALUE,
        PROP_DEFAULT_VALUE,
-       PROP_VISIBLE
+       PROP_VISIBLE,
+       PROP_EDITABLE
 };
 
 static void zak_form_element_class_init (ZakFormElementClass *class);
@@ -56,6 +57,7 @@ typedef struct
                gchar *value;
                gchar *default_value;
                gboolean visible;
+               gboolean editable;
                GPtrArray *pa_filters;
                GPtrArray *pa_validators;
                GPtrArray *pa_messages;
@@ -89,12 +91,19 @@ zak_form_element_class_init (ZakFormElementClass *class)
                                                              "",
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
-       g_object_class_install_property (object_class, PROP_DEFAULT_VALUE,
+       g_object_class_install_property (object_class, PROP_VISIBLE,
                                         g_param_spec_boolean ("visible",
                                                               "Visible",
                                                               "Visible",
                                                               TRUE,
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_EDITABLE,
+                                        g_param_spec_boolean ("editable",
+                                                              "Editable",
+                                                              "Editable",
+                                                              TRUE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 }
 
 static void
@@ -263,6 +272,37 @@ zak_form_element_get_visible (ZakFormElement *element)
        return priv->visible;
 }
 
+/**
+ * zak_form_element_set_editable:
+ * @element:
+ * @editable:
+ *
+ */
+void
+zak_form_element_set_editable (ZakFormElement *element, gboolean editable)
+{
+       ZakFormElementPrivate *priv;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       priv->editable = editable;
+}
+
+/**
+ * zak_form_element_get_editable:
+ * @element:
+ *
+ */
+gboolean
+zak_form_element_get_editable (ZakFormElement *element)
+{
+       ZakFormElementPrivate *priv;
+
+       priv = zak_form_element_get_instance_private (element);
+
+       return priv->editable;
+}
+
 /**
  * zak_form_element_clear:
  * @element:
@@ -369,6 +409,14 @@ zak_form_element_set_property (GObject *object,
                    zak_form_element_set_default_value (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;
+
+               case PROP_EDITABLE:
+                   zak_form_element_set_editable (zak_form_element, g_value_get_boolean (value));
+                       break;
+
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                        break;
@@ -394,6 +442,14 @@ zak_form_element_get_property (GObject *object,
                        g_value_set_string (value, zak_form_element_get_default_value (zak_form_element));
                        break;
 
+               case PROP_VISIBLE:
+                       g_value_set_boolean (value, zak_form_element_get_visible (zak_form_element));
+                       break;
+
+               case PROP_EDITABLE:
+                       g_value_set_boolean (value, zak_form_element_get_editable (zak_form_element));
+                       break;
+
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                        break;
index 41b63d0106a743ce2f0a5d22f10eff0745875da2..842cf57604b11a0bfe2c926f753e8dce8ea8dff8 100644 (file)
@@ -49,6 +49,9 @@ gchar *zak_form_element_get_default_value (ZakFormElement *element);
 void zak_form_element_set_visible (ZakFormElement *element, gboolean visible);
 gboolean zak_form_element_get_visible (ZakFormElement *element);
 
+void zak_form_element_set_editable (ZakFormElement *element, gboolean editable);
+gboolean zak_form_element_get_editable (ZakFormElement *element);
+
 void zak_form_element_clear (ZakFormElement *element);
 
 void zak_form_element_add_filter (ZakFormElement *element, ZakFormElementFilter *filter);