]> saetta.ns0.it Git - libgtkform/commitdiff
Implemented GtkFormGroup::set_from_datamodel and
authorAndrea Zagli <azagli@libero.it>
Sun, 12 Feb 2012 10:22:44 +0000 (11:22 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 12 Feb 2012 10:22:44 +0000 (11:22 +0100)
GtkFormGroup::set_from_hashtable.

libgtkform/group.c

index a2278f072cd7e3d98e5c8be9a811737fb7fbc92d..e7229b9a561db3ad0b9cce47b5f9cb24627b6a94 100644 (file)
@@ -203,16 +203,39 @@ gtk_form_group_clear (GtkFormGroup *group)
 gboolean
 gtk_form_group_set_from_datamodel (GtkFormGroup *group, GdaDataModel *dm, gint row)
 {
-       gboolean ret = FALSE;
+       gboolean ret;
+
+       GSList *els;
+
+       GtkFormField *ffield;
 
        GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
 
        g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
 
-       /*if (IS_GTK_FORM_GROUP (group) && GTK_FORM_GROUP_GET_CLASS (group)->set_from_datamodel != NULL)
+       ret = FALSE;
+
+       els = priv->elements;
+       while (els != NULL)
                {
-                       ret = GTK_FORM_GROUP_GET_CLASS (group)->set_from_datamodel (group, dm, row);
-               }*/
+                       if (IS_GTK_FORM_WIDGET ((GtkFormWidget *)els->data))
+                               {
+                                       g_object_get (G_OBJECT (els->data), "field", &ffield, NULL);
+                               }
+                       else if (IS_GTK_FORM_FIELD ((GtkFormField *)els->data))
+                               {
+                                       ffield = (GtkFormField *)els->data;
+                               }
+
+                       if (gtk_form_field_is_to_load (ffield))
+                               {
+                                       gtk_form_field_set_from_datamodel (ffield, dm, row);
+                               }
+
+                       els = g_slist_next (els);
+               }
+
+       ret = TRUE;
 
        return ret;
 }
@@ -226,16 +249,39 @@ gtk_form_group_set_from_datamodel (GtkFormGroup *group, GdaDataModel *dm, gint r
 gboolean
 gtk_form_group_set_from_hashtable (GtkFormGroup *group, GHashTable *hashtable)
 {
-       gboolean ret = FALSE;
+       gboolean ret;
+
+       GSList *els;
+
+       GtkFormField *ffield;
 
        GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
 
        g_return_val_if_fail (hashtable != NULL, FALSE);
 
-       /*if (IS_GTK_FORM_GROUP (group) && GTK_FORM_GROUP_GET_CLASS (group)->set_from_hashtable != NULL)
+       ret = FALSE;
+
+       els = priv->elements;
+       while (els != NULL)
                {
-                       ret = GTK_FORM_GROUP_GET_CLASS (group)->set_from_hashtable (group, hashtable);
-               }*/
+                       if (IS_GTK_FORM_WIDGET ((GtkFormWidget *)els->data))
+                               {
+                                       g_object_get (G_OBJECT (els->data), "field", &ffield, NULL);
+                               }
+                       else if (IS_GTK_FORM_FIELD ((GtkFormField *)els->data))
+                               {
+                                       ffield = (GtkFormField *)els->data;
+                               }
+
+                       if (gtk_form_field_is_to_load (ffield))
+                               {
+                                       gtk_form_field_set_from_hashtable (ffield, hashtable);
+                               }
+
+                       els = g_slist_next (els);
+               }
+
+       ret = TRUE;
 
        return ret;
 }