[libgda] UI extension corrections



commit 2a79e7a23a237aff3dae057a93b717729acdda4e
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Oct 15 21:01:22 2009 +0200

    UI extension corrections
    
    - GdauiBasicForm: correctly handle the case when
      the GdaHolder refused to be set to a value after
      the user modified a GdauiDataEntry part of the form
    - GdauiCombo: don't reset the value when the data model
      changes
    - set the default GdauiDataEntry to None when a data type
      is unknown

 libgda-ui/gdaui-basic-form.c |   19 +++++++------------
 libgda-ui/gdaui-combo.c      |   30 ++++++------------------------
 libgda-ui/gdaui-init.c       |    2 +-
 libgda-ui/gdaui-set.h        |    4 ++--
 4 files changed, 16 insertions(+), 39 deletions(-)
---
diff --git a/libgda-ui/gdaui-basic-form.c b/libgda-ui/gdaui-basic-form.c
index a703d20..3bf38be 100644
--- a/libgda-ui/gdaui-basic-form.c
+++ b/libgda-ui/gdaui-basic-form.c
@@ -1887,7 +1887,6 @@ entry_contents_modified (GdauiDataEntry *entry, GdauiBasicForm *form)
 	param = g_object_get_data (G_OBJECT (entry), "param");
 	if (param) { /* single parameter */
 		GValue *value;
-		GError *error = NULL;
 		
 		form->priv->forward_param_updates = FALSE;
 
@@ -1896,19 +1895,15 @@ entry_contents_modified (GdauiDataEntry *entry, GdauiBasicForm *form)
 		if ((!value || gda_value_is_null (value)) &&
 		    (attr & GDA_VALUE_ATTR_IS_DEFAULT))
 			gda_holder_set_value_to_default (param);
-		else if (gda_holder_set_value (param, value, &error)) {
-#ifdef debug_signal
-			g_print (">> 'PARAM_CHANGED' from %s\n", __FUNCTION__);
-#endif
+		else if (gda_holder_set_value (param, value, NULL))
 			g_signal_emit (G_OBJECT (form), gdaui_basic_form_signals[PARAM_CHANGED], 0, param, TRUE);
-#ifdef debug_signal
-			g_print ("<< 'PARAM_CHANGED' from %s\n", __FUNCTION__);
-#endif
-		}
 		else {
-			g_warning (_("Parameter did not accept form's change: %s"),
-				   error && error->message ? error->message : _("No detail"));
-			g_clear_error (&error);
+			/* GdaHolder refused value => reset GdaDataEntry */
+			g_signal_handlers_block_by_func (G_OBJECT (entry),
+							 G_CALLBACK (entry_contents_modified), form);
+			gdaui_data_entry_set_value (entry, gda_holder_get_value (param));
+			g_signal_handlers_unblock_by_func (G_OBJECT (entry),
+							   G_CALLBACK (entry_contents_modified), form);
 		}
 		gda_value_free (value);
 		form->priv->forward_param_updates = TRUE;
diff --git a/libgda-ui/gdaui-combo.c b/libgda-ui/gdaui-combo.c
index af0e169..e1e14bf 100644
--- a/libgda-ui/gdaui-combo.c
+++ b/libgda-ui/gdaui-combo.c
@@ -1,6 +1,6 @@
 /* GNOME DB library
  *
- * Copyright (C) 1999 - 2008 The Free Software Foundation
+ * Copyright (C) 1999 - 2009 The Free Software Foundation
  *
  * AUTHORS:
  *      Rodrigo Moya <rodrigo gnome-db org>
@@ -31,7 +31,7 @@
 
 struct _GdauiComboPrivate {
 	GdaDataModel     *model; /* proxied model (the one when _set_model() is called) */
-	GdauiDataStore *store; /* model proxy */
+	GdauiDataStore   *store; /* model proxy */
 
 	/* columns of the model to display */
 	gint              n_cols;
@@ -161,24 +161,6 @@ gdaui_combo_get_property (GObject *object,
 }
 
 static void
-model_changed_cb (GdaDataModel *model, GdauiCombo *combo)
-{
-	gtk_combo_box_set_active (GTK_COMBO_BOX (combo), -1);
-}
-
-static void
-get_rid_of_model (GdaDataModel *model, GdauiCombo *combo)
-{
-	g_assert (model == combo->priv->model);
-	g_signal_handlers_disconnect_by_func (model,
-					      G_CALLBACK (get_rid_of_model), combo);
-	g_signal_handlers_disconnect_by_func (model,
-					      G_CALLBACK (model_changed_cb), combo);
-	g_object_unref (model);
-	combo->priv->model = NULL;
-}
-
-static void
 gdaui_combo_dispose (GObject *object)
 {
 	GdauiCombo *combo = (GdauiCombo *) object;
@@ -285,8 +267,10 @@ gdaui_combo_set_model (GdauiCombo *combo, GdaDataModel *model, gint n_cols, gint
 		g_object_unref (G_OBJECT (combo->priv->store));
 		combo->priv->store = NULL;
 	}
-	if (combo->priv->model) 
-		get_rid_of_model (combo->priv->model, combo);
+	if (combo->priv->model) {
+		g_object_unref (combo->priv->model);
+		combo->priv->model = NULL;
+	}
 	if (combo->priv->cols_index) {
 		g_free (combo->priv->cols_index);
 		combo->priv->cols_index = NULL;
@@ -301,8 +285,6 @@ gdaui_combo_set_model (GdauiCombo *combo, GdaDataModel *model, gint n_cols, gint
 		
 		combo->priv->store = GDAUI_DATA_STORE (gdaui_data_store_new (combo->priv->model));
 		gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (combo->priv->store));
-		g_signal_connect (G_OBJECT (model), "changed",
-				  G_CALLBACK (model_changed_cb), combo);
 	} 
 	
 	if (!n_cols && model) {
diff --git a/libgda-ui/gdaui-init.c b/libgda-ui/gdaui-init.c
index 7b92503..d8946ec 100644
--- a/libgda-ui/gdaui-init.c
+++ b/libgda-ui/gdaui-init.c
@@ -157,7 +157,7 @@ gdaui_new_data_entry (GType type, const gchar *plugin_name)
 		else if (type == G_TYPE_DATE)
 			entry = (GdauiDataEntry *) gdaui_entry_date_new (dh);
 		else
-			entry = (GdauiDataEntry *) gdaui_entry_string_new (dh, type, spec_options);
+			entry = (GdauiDataEntry *) gdaui_entry_none_new (type);
 	}
 
 	g_free (spec_options);
diff --git a/libgda-ui/gdaui-set.h b/libgda-ui/gdaui-set.h
index df90708..6823976 100644
--- a/libgda-ui/gdaui-set.h
+++ b/libgda-ui/gdaui-set.h
@@ -41,7 +41,7 @@ typedef struct _GdauiSetSource GdauiSetSource;
 
 struct _GdauiSetGroup {
         GdaSetGroup      *group;
-        GdauiSetSource *source; /* if NULL, then @group->nodes contains exactly one entry */
+        GdauiSetSource   *source; /* if NULL, then @group->nodes contains exactly one entry */
 
 	/*< private >*/
         /* Padding for future expansion */
@@ -76,7 +76,7 @@ struct _GdauiSetSource {
 struct _GdauiSet
 {
 	GObject         object;
-	GdauiSetPriv *priv;
+	GdauiSetPriv   *priv;
 
 	/*< public >*/
 	GSList         *sources_list; /* list of GdauiSetSource */



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