mergeant r880 - in trunk: . data src src/binreloc



Author: vivien
Date: Wed Jul  2 19:52:16 2008
New Revision: 880
URL: http://svn.gnome.org/viewvc/mergeant?rev=880&view=rev

Log:
2008-07-02  Vivien Malerba <malerba gnome-db org>

	Very preliminary work to use Libgda and Libgnomedb's V4 API


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/data/application-x-mergeant.png
   trunk/src/Makefile.am
   trunk/src/binreloc/   (props changed)
   trunk/src/main.c
   trunk/src/mg-plugin-editor.c
   trunk/src/mg-plugin-editor.h
   trunk/src/query-druid.c
   trunk/src/query-druid.h
   trunk/src/query-editor.h
   trunk/src/utils.c
   trunk/src/utils.h
   trunk/src/workspace-window.c
   trunk/src/workspace-window.h
   trunk/src/workspace.c
   trunk/src/workspace.h
   trunk/src/ws-datatypes.h
   trunk/src/ws-dbrels.h
   trunk/src/ws-queries.h
   trunk/src/ws-tables.c
   trunk/src/ws-tables.h

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Wed Jul  2 19:52:16 2008
@@ -92,9 +92,10 @@
 ALL_LINGUAS="am ar az ca cs da de dz el en_CA en_GB es eu fa fi fr ga gl hr it ja lt lv mk ml ms nb ne nl oc pa pl pt pt_BR ru rw sk sl sq sr sr Latn sv tr uk vi zh_CN  zh_HK zh_TW"
 AM_GLIB_GNU_GETTEXT
 
-PKG_CHECK_MODULES(MERGEANT, libgnomedb-3.0 >= 3.0.0 \
-	libgnomedb-extra-3.0 \
-        libgda-3.0 >= 3.0.0 \
+PKG_CHECK_MODULES(MERGEANT, libgnomedb-4.0 >= 3.99.3 \
+	libgnomedb-extra-4.0 \
+	libgnomedb-graph-4.0 \
+        libgda-4.0 >= 3.99.3 \
         gtk+-2.0 >= 2.10.0 \
 	gdk-pixbuf-2.0 \
 	libxml-2.0 \
@@ -102,29 +103,6 @@
 AC_SUBST(MERGEANT_CFLAGS)
 AC_SUBST(MERGEANT_LIBS)
 
-dnl 
-dnl Checks for Libgnomedb-graph variants
-dnl 
-
-GNOMEDB_GRAPH_MODULES="libgnomedb-goo-3.0"
-PKG_CHECK_MODULES(GNOMEDB_GRAPH, $GNOMEDB_GRAPH_MODULES, have_gnomedb_goocanvas=yes, have_gnomedb_goocanvas=no)
-AM_CONDITIONAL(HAVE_GNOMEDB_GOOCANVAS, test x"$have_gnomedb_goocanvas" = "xyes")
-if test x"$have_gnomedb_goocanvas" = "xyes"
-then
-        GNOMEDB_GRAPH_CFLAGS="$GNOMEDB_GRAPH_CFLAGS -DHAVE_GNOMEDB_GOOCANVAS"
-        LIBGNOMEDB_REQUIRES="$LIBGNOMEDB_REQUIRES $GNOMEDB_GRAPH_MODULES"
-else
-	PKG_CHECK_MODULES(GNOMEDB_GRAPH, libgnomedb-graph-3.0)
-fi
-AC_SUBST(GNOMEDB_GRAPH_CFLAGS)
-AC_SUBST(GNOMEDB_GRAPH_LIBS)
-
-MERGEANT_CFLAGS="$MERGEANT_CFLAGS $GNOMEDB_GRAPH_CFLAGS"
-MERGEANT_LIBS="$MERGEANT_LIBS $GNOMEDB_GRAPH_LIBS"
-AC_SUBST(MERGEANT_CFLAGS)
-AC_SUBST(MERGEANT_LIBS)
-
-
 dnl
 dnl Check if src should be build with the debug mode
 dnl

Modified: trunk/data/application-x-mergeant.png
==============================================================================
Binary files. No diff available.

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Wed Jul  2 19:52:16 2008
@@ -18,20 +18,8 @@
 	main.c \
 	marshal.h \
 	marshal.c \
-	mg-plugin-editor.c \
-	mg-plugin-editor.h \
 	object-detail.c \
 	object-detail.h \
-	query-druid.c \
-	query-druid.h \
-	query-editor.c \
-	query-editor.h \
-	query-fields-editor.c \
-	query-fields-editor.h \
-	query-fields-menu.c \
-	query-fields-menu.h \
-	query-params-editor.c \
-	query-params-editor.h \
 	session.c \
 	session.h \
 	utils.h \
@@ -42,12 +30,6 @@
 	workspace-window.h \
 	workspace-page.h \
 	workspace-page.c \
-	ws-datatypes.h \
-	ws-datatypes.c \
-	ws-dbrels.h \
-	ws-dbrels.c \
-	ws-queries.h \
-	ws-queries.c \
 	ws-tables.h \
 	ws-tables.c \
 	mg-extra-formgrid.c \

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* Mergeant
  *
- * Copyright (C) 1999 - 2006 Vivien Malerba
+ * Copyright (C) 1999 - 2008 Vivien Malerba
  * Copyright (C) 2002 - 2004 Rodrigo Moya
  *
  * Authors:
@@ -68,14 +68,18 @@
 
 
 	/* initialize libraries */
-	gnome_db_init (PACKAGE, VERSION, argc, argv);
+	gnome_db_init ();
+	gtk_init (&argc, &argv);
 
 	if (list_all) {
 		GdaDataModel *model;
+		gchar *appname;
 
-		model = gda_config_get_data_source_model ();
+		model = gda_config_list_dsn ();
+		appname = gnome_db_get_application_exec_path ("gnome-database-properties");
 		g_print ("==================== List of configured data sources ====================\n"
-			 "Use the gnome-database-properties program to add or remove data sources.\n");
+			 "Use the %s program to add or remove data sources.\n", appname);
+		g_free (appname);
 		gda_data_model_dump (model, stdout);
 		g_object_unref (model);
 
@@ -101,12 +105,11 @@
 		WorkspaceOptions *options;
 
 		/* test DSN validity */
-                dsn = gda_config_find_data_source (argv[1]);
+                dsn = gda_config_get_dsn (argv[1]);
                 if (!dsn) {
                         g_print ("Can't find data source: %s\n", argv[1]);
                         exit (1);
                 }
-		gda_data_source_info_free (dsn);
 
 		/* starting */
 		options = g_new0 (WorkspaceOptions, 1);
@@ -115,13 +118,14 @@
 		options->pass = pass;
 		options->start_page = page;
 
-		gnome_db_main_run ((GdaInitFunc) create_new_workspace_window_spec, options);
+		create_new_workspace_window_spec (options);
 	}
 	else {
 		if (user || pass) 
 			g_warning ("No data source specified, ignoring user and password specifications");
-		gnome_db_main_run ((GdaInitFunc) create_new_workspace_window, NULL);
+		create_new_workspace_window_spec (NULL);
 	}
+	gtk_main ();
 
 	return 0;
 }

Modified: trunk/src/mg-plugin-editor.c
==============================================================================
--- trunk/src/mg-plugin-editor.c	(original)
+++ trunk/src/mg-plugin-editor.c	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* mg-plugin-editor.c
  *
- * Copyright (C) 2006 - 2007 Vivien Malerba
+ * Copyright (C) 2006 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -44,14 +44,14 @@
 
 struct _MgPluginEditorPriv
 {
-	GdaDict     *dict;
-	GObject     *work_object;
-	GtkWidget   *table;
-	GtkWidget   *plugins_combo;
-	GtkWidget   *options;
-	GtkWidget   *sample_entry;
+	GdaConnection *cnc;
+	GObject       *work_object;
+	GtkWidget     *table;
+	GtkWidget     *plugins_combo;
+	GtkWidget     *options;
+	GtkWidget     *sample_entry;
 
-	gboolean     setting_up;
+	gboolean       setting_up;
 };
 
 enum
@@ -71,7 +71,7 @@
 {
 	PROP_0,
 	PROP_WORK_OBJECT,
-	PROP_DICT
+	PROP_CNC
 };
 
 GType
@@ -110,9 +110,9 @@
         object_class->get_property = mg_plugin_editor_get_property;
 	object_class->dispose = mg_plugin_editor_dispose;
 
-	g_object_class_install_property (object_class, PROP_DICT,
-                                         g_param_spec_object ("dict", NULL, NULL, 
-							      G_TYPE_OBJECT,
+	g_object_class_install_property (object_class, PROP_CNC,
+                                         g_param_spec_object ("cnc", NULL, NULL, 
+							      GDA_TYPE_CONNECTION,
 							      G_PARAM_CONSTRUCT | G_PARAM_READABLE | G_PARAM_WRITABLE));
 	g_object_class_install_property (object_class, PROP_WORK_OBJECT,
                                          g_param_spec_object ("work_object", NULL, NULL, 
@@ -127,7 +127,7 @@
 	
 	editor->priv = g_new0 (MgPluginEditorPriv, 1);
 
-	editor->priv->dict = NULL;
+	editor->priv->cnc = NULL;
 	editor->priv->work_object = NULL;
 	editor->priv->plugins_combo = gtk_combo_box_new ();
 	editor->priv->options = NULL;
@@ -168,8 +168,8 @@
 
         /* free objects references */
 	if (editor->priv) {
-		if (editor->priv->dict)
-			g_object_remove_weak_pointer ((GObject*) editor->priv->dict, (gpointer) editor->priv->dict);
+		if (editor->priv->cnc)
+			g_object_unref (editor->priv->cnc);
 		mg_plugin_editor_set_work_object (editor, NULL);
 		g_free (editor->priv);
 		editor->priv = NULL;
@@ -180,20 +180,18 @@
 }
 /**
  * mg_plugin_editor_new
- * @model: a #GdaDataModel
+ * @cnc: a #GdaConnection
  *
- * Creates a new #MgPluginEditor widget suitable to display the data in @model
+ * Creates a new #MgPluginEditor widget
  *
  *  Returns: the new widget
  */
 GtkWidget *
-mg_plugin_editor_new (GdaDict *dict)
+mg_plugin_editor_new (GdaConnection *cnc)
 {
-	MgPluginEditor *editor;
-
-	editor = (MgPluginEditor *) g_object_new (MG_TYPE_PLUGIN_EDITOR, "dict", ASSERT_DICT (dict), NULL);
+	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
-	return (GtkWidget *) editor;
+	return (GtkWidget*) g_object_new (MG_TYPE_PLUGIN_EDITOR, "cnc", cnc, NULL);
 }
 
 
@@ -204,22 +202,22 @@
 			       GParamSpec *pspec)
 {
 	MgPluginEditor *editor;
-	GdaDict *dict;
+	GdaConnection *cnc;
 	editor = MG_PLUGIN_EDITOR (object);
 	
 	switch (param_id) {
 	case PROP_WORK_OBJECT:
 		mg_plugin_editor_set_work_object (editor, g_value_get_object (value));
 		break;
-	case PROP_DICT:
-		dict = g_value_get_object (value);
-		if (editor->priv->dict == dict)
+	case PROP_CNC:
+		cnc = g_value_get_object (value);
+		if (editor->priv->cnc == cnc)
 			break;
-		if (editor->priv->dict)
-			g_object_remove_weak_pointer ((GObject*) editor->priv->dict, (gpointer) editor->priv->dict);
-		editor->priv->dict = dict;
-		if (editor->priv->dict)
-			g_object_add_weak_pointer ((GObject*) editor->priv->dict, (gpointer) editor->priv->dict);
+		if (editor->priv->cnc)
+			g_object_unref (editor->priv->cnc);
+		editor->priv->cnc = cnc;
+		if (editor->priv->cnc)
+			g_object_ref (editor->priv->cnc);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -241,8 +239,8 @@
 	case PROP_WORK_OBJECT:
 		g_value_set_object (value, editor->priv->work_object);
 		break;
-	case PROP_DICT:
-		g_value_set_object (value, editor->priv->dict);
+	case PROP_CNC:
+		g_value_set_object (value, editor->priv->cnc);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -261,9 +259,9 @@
 static void  update_sample_data_entry (MgPluginEditor *editor, const gchar *plugin_str);
 static void  compute_new_model (GtkTreeModel *model, GObject *obj);
 static void  plugins_combo_changed_cb (GtkComboBox *combo, MgPluginEditor *editor);
-static void  options_form_param_changed_cb (GnomeDbBasicForm *form, GdaParameter *param, 
+static void  options_form_param_changed_cb (GnomeDbBasicForm *form, GdaHolder *param, 
 					    gboolean is_user_modif, MgPluginEditor *editor);
-static void  options_quarks_foreach_func (const gchar *key, const gchar *value, GdaParameterList *plist);
+static void  options_quarks_foreach_func (const gchar *key, const gchar *value, GdaSet *plist);
 static void  work_object_set_plugin (MgPluginEditor *editor);
 /**
  * mg_plugin_editor_set_work_object
@@ -358,7 +356,7 @@
 			if (options) {
 				if (editor->priv->options && GNOME_DB_IS_BASIC_FORM (editor->priv->options)) {
 					GdaQuarkList *params;
-					GdaParameterList *plist;
+					GdaSet *plist;
 					
 					params = gda_quark_list_new_from_string (options);
 					plist = gnome_db_basic_form_get_data_set (GNOME_DB_BASIC_FORM (editor->priv->options));
@@ -383,13 +381,13 @@
 }
 
 static void
-options_quarks_foreach_func (const gchar *key, const gchar *value, GdaParameterList *plist)
+options_quarks_foreach_func (const gchar *key, const gchar *value, GdaSet *plist)
 {
-	GdaParameter *param;
+	GdaHolder *param;
 
-	param = gda_parameter_list_find_param (plist, key);
+	param = gda_set_get_holder (plist, key);
 	if (param)
-		gda_parameter_set_value_str (param, value);
+		gda_holder_set_value_str (param, NULL, value);
 	else
 		g_warning (_("Options '%s=%s' is set but unknown to the plugin used"), key, value);
 }
@@ -465,8 +463,7 @@
 {
 	GtkWidget *sample = NULL;
 	if (get_work_obj_type (editor->priv->work_object) != G_TYPE_INVALID) {
-		sample = GTK_WIDGET (gnome_db_util_new_data_entry (editor->priv->dict, 
-								   get_work_obj_type (editor->priv->work_object), 
+		sample = GTK_WIDGET (gnome_db_util_new_data_entry (get_work_obj_type (editor->priv->work_object), 
 								   plugin_str));
 		g_object_set (G_OBJECT (sample), "actions", FALSE, NULL);
 	}
@@ -492,13 +489,12 @@
 		model = gtk_combo_box_get_model (combo);
 		gtk_tree_model_get (model, &iter, COLUMN_POINTER, &plugin, -1);
 		if (plugin && plugin->options_xml_spec) {
-			GdaParameterList *plist;
+			GdaSet *plist;
 			GError *error = NULL;
 			
-			/* use %NULL as dict because we want correct data entry widgets to be displayed, even
+			/* use %NULL as cnc because we want correct data entry widgets to be displayed, even
 			 * if the provider does not support a type */
-			plist = gda_parameter_list_new_from_spec_string (NULL, 
-									 plugin->options_xml_spec, &error);
+			plist = gda_set_new_from_spec_string (plugin->options_xml_spec, &error);
 			if (!plist) {
 				g_warning ("Cannot parse XML spec for plugin options: %s",
 					   error && error->message ? error->message : "No detail");
@@ -545,17 +541,17 @@
 			string = g_string_new (plugin->plugin_name);
 			if (GNOME_DB_IS_BASIC_FORM (editor->priv->options)) {
 				GSList *list;
-				GdaParameterList *plist;
+				GdaSet *plist;
 				gchar *str;
 
 				g_string_append_c (string, ':');
 				plist = gnome_db_basic_form_get_data_set (GNOME_DB_BASIC_FORM (editor->priv->options));
-				for (list = plist->parameters; list; list = list->next) {
-					if (list != plist->parameters)
+				for (list = plist->holders; list; list = list->next) {
+					if (list != plist->holders)
 						g_string_append_c (string, ';');
-					g_string_append (string, gda_object_get_id (GDA_OBJECT (list->data)));
+					g_string_append (string, gda_holder_get_id (GDA_HOLDER (list->data)));
 					g_string_append_c (string, '=');
-					str = gda_parameter_get_value_str (GDA_PARAMETER (list->data));
+					str = gda_holder_get_value_str (GDA_HOLDER (list->data), NULL);
 					if (str) {
 						g_string_append (string, str);
 						g_free (str);
@@ -577,7 +573,7 @@
 }
 
 static void
-options_form_param_changed_cb (GnomeDbBasicForm *form, GdaParameter *param, gboolean is_user_modif, 
+options_form_param_changed_cb (GnomeDbBasicForm *form, GdaHolder *param, gboolean is_user_modif, 
 			       MgPluginEditor *editor)
 {
 	work_object_set_plugin (editor);

Modified: trunk/src/mg-plugin-editor.h
==============================================================================
--- trunk/src/mg-plugin-editor.h	(original)
+++ trunk/src/mg-plugin-editor.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* mg-plugin-editor.h
  *
- * Copyright (C) 2006 Vivien Malerba
+ * Copyright (C) 2006 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -22,7 +22,7 @@
 #define __MG_PLUGIN_EDITOR__
 
 #include <gtk/gtk.h>
-#include <libgda/gda-decl.h>
+#include <libgda/libgda.h>
 
 G_BEGIN_DECLS
 
@@ -55,7 +55,7 @@
  */
 GType             mg_plugin_editor_get_type            (void);
 
-GtkWidget        *mg_plugin_editor_new                 (GdaDict *dict);
+GtkWidget        *mg_plugin_editor_new                 (GdaConnection *cnc);
 void              mg_plugin_editor_set_work_object     (MgPluginEditor *editor, GObject *work_obj);
 
 G_END_DECLS

Modified: trunk/src/query-druid.c
==============================================================================
--- trunk/src/query-druid.c	(original)
+++ trunk/src/query-druid.c	Wed Jul  2 19:52:16 2008
@@ -20,21 +20,12 @@
 
 #include <glib/gi18n-lib.h>
 #include "query-druid.h"
+#include <libgda/libgda.>
 #include <libgnomedb-graph/libgnomedb-graph.h>
 #include <libgnomedb-extra/libgnomedb-extra.h>
-#include <libgda/libgda.h>
-#include <libgda/graph/gda-dict-reg-graphs.h>
 #include "workspace-page.h"
 #include "query-fields-editor.h"
 
-#ifdef HAVE_GNOMEDB_GOOCANVAS
-#include <libgnomedb-goo/gnome-db-goo.h>
-#include <libgnomedb-goo/gnome-db-goo-query-struct.h>
-#else
-#include <libgnomedb-graph/gnome-db-canvas.h>
-#include <libgnomedb-graph/gnome-db-canvas-query-struct.h>
-#endif
-
 static void query_druid_class_init (QueryDruidClass *class);
 static void query_druid_init (QueryDruid *wid);
 static void query_druid_dispose (GObject *object);

Modified: trunk/src/query-druid.h
==============================================================================
--- trunk/src/query-druid.h	(original)
+++ trunk/src/query-druid.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* query-druid.h
  *
- * Copyright (C) 2004 - 2007 Vivien Malerba
+ * Copyright (C) 2004 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -55,7 +55,7 @@
  * Generic widget's methods 
 */
 GType      query_druid_get_type            (void);
-GtkWidget *query_druid_new                 (GdaDict *dict);
+GtkWidget *query_druid_new                 (GdaConnection *cnc);
 
 G_END_DECLS
 

Modified: trunk/src/query-editor.h
==============================================================================
--- trunk/src/query-editor.h	(original)
+++ trunk/src/query-editor.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* query-editor.h
  *
- * Copyright (C) 2004 - 2007 Vivien Malerba
+ * Copyright (C) 2004 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -56,7 +56,7 @@
  * Generic widget's methods 
 */
 GType      query_editor_get_type            (void);
-GtkWidget *query_editor_new                 (GdaQuery *query);
+GtkWidget *query_editor_new                 (GdaStatement *stmt);
 
 G_END_DECLS
 

Modified: trunk/src/utils.c
==============================================================================
--- trunk/src/utils.c	(original)
+++ trunk/src/utils.c	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* Mergeant
  *
- * Copyright (C) 2006 Vivien Malerba
+ * Copyright (C) 2006 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -26,7 +26,7 @@
 static void server_op_dlg_response_cb (GtkDialog *dlg, gint resp_id, gpointer data);
 
 GtkWidget *mergeant_server_op_create_dialog (GtkWindow *parent, GdaServerOperationType type, 
-					     GdaConnection *cnc, GdaParameterList *options,
+					     GdaConnection *cnc, GdaSet *options,
 					     const gchar *title, const gchar *foreword,
 					     MergeantServerOpCallback done_cb, gpointer user_data)
 {
@@ -93,9 +93,9 @@
 		gtk_widget_show (label);
 		
 		wid = gnome_db_provider_selector_new ();
-		gnome_db_provider_selector_set_selected_provider (GNOME_DB_PROVIDER_SELECTOR (wid), 
-								  cnc && gda_connection_get_provider (cnc) ? 
-								  gda_connection_get_provider (cnc) : "SQLite");
+		gnome_db_provider_selector_set_provider (GNOME_DB_PROVIDER_SELECTOR (wid), 
+							 cnc && gda_connection_get_provider_name (cnc) ? 
+							 gda_connection_get_provider_name (cnc) : "SQLite");
 		g_signal_connect (G_OBJECT (wid), "changed",
 				  G_CALLBACK (server_op_provider_changed_cb), dlg);
 		gtk_box_pack_start (GTK_BOX (hbox), wid, TRUE, TRUE, 0);
@@ -236,11 +236,11 @@
 
 	/* new settings */
 	box = g_object_get_data (G_OBJECT (dlg), "box");
-	prov = gnome_db_provider_selector_get_selected_provider_obj (prov_sel);
+	prov = gnome_db_provider_selector_get_provider_obj (prov_sel);
 	if (!prov) 
 		wid = gtk_label_new (_("Internal error: can't instantiate a provider object"));
 	else {
-		GdaParameterList *options;
+		GdaSet *options;
 		GdaConnection *cnc;
 
 		g_object_set_data_full (G_OBJECT (dlg), "prov", prov, g_object_unref);
@@ -253,12 +253,12 @@
 
 			cncprov = gda_connection_get_provider_obj (cnc);
 			if (cncprov != prov) {
-				GdaServerProviderInfo* info, *cncinfo;
+				GdaProviderInfo* info, *cncinfo;
 
-				info = gda_server_provider_get_info (prov, NULL);
-				cncinfo = gda_server_provider_get_info (cncprov, cnc);
-				if (info && cncinfo && info->provider_name && 
-				    !strcmp (info->provider_name, cncinfo->provider_name))
+				info = gda_config_get_provider_info (gda_server_provider_get_name (prov));
+				cncinfo = gda_config_get_provider_info (gda_server_provider_get_name (cncprov));
+
+				if (!strcmp (info->id, cncinfo->id))
 					prov = cncprov;
 				else
 					cnc = NULL;

Modified: trunk/src/utils.h
==============================================================================
--- trunk/src/utils.h	(original)
+++ trunk/src/utils.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* Mergeant
  *
- * Copyright (C) 2006 Vivien Malerba
+ * Copyright (C) 2006 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -27,7 +27,7 @@
 #define MERGEANT_SERVER_OP_CALLBACK(x) ((MergeantServerOpCallback)(x))
 
 GtkWidget *mergeant_server_op_create_dialog (GtkWindow *parent, GdaServerOperationType type, 
-					     GdaConnection *cnc, GdaParameterList *options, 
+					     GdaConnection *cnc, GdaSet *options, 
 					     const gchar *title, const gchar *foreword,
 					     MergeantServerOpCallback done_cb, gpointer user_data);
 

Modified: trunk/src/workspace-window.c
==============================================================================
--- trunk/src/workspace-window.c	(original)
+++ trunk/src/workspace-window.c	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* Mergeant
  *
- * Copyright (C) 1999 - 2007 Vivien Malerba
+ * Copyright (C) 1999 - 2008 Vivien Malerba
  * Copyright (C) 2002 - 2003 Rodrigo Moya
  *
  * Authors:
@@ -46,7 +46,7 @@
 	GtkWidget      *status_bar;
 
 	/* the connection to the database */
-	GdaDict        *dict;
+	GdaConnection  *cnc;
 	
 	GSList         *consoles; /* list of GtkDialog for Sql consoles */
 	GtkWidget      *transaction_status;
@@ -56,7 +56,7 @@
 static GtkWidget     *dsn_dialog = NULL;
 
 static void perform_dbms_update (WorkspaceWindowPrivate *priv);
-static void stop_dbms_update_cb (GtkWidget *dialog, gint response, GdaDict *dict);
+static void stop_dbms_update_cb (GtkWidget *dialog, gint response, GdaConnection *cnc);
 
 static void
 destroy_private_data_cb (WorkspaceWindowPrivate *priv)
@@ -70,16 +70,15 @@
 		if (priv->transaction_status)
 			gtk_widget_destroy (priv->transaction_status);
 
-		if (priv->dict) {
-			gda_dict_save (priv->dict, NULL); /* save before destruction */
-			g_object_unref (priv->dict);
-			priv->dict = NULL;
+		if (priv->cnc) {
+			g_object_unref (priv->cnc);
+			priv->cnc = NULL;
 		}
 
 		g_free (priv);
 
 		if (!opened_workspaces)
-			gnome_db_main_quit ();
+			gtk_main_quit ();
 	}
 }
 
@@ -92,31 +91,29 @@
 static void
 on_file_copy_workspace (GtkAction *action, WorkspaceWindowPrivate *priv)
 {
-	create_new_workspace_window (priv->dict);
+	create_new_workspace_window (priv->cnc);
 }
 
 static gboolean
 treat_close_request (WorkspaceWindowPrivate *priv)
 {
 	GtkWidget *window = priv->window;
-	GdaConnection *cnc;
 	GdaTransactionStatus *tstatus;
 	gboolean do_close = TRUE;
 	GList *list;
 
+	g_assert (priv);
+	g_assert (gda_connection_is_opened (priv->cnc));
+
 	/* if the connection is used by another workspace, then allow closing of this window */
 	for (list = opened_workspaces; list; list = list->next) {
 		if (((WorkspaceWindowPrivate*) list->data != priv) &&
-		    (((WorkspaceWindowPrivate*) list->data)->dict == priv->dict))
+		    (((WorkspaceWindowPrivate*) list->data)->cnc == priv->cnc))
 			return TRUE;
 	}
 	
 	/* if a transaction is started, then try to commit it */
-	g_assert (priv);
-	cnc = gda_dict_get_connection (priv->dict);
-	g_assert (cnc);
-	g_assert (gda_connection_is_opened (cnc));
-	tstatus = gda_connection_get_transaction_status (cnc);
+	tstatus = gda_connection_get_transaction_status (priv->cnc);
 	if (tstatus) {
 		gchar *msg;
 		GtkWidget *dlg;
@@ -129,7 +126,7 @@
 					 "transaction was started, <u>commit</u> the transaction to save those changes, "
 					 "or <u>ignore</u> the transaction to let the DBMS handle the transaction (this "
 					 "usually leads to lose any change). What do you want to do?"), 
-				       gda_connection_get_dsn (cnc));
+				       gda_connection_get_dsn (priv->cnc));
 		dlg = gtk_message_dialog_new_with_markup (GTK_WINDOW (window), GTK_DIALOG_MODAL,
 							  GTK_MESSAGE_WARNING,
 							  GTK_BUTTONS_NONE, msg);
@@ -144,7 +141,7 @@
 
 			dlg = NULL;
 			if (result == 1) {
-				if (!gda_connection_rollback_transaction (cnc, NULL, &error))
+				if (!gda_connection_rollback_transaction (priv->cnc, NULL, &error))
 					dlg = gtk_message_dialog_new_with_markup (GTK_WINDOW (window), GTK_DIALOG_MODAL,
 										  GTK_MESSAGE_ERROR,
 										  GTK_BUTTONS_NONE, 
@@ -154,7 +151,7 @@
 										  error->message : _("No detail"));
 			}
 			else {
-				if (gda_connection_commit_transaction (cnc, NULL, &error))
+				if (gda_connection_commit_transaction (priv->cnc, NULL, &error))
 					dlg = gtk_message_dialog_new_with_markup (GTK_WINDOW (window), GTK_DIALOG_MODAL,
 										  GTK_MESSAGE_ERROR,
 										  GTK_BUTTONS_NONE, 
@@ -193,18 +190,6 @@
 }
 
 static void
-on_file_save (GtkAction *action, WorkspaceWindowPrivate *priv)
-{
-	GError *error = NULL;
-
-	/* saving of GdaDict */
-	if (!gda_dict_save (priv->dict, &error)) {
-		g_warning ("Could not save: %s\n", error->message);
-		g_error_free (error);
-	}
-}
-
-static void
 on_file_exit (GtkAction *action, WorkspaceWindowPrivate *priv)
 {
 	while (opened_workspaces) {
@@ -218,7 +203,6 @@
 on_database_sync (GtkAction *action, WorkspaceWindowPrivate *priv)
 {
 	perform_dbms_update (priv);
-	gda_dict_save (priv->dict, NULL);
 }
 
 static void
@@ -243,18 +227,13 @@
 						   GTK_RESPONSE_ACCEPT, NULL);
 		gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
 
-		cnc = gda_dict_get_connection (priv->dict);
-		if (gda_connection_get_username (cnc))
-			title = g_strdup_printf ("Transactions management: %s %s", gda_connection_get_username (cnc),
-						 gda_connection_get_dsn (cnc));
-		else
-			title = g_strdup_printf ("Transactions management: %s", gda_connection_get_dsn (cnc));
-		
+		cnc = priv->cnc;
+		title = g_strdup_printf ("Transactions management: %s", gda_connection_get_dsn (cnc));
 		gtk_window_set_title (GTK_WINDOW (dlg), title);
 		g_free (title);
 
 		/* transactions status widget */
-		status = gnome_db_transaction_status_new (gda_dict_get_connection (priv->dict));
+		status = gnome_db_transaction_status_new (priv->cnc);
 		gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), status, TRUE, TRUE, 0);
 		gtk_widget_set_size_request (status, 400, 350);
 		g_signal_connect (G_OBJECT (dlg), "response",
@@ -277,7 +256,7 @@
 			       _("The 'SQLite' provider allows you to create a database stored in a single file\n"
 				 "and does not require a database server to be set up."));
 	dlg = mergeant_server_op_create_dialog (GTK_WINDOW (priv->window), GDA_SERVER_OPERATION_CREATE_DB, 
-						gda_dict_get_connection (priv->dict), NULL,
+						priv->cnc, NULL,
 						_("Create a database"), str, NULL, NULL);
 	g_free (str);
 	gtk_widget_show (dlg);
@@ -289,7 +268,7 @@
 	GtkWidget *dlg;
 
 	dlg = mergeant_server_op_create_dialog (GTK_WINDOW (priv->window), GDA_SERVER_OPERATION_DROP_DB, 
-						gda_dict_get_connection (priv->dict), NULL,
+						priv->cnc, NULL,
 						_("Delete a database"),
 						_("Database destruction requires that first a database provider be selected."),
 						NULL, NULL);
@@ -302,8 +281,8 @@
 	char *argv[2];
 	GError *error = NULL;
 
-	/* run gnome-database-properties dictig tool */
-	argv[0] = (char *) "gnome-database-properties-3.0";
+	/* run gnome-database-properties tool */
+	argv[0] = gnome_db_get_application_exec_path ("gnome-database-properties");
         argv[1] = NULL;
                                                                                   
 	if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
@@ -320,6 +299,7 @@
 		gtk_dialog_run (GTK_DIALOG (dlg));
 		gtk_widget_destroy (dlg);
 	}
+	g_free (argv[0]);
 }
 
 
@@ -336,13 +316,8 @@
 					   GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
 	gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
 	
-	cnc = gda_dict_get_connection (priv->dict);
-	if (gda_connection_get_username (cnc))
-                title = g_strdup_printf ("SQL console: %s %s", gda_connection_get_username (cnc),
-                                         gda_connection_get_dsn (cnc));
-        else
-                title = g_strdup_printf ("SQL console: %s", gda_connection_get_dsn (cnc));
-	
+	cnc = priv->cnc;
+	title = g_strdup_printf ("SQL console: %s", gda_connection_get_dsn (cnc));
 	gtk_window_set_title (GTK_WINDOW (dlg), title);
 	g_free (title);
 	
@@ -355,7 +330,7 @@
 	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), sw, TRUE, TRUE, 0);
 	gtk_widget_show (sw);
 	
-	console = gnome_db_sql_console_new (priv->dict, _("SQL Console (type \\? + ENTER for help)\n"));
+	console = gnome_db_sql_console_new (priv->cnc, _("SQL Console (type \\? + ENTER for help)\n"));
 	gtk_container_add (GTK_CONTAINER (sw), console);
 	gtk_widget_show (console);
 
@@ -456,11 +431,10 @@
 	{ "FileNewWorkspace", GTK_STOCK_NEW, "_New workspace", NULL, "Open a new workspace", G_CALLBACK (on_file_new_workspace) },
 	{ "FileCopyWorkspace", GTK_STOCK_COPY, "_Copy of this Workspace", NULL, "Open a new workspace with the same connection parameters", G_CALLBACK (on_file_copy_workspace) },
 	{ "FileClose", GTK_STOCK_CLOSE, "_Close", NULL, "Close this window", G_CALLBACK (on_file_close) },
-	{ "FileSave", GTK_STOCK_SAVE, "_Save now", NULL, "Save metadata", G_CALLBACK (on_file_save) },
 	{ "FileExit", GTK_STOCK_QUIT, "_Quit", NULL, "Exit the application", G_CALLBACK (on_file_exit) },
 	{ "Database", NULL, "_Database", NULL, "Database", NULL },
 	{ "DatabaseSync", GTK_STOCK_REFRESH, "_Sync", NULL, "Refresh metadata from database", G_CALLBACK (on_database_sync) },
-	{ "Transactions", NULL, "_Transations", NULL, "Transactions management", G_CALLBACK (on_transaction) },
+	{ "Transactions", NULL, "_Transactions", NULL, "Transactions management", G_CALLBACK (on_transaction) },
 	{ "DatabaseCreate", GTK_STOCK_NEW, "_Create a database", NULL, "Create a new database", G_CALLBACK (on_database_new) },
 	{ "DatabaseDelete", GTK_STOCK_DELETE, "_Delete a database", NULL, "Delete an existing database", G_CALLBACK (on_database_del) },
 	{ "ToolsDataSources", GTK_STOCK_PREFERENCES, "_Datasources", NULL, "Manage the list of declared datasources", G_CALLBACK (on_tools_data_sources) },
@@ -477,7 +451,6 @@
         "      <menuitem name='FileCopyWorkspace' action= 'FileCopyWorkspace'/>"
         "      <separator/>"
         "      <menuitem name='FileClose' action= 'FileClose'/>"
-        "      <menuitem name='FileSave' action= 'FileSave'/>"
         "      <menuitem name='FileExit' action= 'FileExit'/>"
         "    </menu>"
         "    <menu name='Database' action='Database'>"
@@ -505,40 +478,38 @@
 
 
 static void
-stop_dbms_update_cb (GtkWidget *dialog, gint response, GdaDict *dict)
+stop_dbms_update_cb (GtkWidget *dialog, gint response, GdaConnection *cnc)
 {
-	gda_dict_stop_update_dbms_meta_data (dict);
+	/*gda_dict_stop_update_dbms_meta_data (dict);*/
+	TO_IMPLEMENT;
 }
 
 static void
 perform_dbms_update (WorkspaceWindowPrivate *priv)
 {
 	GtkWidget *dialog, *view;
-	GError *error;
+	GError *error = NULL;
 
 	dialog = gtk_dialog_new_with_buttons (_("Metadata synchronisation"),
 					      NULL,
 					      GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
 					      GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
-	g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (stop_dbms_update_cb), priv->dict);
+	g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (stop_dbms_update_cb), priv->cnc);
 	
-	view = gnome_db_dbms_update_viewer_new (priv->dict);
+	view = gtk_label_new (_("Reading database's meta data, please wait..."));
 	gtk_widget_show (view);
 	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), view, TRUE, TRUE, 6);
 	gtk_widget_show (dialog);
 	
-	error = NULL;
-	if (!gda_dict_update_dbms_meta_data (priv->dict, 0, NULL, &error)) {
-		if (error->code != GDA_DICT_META_DATA_UPDATE_USER_STOPPED) {
-			GtkWidget *msg;
-
-                        msg = gtk_message_dialog_new (GTK_WINDOW (dialog),
-                                                      GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                      GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
-                                                      _("Error updating Server metadata:\n%s\n"), error->message);
-                        gtk_dialog_run (GTK_DIALOG (msg));
-                        gtk_widget_destroy (msg);
-		}
+	if (!gda_connection_update_meta_store (priv->cnc, NULL, &error)) {
+		GtkWidget *msg;
+		
+		msg = gtk_message_dialog_new (GTK_WINDOW (dialog),
+					      GTK_DIALOG_DESTROY_WITH_PARENT,
+					      GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+					      _("Error updating Server metadata:\n%s\n"), error->message);
+		gtk_dialog_run (GTK_DIALOG (msg));
+		gtk_widget_destroy (msg);
 		g_error_free (error);
 	}	
 	
@@ -555,50 +526,48 @@
 		gtk_main_quit ();
 }
 
-static void create_new_workspace_window_no_dict (WorkspaceOptions *options);
-static void create_new_workspace_window_with_dict (GdaDict *dict, gboolean force_dbms_update, WorkspaceOptions *options);
+static void create_new_workspace_window_no_cnc (WorkspaceOptions *options);
+static void create_new_workspace_window_with_cnc (GdaConnection *cnc, gboolean force_dbms_update, WorkspaceOptions *options);
 
 /**
  * create_new_workspace_window
- * @dict: a #GdaDict object, or %NULL
- * @ui:
+ * @cnc: a #GdaConnection object, or %NULL
  *
- * Creates a new workspace window. If @dict is not, %NULL
+ * Creates a new workspace window. If @cnc is not %NULL
  * then it is reused for the new workspace.
  *
  * Returns:
  */
 void
-create_new_workspace_window (GdaDict *dict)
+create_new_workspace_window (GdaConnection *cnc)
 {
-	if (dict) {
-		if (! GDA_IS_DICT (dict)) {
-			g_warning ("dict is not a GdaDict object, cancelling workspace window creation");
+	if (cnc) {
+		if (! GDA_IS_CONNECTION (cnc)) {
+			g_warning ("cnc is not a GdaConnection object, cancelling workspace window creation");
 			quit_if_no_other_workspace ();
 			return;
 		}
 		
-		create_new_workspace_window_with_dict (dict, FALSE, NULL);
+		create_new_workspace_window_with_cnc (cnc, FALSE, NULL);
 	}
 	else
-		create_new_workspace_window_no_dict (NULL);
+		create_new_workspace_window_no_cnc (NULL);
 }
 
 /**
  * create_new_workspace_window_spec
  * @options: 
- * @ui:
  *
- * Same as create_new_workspace_window but with specific options
+ * Same as create_new_workspace_window() but with specific options
  */
 void
 create_new_workspace_window_spec (WorkspaceOptions *options)
 {
-	create_new_workspace_window_no_dict (options);
+	create_new_workspace_window_no_cnc (options);
 }
 
 static void 
-create_new_workspace_window_with_dict (GdaDict *dict, gboolean force_dbms_update, WorkspaceOptions *options)
+create_new_workspace_window_with_cnc (GdaConnection *cnc, gboolean force_dbms_update, WorkspaceOptions *options)
 {
 	WorkspaceWindowPrivate *priv;
 	GtkWidget *table;
@@ -606,23 +575,18 @@
 	GtkActionGroup *actions;
         GtkUIManager *ui;
 	GtkWidget *toolbar, *menubar;
-	GdaConnection *cnc;
 
-	/* here we MUST have a valid dictionary */
-	g_assert (dict && GDA_IS_DICT (dict));
-	g_object_ref (dict);
+	/* here we MUST have a valid connection */
+	g_assert (cnc && GDA_IS_CONNECTION (cnc));
 
 	/* create the private structure */
 	priv = g_new0 (WorkspaceWindowPrivate, 1);
-	priv->dict = dict;
+	priv->cnc = cnc;
+	g_object_ref (cnc);
 	opened_workspaces = g_list_prepend (opened_workspaces, priv);
 
-	gda_dict_extend_with_functions (priv->dict);
-
-	if (force_dbms_update) {
+	if (force_dbms_update) 
 		perform_dbms_update (priv);
-		gda_dict_save (dict, NULL);
-	}
 
 	/* create the window */
 	priv->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -636,13 +600,8 @@
 	gtk_window_set_icon_from_file (GTK_WINDOW (priv->window), str, NULL);
 	g_free (str);
 
-	cnc = gda_dict_get_connection (priv->dict);
-        if (gda_connection_get_username (cnc))
-                title = g_strdup_printf ("%s %s - Mergeant", gda_connection_get_username (cnc),
-                                         gda_connection_get_dsn (cnc));
-        else
-                title = g_strdup_printf ("%s - Mergeant", gda_connection_get_dsn (cnc));
-	
+	cnc = priv->cnc;
+	title = g_strdup_printf ("%s - Mergeant", gda_connection_get_dsn (cnc));
 	gtk_window_set_title (GTK_WINDOW (priv->window), title);
 	g_free (title);
 	gtk_widget_set_size_request (priv->window, 900, 700);
@@ -665,7 +624,7 @@
 	gtk_widget_show (toolbar);
 
 	/* create the workspace */
-	priv->workspace = workspace_new (priv->dict, ui);
+	priv->workspace = workspace_new (priv->cnc, ui);
 	gtk_widget_show (priv->workspace);
 	gtk_table_attach (GTK_TABLE (table), priv->workspace, 0, 1, 2, 3,
 			  GTK_SHRINK | GTK_FILL | GTK_EXPAND,
@@ -709,13 +668,10 @@
 /* structure holding data used during the threads usage */
 typedef struct {
 	GdaThreader   *threader;
-	GdaDict       *dict;
-	gchar         *filename;
 	GError       **error;
 
 	gchar         *dsn;
-	gchar         *username;
-	gchar         *password;
+	gchar         *auth;
 	GdaConnection *cnc;
 
 	gboolean       func_retval;
@@ -731,19 +687,15 @@
 {
 	if (thdata->threader)
 		g_object_unref (thdata->threader);
-	if (thdata->dict)
-		g_object_unref (thdata->dict);
-	g_free (thdata->filename);
+	if (thdata->cnc)
+		g_object_unref (thdata->cnc);
 	if (thdata->error) {
 		if (*(thdata->error))
 			g_error_free (*(thdata->error));
 		g_free (thdata->error);
 	}
 	g_free (thdata->dsn);
-	g_free (thdata->username);
-	g_free (thdata->password);
-	if (thdata->cnc)
-		g_object_unref (thdata->cnc);
+	g_free (thdata->auth);
 	g_free (thdata);
 }
 
@@ -763,16 +715,8 @@
 static void
 thread_open_connect (ThreadData *thdata)
 {
-	GdaConnection *cnc;
-	static GdaClient *gda_client = NULL;	
-
-	if (!gda_client)
-		gda_client = gda_client_new ();
-	cnc = gda_dict_get_connection (thdata->dict);
-	g_assert (!cnc);
-	cnc = gda_client_open_connection (gda_client, thdata->dsn, thdata->username, thdata->password, 
-					  0, thdata->error);
-	thdata->cnc = cnc;
+	thdata->cnc = gda_connection_open_from_dsn (thdata->dsn, thdata->auth, 
+						    GDA_CONNECTION_OPTIONS_NONE, thdata->error);
 }
 
 /* 
@@ -806,15 +750,24 @@
 		quit_if_no_other_workspace ();
 	}
 	else {
+		/* associate meta store */
+		gchar *filename;
 		WorkspaceOptions *options;
+		GdaMetaStore *store;
 
-		gda_dict_set_connection (thdata->dict, thdata->cnc);
-		g_object_unref (thdata->cnc);
-		thdata->cnc = NULL;
+#define USER_CONFIG_DIR G_DIR_SEPARATOR_S ".libgda"
+		filename = g_strdup_printf ("%s%smergeant-%s.db",
+					    g_get_home_dir (), USER_CONFIG_DIR G_DIR_SEPARATOR_S,
+					    thdata->dsn);
+		if (! g_file_test (filename, G_FILE_TEST_EXISTS))
+			thdata->force_dbms_update = TRUE;
+		store = gda_meta_store_new_with_file (filename);
+		g_free (filename);
+		g_object_set (G_OBJECT (thdata->cnc), "meta-store", store, NULL);
 
 		options = g_object_get_data (G_OBJECT (dsn_dialog), "options");
 		/* gdk_threads_enter (); */
-		create_new_workspace_window_with_dict (thdata->dict, thdata->force_dbms_update, options);
+		create_new_workspace_window_with_cnc (thdata->cnc, thdata->force_dbms_update, options);
 		/* gdk_threads_leave (); */
 	}
 	
@@ -822,124 +775,13 @@
 	gtk_widget_hide (dsn_dialog);
 }
 
-/*
- * Try to open the connection, run from the main thread.
- */
-static void
-open_connection (ThreadData *thdata)
-{
-	/* try to open the connection */
-	gchar *str;
-	
-	str = g_strdup_printf ("<b>%s:</b>\n%s", _("Opening connection"),
-			       _("The connection to the data source is now being opened."));
-	gtk_label_set_markup (GTK_LABEL (thdata->label), str);
-	g_free (str);
-	
-	thdata->timeout_id = g_timeout_add (PROGRESS_BAR_TIMEOUT, (GSourceFunc) update_progress_bar, thdata->bar);
-	
-	gda_threader_start_thread (thdata->threader, (GThreadFunc) thread_open_connect, thdata, 
-				   (GdaThreaderFunc) thread_open_connect_finished, NULL, NULL);
-}
-
-/* 
- * function executed in another thread, to load a dictionary
- */
-static void
-thread_load_dict (ThreadData *thdata)
-{
-	thdata->func_retval = gda_dict_load_xml_file (thdata->dict, thdata->filename, thdata->error);
-}
-
-static void
-load_dict_error_choose_cb (GtkDialog *dialog, gint response, ThreadData *thdata)
-{
-	g_signal_handlers_disconnect_by_func (G_OBJECT (dialog), G_CALLBACK (load_dict_error_choose_cb), thdata);
-	g_signal_handlers_disconnect_by_func (G_OBJECT (dialog), G_CALLBACK (load_dict_error_choose_cb), thdata);
-
-	gtk_widget_destroy (GTK_WIDGET (dialog));
-	if (response == GTK_RESPONSE_NO) {
-		thread_data_free (thdata);
-		quit_if_no_other_workspace ();
-		return;
-	}
-	else
-		open_connection (thdata);	
-}
-
-/* 
- * called in main thread by an idle loop when thread_load_dict() has finished
- */
-static void
-thread_load_dict_finished (GdaThreader *thread, guint job_id, ThreadData *thdata)
-{
-	g_source_remove (thdata->timeout_id);
-	thdata->timeout_id = 0;
-	
-	if (! thdata->func_retval) {
-		GError *error = *(thdata->error);
-		thdata->force_dbms_update = TRUE;
-
-		if ((error->domain != GDA_DICT_ERROR) || 
-		    (error->code != GDA_DICT_LOAD_FILE_NOT_EXIST_ERROR)) {
-			GtkWidget *dlg;
-			gchar *msg;
-			
-			gtk_widget_hide (dsn_dialog);
-			/* limit the size of error message to 10 lines */
-			if (error->message) {
-				gchar *ptr;
-				gint nlnb = 10;
-				for (ptr = error->message; ptr && (ptr-error->message < 500) && (nlnb >= 0); ptr++) {
-					if (*ptr == '\n')
-						nlnb--;
-				}
-				if (*ptr) {
-					/* truncate error message */
-					ptr -= 7;
-					strcpy (ptr, "\n[...]");
-				}
-			}
-			msg = g_markup_printf_escaped (_("<b><big>Failed loading data dictionary</big></b>\n"
-							 "<small>The previously saved data dictionary for this connection "
-							 "can't be loaded because it contains errors:\n%s</small>\n\n"
-							 "Do you want to force a synchronization with the database "
-							 "dictionary now?\n\n"
-							 "<small><u>Warning:</u> if you answer 'Yes', all the queries, etc. "
-							 "defined will be lost; answering 'No' allows you try to fix the "
-							 "error</small>"), error->message);
-			dlg = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_MODAL,
-								  GTK_MESSAGE_QUESTION,
-								  GTK_BUTTONS_YES_NO, " ");
-			gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dlg), msg);
-			g_free (msg);
-
-			g_signal_connect (G_OBJECT (dlg), "destroy", G_CALLBACK
-					  (load_dict_error_choose_cb), thdata);
-			g_signal_connect (G_OBJECT (dlg), "response", G_CALLBACK
-					  (load_dict_error_choose_cb), thdata);
-			gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
-			gtk_widget_show (dlg);
-		}
-		else 
-			open_connection (thdata);	
-
-		g_error_free (error);
-		*(thdata->error) = NULL;
-	}
-	else
-		open_connection (thdata);
-}
-
-
 static void 
-create_new_workspace_window_no_dict_choose_cb (GtkDialog *dialog, gint response, gpointer data)
+create_new_workspace_window_no_cnc_choose_cb (GtkDialog *dialog, gint response, gpointer data)
 {
 	WorkspaceWindowPrivate *priv;
-	GdaDict *workdict = NULL;
-	const gchar *dsn;
+	GdaConnection *cnc = NULL;
+	const gchar *dsn, *auth;
 	GList *list = opened_workspaces;
-	gchar *username, *password;
 	GtkWidget *nb;
 
 	if (response != GTK_RESPONSE_OK) {
@@ -950,21 +792,16 @@
 	}
 
 	/* User has selected a data source */
-	username = (gchar *) gnome_db_login_dialog_get_username (GNOME_DB_LOGIN_DIALOG (dialog));
-	if (username)
-		username = g_strdup (username);
-	password = (gchar *) gnome_db_login_dialog_get_password (GNOME_DB_LOGIN_DIALOG (dialog));
-	if (password)
-		password = g_strdup (password);
+	auth = gnome_db_login_dialog_get_auth (GNOME_DB_LOGIN_DIALOG (dialog));
 		
 	/* try to find another workspace window with the same DSN */
 	dsn = gnome_db_login_dialog_get_dsn (GNOME_DB_LOGIN_DIALOG (dialog));
-	while (list && !workdict) {
+	while (list && !cnc) {
 		gchar *dsn2;
 		priv = (WorkspaceWindowPrivate *) list->data;
-		dsn2 = (gchar *) gda_connection_get_dsn (gda_dict_get_connection (priv->dict));
+		dsn2 = (gchar *) gda_connection_get_dsn (priv->cnc);
 		if (!strcmp (dsn, dsn2)) 
-			workdict = priv->dict;
+			cnc = priv->cnc;
 		g_free (dsn2);
 		
 		list = g_list_next (list);
@@ -975,42 +812,30 @@
 	gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), 1);
 	gtk_widget_set_sensitive (GTK_DIALOG (dsn_dialog)->action_area, FALSE);
 
-	/* use workdict if not NULL, or create a new one */
-	if (workdict) {
-		create_new_workspace_window_with_dict (workdict, FALSE, NULL);
+	/* use cnc if not NULL, or create a new one */
+	if (cnc) {
+		create_new_workspace_window_with_cnc (cnc, FALSE, NULL);
 		gtk_widget_hide (dsn_dialog);
 	}
 	else {
-		gchar *filename = NULL;
 		ThreadData *thdata;
 		GdaThreader *threader;
 		GtkWidget *wid;		
 		gchar *str;
 
-		workdict = gda_dict_new ();
-		
-		filename = gda_dict_compute_xml_filename (workdict, dsn, NULL, NULL);
-		gda_dict_set_xml_filename (workdict, filename);
-
 		/* structure passed during the multi-thread */
 		thdata = g_new0 (ThreadData, 1);
-		thdata->dict = workdict;
 		thdata->dsn = g_strdup (dsn);
-		thdata->username = username;
-		username = NULL;
-		thdata->password = password;
-		password = NULL;
+		if (auth)
+			thdata->auth = g_strdup (auth);
 		thdata->func_retval = FALSE;
-		thdata->filename = filename;
 		thdata->error = g_new0 (GError *, 1);
 
 		/* set the label */
 		wid = g_object_get_data (G_OBJECT (dsn_dialog), "info_label");
 		thdata->label = wid;
-		str = g_strdup_printf ("<b>%s:</b>\n%s", _("Loading dictionary"),
-				       _("The dictionary is a file where data from a previous "
-					 "session is stored. If this is the first session for the "
-					 "requested data source, then there is no dictionary."));
+		str = g_strdup_printf ("<b>%s:</b>\n%s", _("Opening connection"),
+				       _("The connection to the data source is now being opened."));
 		gtk_label_set_markup (GTK_LABEL (wid), str);
 		g_free (str);
 		gtk_widget_show (wid);
@@ -1022,26 +847,25 @@
 		
 		thdata->timeout_id = g_timeout_add (PROGRESS_BAR_TIMEOUT, (GSourceFunc) update_progress_bar, wid);
 
-		/* try loading dictionary */
+		/* try opening the connection */
 		threader = GDA_THREADER (gda_threader_new ());
 		thdata->threader = threader;
-		gda_threader_start_thread (threader, (GThreadFunc) thread_load_dict, thdata, 
-					   (GdaThreaderFunc) thread_load_dict_finished, NULL, NULL);
-	}
+		gda_threader_start_thread (thdata->threader, (GThreadFunc) thread_open_connect, thdata, 
+					   (GdaThreaderFunc) thread_open_connect_finished, NULL, NULL);
 
-	g_free (username);
-	g_free (password);
+		
+	}
 }
 
 static void 
-create_new_workspace_window_no_dict_destroy_cb (GtkDialog *dialog, gpointer data)
+create_new_workspace_window_no_cnc_destroy_cb (GtkDialog *dialog, gpointer data)
 {
 	gtk_widget_hide (GTK_WIDGET (dialog));
 	quit_if_no_other_workspace ();
 }
 
 static void 
-create_new_workspace_window_no_dict (WorkspaceOptions *options)
+create_new_workspace_window_no_cnc (WorkspaceOptions *options)
 {
 	GtkWidget *nb;
 
@@ -1049,11 +873,11 @@
 		GtkWidget *wid, *hbox, *vbox;
 
 		/* dialog to choose the connection */
-		dsn_dialog = gnome_db_login_dialog_new (_("Connect"));
+		dsn_dialog = gnome_db_login_dialog_new (_("Connect"), NULL);
 		g_signal_connect (G_OBJECT (dsn_dialog), "destroy", G_CALLBACK
-				  (create_new_workspace_window_no_dict_destroy_cb), NULL);
+				  (create_new_workspace_window_no_cnc_destroy_cb), NULL);
 		g_signal_connect (G_OBJECT (dsn_dialog), "response", G_CALLBACK
-				  (create_new_workspace_window_no_dict_choose_cb), NULL);
+				  (create_new_workspace_window_no_cnc_choose_cb), NULL);
 		gtk_window_set_modal (GTK_WINDOW (dsn_dialog), TRUE);
 
 		nb = g_object_get_data (G_OBJECT (dsn_dialog), "main_part");

Modified: trunk/src/workspace-window.h
==============================================================================
--- trunk/src/workspace-window.h	(original)
+++ trunk/src/workspace-window.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* Mergeant
  *
- * Copyright (C) 1999 - 2006 Vivien Malerba
+ * Copyright (C) 1999 - 2008 Vivien Malerba
  * Copyright (C) 2002 - 2003 Rodrigo Moya
  *
  * Authors:
@@ -27,7 +27,7 @@
 #define __WORKSPACE_WINDOW_H__
 
 #include <gtk/gtkwidget.h>
-#include <libgda/gda-dict.h>
+#include <libgda/libgda.h>
 
 typedef struct {
 	gchar *dsn;
@@ -36,7 +36,7 @@
 	gchar *start_page;
 } WorkspaceOptions;
 
-void create_new_workspace_window      (GdaDict *dict);
+void create_new_workspace_window      (GdaConnection *cnc);
 void create_new_workspace_window_spec (WorkspaceOptions *options);
 
 #endif

Modified: trunk/src/workspace.c
==============================================================================
--- trunk/src/workspace.c	(original)
+++ trunk/src/workspace.c	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* Mergeant
  *
- * Copyright (C) 1999 - 2007 Vivien Malerba
+ * Copyright (C) 1999 - 2008 Vivien Malerba
  * Copyright (C) 2002 - 2003 Rodrigo Moya
  *
  * Authors:
@@ -43,12 +43,9 @@
 
 
 struct _WorkspacePrivate {
-	GdaDict        *dict;
+	GdaConnection  *cnc;
 	GtkUIManager   *ui;
 	
-	guint           timeout_event_dict_save; /* returned by g_timeout_add() */
-	guint           idle_event_dict_save; /* returned from g_idle_add() */
-
 	/* main page */
 	GtkWidget      *main_horiz_pane;
 
@@ -92,7 +89,6 @@
 	wk->priv = g_new0 (WorkspacePrivate, 1);
 }
 
-static void dict_changed_cb (GdaDict *dict, Workspace *wk);
 static void
 workspace_dispose (GObject *object)
 {
@@ -132,9 +128,6 @@
 
 	/* free memory */
 	if (wk->priv) {
-		g_signal_handlers_disconnect_by_func (G_OBJECT (wk->priv->dict),
-						      G_CALLBACK (dict_changed_cb), wk);
-
 		g_free (wk->priv);
 		wk->priv = NULL;
 	}
@@ -167,18 +160,18 @@
 
 /**
  * workspace_new
- * @dict:
+ * @cnc: a connection object
  *
  * Returns:
  */
 GtkWidget *
-workspace_new (GdaDict *dict, GtkUIManager *ui)
+workspace_new (GdaConnection *cnc, GtkUIManager *ui)
 {
 	Workspace *wk;
 	WorkspacePage *page;
 
 	wk = g_object_new (workspace_get_type (), NULL);
-	workspace_set_dict (wk, dict);
+	workspace_set_connection (wk, cnc);
 
 	if (ui) {
 		wk->priv->ui = ui;
@@ -187,17 +180,19 @@
 
 	/* create the pages' objects */
 	wk->priv->pages_objects = NULL;
-	page = WORKSPACE_PAGE (ws_tables_new (dict));
+	page = WORKSPACE_PAGE (ws_tables_new (cnc));
 	wk->priv->pages_objects = g_slist_append (wk->priv->pages_objects, page);
 
-	page = WORKSPACE_PAGE (ws_queries_new (dict));
+#ifdef CODEOK
+	page = WORKSPACE_PAGE (ws_queries_new (cnc));
 	wk->priv->pages_objects = g_slist_append (wk->priv->pages_objects, page);
 
-	page = WORKSPACE_PAGE (ws_dbrels_new (dict));
+	page = WORKSPACE_PAGE (ws_dbrels_new (cnc));
 	wk->priv->pages_objects = g_slist_append (wk->priv->pages_objects, page);
 
-	page = WORKSPACE_PAGE (ws_datatypes_new (dict));
+	page = WORKSPACE_PAGE (ws_datatypes_new (cnc));
 	wk->priv->pages_objects = g_slist_append (wk->priv->pages_objects, page);
+#endif
 
 	/* initialize all the widgets */
 	create_widgets (wk);
@@ -205,20 +200,20 @@
 	return GTK_WIDGET (wk);
 }
 
-GdaDict *
-workspace_get_dict (Workspace *wk)
+GdaConnection *
+workspace_get_connection (Workspace *wk)
 {
-	return wk->priv->dict;
+	return wk->priv->cnc;
 }
 
 void
-workspace_set_dict (Workspace *wk, GdaDict *dict)
+workspace_set_connection (Workspace *wk, GdaConnection *cnc)
 {
-	wk->priv->dict = dict;
-
-	/* connecting to GdaDict's signals to handle auto saving */
-	g_signal_connect (G_OBJECT (dict), "changed",
-			  G_CALLBACK (dict_changed_cb), wk);
+	if (wk->priv->cnc)
+		g_object_unref (wk->priv->cnc);
+	wk->priv->cnc = cnc;
+	if (cnc)
+		g_object_ref (cnc);
 }
 
 
@@ -378,42 +373,6 @@
 	workspace_show_page (wk, GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "pageno")));
 }
 
-static void
-dict_changed_cb (GdaDict *dict, Workspace *wk)
-{
-	workspace_queue_dict_save (wk);	
-}
-
-static gboolean timeout_dict_save_cb (Workspace *wk);
-static gboolean idle_dict_save_cb (Workspace *wk);
-void
-workspace_queue_dict_save (Workspace *wk)
-{
-	if (wk->priv->timeout_event_dict_save)
-		g_source_remove (wk->priv->timeout_event_dict_save);
-	
-	wk->priv->timeout_event_dict_save = g_timeout_add (5000, (GSourceFunc) timeout_dict_save_cb, wk);
-}
-
-static gboolean
-timeout_dict_save_cb (Workspace *wk)
-{
-	if (wk->priv->idle_event_dict_save == 0) 
-		wk->priv->idle_event_dict_save = g_idle_add ((GSourceFunc) idle_dict_save_cb, wk);
-	wk->priv->timeout_event_dict_save = 0;
-
-	return FALSE;
-}
-
-static gboolean
-idle_dict_save_cb (Workspace *wk)
-{
-	gda_dict_save (wk->priv->dict, NULL);
-	wk->priv->idle_event_dict_save = 0;
-
-	return FALSE;
-}
-
 /**
  * workspace_show_page
  * @wk:

Modified: trunk/src/workspace.h
==============================================================================
--- trunk/src/workspace.h	(original)
+++ trunk/src/workspace.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* Mergeant
  *
- * Copyright (C) 1999 - 2006 Vivien Malerba
+ * Copyright (C) 1999 - 2008 Vivien Malerba
  * Copyright (C) 2002 - 2003 Rodrigo Moya
  *
  * Authors:
@@ -26,7 +26,7 @@
 #ifndef __WORKSPACE_H__
 #define __WORKSPACE_H__
 
-#include <libgda/gda-dict.h>
+#include <libgda/libgda.h>
 #include <gtk/gtkvbox.h>
 
 #define WORKSPACE_TYPE          (workspace_get_type())
@@ -53,12 +53,10 @@
 } WorkspacePageId;
 
 GType           workspace_get_type        (void);
-GtkWidget      *workspace_new             (GdaDict *dict, GtkUIManager *ui);
-
-GdaDict        *workspace_get_dict        (Workspace *wk);
-void            workspace_set_dict        (Workspace *wk, GdaDict *dict);
-
-void            workspace_queue_dict_save (Workspace *wk);
+GtkWidget      *workspace_new             (GdaConnection *cnc, GtkUIManager *ui);
 
+GdaConnection  *workspace_get_connection  (Workspace *wk);
+void            workspace_set_connection  (Workspace *wk, GdaConnection *cnc);
 void            workspace_show_page       (Workspace *wk, WorkspacePageId page_id);
+
 #endif

Modified: trunk/src/ws-datatypes.h
==============================================================================
--- trunk/src/ws-datatypes.h	(original)
+++ trunk/src/ws-datatypes.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* ws-datatypes.h
  *
- * Copyright (C) 2004 Vivien Malerba
+ * Copyright (C) 2004 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -51,7 +51,7 @@
 };
 
 GType           ws_datatypes_get_type          (void);
-GObject        *ws_datatypes_new               (GdaDict *dict);
+GObject        *ws_datatypes_new               (GdaConnection *cnc);
 
 G_END_DECLS
 

Modified: trunk/src/ws-dbrels.h
==============================================================================
--- trunk/src/ws-dbrels.h	(original)
+++ trunk/src/ws-dbrels.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* ws-dbrels.h
  *
- * Copyright (C) 2004 Vivien Malerba
+ * Copyright (C) 2004 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -52,7 +52,7 @@
 };
 
 GType           ws_dbrels_get_type          (void);
-GObject        *ws_dbrels_new               (GdaDict *dict);
+GObject        *ws_dbrels_new               (GdaConnection *cnc);
 
 G_END_DECLS
 

Modified: trunk/src/ws-queries.h
==============================================================================
--- trunk/src/ws-queries.h	(original)
+++ trunk/src/ws-queries.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* ws-queries.h
  *
- * Copyright (C) 2004 - 2006 Vivien Malerba
+ * Copyright (C) 2004 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -52,7 +52,7 @@
 };
 
 GType           ws_queries_get_type          (void);
-GObject        *ws_queries_new               (GdaDict *dict);
+GObject        *ws_queries_new               (GdaConnection *cnc);
 
 G_END_DECLS
 

Modified: trunk/src/ws-tables.c
==============================================================================
--- trunk/src/ws-tables.c	(original)
+++ trunk/src/ws-tables.c	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* ws-tables.c
  *
- * Copyright (C) 2004 - 2007 Vivien Malerba
+ * Copyright (C) 2004 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -29,6 +29,7 @@
 #include "utils.h"
 #include "mg-extra-formgrid.h"
 #include "mg-plugin-editor.h"
+#include <sql-parser/gda-sql-statement.h>
 
 /* 
  * Main static functions 
@@ -56,7 +57,7 @@
 /* private structure */
 struct _WsTablesPrivate
 {
-	GdaDict        *dict;
+	GdaConnection  *cnc;
 	GtkWidget      *selector;
 	GtkWidget      *work_area;
 	GtkActionGroup *actions;
@@ -66,7 +67,12 @@
 	GtkWidget      *fields;
 	GtkTextBuffer  *integ_descr;
 
-	GObject        *sel_obj;
+	GdaMetaStruct   *mstruct;
+	GdaMetaDbObject *sel_dbo;
+	GValue          *sel_catalog;
+	GValue          *sel_schema;
+	GValue          *sel_table;
+
 	GSList         *opened_dialogs;
 };
 
@@ -133,24 +139,24 @@
 
 /**
  * ws_tables_new
- * @dict: a #GdaDict object
+ * @cnc: a #GdaConnection object
  *
  * Creates a new WsTables object
  *
  * Returns: the new object
  */
 GObject*
-ws_tables_new (GdaDict *dict)
+ws_tables_new (GdaConnection *cnc)
 {
 	GObject  *obj;
 	WsTables *ws;
 
-	g_return_val_if_fail (dict && GDA_IS_DICT (dict), NULL);
+	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
 	obj = g_object_new (WS_TABLES_TYPE, NULL);
 	ws = WS_TABLES (obj);
-	ws->priv->dict = dict;
-	g_object_ref (G_OBJECT (dict));
+	ws->priv->cnc = cnc;
+	g_object_ref (cnc);
 
 	ws_tables_initialize (ws);
 
@@ -168,6 +174,25 @@
 
 	ws = WS_TABLES (object);
 	if (ws->priv) {
+		if (ws->priv->mstruct) {
+			g_object_unref (ws->priv->mstruct);
+			ws->priv->mstruct = NULL;
+			ws->priv->sel_dbo = NULL;
+		}
+
+		if (ws->priv->sel_catalog) {
+			gda_value_free (ws->priv->sel_catalog);
+			ws->priv->sel_catalog = NULL;
+		}
+		if (ws->priv->sel_schema) {
+			gda_value_free (ws->priv->sel_schema);
+			ws->priv->sel_schema = NULL;
+		}
+		if (ws->priv->sel_table) {
+			gda_value_free (ws->priv->sel_table);
+			ws->priv->sel_table = NULL;
+		}
+
 		while (ws->priv->opened_dialogs) 
 			gtk_widget_destroy (GTK_WIDGET (ws->priv->opened_dialogs->data));
 
@@ -186,9 +211,9 @@
 			ws->priv->actions = NULL;
 		}
 
-		if (ws->priv->dict) {
-			g_object_unref (G_OBJECT (ws->priv->dict));
-			ws->priv->dict = NULL;
+		if (ws->priv->cnc) {
+			g_object_unref (G_OBJECT (ws->priv->cnc));
+			ws->priv->cnc = NULL;
 		}
 	}
 
@@ -262,23 +287,34 @@
         "</ui>";
 
 
-static void table_row_activated_cb (GnomeDbSelector *mgsel, GObject *sel_object, WsTables *ws);
-static void table_selection_changed_cb (GnomeDbSelector *mgsel, GObject *sel_object, WsTables *ws);
+static void table_row_activated_cb (GnomeDbSelector *mgsel, GtkTreePath *path,
+				    GtkTreeViewColumn *column, WsTables *ws);
+static void table_selection_changed_cb (GnomeDbSelector *mgsel, GnomeDbSelectorPart *part,
+					GtkTreeStore *store, GtkTreeIter *iter, WsTables *ws);
 static void field_selection_changed_cb (GnomeDbSelector *mgsel, GObject *sel_object, MgPluginEditor *editor);
-static void table_updated_cb (GdaDictDatabase *db, GdaDictTable *table, WsTables *ws);
+static void meta_changed_cb (GdaMetaStore *store, GSList *changes, WsTables *ws);
 static void
 ws_tables_initialize (WsTables *ws)
 {
 	GtkWidget *label, *vbox, *wid, *nb, *vp, *vbox2, *hbox, *sw, *exp;
 
 	/* Selector part */
-	wid = gnome_db_selector_new (ws->priv->dict, NULL,
-			       GNOME_DB_SELECTOR_TABLES, GNOME_DB_SELECTOR_COLUMN_TYPE);
-	ws->priv->selector = wid;
-	g_signal_connect (G_OBJECT (ws->priv->selector), "selection_changed", 
+	sw = gtk_scrolled_window_new (NULL, NULL);
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
+					GTK_POLICY_AUTOMATIC);
+	ws->priv->selector = sw;
+
+	wid = gnome_db_selector_new ();
+	gnome_db_selector_add_parts_for_feature (GNOME_DB_SELECTOR (wid), gda_connection_get_meta_store (ws->priv->cnc), 
+						 GNOME_DB_SELECTOR_FEATURE_SCHEMAS | 
+						 GNOME_DB_SELECTOR_FEATURE_SCHEMA_TABLES |
+						 GNOME_DB_SELECTOR_FEATURE_SCHEMA_VIEWS);
+	gtk_widget_show (wid);
+	gtk_container_add (GTK_CONTAINER (sw), wid);
+	g_signal_connect (G_OBJECT (wid), "selected-object-changed", 
 			  G_CALLBACK (table_selection_changed_cb), ws);
 	gtk_widget_set_size_request (wid, 200, -1);
-	g_signal_connect (G_OBJECT (ws->priv->selector), "row_activated",
+	g_signal_connect (G_OBJECT (wid), "row-activated",
 			  G_CALLBACK (table_row_activated_cb), ws);
 
 	/* WorkArea part */
@@ -292,7 +328,7 @@
 	gtk_widget_show (nb);
 	ws->priv->notebook = nb;
 	
-	label = gtk_label_new (_("Please select a table from the list on the left,\n"
+	label = gtk_label_new (_("Please select a table or view from the list on the left,\n"
 				 "or create a new one using the 'Add' button below."));
 	gtk_notebook_append_page (GTK_NOTEBOOK (nb), label, NULL);
 	gtk_widget_show (label);
@@ -330,14 +366,14 @@
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	gtk_widget_show (label);
 
-	wid = gnome_db_selector_new (ws->priv->dict, NULL,
-				     GNOME_DB_SELECTOR_FIELDS, 
-				     GNOME_DB_SELECTOR_COLUMN_TYPE | GNOME_DB_SELECTOR_COLUMN_FIELD_LENGTH | 
-				     GNOME_DB_SELECTOR_COLUMN_FIELD_NNUL |
-				     GNOME_DB_SELECTOR_COLUMN_FIELD_DEFAULT | GNOME_DB_SELECTOR_COLUMN_COMMENTS);
+	wid = gnome_db_grid_new (NULL);
 	gtk_box_pack_start (GTK_BOX (hbox), wid, TRUE, TRUE, 0);
 	gtk_widget_show (wid);
-	ws->priv->fields = wid;
+	GnomeDbDataWidgetInfo *winfo;
+	g_object_get (G_OBJECT (wid), "raw-grid", &(ws->priv->fields), "widget-info", &winfo, NULL);
+	g_object_unref (ws->priv->fields);
+	g_object_set (G_OBJECT (winfo), "flags", GNOME_DB_DATA_WIDGET_INFO_NONE, NULL);
+	g_object_unref (winfo);
 
 	vbox2 = gtk_vbox_new (FALSE, 5);
 	gtk_paned_add2 (GTK_PANED (vp), vbox2);
@@ -379,8 +415,10 @@
 				    "weight", PANGO_WEIGHT_BOLD,
 				    "foreground", "blue", NULL);
 
-	g_signal_connect (G_OBJECT (gda_dict_get_database (ws->priv->dict)), "table_updated",
-			  G_CALLBACK (table_updated_cb), ws);
+	GdaMetaStore *store;
+	store = gda_connection_get_meta_store (ws->priv->cnc);
+	g_signal_connect (G_OBJECT (store), "meta-changed",
+			  G_CALLBACK (meta_changed_cb), ws);
 
 
 	exp = gtk_expander_new (_("<b>Field's display specifications</b>"));
@@ -395,11 +433,14 @@
 	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 	gtk_widget_show (label);
 
-	wid = mg_plugin_editor_new (ws->priv->dict);
+#ifdef CODEOK
+	wid = mg_plugin_editor_new (ws->priv->cnc);
 	gtk_box_pack_start (GTK_BOX (hbox), wid, TRUE, TRUE, 0);
 	gtk_widget_show (wid);
+	
 	g_signal_connect (G_OBJECT (ws->priv->fields), "selection-changed",
 			  G_CALLBACK (field_selection_changed_cb), wid);
+#endif
 
 	/* actions part */
 	ws->priv->actions = gtk_action_group_new ("Actions");
@@ -410,7 +451,7 @@
 		GdaConnection *cnc;
 		GdaServerProvider *prov;
 
-		cnc = gda_dict_get_connection (ws->priv->dict);
+		cnc = ws->priv->cnc;
 		prov = gda_connection_get_provider_obj (cnc);
 		g_assert (prov);
 
@@ -447,95 +488,183 @@
 	}
 }
 
-static void table_info_display_update (GdaDictTable *table, WsTables *ws);
+static void table_info_display_update (WsTables *ws);
 
 static void
-table_selection_changed_cb (GnomeDbSelector *mgsel, GObject *sel_object, WsTables *ws)
+table_selection_changed_cb (GnomeDbSelector *mgsel, GnomeDbSelectorPart *part,
+			    GtkTreeStore *store, GtkTreeIter *iter, WsTables *ws)
 {
 	GtkAction *action;
+	const GValue *cvalue1, *cvalue2, *cvalue3;
+	gboolean have_table_name = FALSE;
 
-	if (sel_object && !GDA_IS_DICT_TABLE (sel_object))
+	cvalue1 = gnome_db_selector_part_get_value (part, "catalog", store, iter);
+	cvalue2 = gnome_db_selector_part_get_value (part, "schema", store, iter);
+	cvalue3 = gnome_db_selector_part_get_value (part, "table_name", store, iter);
+	if (! gda_value_compare_ext (cvalue1, ws->priv->sel_catalog) &&
+	    ! gda_value_compare_ext (cvalue2, ws->priv->sel_schema) &&
+	    ! gda_value_compare_ext (cvalue3, ws->priv->sel_table))
 		return;
 
-	ws->priv->sel_obj = sel_object;
-	gtk_notebook_set_current_page (GTK_NOTEBOOK (ws->priv->notebook), sel_object ? 1 : 0);
+	ws->priv->sel_dbo = NULL;
+	
+	if (ws->priv->sel_catalog) {
+		gda_value_free (ws->priv->sel_catalog);
+		ws->priv->sel_catalog = NULL;
+	}
+	if (ws->priv->sel_schema) {
+		gda_value_free (ws->priv->sel_schema);
+		ws->priv->sel_schema = NULL;
+	}
+	if (ws->priv->sel_table) {
+		gda_value_free (ws->priv->sel_table);
+		ws->priv->sel_table = NULL;
+	}
+
+	if (cvalue3) {
+		ws->priv->sel_table = gda_value_copy (cvalue3);
+
+		if (!ws->priv->mstruct) 
+			/* FIXME: check that meta struct's current data is still up to date */
+			ws->priv->mstruct = gda_meta_struct_new (gda_connection_get_meta_store (ws->priv->cnc),
+								 GDA_META_STRUCT_FEATURE_FOREIGN_KEYS);
+
+		ws->priv->sel_dbo = gda_meta_struct_complement (ws->priv->mstruct, 
+								GDA_META_DB_TABLE, cvalue1,
+								cvalue2, cvalue3, NULL);
+		if (!ws->priv->sel_dbo)
+			ws->priv->sel_dbo = gda_meta_struct_complement (ws->priv->mstruct, 
+									GDA_META_DB_VIEW, cvalue1,
+									cvalue2, cvalue3, NULL);
+		if (ws->priv->sel_dbo) {
+			have_table_name = TRUE;
+			g_value_set_string ((ws->priv->sel_catalog = gda_value_new (G_TYPE_STRING)), 
+					    ws->priv->sel_dbo->obj_catalog);
+			g_value_set_string ((ws->priv->sel_schema = gda_value_new (G_TYPE_STRING)), 
+					    ws->priv->sel_dbo->obj_schema);
+		}
+	}
+
+	gtk_notebook_set_current_page (GTK_NOTEBOOK (ws->priv->notebook), have_table_name ? 1 : 0);
 
 	action = gtk_action_group_get_action (ws->priv->actions, "DROP_TABLE");
 	if (action)
-		gtk_action_set_sensitive (action, sel_object ? TRUE : FALSE);
+		gtk_action_set_sensitive (action, have_table_name ? TRUE : FALSE);
 
 	action = gtk_action_group_get_action (ws->priv->actions, "RENAME_TABLE");
 	if (action)
-		gtk_action_set_sensitive (action, sel_object ? TRUE : FALSE);
+		gtk_action_set_sensitive (action, have_table_name ? TRUE : FALSE);
 
 	action = gtk_action_group_get_action (ws->priv->actions, "ADD_COLUMN");
 	if (action)
-		gtk_action_set_sensitive (action, sel_object ? TRUE : FALSE);
+		gtk_action_set_sensitive (action, have_table_name ? TRUE : FALSE);
 
 	action = gtk_action_group_get_action (ws->priv->actions, "DROP_COLUMN");
 	if (action)
-		gtk_action_set_sensitive (action, sel_object ? TRUE : FALSE);
+		gtk_action_set_sensitive (action, have_table_name ? TRUE : FALSE);
 
 	action = gtk_action_group_get_action (ws->priv->actions, "TableContents");
-	gtk_action_set_sensitive (action, sel_object ? TRUE : FALSE);
+	gtk_action_set_sensitive (action, have_table_name ? TRUE : FALSE);
 
-	table_info_display_update ((GdaDictTable *) sel_object, ws);
+	table_info_display_update (ws);
 }
 
-static void show_table_contents (WsTables *ws, GdaDictTable *table);
+static void show_table_contents (WsTables *ws);
 
 static void
-table_row_activated_cb (GnomeDbSelector *mgsel, GObject *sel_object, WsTables *ws)
+table_row_activated_cb (GnomeDbSelector *mgsel, GtkTreePath *path,
+			GtkTreeViewColumn *column, WsTables *ws)
 {
 	/* show contents of @sel_object */
-	if (sel_object && !GDA_IS_DICT_TABLE (sel_object))
+	if (!ws->priv->sel_dbo || !(ws->priv->sel_dbo->obj_type == GDA_META_DB_TABLE))
 		return;
-	show_table_contents (ws, GDA_DICT_TABLE (sel_object));
+	show_table_contents (ws);
 }
 
 static void
-table_updated_cb (GdaDictDatabase *db, GdaDictTable *table, WsTables *ws)
+meta_changed_cb (GdaMetaStore *store, GSList *changes, WsTables *ws)
 {
-	if ((GObject *)table == ws->priv->sel_obj)
-		table_info_display_update (table, ws);
+	/* FIXME: filter on the @changes */
+	table_info_display_update (ws);
 }
 
 static void
 action_table_contents_cb (GtkAction *action, WsTables *ws)
 {
-	show_table_contents (ws, GDA_DICT_TABLE (ws->priv->sel_obj));
+	show_table_contents (ws);
 }
 
 static void
-show_table_contents (WsTables *ws, GdaDictTable *table)
+show_table_contents (WsTables *ws)
 {
-	GdaQuery *query;
-	GdaDict *dict = ws->priv->dict;
+	/* statement creation... */
+	GdaStatement *stmt;
+	GdaSqlStatement *st;
+	GdaSqlStatementSelect *sst;
+	GdaSqlSelectTarget *target;
+	GdaSqlSelectField *selfield;
+	GdaSqlExpr *expr;
+	
+	g_assert (ws->priv->sel_dbo);
+	g_assert ((ws->priv->sel_dbo->obj_type == GDA_META_DB_VIEW) ||
+		  (ws->priv->sel_dbo->obj_type == GDA_META_DB_TABLE));
+
+	sst = g_new0 (GdaSqlStatementSelect, 1);
+        GDA_SQL_ANY_PART (sst)->type = GDA_SQL_ANY_STMT_SELECT;
+
+	sst->from = g_new0 (GdaSqlSelectFrom, 1);
+	GDA_SQL_ANY_PART (sst->from)->type = GDA_SQL_ANY_SQL_SELECT_FROM;
+	GDA_SQL_ANY_PART (sst->from)->parent = GDA_SQL_ANY_PART (sst);
+
+	/* ... target part */
+	target = g_new0 (GdaSqlSelectTarget, 1);
+	GDA_SQL_ANY_PART (target)->type = GDA_SQL_ANY_SQL_SELECT_TARGET;
+	GDA_SQL_ANY_PART (target)->parent = GDA_SQL_ANY_PART (sst->from);
+	sst->from->targets = g_slist_append (NULL, target);
+	
+	expr = g_new0 (GdaSqlExpr, 1);
+	GDA_SQL_ANY_PART (expr)->type = GDA_SQL_ANY_EXPR;
+	GDA_SQL_ANY_PART (expr)->parent = GDA_SQL_ANY_PART (target);
+	target->expr = expr;
+	g_value_set_string ((expr->value = gda_value_new (G_TYPE_STRING)), ws->priv->sel_dbo->obj_full_name);
+
+	/* ... fields list part */
+	GdaMetaTable *mtable = GDA_META_TABLE (ws->priv->sel_dbo);
+	GSList *list;
+	for (list = mtable->columns; list; list = list->next) {
+		selfield = g_new0 (GdaSqlSelectField, 1);
+		GDA_SQL_ANY_PART (selfield)->type = GDA_SQL_ANY_SQL_SELECT_FIELD;
+		GDA_SQL_ANY_PART (selfield)->parent = GDA_SQL_ANY_PART (sst);
+		sst->expr_list = g_slist_append (sst->expr_list, selfield);
+		
+		expr = g_new0 (GdaSqlExpr, 1);
+		GDA_SQL_ANY_PART (expr)->type = GDA_SQL_ANY_EXPR;
+		GDA_SQL_ANY_PART (expr)->parent = GDA_SQL_ANY_PART (selfield);
+		selfield->expr = expr;
+		g_value_set_string ((expr->value = gda_value_new (G_TYPE_STRING)), 
+				    GDA_META_TABLE_COLUMN (list->data)->column_name);
+	}
+	
+	st = gda_sql_statement_new (GDA_SQL_STATEMENT_SELECT);
+        st->contents = sst;
+	g_print ("==> %s\n", gda_sql_statement_serialize (st));
+
+	stmt = gda_statement_new ();
+	g_object_set (stmt, "structure", st, NULL);
+	gda_sql_statement_free (st);
+
 	GError *error = NULL;
 	GtkWidget *window = NULL;
-	GdaQueryTarget* target;
-        GdaQueryField* allFields;
 
 	GtkWidget *grid, *label;
 	gchar *str, *mstr, *warn = NULL;
 	GdaDataModel *model;
 
-	/* query */
-	query = gda_query_new (dict);
-        gda_query_set_query_type (query, GDA_QUERY_TYPE_SELECT);
-	target = gda_query_target_new (query, gda_object_get_name (GDA_OBJECT (table)));
-	gda_query_add_target (query, target, NULL);
-        g_object_unref (G_OBJECT(target));
-	allFields = gda_query_field_all_new (query, gda_object_get_name (GDA_OBJECT (table)));
-        gda_query_field_set_visible (allFields, TRUE);
-        gda_entity_add_field (GDA_ENTITY (query), GDA_ENTITY_FIELD (allFields));
-        g_object_unref (G_OBJECT (allFields));
-
 	/* data model */
-	model = gda_data_model_query_new (query);
-	if (! gda_dict_table_is_view (table)) {
-		if (!gda_data_model_query_compute_modification_queries (GDA_DATA_MODEL_QUERY (model), 
-									NULL, 0, &error)) {
+	model = gda_data_model_query_new (ws->priv->cnc, stmt);
+	g_object_unref (stmt);
+	if (ws->priv->sel_dbo->obj_type == GDA_META_DB_TABLE) {
+		if (!gda_data_model_query_compute_modification_queries (GDA_DATA_MODEL_QUERY (model), NULL, 0, &error)) {
 			if (error && error->message)
 				warn = g_strdup_printf (_("Data cannot be modified for the following reason:\n%s"), 
 							error->message);
@@ -552,10 +681,10 @@
 	grid = mg_extra_formgrid_new (model);
 	g_object_unref (model);
 
-	if (gda_dict_table_is_view (table))
-		str = g_strdup_printf (_("Contents of view '%s'"), gda_object_get_name (table));
+	if (ws->priv->sel_dbo->obj_type == GDA_META_DB_VIEW)
+		str = g_strdup_printf (_("Contents of view '%s'"), ws->priv->sel_dbo->obj_short_name);
 	else
-		str = g_strdup_printf (_("Contents of table '%s'"), gda_object_get_name (table));
+		str = g_strdup_printf (_("Contents of table '%s'"), ws->priv->sel_dbo->obj_short_name);
 
 	window = gtk_dialog_new_with_buttons (str, NULL, 0,
 					      GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT,
@@ -588,33 +717,59 @@
 	gtk_window_set_default_size (GTK_WINDOW (window), 800, 300);
 	gtk_widget_show (window);
 
-	g_object_unref (G_OBJECT (query));
-
 	ws->priv->opened_dialogs = g_slist_append (ws->priv->opened_dialogs, window);
 	g_signal_connect (G_OBJECT (window), "destroy",
 			  G_CALLBACK (opened_dialog_closed_cb), ws);
 }
 
 static void
-table_info_display_update (GdaDictTable *table, WsTables *ws)
+table_info_display_update (WsTables *ws)
 {
+	
 	const gchar *str = NULL;
 	gchar *title = NULL;
 	GtkTextIter start, end;
 	
-	if (table)
-		str = gda_object_get_description (GDA_OBJECT (table));
+	if (ws->priv->sel_dbo) {
+		g_assert ((ws->priv->sel_dbo->obj_type == GDA_META_DB_TABLE) ||
+			  (ws->priv->sel_dbo->obj_type == GDA_META_DB_VIEW));
+		str = "A missing description...";
+	}
 	if (str && *str) 
 		gtk_label_set_text (GTK_LABEL (ws->priv->description), str);
 	else
 		gtk_label_set_text (GTK_LABEL (ws->priv->description), "---");
 	
-	gnome_db_selector_set_mode_columns (GNOME_DB_SELECTOR (ws->priv->fields), (GObject*) table,
-					    GNOME_DB_SELECTOR_FIELDS, 
-					    GNOME_DB_SELECTOR_COLUMN_TYPE | GNOME_DB_SELECTOR_COLUMN_FIELD_LENGTH | 
-					    GNOME_DB_SELECTOR_COLUMN_FIELD_NNUL |
-					    GNOME_DB_SELECTOR_COLUMN_FIELD_DEFAULT | GNOME_DB_SELECTOR_COLUMN_COMMENTS);
-
+	if (ws->priv->sel_dbo) {
+		GdaDataModel *model;
+		GError *error = NULL;
+
+		model = gda_meta_store_extract (gda_connection_get_meta_store (ws->priv->cnc),
+						"SELECT column_name, data_type, is_nullable, column_default, column_comments "
+						"FROM _columns "
+						"WHERE table_catalog = ##catalog::string AND table_schema = ##schema::string "
+						"AND table_name = ##tname::string "
+						"ORDER BY ordinal_position", &error,
+						"catalog", ws->priv->sel_catalog, 
+						"schema", ws->priv->sel_schema, 
+						"tname", ws->priv->sel_table, 
+						NULL);
+		if (!model) {
+			TO_IMPLEMENT; /* show a warning message */
+			g_error_free (error);
+		}
+		else {
+			gda_data_model_set_column_title (model, 0, _("Column"));
+			gda_data_model_set_column_title (model, 1, _("Type"));
+			gda_data_model_set_column_title (model, 2, _("Can be NULL"));
+			gda_data_model_set_column_title (model, 3, _("Default"));
+			gda_data_model_set_column_title (model, 4, _("Comments"));
+		}
+		
+		g_object_set (G_OBJECT (ws->priv->fields), "model", model, NULL);
+		g_object_unref (model);
+	}
+       
 	/* global title update */
 	title = ws_tables_get_description (WORKSPACE_PAGE (ws));
 	g_signal_emit_by_name (G_OBJECT (ws), "description_changed", title);
@@ -625,136 +780,122 @@
 	gtk_text_buffer_get_end_iter (ws->priv->integ_descr, &end);
 	gtk_text_buffer_delete (ws->priv->integ_descr, &start, &end);
 	
-	if (table) {
+	if (ws->priv->sel_dbo) {
+		GdaMetaTable *mtable = GDA_META_TABLE (ws->priv->sel_dbo);
 		GtkTextIter current;
-		GSList *constraints, *list;
+		gtk_text_buffer_get_start_iter (ws->priv->integ_descr, &current);
 
-		gtk_text_buffer_get_start_iter (ws->priv->integ_descr, &current);		
-		/* constraints list */
-		constraints = gda_dict_table_get_constraints (table);
-		
-		/* PKey */
-		list = constraints;
-		while (list) {
-			gboolean first = TRUE;
-			if (gda_dict_constraint_get_constraint_type (GDA_DICT_CONSTRAINT (list->data)) == 
-			    CONSTRAINT_PRIMARY_KEY) {
-				GdaDictConstraint *cstr = GDA_DICT_CONSTRAINT (list->data);
-				GSList *fields, *list2;
-				gboolean header = FALSE;
-
-				fields = gda_dict_constraint_pkey_get_fields (cstr);
-				list2 = fields;
-				while (list2) {
-					if (!header) {
-						header = TRUE;
-						gtk_text_buffer_insert_with_tags_by_name (ws->priv->integ_descr,
-											  &current, 
-											  _("Primary key"), -1,
-											  "section", NULL);
-						gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n", -1);
-					}
-
-					if (first) 
-						first = FALSE;
-					else
-						gtk_text_buffer_insert (ws->priv->integ_descr, &current, ", ", -1);
-
-					gtk_text_buffer_insert (ws->priv->integ_descr, &current, 
-								gda_object_get_name (GDA_OBJECT (list2->data)), -1);
-					list2 = g_slist_next (list2);
-				}
-				g_slist_free (fields);
-				gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n\n", -1);
+		/* Primary key */
+		if (mtable->pk_cols_nb > 0) {
+			gint i;
+
+			gtk_text_buffer_insert_with_tags_by_name (ws->priv->integ_descr,
+								  &current, 
+								  _("Primary key"), -1,
+								  "section", NULL);
+			gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n", -1);
+			for (i = 0; i < mtable->pk_cols_nb; i++) {
+				GdaMetaTableColumn *col;
+				if (i > 0)
+					gtk_text_buffer_insert (ws->priv->integ_descr, &current, ", ", -1);
+				col = g_slist_nth_data (mtable->columns, mtable->pk_cols_array [i]);
+				gtk_text_buffer_insert (ws->priv->integ_descr, &current, 
+							col ? col->column_name : "???", -1);
 			}
-			list = g_slist_next (list);
+			gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n\n", -1);
 		}
-
-		/* FKey */
-		list = constraints;
-		while (list) {
-			if (gda_dict_constraint_get_constraint_type (GDA_DICT_CONSTRAINT (list->data)) == 
-			    CONSTRAINT_FOREIGN_KEY) {
-				GdaDictConstraint *cstr = GDA_DICT_CONSTRAINT (list->data);
-				GSList *fields, *list2;
-				gboolean header = FALSE;
-
-				fields = gda_dict_constraint_fkey_get_fields (cstr);
-				list2 = fields;
-				while (list2) {
-					GdaEntity *ent;
-					if (!header) {
-						header = TRUE;
-						gtk_text_buffer_insert_with_tags_by_name (ws->priv->integ_descr,
-											  &current, 
-											  _("Foreign key"), -1,
-											  "section", NULL);
-						gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n", -1);
-					}
-						
-					str = gda_object_get_name (GDA_OBJECT (GDA_DICT_CONSTRAINT_FK_PAIR (list2->data)->fkey));
-					gtk_text_buffer_insert (ws->priv->integ_descr, &current, str, -1);
-					gtk_text_buffer_insert (ws->priv->integ_descr, &current, " --> ", -1);
-					ent = gda_entity_field_get_entity (GDA_ENTITY_FIELD (GDA_DICT_CONSTRAINT_FK_PAIR (list2->data)->ref_pkey));
-					str = gda_object_get_name (GDA_OBJECT (ent));
-					gtk_text_buffer_insert (ws->priv->integ_descr, &current, str, -1);
-					gtk_text_buffer_insert (ws->priv->integ_descr, &current, ".", -1);
-					str = gda_object_get_name (GDA_OBJECT (GDA_DICT_CONSTRAINT_FK_PAIR (list2->data)->ref_pkey));
-					gtk_text_buffer_insert (ws->priv->integ_descr, &current, str, -1);
-					gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n", -1);
-						
-					list2 = g_slist_next (list2);
-				}
-				g_slist_free (fields);
+		
+		/* Foreign keys */
+		GSList *list;
+		for (list = mtable->fk_list; list; list = list->next) {
+			GdaMetaTableForeignKey *fk = GDA_META_TABLE_FOREIGN_KEY (list->data);
+			gchar *str;
+			GdaMetaDbObject *fdbo = fk->depend_on;
+			gint i;
+
+			if (fdbo->obj_type == GDA_META_DB_UNKNOWN) {
+				GValue *v1, *v2, *v3;
+				g_value_set_string ((v1 = gda_value_new (G_TYPE_STRING)), fdbo->obj_catalog);
+				g_value_set_string ((v2 = gda_value_new (G_TYPE_STRING)), fdbo->obj_schema);
+				g_value_set_string ((v3 = gda_value_new (G_TYPE_STRING)), fdbo->obj_name);
+				gda_meta_struct_complement (ws->priv->mstruct, 
+							    GDA_META_DB_TABLE, v1, v2, v3, NULL);
+				gda_value_free (v1);
+				gda_value_free (v2);
+				gda_value_free (v3);
+			}
+			if (fdbo->obj_type != GDA_META_DB_UNKNOWN)
+				str = g_strdup_printf (_("Foreign key on '%s'"), fdbo->obj_short_name);
+			else
+				str = g_strdup_printf (_("Foreign key on '%s'"), fdbo->obj_name);
+			gtk_text_buffer_insert_with_tags_by_name (ws->priv->integ_descr,
+								  &current, 
+								  str, -1,
+								  "section", NULL);
+			g_free (str);
+			for (i = 0; i < fk->cols_nb; i++) {
 				gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n", -1);
+				gtk_text_buffer_insert (ws->priv->integ_descr, &current, fk->fk_names_array [i], -1);
+				gtk_text_buffer_insert (ws->priv->integ_descr, &current, " --> ", -1);
+				gtk_text_buffer_insert (ws->priv->integ_descr, &current, fk->ref_pk_names_array [i], -1);
 			}
-			list = g_slist_next (list);
+			
+			gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n\n", -1);
+			
 		}
 
-		/* Unique */
-		list = constraints;
-		while (list) {
-			if (gda_dict_constraint_get_constraint_type (GDA_DICT_CONSTRAINT (list->data)) == 
-			    CONSTRAINT_UNIQUE) {
-				GdaDictConstraint *cstr = GDA_DICT_CONSTRAINT (list->data);
-				GSList *fields, *list2;
-				gboolean header = FALSE;
-
-				fields = gda_dict_constraint_unique_get_fields (cstr);
-				list2 = fields;
-				while (list2) {
-					if (!header) {
-						header = TRUE;
+		/* Unique constraints */
+		GdaDataModel *model;
+		GError *error = NULL;
+		model = gda_meta_store_extract (gda_connection_get_meta_store (ws->priv->cnc),
+						"SELECT tc.constraint_name, k.column_name FROM _key_column_usage k INNER JOIN _table_constraints tc ON (k.table_catalog=tc.table_catalog AND k.table_schema=tc.table_schema AND k.table_name=tc.table_name AND k.constraint_name=tc.constraint_name) WHERE tc.constraint_type='UNIQUE' AND k.table_catalog = ##catalog::string AND k.table_schema = ##schema::string AND k.table_name = ##tname::string ORDER by k.ordinal_position", &error,
+						"catalog", ws->priv->sel_catalog, 
+						"schema", ws->priv->sel_schema, 
+						"tname", ws->priv->sel_table, NULL);
+		if (!model) {
+			g_warning ("Could not compute table's UNIQUE constraints for %s.%s.%s",
+				   g_value_get_string (ws->priv->sel_catalog), 
+				   g_value_get_string (ws->priv->sel_schema), 
+				   g_value_get_string (ws->priv->sel_table));
+			g_error_free (error);
+		}
+		else {
+			gint nrows;
+			
+			nrows = gda_data_model_get_n_rows (model);
+			if (nrows > 0) {
+				gint i;
+				GValue *current_value = NULL;
+				const GValue *cvalue;
+				for (i = 0; i < nrows; i++) {
+					cvalue = gda_data_model_get_value_at (model, 0, i);
+					if (!current_value || 
+					    gda_value_compare_ext (cvalue, current_value)) {
 						gtk_text_buffer_insert_with_tags_by_name (ws->priv->integ_descr,
 											  &current, 
-											  _("UNIQUE constraint"), -1,
+											  _("Unique constraint"), -1,
 											  "section", NULL);
 						gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n", -1);
+						current_value = gda_value_copy (cvalue);
 					}
 					else
 						gtk_text_buffer_insert (ws->priv->integ_descr, &current, ", ", -1);
-
+					cvalue = gda_data_model_get_value_at (model, 1, i);
 					gtk_text_buffer_insert (ws->priv->integ_descr, &current, 
-								gda_object_get_name (GDA_OBJECT (list2->data)), -1);
-						
-					list2 = g_slist_next (list2);
+								g_value_get_string (cvalue), -1);
 				}
-				g_slist_free (fields);
-				gtk_text_buffer_insert (ws->priv->integ_descr, &current, "\n\n", -1);
 			}
-			list = g_slist_next (list);
+			g_object_unref (model);
 		}
-
-		/* check constraint: FIXME */
-
-		g_slist_free (constraints);			
 	}
 }
 
 static void
 field_selection_changed_cb (GnomeDbSelector *mgsel, GObject *sel_object, MgPluginEditor *editor)
 {
+#ifdef CODEOK
 	mg_plugin_editor_set_work_object (editor, sel_object);
+#endif
 }
 
 
@@ -780,13 +921,11 @@
 	g_return_val_if_fail (WS_TABLES (iface)->priv, NULL);
 
 	ws = WS_TABLES (iface);
-	if (ws->priv->sel_obj) {
-		if (gda_dict_table_is_view (GDA_DICT_TABLE (ws->priv->sel_obj)))
-			str = g_strdup_printf ("View: <b>%s</b>", 
-					       gda_object_get_name (GDA_OBJECT (ws->priv->sel_obj)));
+	if (ws->priv->sel_dbo) {
+		if (ws->priv->sel_dbo->obj_type == GDA_META_DB_TABLE)
+			str = g_strdup_printf ("Table: <b>%s</b>", ws->priv->sel_dbo->obj_short_name);
 		else
-			str = g_strdup_printf ("Table: <b>%s</b>", 
-					       gda_object_get_name (GDA_OBJECT (ws->priv->sel_obj)));
+			str = g_strdup_printf ("View: <b>%s</b>", ws->priv->sel_dbo->obj_short_name);
 	}
 	else
 		str = g_strdup_printf ("<b>%s</b>", _("No table selected"));
@@ -864,7 +1003,7 @@
 	GtkWidget *dlg;
 
 	dlg = mergeant_server_op_create_dialog (NULL, GDA_SERVER_OPERATION_CREATE_TABLE, 
-						gda_dict_get_connection (ws->priv->dict), NULL,
+						ws->priv->cnc, NULL,
 						_("Create a table"), NULL,
 						MERGEANT_SERVER_OP_CALLBACK (action_done_cb), ws);
 	gtk_widget_show (dlg);
@@ -877,17 +1016,18 @@
 static void
 action_drop_table_cb (GtkAction *action, WsTables *ws)
 {
-	GdaParameterList *options;
+#ifdef CODEOK
+	GdaSet *options;
 	GtkWidget *dlg;
 
 	g_return_if_fail (GDA_IS_DICT_TABLE (ws->priv->sel_obj));
 
-	options = gda_parameter_list_new (NULL);
+	options = gda_set_new (NULL);
 	gda_parameter_list_add_param_from_string (options, "/TABLE_DESC_P/TABLE_NAME", G_TYPE_STRING,
-						  gda_object_get_name (GDA_OBJECT (ws->priv->sel_obj)));
+						  ws->priv->sel_dbo->obj_name);
 
 	dlg = mergeant_server_op_create_dialog (NULL, GDA_SERVER_OPERATION_DROP_TABLE, 
-						gda_dict_get_connection (ws->priv->dict), options,
+						ws->priv->cnc, options,
 						_("Delete a table"), NULL,
 						MERGEANT_SERVER_OP_CALLBACK (action_done_cb), ws);
 	g_object_unref (options);
@@ -897,47 +1037,38 @@
 	ws->priv->opened_dialogs = g_slist_append (ws->priv->opened_dialogs, dlg);
 	g_signal_connect (G_OBJECT (dlg), "destroy",
 			  G_CALLBACK (opened_dialog_closed_cb), ws);
+#endif
 }
 
 static void
 action_done_cb (GtkWidget *dlg, gboolean succeed, WsTables *ws)
 {
 	if (succeed) {
-		GdaDictDatabase *db;
 		GdaServerOperation *op;
 		const GValue *value;
-		const gchar *table_name;
 		
-		db = gda_dict_get_database (ws->priv->dict);
 		op = g_object_get_data (G_OBJECT (dlg), "op");
 
 		value = gda_server_operation_get_value_at (op, "/TABLE_DEF_P/TABLE_NAME");
-		if (value) {
-			table_name = g_value_get_string (value);
-			gda_dict_database_update_dbms_data (db, GDA_TYPE_DICT_TABLE, table_name, NULL);
-		}
+		if (!value) 
+			value = gda_server_operation_get_value_at (op, "/TABLE_DESC_P/TABLE_NAME");
+		if (!value)
+			value = gda_server_operation_get_value_at (op, "/TABLE_DESC_P/TABLE_NEW_NAME");
+		if (!value)
+			value = gda_server_operation_get_value_at (op, "/COLUMN_DEF_P/TABLE_NAME");
+		if (!value)
+			value = gda_server_operation_get_value_at (op, "/COLUMN_DESC_P/TABLE_NAME");
 
-		value = gda_server_operation_get_value_at (op, "/TABLE_DESC_P/TABLE_NAME");
-		if (value) {
-			table_name = g_value_get_string (value);
-			gda_dict_database_update_dbms_data (db, GDA_TYPE_DICT_TABLE, table_name, NULL);
-		}
-
-		value = gda_server_operation_get_value_at (op, "/TABLE_DESC_P/TABLE_NEW_NAME");
-		if (value) {
-			table_name = g_value_get_string (value);
-			gda_dict_database_update_dbms_data (db, GDA_TYPE_DICT_TABLE, table_name, NULL);
-		}
-
-		value = gda_server_operation_get_value_at (op, "/COLUMN_DEF_P/TABLE_NAME");
-		if (value) {
-			table_name = g_value_get_string (value);
-			gda_dict_database_update_dbms_data (db, GDA_TYPE_DICT_TABLE, table_name, NULL);
-		}
-		value = gda_server_operation_get_value_at (op, "/COLUMN_DESC_P/TABLE_NAME");
 		if (value) {
-			table_name = g_value_get_string (value);
-			gda_dict_database_update_dbms_data (db, GDA_TYPE_DICT_TABLE, table_name, NULL);
+			GdaMetaContext context;
+			context.table_name = "_tables";
+			context.size = 1;
+			context.column_names = g_new0 (gchar *, 1);
+			context.column_names [0] =  "table_name";
+			context.column_values = g_new0 (GValue *, 1);
+			context.column_values[0] = (GValue*) value;
+			gda_connection_update_meta_store (ws->priv->cnc, &context, NULL);
+			g_free (context.column_values);
 		}
 	}
 }
@@ -945,17 +1076,18 @@
 static void
 action_rename_table_cb (GtkAction *action, WsTables *ws)
 {
+#ifdef CODEOK
 	GdaParameterList *options;
 	GtkWidget *dlg;
 
 	g_return_if_fail (GDA_IS_DICT_TABLE (ws->priv->sel_obj));
 
-	options = gda_parameter_list_new (NULL);
+	options = gda_set_new (NULL);
 	gda_parameter_list_add_param_from_string (options, "/TABLE_DESC_P/TABLE_NAME", G_TYPE_STRING,
 						  gda_object_get_name (GDA_OBJECT (ws->priv->sel_obj)));
 
 	dlg = mergeant_server_op_create_dialog (NULL, GDA_SERVER_OPERATION_RENAME_TABLE, 
-						gda_dict_get_connection (ws->priv->dict), options,
+						ws->priv->cnc, options,
 						_("Rename a table"), NULL,
 						MERGEANT_SERVER_OP_CALLBACK (action_done_cb), ws);
 	g_object_unref (options);
@@ -965,22 +1097,24 @@
 	ws->priv->opened_dialogs = g_slist_append (ws->priv->opened_dialogs, dlg);
 	g_signal_connect (G_OBJECT (dlg), "destroy",
 			  G_CALLBACK (opened_dialog_closed_cb), ws);
+#endif
 }
 
 static void
 action_add_column_cb (GtkAction *action, WsTables *ws)
 {
+#ifdef CODEOK
 	GdaParameterList *options;
 	GtkWidget *dlg;
 
 	g_return_if_fail (GDA_IS_DICT_TABLE (ws->priv->sel_obj));
 
-	options = gda_parameter_list_new (NULL);
+	options = gda_set_new (NULL);
 	gda_parameter_list_add_param_from_string (options, "/COLUMN_DEF_P/TABLE_NAME", G_TYPE_STRING,
 						  gda_object_get_name (GDA_OBJECT (ws->priv->sel_obj)));
 
 	dlg = mergeant_server_op_create_dialog (NULL, GDA_SERVER_OPERATION_ADD_COLUMN, 
-						gda_dict_get_connection (ws->priv->dict), options,
+						ws->priv->cnc, options,
 						_("Add a column to a table"), NULL,
 						MERGEANT_SERVER_OP_CALLBACK (action_done_cb), ws);
 	g_object_unref (options);
@@ -990,18 +1124,20 @@
 	ws->priv->opened_dialogs = g_slist_append (ws->priv->opened_dialogs, dlg);
 	g_signal_connect (G_OBJECT (dlg), "destroy",
 			  G_CALLBACK (opened_dialog_closed_cb), ws);
+#endif
 }
 
 static void
 action_drop_column_cb (GtkAction *action, WsTables *ws)
 {
+#ifdef CODEOK
 	GdaParameterList *options;
 	GtkWidget *dlg;
 	GdaDictField *sel_field;
 
 	g_return_if_fail (GDA_IS_DICT_TABLE (ws->priv->sel_obj));
 
-	options = gda_parameter_list_new (NULL);
+	options = gda_set_new (NULL);
 	gda_parameter_list_add_param_from_string (options, "/COLUMN_DESC_P/TABLE_NAME", G_TYPE_STRING,
 						  gda_object_get_name (GDA_OBJECT (ws->priv->sel_obj)));
 
@@ -1011,7 +1147,7 @@
 						  gda_object_get_name (GDA_OBJECT (sel_field)));
 
 	dlg = mergeant_server_op_create_dialog (NULL, GDA_SERVER_OPERATION_DROP_COLUMN, 
-						gda_dict_get_connection (ws->priv->dict), options,
+						ws->priv->cnc, options,
 						_("Delete a column drom a table"), NULL,
 						MERGEANT_SERVER_OP_CALLBACK (action_done_cb), ws);
 	g_object_unref (options);
@@ -1021,6 +1157,7 @@
 	ws->priv->opened_dialogs = g_slist_append (ws->priv->opened_dialogs, dlg);
 	g_signal_connect (G_OBJECT (dlg), "destroy",
 			  G_CALLBACK (opened_dialog_closed_cb), ws);
+#endif
 }
 
 static void

Modified: trunk/src/ws-tables.h
==============================================================================
--- trunk/src/ws-tables.h	(original)
+++ trunk/src/ws-tables.h	Wed Jul  2 19:52:16 2008
@@ -1,6 +1,6 @@
 /* ws-tables.h
  *
- * Copyright (C) 2004 Vivien Malerba
+ * Copyright (C) 2004 - 2008 Vivien Malerba
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -51,7 +51,7 @@
 };
 
 GType           ws_tables_get_type          (void);
-GObject        *ws_tables_new               (GdaDict *dict);
+GObject        *ws_tables_new               (GdaConnection *cnc);
 
 G_END_DECLS
 



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