From 58050c1d1538106928c2803e6790044bf05df9c6 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sun, 12 Feb 2012 11:22:44 +0100 Subject: [PATCH] Implemented GtkFormGroup::set_from_datamodel and GtkFormGroup::set_from_hashtable. --- libgtkform/group.c | 62 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/libgtkform/group.c b/libgtkform/group.c index a2278f0..e7229b9 100644 --- a/libgtkform/group.c +++ b/libgtkform/group.c @@ -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; } -- 2.49.0