[libgda] UI form corrections



commit 3794f2a005e0829712b8675728cd201de9397465
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Feb 2 20:44:40 2010 +0100

    UI form corrections

 libgda-ui/gdaui-basic-form.c |   23 ++++++++------
 libgda-ui/gdaui-raw-form.c   |   64 ++++++++++++------------------------------
 2 files changed, 31 insertions(+), 56 deletions(-)
---
diff --git a/libgda-ui/gdaui-basic-form.c b/libgda-ui/gdaui-basic-form.c
index 3cbff52..81c65d6 100644
--- a/libgda-ui/gdaui-basic-form.c
+++ b/libgda-ui/gdaui-basic-form.c
@@ -286,23 +286,23 @@ gdaui_basic_form_init (GdauiBasicForm * wid)
 
 /**
  * gdaui_basic_form_new
- * @paramlist: a #GdaSet structure
+ * @data_set: a #GdaSet structure
  *
- * Creates a new #GdauiBasicForm widget using all the parameters provided in @paramlist.
+ * Creates a new #GdauiBasicForm widget using all the #GdaHolder objects provided in @data_set.
  *
  * The global layout is rendered using a table (a #GtkTable), and an entry is created for each
- * node of @paramlist.
+ * node of @data_set.
  *
  * Returns: the new widget
  *
  * Since: 4.2
  */
 GtkWidget *
-gdaui_basic_form_new (GdaSet *paramlist)
+gdaui_basic_form_new (GdaSet *data_set)
 {
 	GObject *obj;
 
-	obj = g_object_new (GDAUI_TYPE_BASIC_FORM, "paramlist", paramlist, NULL);
+	obj = g_object_new (GDAUI_TYPE_BASIC_FORM, "paramlist", data_set, NULL);
 
 	return (GtkWidget *) obj;
 }
@@ -712,8 +712,11 @@ create_entry_widget (SingleEntry *sentry)
 		/* set current value */
 		if (gda_holder_is_valid (param))
 			gdaui_data_entry_set_value (GDAUI_DATA_ENTRY (entry), val);
-		else
-			gdaui_data_entry_set_value (GDAUI_DATA_ENTRY (entry), NULL);
+		else {
+			GValue value;
+			memset (&value, 0, sizeof (GValue));
+			gdaui_data_entry_set_value (GDAUI_DATA_ENTRY (entry), &value);
+		}
 
 		if (!nnul ||
 		    (nnul && value &&
@@ -1822,7 +1825,7 @@ gdaui_basic_form_get_label_widget (GdauiBasicForm *form, GdaHolder *param)
 
 /**
  * gdaui_basic_form_new_in_dialog
- * @paramlist: a #GdaSet structure
+ * @data_set: a #GdaSet object
  * @parent: the parent window for the new dialog, or %NULL
  * @title: the title of the dialog window, or %NULL
  * @header: a helper text displayed at the top of the dialog, or %NULL
@@ -1839,14 +1842,14 @@ gdaui_basic_form_get_label_widget (GdauiBasicForm *form, GdaHolder *param)
  * Since: 4.2
  */
 GtkWidget *
-gdaui_basic_form_new_in_dialog (GdaSet *paramlist, GtkWindow *parent,
+gdaui_basic_form_new_in_dialog (GdaSet *data_set, GtkWindow *parent,
 				const gchar *title, const gchar *header)
 {
 	GtkWidget *form;
 	GtkWidget *dlg;
 	const gchar *rtitle;
 
-	form = gdaui_basic_form_new (paramlist);
+	form = gdaui_basic_form_new (data_set);
 
 	rtitle = title;
 	if (!rtitle)
diff --git a/libgda-ui/gdaui-raw-form.c b/libgda-ui/gdaui-raw-form.c
index 2d3c550..263a358 100644
--- a/libgda-ui/gdaui-raw-form.c
+++ b/libgda-ui/gdaui-raw-form.c
@@ -44,8 +44,6 @@ static void gdaui_raw_form_get_property (GObject *object,
 					 GValue *value,
 					 GParamSpec *pspec);
 
-static void gdaui_raw_form_initialize (GdauiRawForm *form, GtkWidget *layout, GHashTable *box_widgets);
-
 static GError *iter_validate_set_cb (GdaDataModelIter *iter, GdauiRawForm *form);
 static void iter_row_changed_cb (GdaDataModelIter *iter, gint row, GdauiRawForm *form);
 static void proxy_changed_cb (GdaDataProxy *proxy, GdauiRawForm *form);
@@ -453,7 +451,24 @@ gdaui_raw_form_set_property (GObject *object,
 					/* we don't want chuncking */
 					g_object_set (object, "paramlist", form->priv->iter, NULL);
 					gda_data_proxy_set_sample_size (form->priv->proxy, 0);
-					gdaui_raw_form_initialize (form, NULL, NULL);
+
+					/* handle invalie iterators' GdaHolder */
+					GSList *list;
+					for (list = GDA_SET (form->priv->iter)->holders; list; list = list->next) {
+						GtkWidget *entry;
+						entry = gdaui_basic_form_get_entry_widget (GDAUI_BASIC_FORM (form),
+											   (GdaHolder*) list->data);
+						if (entry)
+							gdaui_entry_shell_set_unknown ((GdauiEntryShell*) entry,
+										       !gda_holder_is_valid ((GdaHolder*) list->data));
+					}
+
+					/* actions */
+					if (gda_data_proxy_is_read_only (form->priv->proxy))
+						g_object_set ((GObject*) form, "show-actions", FALSE, NULL);
+					
+					/* data display update */
+					proxy_changed_cb (form->priv->proxy, form);					
 				}
 				if (form->priv->iter)
 					iter_row_changed_cb (form->priv->iter,
@@ -565,49 +580,6 @@ proxy_row_inserted_or_removed_cb (GdaDataProxy *proxy, gint row, GdauiRawForm *f
 }
 
 /*
- * Real initialization
- */
-static void
-gdaui_raw_form_initialize (GdauiRawForm *form, GtkWidget *layout, GHashTable *box_widgets)
-{
-	/*
-	 * handling of the layout
-	 */
-	if (layout && box_widgets) {
-		/* REM: the @box_widgets has keys for query fields, and we need to provide
-		   gdaui_basic_form_new_in_layout() with a hash table which has keys for GdaSetNode;
-		   this is why we need to use another hash table: 'fbw' */
-
-		TO_IMPLEMENT;
-		/* GSList *list; */
-		/* 		GdaHolder *param; */
-		/* 		GdaSetNode *node; */
-		/* 		gpointer widget; */
-
-		/* 		fbw = g_hash_table_new (NULL, NULL); */
-		/* 		g_object_get (G_OBJECT (orig_query), "really_all_fields", &list, NULL); */
-		/* 		while (list) { */
-		/* 			widget = g_hash_table_lookup (box_widgets, list->data); */
-		/* 			if (widget) { */
-		/* 				node = gdaui_work_core_find_context_node (form->priv->core, GDA_QUERY_FIELD (list->data)); */
-		/* 				if (node) */
-		/* 					g_hash_table_insert (fbw, node, widget); */
-		/* 			} */
-		/* 			list = g_slist_next (list); */
-		/* 		} */
-	}
-
-	/*
-	 * the form itself
-	 */
-	if (!layout && gda_data_proxy_is_read_only (form->priv->proxy))
-		g_object_set ((GObject*) form, "show-actions", FALSE, NULL);
-
-	/* data display update */
-	proxy_changed_cb (form->priv->proxy, form);
-}
-
-/*
  *
  * Modification buttons (Commit changes, Reset form, New entry, Delete)
  *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]