Update the progress bar while loading the price DB from an XML file.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23429 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Mike Alexander 2013-11-22 21:07:51 +00:00
parent 3617271ead
commit 71a50a8bb4
2 changed files with 15 additions and 5 deletions

View File

@ -32,6 +32,7 @@
#include "sixtp-dom-parsers.h" #include "sixtp-dom-parsers.h"
#include "sixtp-dom-generators.h" #include "sixtp-dom-generators.h"
#include "io-gncxml-gen.h" #include "io-gncxml-gen.h"
#include "io-gncxml-v2.h"
#include "gnc-pricedb.h" #include "gnc-pricedb.h"
#include "gnc-pricedb-p.h" #include "gnc-pricedb-p.h"
@ -282,6 +283,8 @@ pricedb_after_child_handler(gpointer data_for_children,
const gchar *child_tag, const gchar *child_tag,
sixtp_child_result *child_result) sixtp_child_result *child_result)
{ {
gxpf_data *gdata = global_data;
sixtp_gdv2 *gd = gdata->parsedata;
GNCPriceDB *db = (GNCPriceDB *) * result; GNCPriceDB *db = (GNCPriceDB *) * result;
g_return_val_if_fail(db, FALSE); g_return_val_if_fail(db, FALSE);
@ -296,9 +299,8 @@ pricedb_after_child_handler(gpointer data_for_children,
g_return_val_if_fail(p, FALSE); g_return_val_if_fail(p, FALSE);
gnc_pricedb_add_price(db, p); gnc_pricedb_add_price(db, p);
/* can't do this because the v1 parser doesn't use this data gd->counter.prices_loaded++;
structure as global data */ run_callback(gd, "prices");
/* ((sixtp_gdv2*)global_data)->counter.prices_loaded++; */
return TRUE; return TRUE;
} }
else else

View File

@ -424,6 +424,10 @@ gnc_counter_end_handler(gpointer data_for_children,
{ {
sixdata->counter.budgets_total = val; sixdata->counter.budgets_total = val;
} }
else if (g_strcmp0(type, "price") == 0)
{
sixdata->counter.prices_total = val;
}
else else
{ {
struct file_backend be_data; struct file_backend be_data;
@ -488,10 +492,12 @@ file_rw_feedback (sixtp_gdv2 *gd, const char *type)
counter = &gd->counter; counter = &gd->counter;
loaded = counter->transactions_loaded + counter->accounts_loaded + loaded = counter->transactions_loaded + counter->accounts_loaded +
counter->books_loaded + counter->commodities_loaded + counter->books_loaded + counter->commodities_loaded +
counter->schedXactions_loaded + counter->budgets_loaded; counter->schedXactions_loaded + counter->budgets_loaded +
counter->prices_loaded;
total = counter->transactions_total + counter->accounts_total + total = counter->transactions_total + counter->accounts_total +
counter->books_total + counter->commodities_total + counter->books_total + counter->commodities_total +
counter->schedXactions_total + counter->budgets_total; counter->schedXactions_total + counter->budgets_total +
counter->prices_total;
if (total == 0) if (total == 0)
total = 1; total = 1;
@ -1035,6 +1041,7 @@ write_book(FILE *out, QofBook *book, sixtp_gdv2 *gd)
g_list_length(gnc_book_get_schedxactions(book)->sx_list), g_list_length(gnc_book_get_schedxactions(book)->sx_list),
"budget", qof_collection_count( "budget", qof_collection_count(
qof_book_get_collection(book, GNC_ID_BUDGET)), qof_book_get_collection(book, GNC_ID_BUDGET)),
"price", gnc_pricedb_get_num_prices(gnc_pricedb_get_db(book)),
NULL)) NULL))
return FALSE; return FALSE;
@ -1318,6 +1325,7 @@ gnc_book_write_to_xml_filehandle_v2(QofBook *book, FILE *out)
g_list_length(gnc_book_get_schedxactions(book)->sx_list); g_list_length(gnc_book_get_schedxactions(book)->sx_list);
gd->counter.budgets_total = qof_collection_count( gd->counter.budgets_total = qof_collection_count(
qof_book_get_collection(book, GNC_ID_BUDGET)); qof_book_get_collection(book, GNC_ID_BUDGET));
gd->counter.prices_total = gnc_pricedb_get_num_prices(gnc_pricedb_get_db(book));
if (!write_book(out, book, gd) if (!write_book(out, book, gd)
|| fprintf(out, "</" GNC_V2_STRING ">\n\n") < 0) || fprintf(out, "</" GNC_V2_STRING ">\n\n") < 0)