Re-indentation of source code.

This re-indentation was done using astyle-1.24 using the following options:

  astyle --indent=spaces=4 --brackets=break --pad-oper --pad-header --suffix=none

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20163 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2011-01-24 14:10:09 +00:00
parent bd17b5fa41
commit c8f1244fff
35 changed files with 1308 additions and 1258 deletions

View File

@ -479,28 +479,28 @@ gnc_ui_account_get_tax_info_string (const Account *account)
account_descendants = gnc_account_get_descendants (account);
if (account_descendants)
{
gint sub_acct_tax_number = 0;
for (descendant = account_descendants; descendant;
descendant = g_list_next(descendant))
{
gint sub_acct_tax_number = 0;
for (descendant = account_descendants; descendant;
descendant = g_list_next(descendant))
{
if (xaccAccountGetTaxRelated (descendant->data))
sub_acct_tax_number++;
}
/* Translators: This and the following strings appear on
* the account tab if the Tax Info column is displayed,
* i.e. if the user wants to record the tax form number
* and location on that tax form which corresponds to this
* gnucash account. For the US Income Tax support in
* gnucash, each tax code that can be assigned to an
* account generally corresponds to a specific line number
* on a paper form and each form has a unique
* identification (e.g., Form 1040, Schedule A). */
descendant_txt = (sub_acct_tax_number == 0) ? "" :
g_strdup_printf (_("(Tax-related subaccounts: %d)"),
sub_acct_tax_number);
sub_acct_tax_number++;
}
/* Translators: This and the following strings appear on
* the account tab if the Tax Info column is displayed,
* i.e. if the user wants to record the tax form number
* and location on that tax form which corresponds to this
* gnucash account. For the US Income Tax support in
* gnucash, each tax code that can be assigned to an
* account generally corresponds to a specific line number
* on a paper form and each form has a unique
* identification (e.g., Form 1040, Schedule A). */
descendant_txt = (sub_acct_tax_number == 0) ? "" :
g_strdup_printf (_("(Tax-related subaccounts: %d)"),
sub_acct_tax_number);
}
else
descendant_txt = "";
descendant_txt = "";
tax_related = xaccAccountGetTaxRelated (account);
code = xaccAccountGetTaxUSCode (account);
@ -509,19 +509,19 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (!tax_related)
{
if (safe_strcmp (descendant_txt, "") == 0)
return NULL;
else
return g_strdup_printf ("%s", descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return NULL;
else
return g_strdup_printf ("%s", descendant_txt);
}
/* tax_related && !code */
else
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup (_("Tax-related but has no tax code"));
else
return g_strdup_printf
(_("Tax-related but has no tax code; %s"), descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup (_("Tax-related but has no tax code"));
else
return g_strdup_printf
(_("Tax-related but has no tax code; %s"), descendant_txt);
}
}
else /* with tax code */
@ -532,11 +532,11 @@ gnc_ui_account_get_tax_info_string (const Account *account)
tax_type = gnc_get_current_book_tax_type ();
if (tax_type == NULL || (safe_strcmp (tax_type, "") == 0))
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup (_("Tax entity type not specified"));
else
return g_strdup_printf
(_("Tax entity type not specified; %s"), descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup (_("Tax entity type not specified"));
else
return g_strdup_printf
(_("Tax entity type not specified; %s"), descendant_txt);
}
atype = xaccAccountGetType (account);
/* tax_entity_type = scm_from_locale_string (tax_type); <- requires guile 1.8*/
@ -603,25 +603,25 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (tax_related)
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Tax type %s: invalid code %s for account type"),
tax_type, num_code);
else
return g_strdup_printf
(_("Tax type %s: invalid code %s for account type; %s"),
tax_type, num_code, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Tax type %s: invalid code %s for account type"),
tax_type, num_code);
else
return g_strdup_printf
(_("Tax type %s: invalid code %s for account type; %s"),
tax_type, num_code, descendant_txt);
}
else
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; tax type %s: invalid code %s for account type"),
tax_type, num_code);
else
return g_strdup_printf
(_("Not tax-related; tax type %s: invalid code %s for account type; %s"),
tax_type, num_code, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; tax type %s: invalid code %s for account type"),
tax_type, num_code);
else
return g_strdup_printf
(_("Not tax-related; tax type %s: invalid code %s for account type; %s"),
tax_type, num_code, descendant_txt);
}
}
@ -631,25 +631,25 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (tax_related)
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Invalid code %s for tax type %s"),
num_code, tax_type);
else
return g_strdup_printf
(_("Invalid code %s for tax type %s; %s"),
num_code, tax_type, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Invalid code %s for tax type %s"),
num_code, tax_type);
else
return g_strdup_printf
(_("Invalid code %s for tax type %s; %s"),
num_code, tax_type, descendant_txt);
}
else
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; invalid code %s for tax type %s"),
num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; invalid code %s for tax type %s; %s"),
num_code, tax_type, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; invalid code %s for tax type %s"),
num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; invalid code %s for tax type %s; %s"),
num_code, tax_type, descendant_txt);
}
}
@ -658,24 +658,24 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (tax_related)
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("No form: code %s, tax type %s"), num_code, tax_type);
else
return g_strdup_printf
(_("No form: code %s, tax type %s; %s"),
num_code, tax_type, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("No form: code %s, tax type %s"), num_code, tax_type);
else
return g_strdup_printf
(_("No form: code %s, tax type %s; %s"),
num_code, tax_type, descendant_txt);
}
else
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; no form: code %s, tax type %s"),
num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no form: code %s, tax type %s; %s"),
num_code, tax_type, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; no form: code %s, tax type %s"),
num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no form: code %s, tax type %s; %s"),
num_code, tax_type, descendant_txt);
}
}
@ -684,25 +684,25 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (tax_related)
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s"),
form, num_code, tax_type);
else
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s; %s"),
form, num_code, tax_type, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s"),
form, num_code, tax_type);
else
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s; %s"),
form, num_code, tax_type, descendant_txt);
}
else
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
form, num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
form, num_code, tax_type, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
form, num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
form, num_code, tax_type, descendant_txt);
}
}
@ -711,25 +711,25 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (tax_related)
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s"),
form, num_code, tax_type);
else
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s; %s"),
form, num_code, tax_type, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s"),
form, num_code, tax_type);
else
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s; %s"),
form, num_code, tax_type, descendant_txt);
}
else
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
form, num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
form, num_code, tax_type, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
form, num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
form, num_code, tax_type, descendant_txt);
}
}
@ -741,31 +741,31 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (safe_strcmp (form, "") == 0)
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf ("%s", desc);
else
return g_strdup_printf ("%s; %s", desc, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf ("%s", desc);
else
return g_strdup_printf ("%s; %s", desc, descendant_txt);
}
else
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf ("%s%s: %s", form, copy_txt, desc);
else
return g_strdup_printf ("%s%s: %s; %s",
form, copy_txt, desc, descendant_txt);
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf ("%s%s: %s", form, copy_txt, desc);
else
return g_strdup_printf ("%s%s: %s; %s",
form, copy_txt, desc, descendant_txt);
}
}
else
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
form, copy_txt, desc, num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; %s%s: %s (code %s, tax type %s); %s"),
form, copy_txt, desc, num_code, tax_type, descendant_txt);
}
{
if (safe_strcmp (descendant_txt, "") == 0)
return g_strdup_printf
(_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
form, copy_txt, desc, num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; %s%s: %s (code %s, tax type %s); %s"),
form, copy_txt, desc, num_code, tax_type, descendant_txt);
}
}
}

View File

@ -153,9 +153,9 @@ static void
gnc_table_slist_free( GSList *table_list )
{
GSList *list;
for ( list = table_list; list !=NULL; list = g_slist_next( list ))
for ( list = table_list; list != NULL; list = g_slist_next( list ))
{
g_free( list->data );
g_free( list->data );
}
g_slist_free( table_list );
}
@ -252,19 +252,19 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
/* Remove uri type if present */
filepath = gnc_uri_get_path ( book_id );
file_exists = g_file_test( filepath,
G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS );
G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS );
if ( !create && !file_exists )
{
qof_backend_set_error( qbe, ERR_FILEIO_FILE_NOT_FOUND );
qof_backend_set_message(qbe, "Sqlite3 file %s not found", filepath);
goto exit;
goto exit;
}
if ( create && !force && file_exists )
{
qof_backend_set_error (qbe, ERR_BACKEND_STORE_EXISTS);
msg = "Might clobber, no force";
goto exit;
goto exit;
}
@ -277,7 +277,7 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
{
PERR( "Unable to create sqlite3 dbi connection\n" );
qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
goto exit;
goto exit;
}
dirname = g_path_get_dirname( filepath );
@ -289,21 +289,21 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
{
PERR( "Error setting 'host' option\n" );
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
goto exit;
}
result = dbi_conn_set_option( be->conn, "dbname", basename );
if ( result < 0 )
{
PERR( "Error setting 'dbname' option\n" );
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
goto exit;
}
result = dbi_conn_set_option( be->conn, "sqlite3_dbdir", dirname );
if ( result < 0 )
{
PERR( "Error setting 'sqlite3_dbdir' option\n" );
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
goto exit;
}
result = dbi_conn_connect( be->conn );
@ -311,26 +311,28 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
{
PERR( "Unable to connect to %s: %d\n", book_id, result );
qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
goto exit;
goto exit;
}
if ( !conn_test_dbi_library( be->conn ) ) {
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe, "DBI library fails large number test" );
if ( create && !file_exists ) /* File didn't exist before, but it */
{ /* does now, and we don't want to */
dbi_conn_close( be->conn );/* leave it lying around. */
be->conn = NULL;
g_unlink( filepath );
}
msg = "Bad DBI Library";
goto exit;
if ( !conn_test_dbi_library( be->conn ) )
{
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe, "DBI library fails large number test" );
if ( create && !file_exists ) /* File didn't exist before, but it */
{
/* does now, and we don't want to */
dbi_conn_close( be->conn );/* leave it lying around. */
be->conn = NULL;
g_unlink( filepath );
}
msg = "Bad DBI Library";
goto exit;
}
if ( !gnc_dbi_lock_database( qbe, ignore_lock ) )
{
qof_backend_set_error( qbe, ERR_BACKEND_LOCKED );
msg = "Locked";
goto exit;
goto exit;
}
if ( be->sql_be.conn != NULL )
@ -354,8 +356,8 @@ conn_get_index_list_sqlite3( dbi_conn conn )
dbi_result result = dbi_conn_query( conn, "SELECT name FROM sqlite_master WHERE type = 'index' AND name NOT LIKE 'sqlite_autoindex%'" );
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
{
g_print( "Index Table Retrieval Error: %s\n", errmsg );
return NULL;
g_print( "Index Table Retrieval Error: %s\n", errmsg );
return NULL;
}
while ( dbi_result_next_row( result ) != 0 )
{
@ -761,12 +763,13 @@ gnc_dbi_mysql_session_begin( QofBackend* qbe, QofSession *session,
result = dbi_conn_connect( be->conn );
if ( result == 0 )
{
if ( !conn_test_dbi_library( be->conn ) ) {
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe,
"DBI library fails large number test" );
goto exit;
}
if ( !conn_test_dbi_library( be->conn ) )
{
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe,
"DBI library fails large number test" );
goto exit;
}
if (create && !force && save_may_clobber_data( qbe ) )
{
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
@ -833,13 +836,14 @@ gnc_dbi_mysql_session_begin( QofBackend* qbe, QofSession *session,
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
}
if ( !conn_test_dbi_library( be->conn ) ) {
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe,
"DBI library fails large number test" );
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbname );
goto exit;
}
if ( !conn_test_dbi_library( be->conn ) )
{
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe,
"DBI library fails large number test" );
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbname );
goto exit;
}
success = gnc_dbi_lock_database ( qbe, ignore_lock );
}
else
@ -891,28 +895,28 @@ conn_get_index_list_mysql( dbi_conn conn )
table_list = dbi_conn_get_table_list( conn, dbname, NULL );
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
{
g_print( "Table Retrieval Error: %s\n", errmsg );
return NULL;
g_print( "Table Retrieval Error: %s\n", errmsg );
return NULL;
}
while ( dbi_result_next_row( table_list ) != 0 )
{
dbi_result result;
const gchar *table_name = dbi_result_get_string_idx( table_list, 1 );
result = dbi_conn_queryf( conn,
"SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
table_name );
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
{
g_print( "Index Table Retrieval Error: %s\n", errmsg );
continue;
}
dbi_result result;
const gchar *table_name = dbi_result_get_string_idx( table_list, 1 );
result = dbi_conn_queryf( conn,
"SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
table_name );
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
{
g_print( "Index Table Retrieval Error: %s\n", errmsg );
continue;
}
while ( dbi_result_next_row( result ) != 0 )
{
const gchar* index_name = dbi_result_get_string_idx( result, 3 );
index_list = g_slist_prepend( index_list, strdup( index_name ) );
}
dbi_result_free( result );
while ( dbi_result_next_row( result ) != 0 )
{
const gchar* index_name = dbi_result_get_string_idx( result, 3 );
index_list = g_slist_prepend( index_list, strdup( index_name ) );
}
dbi_result_free( result );
}
return index_list;
@ -1027,12 +1031,13 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
result = dbi_conn_connect( be->conn );
if ( result == 0 )
{
if ( !conn_test_dbi_library( be->conn ) ) {
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe,
"DBI library fails large number test" );
goto exit;
}
if ( !conn_test_dbi_library( be->conn ) )
{
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe,
"DBI library fails large number test" );
goto exit;
}
if (create && !force && save_may_clobber_data( qbe ) )
{
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
@ -1100,14 +1105,15 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
}
if ( !conn_test_dbi_library( be->conn ) ) {
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe,
"DBI library fails large number test" );
dbi_conn_select_db( be->conn, "template1" );
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbnamelc );
goto exit;
}
if ( !conn_test_dbi_library( be->conn ) )
{
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
qof_backend_set_message( qbe,
"DBI library fails large number test" );
dbi_conn_select_db( be->conn, "template1" );
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbnamelc );
goto exit;
}
success = gnc_dbi_lock_database ( qbe, ignore_lock );
}
else
@ -1146,8 +1152,8 @@ conn_get_index_list_pgsql( dbi_conn conn )
result = dbi_conn_query( conn, "SELECT relname FROM pg_class AS a INNER JOIN pg_index AS b ON (b.indexrelid = a.oid) INNER JOIN pg_namespace AS c ON (a.relnamespace = c.oid) WHERE reltype = '0' AND indisprimary = 'f' AND nspname = 'public'" );
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
{
g_print( "Index Table Retrieval Error: %s\n", errmsg );
return NULL;
g_print( "Index Table Retrieval Error: %s\n", errmsg );
return NULL;
}
while ( dbi_result_next_row( result ) != 0 )
{
@ -1226,19 +1232,19 @@ gnc_dbi_load( QofBackend* qbe, /*@ dependent @*/ QofBook *book, QofBackendLoadTy
if ( GNC_RESAVE_VERSION > gnc_sql_get_table_version( &be->sql_be, "Gnucash" ) )
{
/* The database was loaded with an older database schema or
* data semantics. In order to ensure consistency, the whole
* thing needs to be saved anew. */
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_OLD );
/* The database was loaded with an older database schema or
* data semantics. In order to ensure consistency, the whole
* thing needs to be saved anew. */
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_OLD );
}
else if ( GNC_RESAVE_VERSION < gnc_sql_get_table_version( &be->sql_be,
"Gnucash-Resave"))
"Gnucash-Resave"))
{
/* Worse, the database was created with a newer version. We
* can't safely write to this database, so the user will have
* to do a "save as" to make one that we can write to.
*/
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_NEW );
/* Worse, the database was created with a newer version. We
* can't safely write to this database, so the user will have
* to do a "save as" to make one that we can write to.
*/
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_NEW );
}
@ -1268,26 +1274,26 @@ save_may_clobber_data( QofBackend* qbe )
static dbi_result
conn_table_manage_backup (GncDbiSqlConnection *conn,
gchar *table_name, TableOpType op )
gchar *table_name, TableOpType op )
{
gchar *new_name = g_strdup_printf( "%s_%s", table_name, "back" );
dbi_result result;
switch ( op )
{
case backup:
result = dbi_conn_queryf( conn->conn, "ALTER TABLE %s RENAME TO %s",
table_name, new_name );
break;
result = dbi_conn_queryf( conn->conn, "ALTER TABLE %s RENAME TO %s",
table_name, new_name );
break;
case rollback:
result = dbi_conn_queryf( conn->conn,
"ALTER TABLE %s RENAME TO %s",
new_name, table_name );
break;
result = dbi_conn_queryf( conn->conn,
"ALTER TABLE %s RENAME TO %s",
new_name, table_name );
break;
case drop_backup:
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
new_name );
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
new_name );
default:
break;
break;
}
g_free( new_name );
return result;
@ -1320,7 +1326,7 @@ conn_table_manage_backup (GncDbiSqlConnection *conn,
static gboolean
conn_table_operation( GncSqlConnection *sql_conn, GSList *table_name_list,
TableOpType op )
TableOpType op )
{
GSList* node;
gboolean result = TRUE;
@ -1330,55 +1336,56 @@ conn_table_operation( GncSqlConnection *sql_conn, GSList *table_name_list,
g_return_val_if_fail( table_name_list != NULL, FALSE );
if ( op == rollback )
full_table_name_list =
conn->provider->get_table_list( conn->conn, dbname );
full_table_name_list =
conn->provider->get_table_list( conn->conn, dbname );
for ( node = table_name_list; node != NULL && result; node = node->next )
{
gchar* table_name = (gchar*)node->data;
dbi_result result;
/* Ignore the lock table */
if ( g_strcmp0(table_name, lock_table) == 0)
{
continue;
}
do
{
gnc_dbi_init_error( conn );
switch( op ) {
case rollback:
if (g_slist_find(full_table_name_list, table_name))
{
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
table_name );
if ( result )
break;
}
/* Note fall-through */
case backup:
case drop_backup:
result = conn_table_manage_backup( conn, table_name, op );
break;
case empty:
result = dbi_conn_queryf( conn->conn, "DELETE FROM TABLE %s",
table_name );
break;
case drop:
default:
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
table_name );
break;
}
}
while ( conn->retry );
if ( result != NULL )
{
if ( dbi_result_free( result ) < 0 )
{
PERR( "Error in dbi_result_free() result\n" );
result = FALSE;
}
}
gchar* table_name = (gchar*)node->data;
dbi_result result;
/* Ignore the lock table */
if ( g_strcmp0(table_name, lock_table) == 0)
{
continue;
}
do
{
gnc_dbi_init_error( conn );
switch ( op )
{
case rollback:
if (g_slist_find(full_table_name_list, table_name))
{
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
table_name );
if ( result )
break;
}
/* Note fall-through */
case backup:
case drop_backup:
result = conn_table_manage_backup( conn, table_name, op );
break;
case empty:
result = dbi_conn_queryf( conn->conn, "DELETE FROM TABLE %s",
table_name );
break;
case drop:
default:
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
table_name );
break;
}
}
while ( conn->retry );
if ( result != NULL )
{
if ( dbi_result_free( result ) < 0 )
{
PERR( "Error in dbi_result_free() result\n" );
result = FALSE;
}
}
}
gnc_table_slist_free( full_table_name_list );
return result;
@ -1409,7 +1416,7 @@ gnc_dbi_sync_all( QofBackend* qbe, /*@ dependent @*/ QofBook *book )
dbname = dbi_conn_get_option( be->conn, "dbname" );
table_name_list = conn->provider->get_table_list( conn->conn, dbname );
if ( !conn_table_operation( (GncSqlConnection*)conn, table_name_list,
drop ) )
drop ) )
{
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
return;
@ -1448,33 +1455,33 @@ gnc_dbi_safe_sync_all( QofBackend *qbe, QofBook *book )
dbname = dbi_conn_get_option( be->conn, "dbname" );
table_list = conn->provider->get_table_list( conn->conn, dbname );
if ( !conn_table_operation( (GncSqlConnection*)conn, table_list,
backup ) )
backup ) )
{
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
conn_table_operation( (GncSqlConnection*)conn, table_list,
rollback );
LEAVE( "Failed to rename tables" );
gnc_table_slist_free( table_list );
return;
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
conn_table_operation( (GncSqlConnection*)conn, table_list,
rollback );
LEAVE( "Failed to rename tables" );
gnc_table_slist_free( table_list );
return;
}
index_list = conn->provider->get_index_list( conn->conn );
for ( iter = index_list; iter != NULL; iter = g_slist_next( iter) )
{
const char *errmsg;
dbi_result result =
dbi_conn_queryf( conn->conn, "DROP INDEX %s", iter->data );
if ( result )
dbi_result_free( result );
if ( DBI_ERROR_NONE != dbi_conn_error( conn->conn, &errmsg ) )
{
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
gnc_table_slist_free( index_list );
conn_table_operation( (GncSqlConnection*)conn, table_list,
rollback );
gnc_table_slist_free( table_list );
LEAVE( "Failed to drop indexes %s", errmsg );
return;
}
const char *errmsg;
dbi_result result =
dbi_conn_queryf( conn->conn, "DROP INDEX %s", iter->data );
if ( result )
dbi_result_free( result );
if ( DBI_ERROR_NONE != dbi_conn_error( conn->conn, &errmsg ) )
{
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
gnc_table_slist_free( index_list );
conn_table_operation( (GncSqlConnection*)conn, table_list,
rollback );
gnc_table_slist_free( table_list );
LEAVE( "Failed to drop indexes %s", errmsg );
return;
}
}
gnc_table_slist_free( index_list );
@ -1484,13 +1491,13 @@ gnc_dbi_safe_sync_all( QofBackend *qbe, QofBook *book )
gnc_sql_sync_all( &be->sql_be, book );
if ( ERR_BACKEND_NO_ERR != qof_backend_get_error( qbe ) )
{
conn_table_operation( (GncSqlConnection*)conn, table_list,
rollback );
LEAVE( "Failed to create new database tables" );
return;
conn_table_operation( (GncSqlConnection*)conn, table_list,
rollback );
LEAVE( "Failed to create new database tables" );
return;
}
conn_table_operation( (GncSqlConnection*)conn, table_list,
drop_backup );
drop_backup );
gnc_table_slist_free( table_list );
LEAVE("book=%p", book);
}
@ -2860,58 +2867,58 @@ conn_test_dbi_library( dbi_conn conn )
gboolean retval = TRUE;
result = dbi_conn_query( conn, "CREATE TEMPORARY TABLE numtest "
"( test_int BIGINT, test_unsigned BIGINT,"
" test_double FLOAT8 )" );
"( test_int BIGINT, test_unsigned BIGINT,"
" test_double FLOAT8 )" );
if ( result == NULL )
{
PWARN("Test_DBI_Library: Create table failed");
return FALSE;
PWARN("Test_DBI_Library: Create table failed");
return FALSE;
}
dbi_result_free( result );
result = dbi_conn_queryf( conn,
"INSERT INTO numtest VALUES (%lld, %llu, %17e)",
testlonglong, testulonglong, testdouble );
"INSERT INTO numtest VALUES (%lld, %llu, %17e)",
testlonglong, testulonglong, testdouble );
if ( result == NULL )
{
PWARN("Test_DBI_Library: Failed to insert test row into table" );
return FALSE;
PWARN("Test_DBI_Library: Failed to insert test row into table" );
return FALSE;
}
dbi_result_free( result );
result = dbi_conn_query( conn, "SELECT * FROM numtest" );
if ( result == NULL )
{
const char *errmsg;
dbi_conn_error( conn, &errmsg );
PWARN("Test_DBI_Library: Failed to retrieve test row into table: %s",
errmsg );
result = dbi_conn_query( conn, "DROP TABLE numtest" );
return FALSE;
const char *errmsg;
dbi_conn_error( conn, &errmsg );
PWARN("Test_DBI_Library: Failed to retrieve test row into table: %s",
errmsg );
result = dbi_conn_query( conn, "DROP TABLE numtest" );
return FALSE;
}
while ( dbi_result_next_row( result ))
{
resultlonglong = dbi_result_get_longlong( result, "test_int" );
resultulonglong = dbi_result_get_ulonglong( result, "test_unsigned" );
resultdouble = dbi_result_get_double( result, "test_double" );
resultlonglong = dbi_result_get_longlong( result, "test_int" );
resultulonglong = dbi_result_get_ulonglong( result, "test_unsigned" );
resultdouble = dbi_result_get_double( result, "test_double" );
}
if ( testlonglong != resultlonglong )
{
PWARN( "Test_DBI_Library: LongLong Failed %" G_GINT64_FORMAT " != % " G_GINT64_FORMAT,
testlonglong, resultlonglong );
retval = FALSE;
PWARN( "Test_DBI_Library: LongLong Failed %" G_GINT64_FORMAT " != % " G_GINT64_FORMAT,
testlonglong, resultlonglong );
retval = FALSE;
}
if ( testulonglong != resultulonglong )
{
PWARN( "Test_DBI_Library: Unsigned longlong Failed %" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT,
testulonglong, resultulonglong );
retval = FALSE;
PWARN( "Test_DBI_Library: Unsigned longlong Failed %" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT,
testulonglong, resultulonglong );
retval = FALSE;
}
/* A bug in libdbi stores only 7 digits of precision */
if ( testdouble >= resultdouble + 0.000001e307 ||
testdouble <= resultdouble - 0.000001e307 )
testdouble <= resultdouble - 0.000001e307 )
{
PWARN( "Test_DBI_Library: Double Failed %17e != %17e",
testdouble, resultdouble );
retval = FALSE;
PWARN( "Test_DBI_Library: Double Failed %17e != %17e",
testdouble, resultdouble );
retval = FALSE;
}
return retval;
}

View File

@ -121,9 +121,9 @@ int main (int argc, char ** argv)
{
session_1 = create_session();
test_dbi_store_and_reload( "mysql", session_1, TEST_MYSQL_URL );
session_1 = create_session();
test_dbi_safe_save( "mysql", filename );
test_dbi_version_control( "mysql", filename );
session_1 = create_session();
test_dbi_safe_save( "mysql", filename );
test_dbi_version_control( "mysql", filename );
}
#endif
#ifdef TEST_PGSQL_URL
@ -132,9 +132,9 @@ int main (int argc, char ** argv)
{
session_1 = create_session();
test_dbi_store_and_reload( "pgsql", session_1, TEST_PGSQL_URL );
session_1 = create_session();
test_dbi_safe_save( "pgsql", filename );
test_dbi_version_control( "pgsql", filename );
session_1 = create_session();
test_dbi_safe_save( "pgsql", filename );
test_dbi_version_control( "pgsql", filename );
}
#endif
print_test_results();

View File

@ -141,8 +141,8 @@ test_conn_get_index_list( QofBackend *qbe )
g_print ( "Returned from index list\n");
if ( index_list == NULL )
{
do_test( FALSE, "Index List Test -- No List" );
return;
do_test( FALSE, "Index List Test -- No List" );
return;
}
do_test( g_slist_length( index_list ) == 4, "Index List Test" );
g_slist_free( index_list );
@ -177,16 +177,16 @@ test_dbi_store_and_reload( const gchar* driver, QofSession* session_1, const gch
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %d, %s", qof_session_get_error(session_2), qof_session_get_error_message(session_2));
do_test( FALSE, "First DB Session Creation Failed");
return;
do_test( FALSE, "First DB Session Creation Failed");
return;
}
qof_session_swap_data( session_1, session_2 );
qof_session_save( session_2, NULL );
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %s", qof_session_get_error_message(session_2));
do_test( FALSE, "First DB Session Save Failed");
return;
do_test( FALSE, "First DB Session Save Failed");
return;
}
// Reload the session data
@ -195,15 +195,15 @@ test_dbi_store_and_reload( const gchar* driver, QofSession* session_1, const gch
if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %s", qof_session_get_error_message(session_3));
do_test( FALSE, "Second DB Session Creation Failed");
return;
do_test( FALSE, "Second DB Session Creation Failed");
return;
}
qof_session_load( session_3, NULL );
if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %s", qof_session_get_error_message(session_3));
do_test( FALSE, "Second DBI Session Load Failed");
return;
do_test( FALSE, "Second DBI Session Load Failed");
return;
}
// Compare with the original data
compare_books( qof_session_get_book( session_2 ), qof_session_get_book( session_3 ) );
@ -236,18 +236,18 @@ test_dbi_safe_save( const gchar* driver, const gchar* url )
if (session_1 && qof_session_get_error(session_1) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %d, %s", qof_session_get_error(session_1),
qof_session_get_error_message(session_1));
do_test( FALSE, "DB Session Creation Failed");
goto cleanup;
qof_session_get_error_message(session_1));
do_test( FALSE, "DB Session Creation Failed");
goto cleanup;
}
qof_session_load( session_1, NULL );
/* Do a safe save */
/* Do a safe save */
qof_session_safe_save( session_1, NULL );
if (session_1 && qof_session_get_error(session_1) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %s", qof_session_get_error_message(session_1));
do_test( FALSE, "DB Session Safe Save Failed");
goto cleanup;
do_test( FALSE, "DB Session Safe Save Failed");
goto cleanup;
}
/* Destroy the session and reload it */
@ -256,13 +256,13 @@ test_dbi_safe_save( const gchar* driver, const gchar* url )
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %d, %s", qof_session_get_error(session_2),
qof_session_get_error_message(session_2));
do_test( FALSE, "DB Session re-creation Failed");
goto cleanup;
qof_session_get_error_message(session_2));
do_test( FALSE, "DB Session re-creation Failed");
goto cleanup;
}
qof_session_load( session_2, NULL );
compare_books( qof_session_get_book( session_1 ),
qof_session_get_book( session_2 ) );
compare_books( qof_session_get_book( session_1 ),
qof_session_get_book( session_2 ) );
cleanup:
qof_session_end( session_2 );
@ -294,16 +294,16 @@ test_dbi_version_control( const gchar* driver, const gchar* url )
if (sess && qof_session_get_error(sess) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %d, %s", qof_session_get_error(sess),
qof_session_get_error_message(sess));
do_test( FALSE, "DB Session Creation Failed");
goto cleanup;
qof_session_get_error_message(sess));
do_test( FALSE, "DB Session Creation Failed");
goto cleanup;
}
qof_session_load( sess, NULL );
qbe = qof_session_get_backend( sess );
book = qof_session_get_book( sess );
qof_book_begin_edit( book );
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
"Gnucash", GNC_RESAVE_VERSION - 1 );
"Gnucash", GNC_RESAVE_VERSION - 1 );
qof_book_commit_edit( book );
qof_session_end( sess );
qof_session_destroy( sess );
@ -316,9 +316,9 @@ test_dbi_version_control( const gchar* driver, const gchar* url )
book = qof_session_get_book( sess );
qof_book_begin_edit( book );
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
"Gnucash", ourversion );
"Gnucash", ourversion );
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
"Gnucash-Resave", ourversion + 1 );
"Gnucash-Resave", ourversion + 1 );
qof_book_commit_edit( book );
qof_session_end( sess );
qof_session_destroy( sess );

View File

@ -161,7 +161,7 @@ create_tables_cb( const gchar* type, gpointer data_p, gpointer be_p )
if ( pData->create_tables != NULL )
{
update_progress( be );
update_progress( be );
(pData->create_tables)( be );
}
}
@ -194,14 +194,14 @@ initial_load_cb( const gchar* type, gpointer data_p, gpointer be_p )
// Don't need to load anything if it has already been loaded with the fixed order
for ( i = 0; fixed_load_order[i] != NULL; i++ )
{
update_progress( be );
update_progress( be );
if ( g_ascii_strcasecmp( type, fixed_load_order[i] ) == 0 ) return;
}
if ( other_load_order != NULL )
{
for ( i = 0; other_load_order[i] != NULL; i++ )
{
update_progress( be );
update_progress( be );
if ( g_ascii_strcasecmp( type, other_load_order[i] ) == 0 ) return;
}
}
@ -237,7 +237,7 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
pData = qof_object_lookup_backend( fixed_load_order[i], GNC_SQL_BACKEND );
if ( pData->initial_load != NULL )
{
update_progress( be );
update_progress( be );
(pData->initial_load)( be );
}
}
@ -248,7 +248,7 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
pData = qof_object_lookup_backend( other_load_order[i], GNC_SQL_BACKEND );
if ( pData->initial_load != NULL )
{
update_progress( be );
update_progress( be );
(pData->initial_load)( be );
}
}
@ -350,7 +350,7 @@ write_account_tree( GncSqlBackend* be, Account* root )
{
is_ok = gnc_sql_save_account( be, QOF_INSTANCE(GNC_ACCOUNT(node->data)) );
if ( !is_ok ) break;
}
}
g_list_free( descendants );
}
update_progress( be );
@ -369,7 +369,7 @@ write_accounts( GncSqlBackend* be )
is_ok = write_account_tree( be, gnc_book_get_root_account( be->primary_book ) );
if ( is_ok )
{
update_progress( be );
update_progress( be );
is_ok = write_account_tree( be, gnc_book_get_template_root( be->primary_book ) );
}
@ -407,7 +407,7 @@ write_transactions( GncSqlBackend* be )
data.be = be;
data.is_ok = TRUE;
(void)xaccAccountTreeForEachTransaction(
gnc_book_get_root_account( be->primary_book ), write_tx, &data );
gnc_book_get_root_account( be->primary_book ), write_tx, &data );
update_progress( be );
return data.is_ok;
}
@ -426,7 +426,7 @@ write_template_transactions( GncSqlBackend* be )
if ( gnc_account_n_descendants( ra ) > 0 )
{
(void)xaccAccountTreeForEachTransaction( ra, write_tx, &data );
update_progress( be );
update_progress( be );
}
return data.is_ok;
@ -465,7 +465,7 @@ write_cb( const gchar* type, gpointer data_p, gpointer be_p )
if ( pData->write != NULL )
{
(void)(pData->write)( be );
update_progress( be );
update_progress( be );
}
}
@ -549,7 +549,7 @@ gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book )
}
else
{
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
is_ok = gnc_sql_connection_rollback_transaction( be->conn );
}
finish_progress( be );
@ -616,9 +616,9 @@ gnc_sql_commit_edit( GncSqlBackend *be, QofInstance *inst )
if ( qof_book_is_readonly( be->primary_book ) )
{
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_READONLY );
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_READONLY );
(void)gnc_sql_connection_rollback_transaction( be->conn );
return;
return;
}
/* During initial load where objects are being created, don't commit
anything, but do mark the object as clean. */
@ -665,7 +665,7 @@ gnc_sql_commit_edit( GncSqlBackend *be, QofInstance *inst )
be_data.is_ok = TRUE;
/* Set/update the application version in the database */
if ( gnc_sql_get_table_version( be, "Gnucash") != gnc_version )
gnc_sql_set_table_version( be, "Gnucash", gnc_version );
gnc_sql_set_table_version( be, "Gnucash", gnc_version );
qof_object_foreach_backend( GNC_SQL_BACKEND, commit_cb, &be_data );

View File

@ -705,7 +705,7 @@ gnc_plugin_page_invoice_cmd_edit (GtkAction *action,
static void
gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action,
GncPluginPageInvoice *plugin_page)
GncPluginPageInvoice *plugin_page)
{
GncPluginPageInvoicePrivate *priv;
@ -828,7 +828,7 @@ gnc_plugin_page_invoice_cmd_blank (GtkAction *action,
static void
gnc_plugin_page_invoice_cmd_duplicateEntry (GtkAction *action,
GncPluginPageInvoice *plugin_page)
GncPluginPageInvoice *plugin_page)
{
GncPluginPageInvoicePrivate *priv;

View File

@ -276,7 +276,7 @@ static QofQuery *new_query_for_entry_desc(GncEntryLedger *reg, const char* desc,
/* For invoice entries, Entry->Bill must be NULL, and vice versa */
qof_query_add_guid_match (query,
qof_query_build_param_list (should_be_null,
QOF_PARAM_GUID, NULL),
QOF_PARAM_GUID, NULL),
NULL, QOF_QUERY_AND);
/* Set the sort order: By DATE_ENTERED, increasing, and returning
@ -494,9 +494,9 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
auto_entry =
/* Use this for book-wide auto-completion of the invoice entries */
find_entry_in_book_by_desc(ledger, desc);
/* #else */
/* gnc_find_entry_in_reg_by_desc(ledger, desc); */
/* #endif */
/* #else */
/* gnc_find_entry_in_reg_by_desc(ledger, desc); */
/* #endif */
if (auto_entry == NULL)
return FALSE;

View File

@ -1805,9 +1805,9 @@ xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
xaccTransBeginEdit(trans);
if (is_closing)
kvp_frame_set_gint64 (trans->inst.kvp_data, trans_is_closing_str, 1);
kvp_frame_set_gint64 (trans->inst.kvp_data, trans_is_closing_str, 1);
else
kvp_frame_replace_value_nc (trans->inst.kvp_data, trans_is_closing_str, NULL);
kvp_frame_replace_value_nc (trans->inst.kvp_data, trans_is_closing_str, NULL);
qof_instance_set_dirty(QOF_INSTANCE(trans));
xaccTransCommitEdit(trans);
}
@ -1873,8 +1873,8 @@ gboolean
xaccTransGetIsClosingTxn (const Transaction *trans)
{
return trans ?
kvp_frame_get_gint64 (trans->inst.kvp_data, trans_is_closing_str)
: FALSE;
kvp_frame_get_gint64 (trans->inst.kvp_data, trans_is_closing_str)
: FALSE;
}
/********************************************************************\

View File

@ -326,7 +326,7 @@ clone_budget_values_cb(Account* a, gpointer user_data)
if ( gnc_budget_is_account_period_value_set(data->old_b, a, i) )
{
gnc_budget_set_account_period_value(data->new_b, a, i,
gnc_budget_get_account_period_value(data->old_b, a, i));
gnc_budget_get_account_period_value(data->old_b, a, i));
}
}
}

View File

@ -1354,10 +1354,10 @@ gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz)
priv = GET_PRIVATE(cm);
if (tz == priv->quote_tz)
if (tz == priv->quote_tz)
{
LEAVE("Already correct TZ");
return;
LEAVE("Already correct TZ");
return;
}
gnc_commodity_begin_edit(cm);

View File

@ -104,7 +104,7 @@ find_or_create_txn(struct CloseAccountsCB* cacb, gnc_commodity* cmdty)
xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
xaccTransSetDescription(txn->txn, cacb->cbw->desc);
xaccTransSetCurrency(txn->txn, cmdty);
xaccTransSetIsClosingTxn(txn->txn, TRUE);
xaccTransSetIsClosingTxn(txn->txn, TRUE);
g_hash_table_insert(cacb->txns, cmdty, txn);
}

View File

@ -55,8 +55,8 @@ listen_for_gncentry_events(QofInstance *entity, QofEventId event_type,
if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
return;
/* g_warning("entity %p, entity type %s, event type %s, user data %p, ecent data %p", */
/* entity, entity->e_type, qofeventid_to_string(event_type), user_data, event_data); */
/* g_warning("entity %p, entity type %s, event type %s, user data %p, ecent data %p", */
/* entity, entity->e_type, qofeventid_to_string(event_type), user_data, event_data); */
desc = gncEntryGetDescription(GNC_ENTRY(entity));
if (event_type & QOF_EVENT_MODIFY)
@ -124,7 +124,7 @@ static EntryQF* build_shared_quickfill (QofBook *book, const char * key, gboolea
QofQuery *query = new_query_for_entrys(book);
GList *entries = qof_query_run(query);
/* g_warning("Found %d GncEntry items", g_list_length (entries)); */
/* g_warning("Found %d GncEntry items", g_list_length (entries)); */
result = g_new0(EntryQF, 1);

View File

@ -412,18 +412,18 @@ show_session_error (QofBackendError io_error,
case ERR_SQL_DB_TOO_OLD:
fmt = _("This database is from an older version of GnuCash. "
"Select OK to upgrade it to the current version, Cancel "
"to mark it read-only.");
"to mark it read-only.");
response = gnc_ok_cancel_dialog(parent, GTK_RESPONSE_CANCEL, "%s", fmt);
uh_oh = (response == GTK_RESPONSE_CANCEL);
uh_oh = (response == GTK_RESPONSE_CANCEL);
break;
case ERR_SQL_DB_TOO_NEW:
fmt = _("This database is from a newer version of GnuCash. "
"This version can read it, but cannot safely save to it. "
"It will be marked read-only until you do File>Save As.");
"It will be marked read-only until you do File>Save As.");
gnc_warning_dialog (parent, "%s", fmt);
uh_oh = TRUE;
uh_oh = TRUE;
break;
case ERR_SQL_DB_BUSY:
@ -437,15 +437,15 @@ show_session_error (QofBackendError io_error,
case ERR_SQL_BAD_DBI:
fmt = _("The library \"libdbi\" installed on your system doesn't correctly "
fmt = _("The library \"libdbi\" installed on your system doesn't correctly "
"store large numbers. This means GnuCash cannot use SQL databases "
"correctly. Gnucash will not open or save to SQL databases until this is "
"fixed by installing a different version of \"libdbi\". Please see "
"https://bugzilla.gnome.org/show_bug.cgi?id=611936 for more "
"information.");
gnc_error_dialog (parent, "%s", fmt);
break;
gnc_error_dialog (parent, "%s", fmt);
break;
default:
PERR("FIXME: Unhandled error %d", io_error);
@ -766,8 +766,8 @@ gnc_post_file_open (const char * filename)
* don't bother with the message, just die. */
io_err = qof_session_get_error (new_session);
if ((ERR_BACKEND_LOCKED == io_err) ||
(ERR_BACKEND_READONLY == io_err) ||
(ERR_BACKEND_NO_SUCH_DB == io_err))
(ERR_BACKEND_READONLY == io_err) ||
(ERR_BACKEND_NO_SUCH_DB == io_err))
{
uh_oh = TRUE;
}
@ -815,24 +815,24 @@ gnc_post_file_open (const char * filename)
}
uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
/* Attempt to update the database if it's too old */
if ( !uh_oh && io_err == ERR_SQL_DB_TOO_OLD )
{
gnc_window_show_progress(_("Re-saving user data..."), 0.0);
qof_session_safe_save(new_session, gnc_window_show_progress);
io_err = qof_session_get_error(new_session);
uh_oh = show_session_error(io_err, newfile, GNC_FILE_DIALOG_SAVE);
}
/* Database is either too old and couldn't (or user didn't
* want it to) be updated or it's too new. Mark it as
* read-only
*/
if (uh_oh && (io_err == ERR_SQL_DB_TOO_OLD ||
/* Attempt to update the database if it's too old */
if ( !uh_oh && io_err == ERR_SQL_DB_TOO_OLD )
{
gnc_window_show_progress(_("Re-saving user data..."), 0.0);
qof_session_safe_save(new_session, gnc_window_show_progress);
io_err = qof_session_get_error(new_session);
uh_oh = show_session_error(io_err, newfile, GNC_FILE_DIALOG_SAVE);
}
/* Database is either too old and couldn't (or user didn't
* want it to) be updated or it's too new. Mark it as
* read-only
*/
if (uh_oh && (io_err == ERR_SQL_DB_TOO_OLD ||
io_err == ERR_SQL_DB_TOO_NEW))
{
qof_book_mark_readonly(qof_session_get_book(new_session));
uh_oh = FALSE;
}
{
qof_book_mark_readonly(qof_session_get_book(new_session));
uh_oh = FALSE;
}
new_root = gnc_book_get_root_account (qof_session_get_book (new_session));
if (uh_oh) new_root = NULL;

View File

@ -2353,13 +2353,13 @@ gnc_main_window_engine_commit_error_callback( gpointer data,
GtkWidget* dialog;
gchar *reason = ".";
if ( errcode == ERR_BACKEND_READONLY )
reason = _(": Book is marked read-only.");
reason = _(": Book is marked read-only.");
dialog = gtk_message_dialog_new( GTK_WINDOW(window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Unable to save to database%s"),
reason );
reason );
gtk_dialog_run(GTK_DIALOG (dialog));
gtk_widget_destroy(dialog);

View File

@ -128,8 +128,8 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
{
g_warning("gnc_ab_getbalance: Error on executing job");
gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
, AB_Job_Status2Char(job_status)
, AB_Job_GetResultText(job));
, AB_Job_Status2Char(job_status)
, AB_Job_GetResultText(job));
goto cleanup;
}

View File

@ -193,8 +193,8 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
{
g_warning("gnc_ab_gettrans: Error on executing job");
gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
, AB_Job_Status2Char(job_status)
, AB_Job_GetResultText(job));
, AB_Job_Status2Char(job_status)
, AB_Job_GetResultText(job));
goto cleanup;
}

View File

@ -435,11 +435,11 @@ gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans)
{
retval = g_strdup_printf("%s %s %s %s",
have_accountid ? _("Account") : "",
have_accountid ? ab_other_accountid : "",
have_bankcode ? _("Bank") : "",
have_bankcode ? ab_other_bankcode : ""
);
g_strstrip(retval);
have_accountid ? ab_other_accountid : "",
have_bankcode ? _("Bank") : "",
have_bankcode ? ab_other_bankcode : ""
);
g_strstrip(retval);
}
else
{

View File

@ -325,15 +325,15 @@ gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account,
gnc_plugin_update_actions(action_group, need_account_actions,
"sensitive",
(account && bankcode && *bankcode
&& accountid && *accountid));
(account && bankcode && *bankcode
&& accountid && *accountid));
gnc_plugin_update_actions(action_group, need_account_actions,
"visible",TRUE);
"visible", TRUE);
}
else
{
gnc_plugin_update_actions(action_group, need_account_actions,
"sensitive",FALSE);
"sensitive", FALSE);
gnc_plugin_update_actions(action_group, need_account_actions,
"visible", FALSE);
}

View File

@ -946,8 +946,8 @@ gnc_import_process_trans_item (GncImportMatchMap *matchmap,
xaccTransBeginEdit(selected_match->trans);
xaccTransSetDatePostedSecs(selected_match->trans,
xaccTransGetDate(xaccSplitGetParent(
gnc_import_TransInfo_get_fsplit(trans_info))));
xaccTransGetDate(xaccSplitGetParent(
gnc_import_TransInfo_get_fsplit(trans_info))));
xaccSplitSetAmount(selected_match->split,
xaccSplitGetAmount(
@ -988,7 +988,7 @@ gnc_import_process_trans_item (GncImportMatchMap *matchmap,
if (gnc_import_split_has_online_id(trans_info->first_split))
{
gnc_import_set_split_online_id(selected_match->split,
gnc_import_get_split_online_id(trans_info->first_split));
gnc_import_get_split_online_id(trans_info->first_split));
}
/* Done editing. */
@ -1231,8 +1231,8 @@ gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info,
trans_info->action = GNCImport_ADD;
}
if (best_match &&
trans_info->action == GNCImport_CLEAR &&
gnc_import_Settings_get_action_update_enabled(settings))
trans_info->action == GNCImport_CLEAR &&
gnc_import_Settings_get_action_update_enabled(settings))
{
if (best_match->update_proposed)
{

View File

@ -331,8 +331,8 @@ gnc_gen_trans_clear_toggled_cb (GtkCellRendererToggle *cell_renderer,
static void
gnc_gen_trans_update_toggled_cb (GtkCellRendererToggle *cell_renderer,
gchar *path,
GNCImportMainMatcher *gui)
gchar *path,
GNCImportMainMatcher *gui)
{
GtkTreeModel *model;
GtkTreeIter iter;

View File

@ -2645,7 +2645,7 @@ gnc_ui_qif_import_convert_progress_show_cb(GtkWidget *widget,
wind->memo_map_info,
wind->security_hash,
scm_makfrom0str(currname),
wind->transaction_status,
wind->transaction_status,
progress),
SCM_EOL);
gnc_progress_dialog_pop(wind->convert_progress);
@ -3239,18 +3239,21 @@ get_preferences(QIFImportWindow *wind)
/* Clear / Reconcile transaction if not specified in QIF file. */
status_pref = gnc_gconf_get_string(
GCONF_SECTION, GCONF_NAME_DEFAULT_TRANSACTION_STATUS, &err);
GCONF_SECTION, GCONF_NAME_DEFAULT_TRANSACTION_STATUS, &err);
if (err != NULL)
{
g_warning("QIF import: gnc_gconf_get_string error: %s", err->message);
g_error_free(err);
g_warning("QIF import: Couldn't get %s setting from gconf.",
GCONF_NAME_DEFAULT_TRANSACTION_STATUS);
} else {
}
else
{
if (g_strcmp0(status_pref, "cleared") == 0)
{
tmp_transaction_status = 'c';
} else if (g_strcmp0(status_pref, "reconciled") == 0)
}
else if (g_strcmp0(status_pref, "reconciled") == 0)
{
tmp_transaction_status = 'y';
}

View File

@ -373,7 +373,7 @@ Globals: dateCompletion dateCompletionBackMonths
void qof_date_completion_set(QofDateCompletion dc, int backmonths)
{
if (dc == QOF_DATE_COMPLETION_THISYEAR ||
dc == QOF_DATE_COMPLETION_SLIDING)
dc == QOF_DATE_COMPLETION_SLIDING)
{
dateCompletion = dc;
}
@ -655,7 +655,7 @@ floordiv(int a, int b)
}
else
{
return - ((-a-1) / b) - 1;
return - ((-a - 1) / b) - 1;
}
}

View File

@ -470,7 +470,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
/* Check if an error occured */
if (counter < 0)
return NULL;
return NULL;
/* Increment the counter */
counter++;
@ -480,8 +480,8 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
if (!kvp)
{
PWARN ("Book has no KVP_Frame");
return NULL;
PWARN ("Book has no KVP_Frame");
return NULL;
}
/* Save off the new counter */
@ -576,10 +576,10 @@ qof_book_validate_counter_format(const gchar *p)
/* Skip two adjacent percent marks, which are literal percent
* marks */
if (p[0] == '%' && p[1] == '%')
{
{
p += 2;
continue;
}
continue;
}
/* Break on a single percent mark, which is the start of the
* conversion specification */
if (*p == '%')
@ -621,7 +621,9 @@ qof_book_validate_counter_format(const gchar *p)
if (tmp == NULL)
{
return g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.2s'), it should be: " G_GINT64_FORMAT, p);
} else if (tmp != p) {
}
else if (tmp != p)
{
return g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
}
@ -634,10 +636,10 @@ qof_book_validate_counter_format(const gchar *p)
/* Skip two adjacent percent marks, which are literal percent
* marks */
if (p[0] == '%' && p[1] == '%')
{
{
p += 2;
continue;
}
continue;
}
/* Break on a single percent mark, which is the start of the
* conversion specification */
if (*p == '%')

View File

@ -1250,10 +1250,10 @@ qof_session_load (QofSession *session,
*/
err = qof_session_get_error(session);
if ((err != ERR_BACKEND_NO_ERR) &&
(err != ERR_FILEIO_FILE_TOO_OLD) &&
(err != ERR_FILEIO_NO_ENCODING) &&
(err != ERR_SQL_DB_TOO_OLD) &&
(err != ERR_SQL_DB_TOO_NEW))
(err != ERR_FILEIO_FILE_TOO_OLD) &&
(err != ERR_FILEIO_NO_ENCODING) &&
(err != ERR_SQL_DB_TOO_OLD) &&
(err != ERR_SQL_DB_TOO_NEW))
{
/* Something broke, put back the old stuff */
qof_book_set_backend (newbook, NULL);
@ -1464,9 +1464,9 @@ qof_session_safe_save(QofSession *session, QofPercentageFunc percentage_func)
msg = qof_backend_get_message(session->backend);
if (err != ERR_BACKEND_NO_ERR)
{
g_free(session->book_id);
session->book_id = NULL;
qof_session_push_error (session, err, msg);
g_free(session->book_id);
session->book_id = NULL;
qof_session_push_error (session, err, msg);
}
}

View File

@ -243,7 +243,7 @@ void qof_session_save (QofSession *session,
* the new tables back.
*/
void qof_session_safe_save (QofSession *session,
QofPercentageFunc percentage_func);
QofPercentageFunc percentage_func);
/**
* The qof_session_end() method will release the session lock. For the

View File

@ -27,5 +27,5 @@ static const gchar *suitename = "qof/qofbackend";
GTestSuite*
test_suite_qofbackend ( void )
{
}

View File

@ -65,8 +65,8 @@ static void
test_session_safe_save( Fixture *fixture, gconstpointer pData )
{
qof_session_safe_save( fixture->session, percentage_fn );
g_assert_cmpint( ERR_BACKEND_DATA_CORRUPT, ==,
qof_session_get_error( fixture->session ));
g_assert_cmpint( ERR_BACKEND_DATA_CORRUPT, == ,
qof_session_get_error( fixture->session ));
g_assert( NULL == qof_session_get_url( fixture->session ));
}

View File

@ -3,16 +3,16 @@
int main()
{
qof_log_init();
qof_init();
gnc_module_system_init();
char * no_args[1] = { NULL };
gnc_engine_init(0, no_args);
qof_log_init();
qof_init();
gnc_module_system_init();
char * no_args[1] = { NULL };
gnc_engine_init(0, no_args);
QofSession * s = qof_session_new();
qof_session_begin(s, "sqlite3:///tmp/blah.gnucash", 0, 1, 0);
qof_session_load(s, NULL);
qof_session_save(s, NULL);
qof_session_end(s);
return 0;
QofSession * s = qof_session_new();
qof_session_begin(s, "sqlite3:///tmp/blah.gnucash", 0, 1, 0);
qof_session_load(s, NULL);
qof_session_save(s, NULL);
qof_session_end(s);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -37,23 +37,26 @@
G_BEGIN_DECLS
// model
enum bi_import_model_columns {
ID, DATE_OPENED, OWNER_ID, BILLING_ID, NOTES, // invoice settings
DATE, DESC, ACTION, ACCOUNT, QUANTITY, PRICE, DISC_TYPE, DISC_HOW, DISCOUNT, TAXABLE, TAXINCLUDED, TAX_TABLE, // entry settings
DATE_POSTED, DUE_DATE, ACCOUNT_POSTED, MEMO_POSTED, ACCU_SPLITS, // autopost settings
N_COLUMNS
enum bi_import_model_columns
{
ID, DATE_OPENED, OWNER_ID, BILLING_ID, NOTES, // invoice settings
DATE, DESC, ACTION, ACCOUNT, QUANTITY, PRICE, DISC_TYPE, DISC_HOW, DISCOUNT, TAXABLE, TAXINCLUDED, TAX_TABLE, // entry settings
DATE_POSTED, DUE_DATE, ACCOUNT_POSTED, MEMO_POSTED, ACCU_SPLITS, // autopost settings
N_COLUMNS
};
enum _bi_import_result {
RESULT_OK,
RESULT_OPEN_FAILED,
RESULT_ERROR_IN_REGEXP,
enum _bi_import_result
{
RESULT_OK,
RESULT_OPEN_FAILED,
RESULT_ERROR_IN_REGEXP,
};
typedef enum _bi_import_result bi_import_result;
struct _bi_import_stats {
int n_imported, n_ignored;
GString *ignored_lines;
struct _bi_import_stats
{
int n_imported, n_ignored;
GString *ignored_lines;
};
typedef struct _bi_import_stats bi_import_stats;

View File

@ -51,9 +51,10 @@ static void gnc_plugin_bi_import_cmd_test (GtkAction *action, GncMainWindowActio
#define PLUGIN_ACTIONS_NAME "gnc-plugin-bi_import-actions"
#define PLUGIN_UI_FILENAME "gnc-plugin-bi_import-ui.xml"
static GtkActionEntry gnc_plugin_actions [] = {
static GtkActionEntry gnc_plugin_actions [] =
{
/* Menu Items */
{ "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL },
{ "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL },
{ "bi_importAction", NULL, N_("Import Bills & Invoices..."), NULL, N_("bi_import tooltip"), G_CALLBACK(gnc_plugin_bi_import_cmd_test) },
};
static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);

View File

@ -47,11 +47,13 @@ G_BEGIN_DECLS
#define GNC_PLUGIN_bi_import_NAME "gnc-plugin-bi_import"
/* typedefs & structures */
typedef struct {
typedef struct
{
GncPlugin gnc_plugin;
} GncPluginbi_import;
typedef struct {
typedef struct
{
GncPluginClass gnc_plugin;
} GncPluginbi_importClass;

View File

@ -66,24 +66,29 @@ libgncmod_bi_import_gnc_module_description (void)
int
libgncmod_bi_import_gnc_module_init (int refcount)
{
if (!gnc_module_load ("gnucash/app-utils", 0)) {
if (!gnc_module_load ("gnucash/app-utils", 0))
{
return FALSE;
}
if (!gnc_module_load ("gnucash/gnome-utils", 0)) {
if (!gnc_module_load ("gnucash/gnome-utils", 0))
{
return FALSE;
}
if (!gnc_module_load ("gnucash/business-core", 0)) {
if (!gnc_module_load ("gnucash/business-core", 0))
{
return FALSE;
}
if (!gnc_module_load ("gnucash/engine", 0)) {
if (!gnc_module_load ("gnucash/engine", 0))
{
return FALSE;
}
if (refcount == 0) {
if (refcount == 0)
{
/* this is the first time the module is loaded */
gnc_plugin_manager_add_plugin ( gnc_plugin_manager_get (),
gnc_plugin_bi_import_new ());
gnc_plugin_bi_import_new ());
}
return TRUE;
@ -92,7 +97,8 @@ libgncmod_bi_import_gnc_module_init (int refcount)
int
libgncmod_bi_import_gnc_module_end (int refcount)
{
if (refcount == 0) {
if (refcount == 0)
{
/* this is the last time the module is unloaded */
}

View File

@ -43,15 +43,16 @@
#include "bi_import.h"
#include "gui.h"
struct _bi_import_gui {
GtkWidget *dialog;
GtkWidget *tree_view;
GtkWidget *entryFilename;
GtkListStore *store;
gint component_id;
GString *regexp;
QofBook *book;
gchar *type;
struct _bi_import_gui
{
GtkWidget *dialog;
GtkWidget *tree_view;
GtkWidget *entryFilename;
GtkListStore *store;
gint component_id;
GString *regexp;
QofBook *book;
gchar *type;
};
@ -81,251 +82,257 @@ static void gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar
BillImportGui *
gnc_plugin_bi_import_showGUI(void)
{
BillImportGui *gui;
GladeXML *xml;
GList *glist;
GtkTreeIter iter;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
BillImportGui *gui;
GladeXML *xml;
GList *glist;
GtkTreeIter iter;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
// if window exists already, activate it
glist = gnc_find_gui_components ("dialog-bi_import_gui", NULL, NULL);
if (glist) {
// window found
gui = g_list_nth_data (glist,0);
g_list_free (glist);
gtk_window_present (GTK_WINDOW(gui->dialog));
return gui;
}
// if window exists already, activate it
glist = gnc_find_gui_components ("dialog-bi_import_gui", NULL, NULL);
if (glist)
{
// window found
gui = g_list_nth_data (glist, 0);
g_list_free (glist);
gtk_window_present (GTK_WINDOW(gui->dialog));
return gui;
}
// create new window
gui = g_new0 (BillImportGui, 1);
gui->type = "BILL"; // Set default type to match gui. really shouldn't be here TODO change me
// create new window
gui = g_new0 (BillImportGui, 1);
gui->type = "BILL"; // Set default type to match gui. really shouldn't be here TODO change me
xml = gnc_glade_xml_new ("bi_import.glade", "bi_import Dialog");
gui->dialog = glade_xml_get_widget (xml, "bi_import Dialog");
gui->dialog = glade_xml_get_widget (xml, "bi_import Dialog");
gui->tree_view = glade_xml_get_widget (xml, "treeview1");
gui->entryFilename = glade_xml_get_widget (xml, "entryFilename");
gui->entryFilename = glade_xml_get_widget (xml, "entryFilename");
gui->book = gnc_get_current_book();
gui->book = gnc_get_current_book();
gui->regexp = g_string_new ( "^(?<id>[^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*)(;?(?<disc_type>[^;]*)(;?(?<disc_how>[^;]*)(;?(?<discount>[^;]*)(;?(?<taxable>[^;]*)(;?(?<taxincluded>[^;]*)(;?(?<tax_table>[^;]*)(;(?<date_posted>[^;]*)(;(?<due_date>[^;]*)(;(?<account_posted>[^;]*)(;(?<memo_posted>[^;]*)(;(?<accu_splits>[^;]*))?)?)?)?)?)?)?)?)?)?)?");
gui->regexp = g_string_new ( "^(?<id>[^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*)(;?(?<disc_type>[^;]*)(;?(?<disc_how>[^;]*)(;?(?<discount>[^;]*)(;?(?<taxable>[^;]*)(;?(?<taxincluded>[^;]*)(;?(?<tax_table>[^;]*)(;(?<date_posted>[^;]*)(;(?<due_date>[^;]*)(;(?<account_posted>[^;]*)(;(?<memo_posted>[^;]*)(;(?<accu_splits>[^;]*))?)?)?)?)?)?)?)?)?)?)?");
// create model and bind to view
gui->store = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // invoice settings
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // entry settings
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); // autopost settings
gtk_tree_view_set_model( GTK_TREE_VIEW(gui->tree_view), GTK_TREE_MODEL(gui->store) );
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // invoice settings
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // entry settings
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); // autopost settings
gtk_tree_view_set_model( GTK_TREE_VIEW(gui->tree_view), GTK_TREE_MODEL(gui->store) );
#define CREATE_COLUMN(description,column_id) \
renderer = gtk_cell_renderer_text_new (); \
column = gtk_tree_view_column_new_with_attributes (description, renderer, "text", column_id, NULL); \
gtk_tree_view_column_set_resizable (column, TRUE); \
gtk_tree_view_append_column (GTK_TREE_VIEW (gui->tree_view), column);
CREATE_COLUMN ("id", ID);
CREATE_COLUMN ("date__opened", DATE_OPENED);
CREATE_COLUMN ("owner__id", OWNER_ID);
CREATE_COLUMN ("billing_id", BILLING_ID);
CREATE_COLUMN ("notes", NOTES);
CREATE_COLUMN ("id", ID);
CREATE_COLUMN ("date__opened", DATE_OPENED);
CREATE_COLUMN ("owner__id", OWNER_ID);
CREATE_COLUMN ("billing_id", BILLING_ID);
CREATE_COLUMN ("notes", NOTES);
CREATE_COLUMN ("date", DATE);
CREATE_COLUMN ("desc", DESC);
CREATE_COLUMN ("action", ACTION);
CREATE_COLUMN ("account", ACCOUNT);
CREATE_COLUMN ("quantity", QUANTITY);
CREATE_COLUMN ("price", PRICE);
CREATE_COLUMN ("disc__type", DISC_TYPE);
CREATE_COLUMN ("disc__how", DISC_HOW);
CREATE_COLUMN ("discount", DISCOUNT);
CREATE_COLUMN ("taxable", TAXABLE);
CREATE_COLUMN ("taxincluded", TAXINCLUDED);
CREATE_COLUMN ("tax__table", TAX_TABLE);
CREATE_COLUMN ("date", DATE);
CREATE_COLUMN ("desc", DESC);
CREATE_COLUMN ("action", ACTION);
CREATE_COLUMN ("account", ACCOUNT);
CREATE_COLUMN ("quantity", QUANTITY);
CREATE_COLUMN ("price", PRICE);
CREATE_COLUMN ("disc__type", DISC_TYPE);
CREATE_COLUMN ("disc__how", DISC_HOW);
CREATE_COLUMN ("discount", DISCOUNT);
CREATE_COLUMN ("taxable", TAXABLE);
CREATE_COLUMN ("taxincluded", TAXINCLUDED);
CREATE_COLUMN ("tax__table", TAX_TABLE);
CREATE_COLUMN ("date__posted", DATE_POSTED);
CREATE_COLUMN ("due__date", DUE_DATE);
CREATE_COLUMN ("account__posted", ACCOUNT_POSTED);
CREATE_COLUMN ("memo__posted", MEMO_POSTED);
CREATE_COLUMN ("accu__splits", ACCU_SPLITS);
CREATE_COLUMN ("date__posted", DATE_POSTED);
CREATE_COLUMN ("due__date", DUE_DATE);
CREATE_COLUMN ("account__posted", ACCOUNT_POSTED);
CREATE_COLUMN ("memo__posted", MEMO_POSTED);
CREATE_COLUMN ("accu__splits", ACCU_SPLITS);
gui->component_id = gnc_register_gui_component ("dialog-bi_import_gui",
NULL,
gnc_bi_import_gui_close_handler,
gui);
NULL,
gnc_bi_import_gui_close_handler,
gui);
/* Setup signals */
glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func, gui );
/* Setup signals */
glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func, gui );
gtk_widget_show_all ( gui->dialog );
return gui;
return gui;
}
static gchar *
gnc_plugin_bi_import_getFilename(void)
{
// prepare file import dialog
gchar *filename;
GList *filters;
GtkFileFilter *filter;
filters = NULL;
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, "comma separated values (*.csv)");
gtk_file_filter_add_pattern (filter, "*.csv");
filters = g_list_append( filters, filter );
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, "text files (*.txt)");
gtk_file_filter_add_pattern (filter, "*.txt");
filters = g_list_append( filters, filter );
filename = gnc_file_dialog(_("Import Bills or Invoices from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT);
// prepare file import dialog
gchar *filename;
GList *filters;
GtkFileFilter *filter;
filters = NULL;
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, "comma separated values (*.csv)");
gtk_file_filter_add_pattern (filter, "*.csv");
filters = g_list_append( filters, filter );
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, "text files (*.txt)");
gtk_file_filter_add_pattern (filter, "*.txt");
filters = g_list_append( filters, filter );
filename = gnc_file_dialog(_("Import Bills or Invoices from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT);
return filename;
return filename;
}
void
gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
bi_import_stats stats;
bi_import_result res;
guint n_fixed, n_deleted, n_invoices_created, n_invoices_updated;
GString *info;
BillImportGui *gui = data;
gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
bi_import_stats stats;
bi_import_result res;
guint n_fixed, n_deleted, n_invoices_created, n_invoices_updated;
GString *info;
// import
info = g_string_new("");
// import
info = g_string_new("");
gtk_list_store_clear (gui->store);
res = gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats);
if (res == RESULT_OK) {
gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info);
if (info->len > 0)
gnc_info_dialog (gui->dialog, "%s", info->str);
g_string_free( info, TRUE );
gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type);
gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n %u fixes\n %u ignored (not fixable)\n\n %u created\n %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated);
gtk_list_store_clear (gui->store);
res = gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats);
if (res == RESULT_OK)
{
gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info);
if (info->len > 0)
gnc_info_dialog (gui->dialog, "%s", info->str);
g_string_free( info, TRUE );
gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type);
gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n %u fixes\n %u ignored (not fixable)\n\n %u created\n %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated);
if (stats.n_ignored > 0)
gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str);
if (stats.n_ignored > 0)
gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str);
g_string_free (stats.ignored_lines,TRUE);
gnc_close_gui_component (gui->component_id);
} else
if (res == RESULT_OPEN_FAILED) {
gnc_error_dialog (gui->dialog, _("The input file can not be opened."));
} else
if (res == RESULT_ERROR_IN_REGEXP) {
//gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str);
}
g_string_free (stats.ignored_lines, TRUE);
gnc_close_gui_component (gui->component_id);
}
else if (res == RESULT_OPEN_FAILED)
{
gnc_error_dialog (gui->dialog, _("The input file can not be opened."));
}
else if (res == RESULT_ERROR_IN_REGEXP)
{
//gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str);
}
}
void
gnc_bi_import_gui_cancel_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
BillImportGui *gui = data;
gnc_close_gui_component (gui->component_id);
gnc_close_gui_component (gui->component_id);
}
void
gnc_bi_import_gui_help_cb (GtkWidget *widget, gpointer data)
{
gnc_gnome_help(HF_HELP, HL_USAGE);
gnc_gnome_help(HF_HELP, HL_USAGE);
}
static void
gnc_bi_import_gui_close_handler (gpointer user_data)
{
BillImportGui *gui = user_data;
BillImportGui *gui = user_data;
gtk_widget_destroy (gui->dialog);
// gui has already been freed by this point.
// gui->dialog = NULL;
gtk_widget_destroy (gui->dialog);
// gui has already been freed by this point.
// gui->dialog = NULL;
}
void
gnc_bi_import_gui_destroy_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
BillImportGui *gui = data;
gnc_suspend_gui_refresh ();
gnc_unregister_gui_component (gui->component_id);
gnc_resume_gui_refresh ();
gnc_suspend_gui_refresh ();
gnc_unregister_gui_component (gui->component_id);
gnc_resume_gui_refresh ();
g_object_unref (gui->store);
g_string_free (gui->regexp, TRUE);
g_free (gui);
g_object_unref (gui->store);
g_string_free (gui->regexp, TRUE);
g_free (gui);
}
void gnc_bi_import_gui_buttonOpen_cb (GtkWidget *widget, gpointer data)
{
gchar *filename;
BillImportGui *gui = data;
gchar *filename;
BillImportGui *gui = data;
filename = gnc_plugin_bi_import_getFilename();
if (filename) {
//printf("Setting filename"); // debug
gtk_entry_set_text( GTK_ENTRY(gui->entryFilename), filename );
//printf("Set filename"); // debug
g_free( filename );
}
filename = gnc_plugin_bi_import_getFilename();
if (filename)
{
//printf("Setting filename"); // debug
gtk_entry_set_text( GTK_ENTRY(gui->entryFilename), filename );
//printf("Set filename"); // debug
g_free( filename );
}
}
void gnc_bi_import_gui_filenameChanged_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
BillImportGui *gui = data;
gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
// generate preview
gtk_list_store_clear (gui->store);
gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 10, NULL);
// generate preview
gtk_list_store_clear (gui->store);
gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 10, NULL);
g_free( filename );
g_free( filename );
}
void gnc_bi_import_gui_option1_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
void gnc_bi_import_gui_option2_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
g_string_assign (gui->regexp, "^(?<id>[^!#+^,]*),(?<date_opened>[^,]*),(?<owner_id>[^,]*),(?<billingid>[^,]*),?(?<notes>[^,]*),?(?<date>[^,]*),?(?<desc>[^,]*),?(?<action>[^,]*),?(?<account>[^,]*),?(?<quantity>[^,]*),?(?<price>[^,]*),?(?<disc_type>[^,]*),?(?<disc_how>[^,]*),?(?<discount>[^,]*),?(?<taxable>[^,]*),?(?<taxincluded>[^,]*),?(?<tax_table>[^,]*),(?<date_posted>[^,]*),(?<due_date>[^,]*),(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)");
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
g_string_assign (gui->regexp, "^(?<id>[^!#+^,]*),(?<date_opened>[^,]*),(?<owner_id>[^,]*),(?<billingid>[^,]*),?(?<notes>[^,]*),?(?<date>[^,]*),?(?<desc>[^,]*),?(?<action>[^,]*),?(?<account>[^,]*),?(?<quantity>[^,]*),?(?<price>[^,]*),?(?<disc_type>[^,]*),?(?<disc_how>[^,]*),?(?<discount>[^,]*),?(?<taxable>[^,]*),?(?<taxincluded>[^,]*),?(?<tax_table>[^,]*),(?<date_posted>[^,]*),(?<due_date>[^,]*),(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)");
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
void gnc_bi_import_gui_option3_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
gchar *temp;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
BillImportGui *gui = data;
gchar *temp;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), gui->regexp->str);
if (temp) {
g_string_assign (gui->regexp,temp);
g_free (temp);
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
if (temp)
{
g_string_assign (gui->regexp, temp);
g_free (temp);
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
}
/*****************************************************************
* Set whether we are importing a bi, invoice, Customer or Vendor
@ -333,12 +340,12 @@ void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
void gnc_import_gui_type(GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
if (g_ascii_strcasecmp(widget->name,"radiobuttonInvoice") == 0)gui->type="INVOICE";
else if (g_ascii_strcasecmp(widget->name,"radiobuttonBill") == 0)gui->type="BILL";
//printf ("TYPE set to, %s\n",gui->type);
BillImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
if (g_ascii_strcasecmp(widget->name, "radiobuttonInvoice") == 0)gui->type = "INVOICE";
else if (g_ascii_strcasecmp(widget->name, "radiobuttonBill") == 0)gui->type = "BILL";
//printf ("TYPE set to, %s\n",gui->type);
}
@ -376,10 +383,10 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
NULL);
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
NULL);
#ifdef HAVE_GTK_2_14
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
#else
@ -403,11 +410,12 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
if (result == GTK_RESPONSE_REJECT)
user_input = 0;
else {
else
{
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
user_input = gtk_text_buffer_get_text (buffer,
&start, &end, FALSE);
&start, &end, FALSE);
}
gtk_widget_destroy (dialog);
@ -435,13 +443,13 @@ gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
GtkTextBuffer *buffer;
gchar *user_input;
GtkTextIter start, end;
gint width,height;
gint width, height;
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
NULL);
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
NULL);
#ifdef HAVE_GTK_2_14
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
#else
@ -449,22 +457,23 @@ gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
#endif
// add a scroll area
scrolledwindow = gtk_scrolled_window_new (NULL,NULL);
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (content_area), scrolledwindow);
// add a textview
view = gtk_text_view_new ();
// gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, msg, -1);
gtk_container_add (GTK_CONTAINER (scrolledwindow), view);
// run the dialog
if (parent) {
gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
}
if (parent)
{
gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
}
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);

View File

@ -28,53 +28,53 @@
//! \brief helper function
gboolean text2bool( const gchar *text )
{
gboolean erg = FALSE;
gchar *temp;
gboolean erg = FALSE;
gchar *temp;
if (!text)
return erg;
if (!text)
return erg;
temp = g_strdup( text );
g_strstrip( temp );
if ((g_ascii_strcasecmp( temp, "yes" ) == 0) || (g_ascii_strcasecmp( temp, "true" ) == 0) ||
(g_ascii_strcasecmp( temp, "1" ) == 0) || (g_ascii_strcasecmp( temp, "x" ) == 0))
erg = TRUE;
g_free( temp );
return erg;
temp = g_strdup( text );
g_strstrip( temp );
if ((g_ascii_strcasecmp( temp, "yes" ) == 0) || (g_ascii_strcasecmp( temp, "true" ) == 0) ||
(g_ascii_strcasecmp( temp, "1" ) == 0) || (g_ascii_strcasecmp( temp, "x" ) == 0))
erg = TRUE;
g_free( temp );
return erg;
}
//! \brief helper function
GncAmountType text2disc_type( const gchar *text )
{
GncAmountType type = GNC_AMT_TYPE_PERCENT;
gchar *temp;
GncAmountType type = GNC_AMT_TYPE_PERCENT;
gchar *temp;
if (!text)
return type;
if (!text)
return type;
temp = g_strdup( text );
g_strstrip( temp );
if ((strlen(temp) > 0) && (g_ascii_strcasecmp( temp, "%" ) != 0))
type = GNC_AMT_TYPE_VALUE;
g_free( temp );
return type;
temp = g_strdup( text );
g_strstrip( temp );
if ((strlen(temp) > 0) && (g_ascii_strcasecmp( temp, "%" ) != 0))
type = GNC_AMT_TYPE_VALUE;
g_free( temp );
return type;
}
//! \brief helper function
GncDiscountHow text2disc_how( const gchar *text )
{
GncDiscountHow how = GNC_DISC_PRETAX;
gchar *temp;
GncDiscountHow how = GNC_DISC_PRETAX;
gchar *temp;
if (!text)
return how;
if (!text)
return how;
temp = g_strdup( text );
g_strstrip( temp );
if (g_ascii_strcasecmp( temp, "=" ) == 0)
how = GNC_DISC_SAMETIME;
else if (g_ascii_strcasecmp( temp, ">" ) == 0)
how = GNC_DISC_POSTTAX;
g_free( temp );
return how;
temp = g_strdup( text );
g_strstrip( temp );
if (g_ascii_strcasecmp( temp, "=" ) == 0)
how = GNC_DISC_SAMETIME;
else if (g_ascii_strcasecmp( temp, ">" ) == 0)
how = GNC_DISC_POSTTAX;
g_free( temp );
return how;
}