r17322 - gnucash/branches/gda-dev2/src - 1) Reintroduce 'database connection' UI. This UI lets you save or load a mysql

Phil Longstaff plongstaff at cvs.gnucash.org
Sun Jul 13 14:33:58 EDT 2008


Author: plongstaff
Date: 2008-07-13 14:33:57 -0400 (Sun, 13 Jul 2008)
New Revision: 17322
Trac: http://svn.gnucash.org/trac/changeset/17322

Modified:
   gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.c
   gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.h
   gnucash/branches/gda-dev2/src/backend/sql/gnc-backend-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-transaction-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-address-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-entry-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-invoice-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-order-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-owner-sql.c
   gnucash/branches/gda-dev2/src/gnome-utils/Makefile.am
   gnucash/branches/gda-dev2/src/gnome-utils/dialog-database-connection.c
   gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-database-connection.glade
   gnucash/branches/gda-dev2/src/gnome/gnc-plugin-basic-commands.c
   gnucash/branches/gda-dev2/src/gnome/ui/gnc-plugin-basic-commands-ui.xml
Log:
1) Reintroduce 'database connection' UI.  This UI lets you save or load a mysql
or postgresql database (postgresql support not there yet so the postgresql
radio button is insensitive).  For a db, you can specify a) host (default is
'localhost'), b) db name (default is 'gnucash'), c) username (default is ''),
and d) password (default is '').
2) Add backend support for mysql db access through dbi.
3) Fix bug in which when a transaction was saved to a fresh db, the splits
weren't being saved.
4) Fix bug where invoice reference guids in other records weren't resolved to
the proper invoice.
5) Fix bug where order reference guids in other records weren't resolved to the
proper order.
6) Fix column type for gncEntry bill terms reference guid (was reference to
invoices table, not billterms table).
7) Fix bug where gncAddress field definitions didn't have proper length



Modified: gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -54,8 +54,30 @@
 
 static QofLogModule log_module = G_LOG_DOMAIN;
 
-static GncSqlConnection* create_dbi_connection( dbi_conn conn );
+static GncSqlConnection* create_dbi_connection( gint provider, dbi_conn conn );
 
+#define GNC_DBI_PROVIDER_SQLITE 0
+#define GNC_DBI_PROVIDER_MYSQL  1
+#define GNC_DBI_PROVIDER_PGSQL  2
+
+struct GncDbiBackend_struct
+{
+  GncSqlBackend sql_be;
+
+  dbi_conn conn;
+
+  QofBook *primary_book;	/* The primary, main open book */
+  gboolean	loading;		/* We are performing an initial load */
+  gboolean  in_query;
+  gboolean  supports_transactions;
+  gboolean  is_pristine_db;	// Are we saving to a new pristine db?
+
+  gint obj_total;			// Total # of objects (for percentage calculation)
+  gint operations_done;		// Number of operations (save/load) done
+//  GHashTable* versions;		// Version number for each table
+};
+typedef struct GncDbiBackend_struct GncDbiBackend;
+
 /* ================================================================= */
 
 static void
@@ -123,7 +145,7 @@
         return;
 	}
 
-	be->sql_be.conn = create_dbi_connection( be->conn );
+	be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_SQLITE, be->conn );
 
     LEAVE (" ");
 }
@@ -136,14 +158,12 @@
 {
     GncDbiBackend *be = (GncDbiBackend*)qbe;
     GError* error = NULL;
-    gchar* dsn;
+	gchar* dsn;
+	gchar* host;
+	gchar* dbname;
     gchar* username;
     gchar* password;
-	gchar* provider;
-	gboolean uriOK;
 	gint result;
-	gchar* dirname;
-	gchar* basename;
 
 	g_return_if_fail( qbe != NULL );
 	g_return_if_fail( session != NULL );
@@ -151,23 +171,32 @@
 
     ENTER (" ");
 
-	dirname = g_path_get_dirname( book_id );
-	basename = g_path_get_basename( book_id );
+	/* Split the book-id (format host:dbname:username:password) */
+	dsn = g_strdup( book_id );
+	for( host = dsn; *host != '/'; host++ ) {}
+	host += 2;
+	for( dbname = host; *dbname != ':'; dbname++ ) {}
+	*dbname++ = '\0';
+	for( username = dbname; *username != ':'; username++ ) {}
+	*username++ = '\0';
+	for( password = username; *password != ':'; password++ ) {}
+	*password++ = '\0';
 
-	be->conn = dbi_conn_new( "sqlite3" );
+	be->conn = dbi_conn_new( "mysql" );
 	if( be->conn == NULL ) {
-		PERR( "Unable to create sqlite3 dbi connection\n" );
+		PERR( "Unable to create mysql dbi connection\n" );
         qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
 		LEAVE( " " );
 		return;
 	}
 	dbi_conn_error_handler( be->conn, error_fn, be );
-	dbi_conn_set_option( be->conn, "host", "localhost" );
-	dbi_conn_set_option( be->conn, "dbname", basename );
-	dbi_conn_set_option( be->conn, "sqlite3_dbdir", dirname );
+	dbi_conn_set_option( be->conn, "host", host );
+	dbi_conn_set_option_numeric( be->conn, "port", 0 );
+	dbi_conn_set_option( be->conn, "dbname", dbname );
+	dbi_conn_set_option( be->conn, "username", username );
+	dbi_conn_set_option( be->conn, "password", password );
 	result = dbi_conn_connect( be->conn );
-	g_free( basename );
-	g_free( dirname );
+	g_free( dsn );
 	if( result < 0 ) {
 		PERR( "Unable to connect to %s: %d\n", book_id, result );
         qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
@@ -175,7 +204,7 @@
         return;
 	}
 
-	be->sql_be.conn = create_dbi_connection( be->conn );
+	be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_MYSQL, be->conn );
 
     LEAVE (" ");
 }
@@ -227,7 +256,7 @@
         return;
 	}
 
-	be->sql_be.conn = create_dbi_connection( be->conn );
+	be->sql_be.conn = create_dbi_connection( GNC_DBI_PROVIDER_PGSQL, be->conn );
 
     LEAVE (" ");
 }
@@ -786,6 +815,7 @@
 	GncSqlConnection base;
 
 	dbi_conn conn;
+	gint provider;
 } GncDbiSqlConnection;
 
 static void
@@ -897,20 +927,41 @@
 {
 	GncDbiSqlConnection* dbi_conn = (GncDbiSqlConnection*)conn;
 
-	switch( type ) {
-		case G_TYPE_INT:
-		case G_TYPE_INT64:
-			return "integer";
-			break;
-		case G_TYPE_DOUBLE:
-			return "double";
-			break;
-		case G_TYPE_STRING:
-			return "string";
-			break;
-		default:
-			PERR( "Unknown GType: %d\n", type );
-			return "";
+	if( dbi_conn->provider == GNC_DBI_PROVIDER_SQLITE ) {
+		switch( type ) {
+			case G_TYPE_INT:
+			case G_TYPE_INT64:
+				return "integer";
+				break;
+			case G_TYPE_DOUBLE:
+				return "double";
+				break;
+			case G_TYPE_STRING:
+				return "string";
+				break;
+			default:
+				PERR( "Unknown GType: %d\n", type );
+				return "";
+		}
+	} else if( dbi_conn->provider == GNC_DBI_PROVIDER_MYSQL ) {
+		switch( type ) {
+			case G_TYPE_INT:
+			case G_TYPE_INT64:
+				return "integer";
+				break;
+			case G_TYPE_DOUBLE:
+				return "double";
+				break;
+			case G_TYPE_STRING:
+				return "varchar";
+				break;
+			default:
+				PERR( "Unknown GType: %d\n", type );
+				return "";
+		}
+	} else {
+		PERR( "Unknown provider: %d\n", dbi_conn->provider );
+		return "";
 	}
 }
 
@@ -963,6 +1014,7 @@
     }
 	g_string_append( ddl, ")" );
         
+	DEBUG( "SQL: %s\n", ddl->str );
 	result = dbi_conn_query( dbi_conn->conn, ddl->str );
 	dbi_result_free( result );
 	g_string_free( ddl, TRUE );
@@ -1068,7 +1120,7 @@
 }
 
 static GncSqlConnection*
-create_dbi_connection( dbi_conn conn )
+create_dbi_connection( gint provider, dbi_conn conn )
 {
 	GncDbiSqlConnection* dbi_conn;
 
@@ -1086,6 +1138,7 @@
 	dbi_conn->base.createIndex = conn_create_index;
 	dbi_conn->base.quoteString = conn_quote_string;
 	dbi_conn->conn = conn;
+	dbi_conn->provider = provider;
 
 	return (GncSqlConnection*)dbi_conn;
 }

Modified: gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.h
===================================================================
--- gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.h	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/backend/dbi/gnc-backend-dbi.h	2008-07-13 18:33:57 UTC (rev 17322)
@@ -34,22 +34,4 @@
 G_MODULE_EXPORT void
 qof_backend_module_init(void);
 
-struct GncDbiBackend_struct
-{
-  GncSqlBackend sql_be;
-
-  dbi_conn conn;
-
-  QofBook *primary_book;	/* The primary, main open book */
-  gboolean	loading;		/* We are performing an initial load */
-  gboolean  in_query;
-  gboolean  supports_transactions;
-  gboolean  is_pristine_db;	// Are we saving to a new pristine db?
-
-  gint obj_total;			// Total # of objects (for percentage calculation)
-  gint operations_done;		// Number of operations (save/load) done
-//  GHashTable* versions;		// Version number for each table
-};
-typedef struct GncDbiBackend_struct GncDbiBackend;
-
 #endif /* GNC_BACKEND_DBI_H_ */

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-backend-sql.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-backend-sql.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -361,40 +361,6 @@
 
     ENTER( "book=%p, primary=%p", book, be->primary_book );
 
-#if 0
-    /* Destroy the current contents of the database */
-	mstore = gda_connection_get_meta_store( be->pConnection );
-	tables = gda_connection_get_meta_store_data( be->pConnection, GDA_CONNECTION_META_TABLES, &error, 0 );
-//    tables = gda_connection_get_schema( be->pConnection,
-                                        //GDA_CONNECTION_SCHEMA_TABLES,
-                                        //NULL,
-                                        //&error );
-    if( error != NULL ) {
-        PERR( "SQL error: %s\n", error->message );
-    }
-    numTables = gda_data_model_get_n_rows( tables );
-    for( row = 0; row < numTables; row++ ) {
-        const GValue* row_value;
-        const gchar* table_name;
-		GdaServerOperation* op;
-
-        row_value = gda_data_model_get_value_at( tables, 0, row );
-        table_name = g_value_get_string( row_value );
-        error = NULL;
-		op = gda_prepare_drop_table( be->pConnection, table_name, &error );
-		if( error != NULL ) {
-			PERR( "Unable to create op: %s\n", error->message );
-		}
-		if( op != NULL ) {
-			error = NULL;
-			gda_perform_drop_table( op, &error );
-            if( error != NULL ) {
-                PERR( "SQL error: %s\n", error->message );
-            }
-        }
-    }
-#endif
-
 	reset_version_info( be );
 
     /* Create new tables */

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-transaction-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-transaction-sql.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-transaction-sql.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -509,18 +509,18 @@
     g_list_foreach( pSplitList, save_split_cb, &split_info );
 }
 
-void
-gnc_sql_save_transaction( GncSqlBackend* be, QofInstance* inst )
+static void
+save_transaction( GncSqlBackend* be, Transaction* pTx, gboolean do_save_splits )
 {
-    Transaction* pTx = GNC_TRANS(inst);
     const GUID* guid;
 	gint op;
 	gboolean is_infant;
+	QofInstance* inst;
 
-	g_return_if_fail( inst != NULL );
-	g_return_if_fail( GNC_IS_TRANS(inst) );
 	g_return_if_fail( be != NULL );
+	g_return_if_fail( pTx != NULL );
 
+	inst = QOF_INSTANCE(pTx);
 	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
@@ -537,37 +537,37 @@
 
     (void)gnc_sql_do_db_operation( be, op, TRANSACTION_TABLE, GNC_ID_TRANS, pTx, tx_col_table );
 
+    // Commit slots and splits
     guid = qof_instance_get_guid( inst );
-
-    // Delete any old slots and splits for this transaction
-	if( !be->is_pristine_db ) {
-    	delete_splits( be, pTx );
-	}
-
     if( !qof_instance_get_destroying(inst) ) {
-        // Now, commit any slots and splits
         gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
+		if( do_save_splits ) {
+			save_splits( be, guid, xaccTransGetSplitList( pTx ) );
+		}
     } else {
         gnc_sql_slots_delete( be, guid );
+    	delete_splits( be, pTx );
     }
 }
 
 void
-gnc_sql_transaction_commit_splits( GncSqlBackend* be, Transaction* pTx )
+gnc_sql_save_transaction( GncSqlBackend* be, QofInstance* inst )
 {
-    SplitList* splits;
-    Split* s;
-    QofBackend* qbe = (QofBackend*)be;
-    
 	g_return_if_fail( be != NULL );
-	g_return_if_fail( pTx != NULL );
+	g_return_if_fail( inst != NULL );
+	g_return_if_fail( GNC_IS_TRANS(inst) );
 
-    splits = xaccTransGetSplitList( pTx );
-    for( ; splits != NULL; splits = splits->next ) {
-        s = GNC_SPLIT(splits->data);
+	save_transaction( be, GNC_TRANS(inst), TRUE );
+}
 
-        qbe->commit( qbe, QOF_INSTANCE(s) );
-    }
+static void
+commit_transaction( GncSqlBackend* be, QofInstance* inst )
+{
+	g_return_if_fail( be != NULL );
+	g_return_if_fail( inst != NULL );
+	g_return_if_fail( GNC_IS_TRANS(inst) );
+
+	save_transaction( be, GNC_TRANS(inst), FALSE );
 }
 
 /* ================================================================= */
@@ -727,7 +727,7 @@
     {
         GNC_SQL_BACKEND_VERSION,
         GNC_ID_TRANS,
-        gnc_sql_save_transaction,    /* commit */
+        commit_transaction,          /* commit */
         load_all_tx,                 /* initial_load */
         create_transaction_tables    /* create tables */
     };

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-address-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-address-sql.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-address-sql.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -122,8 +122,9 @@
 		info = g_new0( GncSqlColumnInfo, 1 );
 		info->name = buf;
 		info->type_name = gnc_sql_connection_get_column_type_name( be->conn,
-											G_TYPE_STRING, table_row->size );
+											G_TYPE_STRING, subtable_row->size );
 		info->is_primary_key = (table_row->flags & COL_PKEY) ? TRUE : FALSE;
+		info->size = subtable_row->size;
 		info->null_allowed = (table_row->flags & COL_NNUL) ? FALSE : TRUE;
 		*pList = g_list_append( *pList, info );
 	}

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-entry-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-entry-sql.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-entry-sql.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -41,6 +41,7 @@
 #include "gncOrderP.h"
 #include "gncInvoiceP.h"
 #include "gncTaxTableP.h"
+#include "gnc-bill-term-sql.h"
 #include "gnc-entry-sql.h"
 #include "gnc-invoice-sql.h"
 #include "gnc-order-sql.h"
@@ -82,7 +83,7 @@
 			(QofAccessFunc)gncEntryGetInvTaxTable, (QofSetterFunc)gncEntrySetInvTaxTable },
 	{ "b_acct",        CT_ACCOUNTREF,  0,                   0,        			NULL, ENTRY_BACCT },
 	{ "b_price",       CT_NUMERIC,     0,                   0,        			NULL, ENTRY_BPRICE },
-	{ "bill",          CT_INVOICEREF,  0,                   0,        			NULL, NULL,
+	{ "bill",          CT_BILLTERMREF,  0,                   0,        			NULL, NULL,
 			(QofAccessFunc)gncEntryGetBill, (QofSetterFunc)gncEntrySetBill },
 	{ "b_taxable",     CT_BOOLEAN,     0,                   0,        			NULL, ENTRY_BILL_TAXABLE },
 	{ "b_taxincluded", CT_BOOLEAN,     0,                   0,        			NULL, ENTRY_BILL_TAX_INC },

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-invoice-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-invoice-sql.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-invoice-sql.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -245,7 +245,7 @@
 	g_return_if_fail( table_row != NULL );
 
     val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
-    if( val != NULL ) {
+    if( val == NULL ) {
         pGuid = NULL;
     } else {
         string_to_guid( g_value_get_string( val ), &guid );

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-order-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-order-sql.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-order-sql.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -201,7 +201,7 @@
 	g_return_if_fail( table_row != NULL );
 
     val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
-    if( val != NULL ) {
+    if( val == NULL ) {
         pGuid = NULL;
     } else {
         string_to_guid( g_value_get_string( val ), &guid );

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-owner-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-owner-sql.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-owner-sql.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -154,6 +154,7 @@
 											G_TYPE_INT, table_row->size );
 	info->is_primary_key = (table_row->flags & COL_PKEY) ? TRUE : FALSE;
 	info->null_allowed = (table_row->flags & COL_NNUL) ? FALSE : TRUE;
+	info->size = table_row->size;
 	*pList = g_list_append( *pList, info );
 
    	buf = g_strdup_printf( "%s_guid", table_row->col_name );

Modified: gnucash/branches/gda-dev2/src/gnome/gnc-plugin-basic-commands.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/gnc-plugin-basic-commands.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/gnome/gnc-plugin-basic-commands.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -103,11 +103,9 @@
   { "FileOpenAction", GTK_STOCK_OPEN, N_("_Open..."), NULL,
     N_("Open an existing GnuCash file"),
     G_CALLBACK (gnc_main_window_cmd_file_open) },
-#if 0
   { "FileDatabaseConnectionAction", NULL, N_("_Database Connection"), NULL,
     N_("Connect to a database"),
     G_CALLBACK (gnc_main_window_cmd_file_db_connection) },
-#endif
   { "FileSaveAction", GTK_STOCK_SAVE, N_("_Save"), "<control>s",
     N_("Save the current file"),
     G_CALLBACK (gnc_main_window_cmd_file_save) },
@@ -347,7 +345,7 @@
   if (!gnc_main_window_all_finish_pending())
     return;
 
-//  gnc_ui_database_connection();
+  gnc_ui_database_connection();
 }
 
 static void

Modified: gnucash/branches/gda-dev2/src/gnome/ui/gnc-plugin-basic-commands-ui.xml
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/ui/gnc-plugin-basic-commands-ui.xml	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/gnome/ui/gnc-plugin-basic-commands-ui.xml	2008-07-13 18:33:57 UTC (rev 17322)
@@ -14,6 +14,7 @@
       <placeholder name="FileSavePlaceholder">
         <menuitem name="FileSave" action="FileSaveAction"/>
         <menuitem name="FileSaveAs" action="FileSaveAsAction"/>
+		<menuitem name="FileDatabaseConnection" action="FileDatabaseConnectionAction"/>
       </placeholder>
       <menu name="FileExport" action="FileExportAction">
         <menuitem name="FileExportAccounts" action="FileExportAccountsAction"/>

Modified: gnucash/branches/gda-dev2/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/Makefile.am	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/gnome-utils/Makefile.am	2008-07-13 18:33:57 UTC (rev 17322)
@@ -30,6 +30,7 @@
   dialog-account.c \
   dialog-book-close.c \
   dialog-commodity.c \
+  dialog-database-connection.c \
   dialog-options.c \
   dialog-preferences.c \
   dialog-query-list.c \
@@ -104,6 +105,7 @@
   dialog-account.h \
   dialog-book-close.h \
   dialog-commodity.h \
+  dialog-database-connection.h \
   dialog-preferences.h \
   dialog-options.h \
   dialog-query-list.h \
@@ -194,8 +196,7 @@
   ${QOF_LIBS} \
   ${GOFFICE_LIBS} \
   ${REGEX_LIBS} \
-  ${LIBXML2_LIBS} \
-  ${LIBGDA_LIBS}
+  ${LIBXML2_LIBS}
 
 if BUILDING_FROM_SVN
 swig-gnome-utils.c: gnome-utils.i gnc-html.h \

Modified: gnucash/branches/gda-dev2/src/gnome-utils/dialog-database-connection.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/dialog-database-connection.c	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/gnome-utils/dialog-database-connection.c	2008-07-13 18:33:57 UTC (rev 17322)
@@ -30,8 +30,6 @@
 #include <glib/gi18n.h>
 #include <glade/glade.h>
 
-#include <libgda/libgda.h>
-
 #include "gnc-ui.h"
 #include "dialog-utils.h"
 #include "dialog-database-connection.h"
@@ -48,25 +46,36 @@
 {
   /* Parts of the dialog */
   GtkWidget* dialog;
-  GtkWidget* rb_predefined;
-  GtkWidget* rb_general;
-  GtkWidget* cb_predefined;
-  GtkWidget* tf_general;
+  GtkWidget* rb_mysql;
+  GtkWidget* rb_postgresql;
+  GtkWidget* tf_host;
+  GtkWidget* tf_database;
+  GtkWidget* tf_username;
+  GtkWidget* tf_password;
 };
 
 static gchar*
 geturl( struct DatabaseConnectionWindow* dcw )
 {
 	gchar* url;
+	const gchar* host;
+	const gchar* database;
+	const gchar* username;
+	const gchar* password;
+	const gchar* type;
 
-	if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(dcw->rb_predefined) ) ) {
-		/* Selection from predefined list */
-		url = g_strdup_printf( "gda://@%s", gtk_combo_box_get_active_text( GTK_COMBO_BOX(dcw->cb_predefined) ) );
+	host = gtk_entry_get_text( GTK_ENTRY(dcw->tf_host) );
+	database = gtk_entry_get_text( GTK_ENTRY(dcw->tf_database) );
+	username = gtk_entry_get_text( GTK_ENTRY(dcw->tf_username) );
+	password = gtk_entry_get_text( GTK_ENTRY(dcw->tf_password) );
 
+	if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(dcw->rb_mysql) ) ) {
+		type = "mysql";
 	} else {
-		/* Selection using entered info */
-		url = g_strdup_printf( "gdk://%s", gtk_entry_get_text( GTK_ENTRY(dcw->tf_general) ) );
+		type = "postgresql";
 	}
+	url = g_strdup_printf( "%s://%s:%s:%s:%s",
+							type, host, database, username, password );
 
 	return url;
 }
@@ -113,9 +122,6 @@
     GladeXML* xml;
     GtkWidget* box;
 	GList* ds_node;
-	GdaDataModel* dsns;
-	gint numDsns;
-	gint i;
 
     dcw = g_new0(struct DatabaseConnectionWindow, 1);
     g_return_if_fail(dcw);
@@ -124,27 +130,15 @@
     xml = gnc_glade_xml_new( "dialog-database-connection.glade", "Database Connection" );
     dcw->dialog = glade_xml_get_widget( xml, "Database Connection" );
 
-    /* Predefined */
-    dcw->rb_predefined = glade_xml_get_widget( xml, "rb_predefined" );
-	box = glade_xml_get_widget( xml, "predefined_connection_box" );
-	dcw->cb_predefined = gtk_combo_box_new_text();
-	numDsns = gda_config_get_nb_dsn();
-	dsns = gda_config_list_dsn();
-	for( i = 0; i < numDsns; i++ ) {
-		GdaDataSourceInfo* ds_info = gda_config_get_dsn_at_index( i );
-		gtk_combo_box_append_text( GTK_COMBO_BOX(dcw->cb_predefined), g_strdup(ds_info->name) );
-	}
-	if( numDsns != 0 ) {
-		gtk_combo_box_set_active( GTK_COMBO_BOX(dcw->cb_predefined), 0 );
-	} else {
-		gtk_widget_set_sensitive( dcw->rb_predefined, FALSE );
-	}
-	gtk_box_pack_start( GTK_BOX(box), dcw->cb_predefined, TRUE, TRUE, 0 );
+    dcw->rb_mysql = glade_xml_get_widget( xml, "rb_mysql" );
+    dcw->rb_postgresql = glade_xml_get_widget( xml, "rb_postgresql" );
+    dcw->tf_host = glade_xml_get_widget( xml, "tf_host" );
+	gtk_entry_set_text( GTK_ENTRY(dcw->tf_host), "localhost" );
+    dcw->tf_database = glade_xml_get_widget( xml, "tf_database" );
+	gtk_entry_set_text( GTK_ENTRY(dcw->tf_database), "gnucash" );
+    dcw->tf_username = glade_xml_get_widget( xml, "tf_username" );
+    dcw->tf_password = glade_xml_get_widget( xml, "tf_password" );
 
-    /* General */
-    dcw->rb_general = glade_xml_get_widget( xml, "rb_general" );
-    dcw->tf_general = glade_xml_get_widget( xml, "tf_general_db_info" );
-
     /* Autoconnect signals */
     glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func,
 				    					dcw->dialog );

Modified: gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-database-connection.glade
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-database-connection.glade	2008-07-13 16:01:18 UTC (rev 17321)
+++ gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-database-connection.glade	2008-07-13 18:33:57 UTC (rev 17322)
@@ -1,200 +1,205 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
 <glade-interface>
-
-<widget class="GtkDialog" id="Database Connection">
-  <property name="visible">True</property>
-  <property name="title" translatable="yes">Database Connection</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_NONE</property>
-  <property name="modal">False</property>
-  <property name="resizable">True</property>
-  <property name="destroy_with_parent">False</property>
-  <property name="decorated">True</property>
-  <property name="skip_taskbar_hint">False</property>
-  <property name="skip_pager_hint">False</property>
-  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
-  <property name="focus_on_map">True</property>
-  <property name="urgency_hint">False</property>
-  <property name="has_separator">True</property>
-  <signal name="response" handler="gnc_database_connection_response_cb"/>
-
-  <child internal-child="vbox">
-    <widget class="GtkVBox" id="dialog-vbox1">
-      <property name="visible">True</property>
-      <property name="homogeneous">False</property>
-      <property name="spacing">0</property>
-
-      <child internal-child="action_area">
-	<widget class="GtkHButtonBox" id="dialog-action_area1">
-	  <property name="visible">True</property>
-	  <property name="layout_style">GTK_BUTTONBOX_END</property>
-
-	  <child>
-	    <widget class="GtkButton" id="pb_help">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-help</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">-11</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="pb_cancel">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-cancel</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">-6</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="pb_load">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label" translatable="yes">_Load</property>
-	      <property name="use_underline">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">1000</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="pb_save">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label" translatable="yes">_Save</property>
-	      <property name="use_underline">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">1001</property>
-	    </widget>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">True</property>
-	  <property name="fill">True</property>
-	  <property name="pack_type">GTK_PACK_END</property>
-	</packing>
-      </child>
-
-      <child>
-	<widget class="GtkTable" id="table1">
-	  <property name="visible">True</property>
-	  <property name="n_rows">2</property>
-	  <property name="n_columns">2</property>
-	  <property name="homogeneous">False</property>
-	  <property name="row_spacing">0</property>
-	  <property name="column_spacing">0</property>
-
-	  <child>
-	    <widget class="GtkRadioButton" id="rb_predefined">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label" translatable="yes">Predefined</property>
-	      <property name="use_underline">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="active">False</property>
-	      <property name="inconsistent">False</property>
-	      <property name="draw_indicator">True</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">1</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkRadioButton" id="rb_general">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label" translatable="yes">General</property>
-	      <property name="use_underline">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="active">False</property>
-	      <property name="inconsistent">False</property>
-	      <property name="draw_indicator">True</property>
-	      <property name="group">rb_predefined</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">1</property>
-	      <property name="top_attach">1</property>
-	      <property name="bottom_attach">2</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkEntry" id="tf_general_db_info">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="editable">True</property>
-	      <property name="visibility">True</property>
-	      <property name="max_length">0</property>
-	      <property name="text" translatable="yes"></property>
-	      <property name="has_frame">True</property>
-	      <property name="invisible_char">●</property>
-	      <property name="activates_default">False</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">1</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">1</property>
-	      <property name="bottom_attach">2</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkHBox" id="predefined_connection_box">
-	      <property name="visible">True</property>
-	      <property name="homogeneous">False</property>
-	      <property name="spacing">0</property>
-
-	      <child>
-		<placeholder/>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">1</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options">fill</property>
-	    </packing>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">True</property>
-	  <property name="fill">True</property>
-	</packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
+  <widget class="GtkDialog" id="Database Connection">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">Database Connection</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <signal name="response" handler="gnc_database_connection_response_cb"/>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <child>
+          <widget class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <child>
+              <widget class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <child>
+                  <widget class="GtkRadioButton" id="rb_mysql">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">MySQL</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="rb_postgresql">
+                    <property name="visible">True</property>
+                    <property name="sensitive">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">PostgreSQL</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">rb_mysql</property>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkTable" id="table1">
+                <property name="visible">True</property>
+                <property name="n_rows">4</property>
+                <property name="n_columns">2</property>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">host</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label2">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">database</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">username</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label4">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">password</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="tf_host">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="tf_database">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="tf_username">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="tf_password">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="pb_help">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-help</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-11</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="pb_cancel">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-6</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="pb_load">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label" translatable="yes">_Load</property>
+                <property name="use_underline">True</property>
+                <property name="response_id">1000</property>
+              </widget>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="pb_save">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label" translatable="yes">_Save</property>
+                <property name="use_underline">True</property>
+                <property name="response_id">1001</property>
+              </widget>
+              <packing>
+                <property name="position">3</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>



More information about the gnucash-changes mailing list