[libgda/LIBGDA_4.2] Misc. corrections



commit 9fd23430723c5a7b7995af074d0ad09ae8ae1086
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun Jul 24 18:37:51 2011 +0200

    Misc. corrections

 libgda-ui/gdaui-data-proxy-info.c       |   15 ++++++++++++++-
 tools/browser/common/ui-formgrid.c      |   17 +++++++----------
 tools/browser/query-exec/query-result.c |    3 +--
 3 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/libgda-ui/gdaui-data-proxy-info.c b/libgda-ui/gdaui-data-proxy-info.c
index b017fa4..f10b3c9 100644
--- a/libgda-ui/gdaui-data-proxy-info.c
+++ b/libgda-ui/gdaui-data-proxy-info.c
@@ -47,6 +47,8 @@ static void data_proxy_proxy_changed_cb (GdauiDataProxy *data_proxy, GdaDataProx
 static void proxy_changed_cb (GdaDataProxy *proxy, GdauiDataProxyInfo *info);
 static void proxy_sample_changed_cb (GdaDataProxy *proxy, gint sample_start, gint sample_end, GdauiDataProxyInfo *info);
 static void proxy_row_changed_cb (GdaDataProxy *proxy, gint row, GdauiDataProxyInfo *info);
+static void proxy_reset_cb (GdaDataProxy *wid, GdauiDataProxyInfo *info);
+
 static void raw_grid_selection_changed_cb (GdauiRawGrid *grid, GdauiDataProxyInfo *info);
 
 
@@ -192,7 +194,6 @@ data_proxy_destroyed_cb (GdauiDataProxy *wid, GdauiDataProxyInfo *info)
 	info->priv->data_proxy = NULL;
 }
 
-
 static void
 release_proxy (GdauiDataProxyInfo *info)
 {
@@ -202,6 +203,8 @@ release_proxy (GdauiDataProxyInfo *info)
 					      G_CALLBACK (proxy_sample_changed_cb), info);
 	g_signal_handlers_disconnect_by_func (G_OBJECT (info->priv->proxy),
 					      G_CALLBACK (proxy_row_changed_cb), info);
+	g_signal_handlers_disconnect_by_func (G_OBJECT (info->priv->proxy),
+					      G_CALLBACK (proxy_reset_cb), info);
 	g_object_unref (info->priv->proxy);
 	info->priv->proxy = NULL;
 }
@@ -309,6 +312,9 @@ gdaui_data_proxy_info_set_property (GObject *object,
 							  G_CALLBACK (proxy_row_changed_cb), info);
 					g_signal_connect (G_OBJECT (proxy), "row-removed",
 							  G_CALLBACK (proxy_row_changed_cb), info);
+					g_signal_connect (G_OBJECT (proxy), "reset",
+							  G_CALLBACK (proxy_reset_cb), info);
+
 
 					/* iter */
 					iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR
@@ -383,6 +389,13 @@ proxy_row_changed_cb (G_GNUC_UNUSED GdaDataProxy *proxy, G_GNUC_UNUSED gint row,
 }
 
 static void
+proxy_reset_cb (G_GNUC_UNUSED GdaDataProxy *wid, GdauiDataProxyInfo *info)
+{
+	modif_buttons_make (info);
+	modif_buttons_update (info);
+}
+
+static void
 iter_row_changed_cb (G_GNUC_UNUSED GdaDataModelIter *iter, G_GNUC_UNUSED gint row, GdauiDataProxyInfo *info)
 {
 	modif_buttons_update (info);
diff --git a/tools/browser/common/ui-formgrid.c b/tools/browser/common/ui-formgrid.c
index 979c692..28bd99a 100644
--- a/tools/browser/common/ui-formgrid.c
+++ b/tools/browser/common/ui-formgrid.c
@@ -240,7 +240,7 @@ ui_formgrid_init (UiFormGrid *formgrid)
 	formgrid->priv = g_new0 (UiFormGridPriv, 1);
 	formgrid->priv->raw_grid = NULL;
 	formgrid->priv->info = NULL;
-	formgrid->priv->flags = GDAUI_DATA_PROXY_INFO_CURRENT_ROW;
+	formgrid->priv->flags = GDAUI_DATA_PROXY_INFO_CURRENT_ROW | GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS;
 	formgrid->priv->bcnc = NULL;
 	formgrid->priv->autoupdate = TRUE;
 	formgrid->priv->autoupdate_possible = FALSE;
@@ -786,12 +786,6 @@ ui_formgrid_new (GdaDataModel *model, gboolean scroll_form, GdauiDataProxyInfoFl
 	formgrid = (UiFormGrid *) g_object_new (UI_TYPE_FORMGRID, "scroll-form", scroll_form, NULL);
 	formgrid->priv->flags = flags;
 
-	compute_modification_statements (formgrid, model);
-	if (formgrid->priv->mod_stmt [MOD_INSERT] ||
-	    formgrid->priv->mod_stmt [MOD_DELETE] ||
-	    formgrid->priv->mod_stmt [MOD_UPDATE])
-		formgrid->priv->flags = formgrid->priv->flags | GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS;
-
 	/* a raw form and a raw grid for the same proxy */
 	g_object_set (formgrid->priv->raw_grid, "model", model, NULL);
 	proxy = gdaui_data_proxy_get_proxy (GDAUI_DATA_PROXY (formgrid->priv->raw_grid));
@@ -805,8 +799,12 @@ ui_formgrid_new (GdaDataModel *model, gboolean scroll_form, GdauiDataProxyInfoFl
 			  G_CALLBACK (proxy_changed_cb), formgrid);
 
 	/* no more than 300 rows at a time */
-	if (model)
+	if (model) {
 		gda_data_proxy_set_sample_size (proxy, 300);
+		if (flags & GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS)
+			g_object_set (G_OBJECT (formgrid), "compute-mod-statements", TRUE, NULL);
+	}
+
 
 	return (GtkWidget *) formgrid;
 }
@@ -1067,8 +1065,7 @@ compute_modification_statements (UiFormGrid *formgrid, GdaDataModel *model)
 		}
 	}
 
-	g_assert (model);
-	if (!GDA_IS_DATA_SELECT (model))
+	if (!model || !GDA_IS_DATA_SELECT (model))
 		return;
 
 	if (! formgrid->priv->compute_mod_stmt)
diff --git a/tools/browser/query-exec/query-result.c b/tools/browser/query-exec/query-result.c
index 5106a27..b757ae2 100644
--- a/tools/browser/query-exec/query-result.c
+++ b/tools/browser/query-exec/query-result.c
@@ -331,8 +331,7 @@ static GtkWidget *
 make_widget_for_data_model (GdaDataModel *model, QueryResult *qres, const gchar *sql)
 {
 	GtkWidget *grid;
-	grid = ui_formgrid_new (model, TRUE, 0);
-	g_object_set (G_OBJECT (grid), "compute-mod-statements", TRUE, NULL);
+	grid = ui_formgrid_new (model, TRUE, GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS);
 	ui_formgrid_set_sample_size (UI_FORMGRID (grid), 300);
 	if (sql) {
 		BrowserConnection *bcnc;



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