[libgda/LIBGDA_4.2] Added the GdaDataModel::access-changed signal



commit 4c568017b35722a9710a7799844774b2bd4391f5
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed Aug 31 16:46:23 2011 +0200

    Added the GdaDataModel::access-changed signal
    
    which is emitted when the acces flags of a data model change

 libgda-ui/gdaui-raw-form.c |   13 +++++++++++++
 libgda/gda-data-model.c    |   16 ++++++++++++++++
 libgda/gda-data-model.h    |    1 +
 libgda/gda-data-proxy.c    |   13 ++++++++++++-
 libgda/gda-data-select.c   |    2 ++
 5 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/libgda-ui/gdaui-raw-form.c b/libgda-ui/gdaui-raw-form.c
index dcb4ff5..6d78ae2 100644
--- a/libgda-ui/gdaui-raw-form.c
+++ b/libgda-ui/gdaui-raw-form.c
@@ -49,6 +49,7 @@ 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);
 static void proxy_reset_cb (GdaDataProxy *proxy, GdauiRawForm *form);
+static void proxy_access_changed_cb (GdaDataProxy *proxy, GdauiRawForm *form);
 static void proxy_row_inserted_or_removed_cb (GdaDataProxy *proxy, gint row, GdauiRawForm *form);
 
 /* GdauiDataProxy interface */
@@ -346,6 +347,8 @@ gdaui_raw_form_dispose (GObject *object)
 							      G_CALLBACK (proxy_changed_cb), form);
 			g_signal_handlers_disconnect_by_func (G_OBJECT (form->priv->proxy),
 							      G_CALLBACK (proxy_reset_cb), form);
+			g_signal_handlers_disconnect_by_func (G_OBJECT (form->priv->proxy),
+							      G_CALLBACK (proxy_access_changed_cb), form);
 			g_object_unref (form->priv->proxy);
 			form->priv->proxy = NULL;
 		}
@@ -417,6 +420,8 @@ gdaui_raw_form_set_property (GObject *object,
 									      G_CALLBACK (proxy_changed_cb), form);
 					g_signal_handlers_disconnect_by_func (G_OBJECT (form->priv->proxy),
 									      G_CALLBACK (proxy_reset_cb), form);
+					g_signal_handlers_disconnect_by_func (G_OBJECT (form->priv->proxy),
+									      G_CALLBACK (proxy_access_changed_cb), form);
 					g_object_unref (G_OBJECT (form->priv->proxy));
 					form->priv->proxy = NULL;
 					form->priv->model = NULL;
@@ -447,6 +452,8 @@ gdaui_raw_form_set_property (GObject *object,
 							  G_CALLBACK (proxy_changed_cb), form);
 					g_signal_connect (G_OBJECT (form->priv->proxy), "reset",
 							  G_CALLBACK (proxy_reset_cb), form);
+					g_signal_connect (G_OBJECT (form->priv->proxy), "access-changed",
+							  G_CALLBACK (proxy_access_changed_cb), form);
 
 					/* we don't want chuncking */
 					g_object_set (object, "paramlist", form->priv->iter, NULL);
@@ -574,6 +581,12 @@ proxy_reset_cb (GdaDataProxy *proxy, GdauiRawForm *form)
 }
 
 static void
+proxy_access_changed_cb (G_GNUC_UNUSED GdaDataProxy *proxy, GdauiRawForm *form)
+{
+	iter_row_changed_cb (form->priv->iter, gda_data_model_iter_get_row (form->priv->iter), form);
+}
+
+static void
 proxy_row_inserted_or_removed_cb (G_GNUC_UNUSED GdaDataProxy *proxy, gint row, GdauiRawForm *form)
 {
 	if (gda_data_model_get_n_rows (GDA_DATA_MODEL (form->priv->proxy)) != 0)
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 9eb30e7..de95566 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -198,6 +198,22 @@ gda_data_model_class_init (G_GNUC_UNUSED gpointer g_class)
 				      g_cclosure_marshal_VOID__VOID,
 				      G_TYPE_NONE, 0);
 
+		/**
+		 * GdaDataModel::access-changed
+		 * @model: the #GdaDataModel
+		 *
+		 * Gets emitted when @model's access flags have changed. Use
+		 * gda_data_model_get_access_flags() to get the access flags.
+		 */
+		gda_data_model_signals[RESET] =
+			g_signal_new ("access-changed",
+				      GDA_TYPE_DATA_MODEL,
+				      G_SIGNAL_RUN_LAST,
+				      G_STRUCT_OFFSET (GdaDataModelIface, access_changed),
+				      NULL, NULL,
+				      g_cclosure_marshal_VOID__VOID,
+				      G_TYPE_NONE, 0);
+
 		initialized = TRUE;
 	}
 	g_static_rec_mutex_unlock (&init_mutex);
diff --git a/libgda/gda-data-model.h b/libgda/gda-data-model.h
index 469f082..4a3d243 100644
--- a/libgda/gda-data-model.h
+++ b/libgda/gda-data-model.h
@@ -122,6 +122,7 @@ struct _GdaDataModelIface {
 	void                 (* row_removed)        (GdaDataModel *model, gint row);
 	void                 (* changed)            (GdaDataModel *model);
 	void                 (* reset)              (GdaDataModel *model);
+	void                 (* access_changed)     (GdaDataModel *model);
 
 	/* getting more information about a data model */
 	GError             **(* i_get_exceptions)   (GdaDataModel *model);
diff --git a/libgda/gda-data-proxy.c b/libgda/gda-data-proxy.c
index 3cb521d..f36eb27 100644
--- a/libgda/gda-data-proxy.c
+++ b/libgda/gda-data-proxy.c
@@ -759,6 +759,7 @@ static void proxied_model_row_inserted_cb (GdaDataModel *model, gint row, GdaDat
 static void proxied_model_row_updated_cb (GdaDataModel *model, gint row, GdaDataProxy *proxy);
 static void proxied_model_row_removed_cb (GdaDataModel *model, gint row, GdaDataProxy *proxy);
 static void proxied_model_reset_cb (GdaDataModel *model, GdaDataProxy *proxy);
+static void proxied_model_access_changed_cb (GdaDataModel *model, GdaDataProxy *proxy);
 
 
 /**
@@ -846,6 +847,8 @@ clean_proxy (GdaDataProxy *proxy)
 						      G_CALLBACK (proxied_model_row_removed_cb), proxy);
 		g_signal_handlers_disconnect_by_func (G_OBJECT (proxy->priv->model),
 						      G_CALLBACK (proxied_model_reset_cb), proxy);
+		g_signal_handlers_disconnect_by_func (G_OBJECT (proxy->priv->model),
+						      G_CALLBACK (proxied_model_access_changed_cb), proxy);
 		g_object_unref (proxy->priv->model);
 		proxy->priv->model = NULL;
 	}
@@ -952,7 +955,9 @@ gda_data_proxy_set_property (GObject *object,
 					  G_CALLBACK (proxied_model_row_removed_cb), proxy);
 			g_signal_connect (G_OBJECT (model), "reset",
 					  G_CALLBACK (proxied_model_reset_cb), proxy);
-			
+			g_signal_connect (G_OBJECT (model), "access-changed",
+					  G_CALLBACK (proxied_model_access_changed_cb), proxy);
+
 			/* initial chunk settings, no need to emit any signal as it's an initial state */
 			proxy->priv->chunk = compute_display_chunk (proxy);
 			if (!proxy->priv->chunk->mapping) {
@@ -1222,6 +1227,12 @@ proxied_model_reset_cb (GdaDataModel *model, GdaDataProxy *proxy)
 	gda_data_model_reset (GDA_DATA_MODEL (proxy));
 }
 
+static void
+proxied_model_access_changed_cb (G_GNUC_UNUSED GdaDataModel *model, GdaDataProxy *proxy)
+{
+	g_signal_emit_by_name (proxy, "access-changed");
+}
+
 /**
  * gda_data_proxy_get_proxied_model:
  * @proxy: a #GdaDataProxy object
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index c737aa5..dd305bb 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -1338,6 +1338,8 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
 	}
 #endif
 
+	g_signal_emit_by_name (model, "access-changed");
+
 	return TRUE;
 }
 



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