diff --git a/ChangeLog b/ChangeLog index 9dbafadcba..280a89b346 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-12-17 Dave Peticolas + + * src/gnome-utils/gw-gnome-utils-spec.scm: add wrapping for widgets + and other api + + * src/backend/postgres/test/test-db.c: add check for initial + account balances + + * src/backend/postgres/PostgresBackend.c: fix bug. begin/commit + account group when loading intitial balances + 2001-12-12 Dave Peticolas * src/report/report-gnome/test/test-load-module: add diff --git a/src/backend/postgres/PostgresBackend.c b/src/backend/postgres/PostgresBackend.c index ed11a31745..298dba949e 100644 --- a/src/backend/postgres/PostgresBackend.c +++ b/src/backend/postgres/PostgresBackend.c @@ -1245,7 +1245,10 @@ pgend_book_load_poll (Backend *bend) pgendKVPInit(be); pgendGetAllAccounts (be, grp); + + xaccAccountGroupBeginEdit (grp); pgendGroupGetAllBalances (be, grp, ts); + xaccAccountGroupCommitEdit (grp); /* re-enable events */ pgendEnable(be); diff --git a/src/backend/postgres/checkpoint.c b/src/backend/postgres/checkpoint.c index 584988d487..f255d05a0e 100644 --- a/src/backend/postgres/checkpoint.c +++ b/src/backend/postgres/checkpoint.c @@ -480,8 +480,8 @@ pgendAccountGetBalance (PGBackend *be, Account *acc, Timespec as_of_date) cleared_baln = gnc_numeric_create (cl_b, deno); reconciled_baln = gnc_numeric_create (rec_b, deno); - xaccAccountSetStartingBalance (acc, baln, - cleared_baln, reconciled_baln); + xaccAccountSetStartingBalance (acc, baln, cleared_baln, reconciled_baln); + DEBUGCMD ({ char buf[80]; gnc_timespec_to_iso8601_buff (as_of_date, buf); @@ -489,8 +489,6 @@ pgendAccountGetBalance (PGBackend *be, Account *acc, Timespec as_of_date) xaccAccountGetDescription (acc), buf, b, deno, cl_b, deno, rec_b, deno); }) - - return; } /* ============================================================= */ @@ -498,7 +496,7 @@ pgendAccountGetBalance (PGBackend *be, Account *acc, Timespec as_of_date) void pgendGroupGetAllBalances (PGBackend *be, AccountGroup *grp, - Timespec as_of_date) + Timespec as_of_date) { GList *acclist, *node; diff --git a/src/backend/postgres/test/test-db.c b/src/backend/postgres/test/test-db.c index 3a9219ae89..5ce612dfca 100644 --- a/src/backend/postgres/test/test-db.c +++ b/src/backend/postgres/test/test-db.c @@ -83,8 +83,6 @@ save_db_file (GNCSession *session, const char *db_name, const char *mode) filename = db_file_url (db_name, mode); - printf("SAVING!!! %s\n", filename); - gnc_session_begin (session, filename, FALSE, TRUE); io_err = gnc_session_get_error (session); if (!do_test_args (io_err == ERR_BACKEND_NO_ERR, @@ -594,6 +592,60 @@ test_trans_query (Transaction *trans, gpointer data) return TRUE; } +static gboolean +compare_balances (GNCSession *session_1, GNCSession *session_2) +{ + GNCBook * book_1 = gnc_session_get_book (session_1); + GNCBook * book_2 = gnc_session_get_book (session_2); + GList * list; + GList * node; + + g_return_val_if_fail (session_1, FALSE); + g_return_val_if_fail (session_2, FALSE); + + list = xaccGroupGetSubAccounts (gnc_book_get_group (book_1)); + for (node = list; node; node = node->next) + { + Account * account_1 = node->data; + Account * account_2; + + account_2 = xaccAccountLookup (xaccAccountGetGUID (account_1), book_2); + if (!account_2) + { + g_warning ("session_1 has account %s but not session_2", + guid_to_string (xaccAccountGetGUID (account_1))); + return FALSE; + } + + if (!gnc_numeric_eq (xaccAccountGetBalance (account_1), + xaccAccountGetBalance (account_2))) + { + g_warning ("balances not equal for account %s", + guid_to_string (xaccAccountGetGUID (account_1))); + return FALSE; + } + + if (!gnc_numeric_eq (xaccAccountGetClearedBalance (account_1), + xaccAccountGetClearedBalance (account_2))) + { + g_warning ("cleared balances not equal for account %s", + guid_to_string (xaccAccountGetGUID (account_1))); + return FALSE; + } + + if (!gnc_numeric_eq (xaccAccountGetReconciledBalance (account_1), + xaccAccountGetReconciledBalance (account_2))) + { + g_warning ("reconciled balances not equal for account %s", + guid_to_string (xaccAccountGetGUID (account_1))); + return FALSE; + } + } + g_list_free (list); + + return TRUE; +} + static gboolean test_queries (GNCSession *session_base, const char *db_name, const char *mode) { @@ -644,7 +696,12 @@ test_mode (const char *db_name, const char *mode, return FALSE; if (multi_user) + { + if (!compare_balances (session, session_db)) + return FALSE; + multi_user_get_everything (session_db, session); + } ok = gnc_book_equal (gnc_session_get_book (session), gnc_session_get_book (session_db)); diff --git a/src/gnome-utils/Makefile.am b/src/gnome-utils/Makefile.am index 1c9578bb2d..8208eaba3b 100644 --- a/src/gnome-utils/Makefile.am +++ b/src/gnome-utils/Makefile.am @@ -146,6 +146,7 @@ gw-gnome-utils.scm gw-gnome-utils.c gw-gnome-utils.h: .scm-links gw-gnome-utils- "(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \ (set! %load-path (cons \"${PWD}\" %load-path)) \ (set! %load-path (cons \"${top_srcdir}/src/engine\" %load-path)) \ + (set! %load-path (cons \"${top_srcdir}/src/app-utils\" %load-path)) \ (primitive-load \"./gw-gnome-utils-spec.scm\") \ (gw:generate-module \"gw-gnome-utils\")" diff --git a/src/gnome-utils/gnc-date-edit.c b/src/gnome-utils/gnc-date-edit.c index 985ac0b404..958227cb41 100644 --- a/src/gnome-utils/gnc-date-edit.c +++ b/src/gnome-utils/gnc-date-edit.c @@ -483,7 +483,8 @@ gnc_date_edit_set_time (GNCDateEdit *gde, time_t the_time) struct tm *mytm; char buffer [40]; - g_return_if_fail(gde != NULL); + g_return_if_fail (gde != NULL); + g_return_if_fail (GNC_IS_DATE_EDIT (gde)); if (the_time == 0) the_time = time (NULL); @@ -506,6 +507,12 @@ gnc_date_edit_set_time (GNCDateEdit *gde, time_t the_time) gtk_entry_set_text (GTK_ENTRY (gde->time_entry), buffer); } +void +gnc_date_edit_set_time_ts (GNCDateEdit *gde, Timespec the_time) +{ + gnc_date_edit_set_time (gde, the_time.tv_sec); +} + /** * gnc_date_edit_set_popup_range: * @gde: The GNCDateEdit widget @@ -518,7 +525,8 @@ gnc_date_edit_set_time (GNCDateEdit *gde, time_t the_time) void gnc_date_edit_set_popup_range (GNCDateEdit *gde, int low_hour, int up_hour) { - g_return_if_fail(gde != NULL); + g_return_if_fail (gde != NULL); + g_return_if_fail (GNC_IS_DATE_EDIT (gde)); gde->lower_hour = low_hour; gde->upper_hour = up_hour; @@ -677,6 +685,12 @@ gnc_date_edit_new (time_t the_time, int show_time, int use_24_format) | (use_24_format ? GNC_DATE_EDIT_24_HR : 0))); } +GtkWidget * +gnc_date_edit_new_ts (Timespec the_time, int show_time, int use_24_format) +{ + return gnc_date_edit_new (the_time.tv_sec, show_time, use_24_format); +} + /** * gnc_date_edit_new_flags: * @the_time: The initial time for the date editor. @@ -794,6 +808,16 @@ gnc_date_edit_get_date (GNCDateEdit *gde) return mktime (&tm); } +Timespec +gnc_date_edit_get_date_ts (GNCDateEdit *gde) +{ + Timespec ts = { 0, 0 }; + + ts.tv_sec = gnc_date_edit_get_date (gde); + + return ts; +} + /** * gnc_date_edit_get_date_end: * @gde: The GNCDateEdit widget @@ -829,6 +853,16 @@ gnc_date_edit_get_date_end (GNCDateEdit *gde) return mktime (&tm); } +Timespec +gnc_date_edit_get_date_end_ts (GNCDateEdit *gde) +{ + Timespec ts = { 0, 0 }; + + ts.tv_sec = gnc_date_edit_get_date_end (gde); + + return ts; +} + /** * gnc_date_edit_set_flags: * @gde: The date editor widget whose flags should be changed. diff --git a/src/gnome-utils/gnc-date-edit.h b/src/gnome-utils/gnc-date-edit.h index 6bd608cde7..22ea5f8d53 100644 --- a/src/gnome-utils/gnc-date-edit.h +++ b/src/gnome-utils/gnc-date-edit.h @@ -88,16 +88,21 @@ guint gnc_date_edit_get_type (void); GtkWidget *gnc_date_edit_new (time_t the_time, int show_time, int use_24_format); +GtkWidget *gnc_date_edit_new_ts (Timespec the_time, + int show_time, int use_24_format); GtkWidget *gnc_date_edit_new_flags (time_t the_time, GNCDateEditFlags flags); void gnc_date_edit_set_time (GNCDateEdit *gde, time_t the_time); +void gnc_date_edit_set_time_ts (GNCDateEdit *gde, Timespec the_time); void gnc_date_edit_set_popup_range (GNCDateEdit *gde, int low_hour, int up_hour); time_t gnc_date_edit_get_date (GNCDateEdit *gde); +Timespec gnc_date_edit_get_date_ts (GNCDateEdit *gde); time_t gnc_date_edit_get_date_end (GNCDateEdit *gde); +Timespec gnc_date_edit_get_date_end_ts (GNCDateEdit *gde); void gnc_date_edit_set_flags (GNCDateEdit *gde, GNCDateEditFlags flags); diff --git a/src/gnome-utils/gw-gnome-utils-spec.scm b/src/gnome-utils/gw-gnome-utils-spec.scm index 3078719e10..025fd3b2c0 100644 --- a/src/gnome-utils/gw-gnome-utils-spec.scm +++ b/src/gnome-utils/gw-gnome-utils-spec.scm @@ -3,6 +3,7 @@ (use-modules (g-wrap)) (use-modules (g-wrapped gw-glib-spec)) (use-modules (g-wrapped gw-engine-spec)) +(use-modules (g-wrapped gw-app-utils-spec)) (debug-set! maxdepth 100000) (debug-set! stack 2000000) @@ -28,23 +29,28 @@ (list (c->scm-converter scm-name c-name) " }\n"))))) - + (gw:module-depends-on mod "gw-runtime") (gw:module-depends-on mod "gw-engine") (gw:module-depends-on mod "gw-glib") + (gw:module-depends-on mod "gw-app-utils") (gw:module-set-guile-module! mod '(g-wrapped gw-gnome-utils)) (gw:module-set-declarations-ccodegen! mod (lambda (client-only?) - (list - "#include \n" - "#include \n" - "#include \n" - "#include \n" + (list + "#include \n" + "#include \n" + "#include \n" + "#include \n" "#include \n" + "#include \n" + "#include \n" + "#include \n" "#include \n" + "#include \n" ))) (let ((nnt (gw:wrap-non-native-type @@ -217,4 +223,194 @@ ( choices)) "Show a dialog offering different mutually exclusive choices in a radio list.") + + + ;; gnc-amount-edit.h + (let ((nnt (gw:wrap-non-native-type + mod + ' + "GNCAmountEdit*" "const GNCAmountEdit*"))) + #t) + + (gw:wrap-function + mod + 'gnc:amount-edit-new + ' + "gnc_amount_edit_new" + '() + "Return a new amount edit widget.") + + (gw:wrap-function + mod + 'gnc:amount-edit-gtk-entry + ' + "gnc_amount_edit_gtk_entry" + '(( amount-edit)) + "Return the gtk entry for a gnc amount edit widget.") + + (gw:wrap-function + mod + 'gnc:amount-edit-set-amount + ' + "gnc_amount_edit_set_amount" + '(( amount-edit) + ( amount)) + "Set the amount of an amount edit widget.") + + (gw:wrap-function + mod + 'gnc:amount-edit-get-amount + ' + "gnc_amount_edit_get_amount" + '(( amount-edit)) + "Return the amount in an amount edit widget.") + + (gw:wrap-function + mod + 'gnc:amount-edit-evaluate + ' + "gnc_amount_edit_evaluate" + '(( amount-edit)) + "Evaluate the contents of an amount edit widget and return +#t if it is a valid entry.") + + (gw:wrap-function + mod + 'gnc:amount-edit-set-print-info + ' + "gnc_amount_edit_set_print_info" + '(( amount-edit) + ( print-info)) + "Set the print info used by the amount edit.") + + (gw:wrap-function + mod + 'gnc:amount-edit-set-fraction + ' + "gnc_amount_edit_set_fraction" + '(( amount-edit) + ( fraction)) + "Set the fraction used by the amount edit widget.") + + (gw:wrap-function + mod + 'gnc:amount-edit-set-evaluate-on-enter + ' + "gnc_amount_edit_set_evaluate_on_enter" + '(( amount-edit) + ( evaluate-on-enter)) + "Set whether the edit widget evaluates on enter.") + + + ;; gnc-date-edit.h + (let ((nnt (gw:wrap-non-native-type + mod + ' + "GNCDateEdit*" "const GNCDateEdit*"))) + #t) + + (gw:wrap-function + mod + 'gnc:date-edit-new + ' + "gnc_date_edit_new_ts" + '(( date) + ( show-time) + ( use-24-hour-format)) + "Return a new date edit widget.") + + (gw:wrap-function + mod + 'gnc:date-edit-set-time + ' + "gnc_date_edit_set_time_ts" + '(( date-edit) + ( time)) + "Set the time used by the date edit widget.") + + (gw:wrap-function + mod + 'gnc:date-edit-get-date + ' + "gnc_date_edit_get_date_ts" + '(( date-edit)) + "Return the date of the date-edit widget.") + + (gw:wrap-function + mod + 'gnc:date-edit-get-date-end + ' + "gnc_date_edit_get_date_end_ts" + '(( date-edit)) + "Return the date of the date-edit widget at the end of the day.") + + + ;; druid-utils.h + (let ((nnt (gw:wrap-non-native-type + mod + ' + "GnomeDruid*" "const GnomeDruid*"))) + #t) + + (gw:wrap-function + mod + 'gnc:druid-set-title-image + ' + "gnc_druid_set_title_image" + '(( druid) + (() image-path)) + "Set the title image of a druid.") + + (gw:wrap-function + mod + 'gnc:druid-set-logo-image + ' + "gnc_druid_set_logo_image" + '(( druid) + (() logo-path)) + "Set the logo image of a druid.") + + (gw:wrap-function + mod + 'gnc:druid-set-watermark-image + ' + "gnc_druid_set_watermark_image" + '(( druid) + (() watermark-path)) + "Set the watermark image of a druid.") + + (gw:wrap-function + mod + 'gnc:druid-set-colors + ' + "gnc_druid_set_colors" + '(( druid)) + "Set the colors of a druid.") + + + ;; dialog-utils.h + (let ((nnt (gw:wrap-non-native-type + mod + ' + "GtkCList*" "const GtkCList*"))) + #t) + + (gw:wrap-function + mod + 'gnc:clist-set-check + ' + "gnc_clist_set_check" + '(( clist) + ( row) + ( col) + ( checked)) + "Set the check status of a clist cell.") + + (gw:wrap-function + mod + 'gnc:clist-columns-autosize + ' + "gnc_clist_columns_autosize" + '(( clist)) + "Autosize the columns of a clist including the titles.") )