GnuCash Daily Diff
Dave Peticolas
peticolas@linas.org
Fri, 11 May 2001 08:02:40 -0500 (CDT)
Index: gnucash/ChangeLog
diff -c gnucash/ChangeLog:1.442 gnucash/ChangeLog:1.447
*** gnucash/ChangeLog:1.442 Thu May 10 04:49:15 2001
--- gnucash/ChangeLog Fri May 11 05:48:00 2001
***************
*** 1,3 ****
--- 1,98 ----
+ 2001-05-11 Dave Peticolas <dave@krondo.com>
+
+ * src/doc/design/engine.texinfo: update docs
+
+ 2001-05-11 Robert Graham Merkel <rgmerk@mira.net>
+
+ * src/scm/report/account-piecharts.scm: add checks for empty
+ data.
+
+ 2001-05-10 Dave Peticolas <dave@krondo.com>
+
+ * src/scm/main-window.scm ((gnc:main-window-book-open-handler
+ book-url)): restore the main window even if we can't get a
+ conf-file-name.
+
+ * src/scm/main.scm (gnc:load-account-file): if we have a file to
+ open, only run book-opened-hook if file open returns false.
+
+ * src/FileDialog.c (gncPostFileOpen): once book-closed-hook has
+ been run, run book-opened-hook if opening the file fails for some
+ reason.
+
+ * src/guile/gnc.gwp: update ui-open-file api.
+
+ * src/gnome/top-level.c (gnucash_ui_open_file): return TRUE/FALSE
+ for success/failure. use gboolean instead of int for boolean
+ returns.
+
+ 2001-05-10 Bill Gribble <grib@billgribble.com>
+
+ * src/gnome/dialog-column-view.c: change handling of component
+ reports. now we explicitly handle the case of the column view,
+ which is the only report that needs to save/restore its children.
+
+ * src/gnome/gnc-html-guppi.c: add printing support for graphs.
+ Doesn't really work on my system ATM. I'll follow up on it.
+
+ * src/gnome/window-main.c: move save/restore forms out of gnome
+ MDI config string. rename some functions.
+
+ * src/gnome/window-report.c: save the initial report in a window
+ for special treatment. It's the one that gets saved and restored,
+ and whose title appears in the tab.
+
+ * src/scm/*: remove instances of report-add-child and friends.
+ The concept is unnecessary.
+
+ * src/scm/main-window.scm: save report and account data to a new
+ file named after the book in the directory ~/.gnucash/books.
+
+ * src/scm/options.scm: run option-changed callbacks in the order
+ they were added. Add gnc:options-touch to dirty the options
+ without changing anything.
+
+ * src/scm/report.scm: add new optional fields for the
+ define-report form: 'options-cleanup-cb and 'options-changed-cb.
+ 'options-cleanup-cb is called before book save to allow you to
+ clean up any mess that you don't want saved. 'options-changed-cb
+ is called after any report option is changed. Both are optional.
+
+ Also get rid of the concept of 'display-lists' for reports and
+ let the displays update themselves with callbacks. Get rid of
+ parents and children for the reports.
+
+ * src/scm/report/view-column.scm: revamp to handle options
+ processing, saving, and rendering better.
+
+ 2001-05-10 James LewisMoss <jimdres@mindspring.com>
+
+ * src/scm/main.scm ((gnc:main)): remove the main window startup
+ with new user startup (moved to end of new user stuff).
+
+ * src/engine/sql/PostgresBackend.c (pgendGetAllAccountKVP): same
+ as below.
+
+ * src/engine/rpc/RpcUtils.c (rpcend_build_gncacctlist):
+ xaccGroupForEachAccountDeeply -> xaccGroupForEachAccount(...TRUE)
+ (rpcend_build_gncacct_verslist): same.
+
+ * src/engine/gnc-book.c (gnc_book_set_group): free account group
+ when setting new one.
+
+ * src/engine/Group.c (xaccGroupForEachAccount): change from
+ xaccGroupForEachAccountDeeply and add argument on whether it
+ should do things deeply.
+
+ * src/engine/Account.c (xaccCloneAccountSimple): new func.
+ (xaccAccountEnumAsString): change arg to GNCAccountType.
+
+ * src/gnc-ui-util.c (gnc_ui_account_get_balance):
+ xaccGroupForEachAccountDeeply -> xaccGroupForEachAccount(...TRUE)
+
+ * src/engine/Account.c (xaccAccountGetChildren): Add children
+ group if ->children == NULL.
+
2001-05-10 Dave Peticolas <dave@krondo.com>
* src/guile/File.c (gncFindFile): handle NULL arg
***************
*** 654,659 ****
--- 749,759 ----
between html & txf
* src/gnome/window-report.c: implement export callback
+
+ 2001-04-19 James LewisMoss <jimdres@mindspring.com>
+
+ * src/gnome/new-user-funs.c (gnc_new_user_get_clist): new func to
+ remove duplicate code.
2001-04-18 Dave Peticolas <dave@krondo.com>
Index: gnucash/doc/RAW-NOTES
diff -c gnucash/doc/RAW-NOTES:1.1 gnucash/doc/RAW-NOTES:1.2
*** gnucash/doc/RAW-NOTES:1.1 Sat Sep 9 05:48:27 2000
--- gnucash/doc/RAW-NOTES Thu May 10 16:58:32 2001
***************
*** 94,96 ****
--- 94,99 ----
Instructins for how to do QIF import should be reviewed/redone
======================================================================
typing + in the check-number field uses the next check number ..
+
+
+ xxx
Index: gnucash/src/FileDialog.c
diff -c gnucash/src/FileDialog.c:1.62 gnucash/src/FileDialog.c:1.63
*** gnucash/src/FileDialog.c:1.62 Wed May 9 19:12:42 2001
--- gnucash/src/FileDialog.c Thu May 10 17:55:00 2001
***************
*** 305,311 ****
/* ======================================================== */
/* private utilities for file open; done in two stages */
! static void
gncPostFileOpen (const char * filename)
{
GNCBook *new_book;
--- 305,311 ----
/* ======================================================== */
/* private utilities for file open; done in two stages */
! static gboolean
gncPostFileOpen (const char * filename)
{
GNCBook *new_book;
***************
*** 314,326 ****
char * newfile;
GNCBackendError io_err = ERR_BACKEND_NO_ERR;
! if (!filename) return;
newfile = xaccResolveURL (filename);
if (!newfile)
{
show_book_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
! return;
}
/* disable events while moving over to the new set of accounts;
--- 314,326 ----
char * newfile;
GNCBackendError io_err = ERR_BACKEND_NO_ERR;
! if (!filename) return FALSE;
newfile = xaccResolveURL (filename);
if (!newfile)
{
show_book_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
! return FALSE;
}
/* disable events while moving over to the new set of accounts;
***************
*** 336,342 ****
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-closed-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
!
gnc_book_destroy (current_book);
current_book = NULL;
--- 336,342 ----
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-closed-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
!
gnc_book_destroy (current_book);
current_book = NULL;
***************
*** 419,442 ****
* reason, we don't want to leave them high & dry without a
* topgroup, because if the user continues, then bad things will
* happen. */
! gncGetCurrentBook ();
g_free (newfile);
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
! return;
}
/* if we got to here, then we've successfully gotten a new session */
/* close up the old file session (if any) */
current_book = new_book;
!
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-opened-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
!
/* --------------- END CORE SESSION CODE -------------- */
/* clean up old stuff, and then we're outta here. */
--- 419,446 ----
* reason, we don't want to leave them high & dry without a
* topgroup, because if the user continues, then bad things will
* happen. */
! current_book = gncGetCurrentBook ();
g_free (newfile);
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
+
+ gh_call2(gh_eval_str("gnc:hook-run-danglers"),
+ gh_eval_str("gnc:*book-opened-hook*"),
+ gh_str02scm(gnc_book_get_url(current_book)));
! return FALSE;
}
/* if we got to here, then we've successfully gotten a new session */
/* close up the old file session (if any) */
current_book = new_book;
!
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-opened-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
!
/* --------------- END CORE SESSION CODE -------------- */
/* clean up old stuff, and then we're outta here. */
***************
*** 446,482 ****
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
}
/* ======================================================== */
! void
gncFileOpen (void)
{
const char * newfile;
if (!gncFileQuerySave ())
! return;
newfile = fileBox(_("Open"), NULL, gnc_history_get_last());
! gncPostFileOpen (newfile);
/* This dialogue can show up early in the startup process. If the
* user fails to pick a file (by e.g. hitting the cancel button), we
* might be left with a null topgroup, which leads to nastiness when
* user goes to create their very first account. So create one. */
gncGetCurrentBook ();
}
! void
gncFileOpenFile (const char * newfile)
{
! if (!newfile) return;
if (!gncFileQuerySave ())
! return;
! gncPostFileOpen (newfile);
}
/* ======================================================== */
--- 450,491 ----
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
+
+ return TRUE;
}
/* ======================================================== */
! gboolean
gncFileOpen (void)
{
const char * newfile;
+ gboolean result;
if (!gncFileQuerySave ())
! return FALSE;
newfile = fileBox(_("Open"), NULL, gnc_history_get_last());
! result = gncPostFileOpen (newfile);
/* This dialogue can show up early in the startup process. If the
* user fails to pick a file (by e.g. hitting the cancel button), we
* might be left with a null topgroup, which leads to nastiness when
* user goes to create their very first account. So create one. */
gncGetCurrentBook ();
+
+ return result;
}
! gboolean
gncFileOpenFile (const char * newfile)
{
! if (!newfile) return FALSE;
if (!gncFileQuerySave ())
! return FALSE;
! return gncPostFileOpen (newfile);
}
/* ======================================================== */
Index: gnucash/src/FileDialog.h
diff -c gnucash/src/FileDialog.h:1.14 gnucash/src/FileDialog.h:1.15
*** gnucash/src/FileDialog.h:1.14 Wed Jan 10 22:16:36 2001
--- gnucash/src/FileDialog.h Thu May 10 17:55:01 2001
***************
*** 125,136 ****
#include "gnc-book.h"
void gncFileNew (void);
! void gncFileOpen (void);
void gncFileQIFImport (void);
void gncFileSave (void);
void gncFileSaveAs (void);
! void gncFileOpenFile (const char *);
gboolean gncFileQuerySave (void);
--- 125,136 ----
#include "gnc-book.h"
void gncFileNew (void);
! gboolean gncFileOpen (void);
void gncFileQIFImport (void);
void gncFileSave (void);
void gncFileSaveAs (void);
! gboolean gncFileOpenFile (const char *filename);
gboolean gncFileQuerySave (void);
Index: gnucash/src/gnc-ui-util.c
diff -c gnucash/src/gnc-ui-util.c:1.28 gnucash/src/gnc-ui-util.c:1.29
*** gnucash/src/gnc-ui-util.c:1.28 Mon Apr 30 01:55:57 2001
--- gnucash/src/gnc-ui-util.c Thu May 10 11:11:16 2001
***************
*** 245,251 ****
children = xaccAccountGetChildren (account);
! xaccGroupForEachAccountDeeply (children, balance_helper, &cb);
balance = cb.balance;
}
--- 245,251 ----
children = xaccAccountGetChildren (account);
! xaccGroupForEachAccount (children, balance_helper, &cb, TRUE);
balance = cb.balance;
}
Index: gnucash/src/doc/design/engine.texinfo
diff -c gnucash/src/doc/design/engine.texinfo:1.31 gnucash/src/doc/design/engine.texinfo:1.32
*** gnucash/src/doc/design/engine.texinfo:1.31 Thu May 10 04:32:57 2001
--- gnucash/src/doc/design/engine.texinfo Fri May 11 05:48:01 2001
***************
*** 1602,1607 ****
--- 1602,1612 ----
Return the @var{I}th Split of @var{trans}.
@end deftypefun
+ @deftypefun {GList *} xaccTransGetSplitList (Transaction * @var{trans})
+ Return a @code{GList} of the Splits in @var{trans}. This list is owned
+ by @var{trans} and should not be modified in any way!
+ @end deftypefun
+
@deftypefun {const char *} xaccTransGetNum (Transaction * @var{trans})
Return the number field of @var{trans}.
@end deftypefun
***************
*** 1690,1696 ****
@section GNCBooks
@tindex GNCBook
! The @dfn{GNCBook} interface encapsulate all the information about a
GnuCash dataset, including the methods used to read and write the
dataset to datastores. This class provides several important services:
--- 1695,1701 ----
@section GNCBooks
@tindex GNCBook
! The @dfn{GNCBook} interface encapsulates all the information about a
GnuCash dataset, including the methods used to read and write the
dataset to datastores. This class provides several important services:
***************
*** 1731,1737 ****
memory associated with it.
@end deftypefun
! @deftypefun gboolean gnc_book_begin (GNCBook * @var{book}, const char * @var{book_id})
Begins a new book editing sesssion. It takes as an argument the book id.
The book id must be a string in the form of a URI/URL. In the current
implementation, only one type of URI is supported, and that is the file
--- 1736,1742 ----
memory associated with it.
@end deftypefun
! @deftypefun gboolean gnc_book_begin (GNCBook * @var{book}, const char * @var{book_id}, gboolean ignore_lock, gboolean create_if_nonexistent)
Begins a new book editing sesssion. It takes as an argument the book id.
The book id must be a string in the form of a URI/URL. In the current
implementation, only one type of URI is supported, and that is the file
***************
*** 1741,1764 ****
relative; that is, if the argument is @url{file:somefile.xac} then a
sequence of search paths are checked for a file of this name.
If the file exists, can be opened and read, and a lock can be obtained
! then a lock will be obtained and the function returns TRUE. Otherwise
! the function returns FALSE.
! @end deftypefun
! @deftypefun gboolean (*GNCBookLockFailHandler) (const char * @var{file})
! A function prototype for lock fail handlers used below.
! @end deftypefun
! @deftypefun gboolean gnc_book_begin_file (GNCBook * @var{book}, const char * @var{filename}, GNCBookLockFailHandler @var{handler})
! This routine is identical to the gnc_book_begin() routine, except that
! the argument is a filename (i.e. the five letters @code{file:} should
! not be prepended) and there is an additional function argument. This
! function is called if gnc_book_begin_file fails to obtain a lock for the
! file. If it returns TRUE, the file is loaded anyway. If it returns
! FALSE, or the handler is NULL, a failed lock attempt will abort the
! load. The lock fail handler is passed the filename of the data file
! being loaded.
@end deftypefun
@deftypefun gboolean gnc_book_load (GNCBook * @var{book})
--- 1746,1762 ----
relative; that is, if the argument is @url{file:somefile.xac} then a
sequence of search paths are checked for a file of this name.
+ The 'ignore_lock' argument, if set to TRUE, will cause this routine to
+ ignore any file locks that it finds. If set to FALSE, then file locks
+ will be tested and obeyed.
+
If the file exists, can be opened and read, and a lock can be obtained
! then a lock will be obtained and the function returns TRUE.
! If the file/database doesn't exist, and the create_if_nonexistent flag
! is set to TRUE, then the database is created.
! Otherwise the function returns FALSE.
@end deftypefun
@deftypefun gboolean gnc_book_load (GNCBook * @var{book})
***************
*** 1766,1772 ****
success.
@end deftypefun
! @deftypefun int gnc_book_get_error (GNCBook * @var{book})
Obtain the reason for a failure. Standard errno values are used. Calling
this routine resets the error value. This routine allows an
implementation of multiple error values, e.g. in a stack, where this
--- 1764,1770 ----
success.
@end deftypefun
! @deftypefun GNCBackendError gnc_book_get_error (GNCBook * @var{book})
Obtain the reason for a failure. Standard errno values are used. Calling
this routine resets the error value. This routine allows an
implementation of multiple error values, e.g. in a stack, where this
***************
*** 1793,1798 ****
--- 1791,1806 ----
book not open when @code{gnc_book_save()} was called.
@end table
+ @end deftypefun
+
+ @deftypefun {const char *} gnc_book_get_error_message(GNCBook * @var{book})
+ Return a string describing the reason for the current error. Calling
+ this routine resets the error value.
+ @end deftypefun
+
+ @deftypefun GNCBackendError gnc_book_pop_error (GNCBook * @var{book})
+ Same as @code{gnc_book_get_error}, but the error value is reset
+ in @var{book}.
@end deftypefun
@deftypefun {AccountGroup *} gnc_book_get_group (GNCBook * @var{book})
Index: gnucash/src/engine/Account.c
diff -c gnucash/src/engine/Account.c:1.142 gnucash/src/engine/Account.c:1.143
*** gnucash/src/engine/Account.c:1.142 Tue May 8 04:36:32 2001
--- gnucash/src/engine/Account.c Thu May 10 11:12:02 2001
***************
*** 135,140 ****
--- 135,161 ----
return acc;
}
+ Account *
+ xaccCloneAccountSimple(const Account *from)
+ {
+ Account *ret;
+
+ ret = xaccMallocAccount();
+ xaccInitAccount(ret);
+
+ ret->type = from->type;
+
+ ret->accountName = g_strdup(from->accountName);
+ ret->accountCode = g_strdup(from->accountCode);
+ ret->description = g_strdup(from->description);
+
+ ret->kvp_data = kvp_frame_copy(from->kvp_data);
+
+ ret->currency = from->currency;
+
+ return ret;
+ }
+
/********************************************************************\
\********************************************************************/
***************
*** 1273,1278 ****
--- 1294,1301 ----
xaccAccountGetChildren (Account *acc)
{
if (!acc) return NULL;
+ if (acc->children == NULL)
+ acc->children = xaccMallocAccountGroup ();
return (acc->children);
}
***************
*** 1755,1761 ****
#define GNC_RETURN_ENUM_AS_STRING(x) case (x): return #x;
char *
! xaccAccountTypeEnumAsString(int type) {
switch(type) {
GNC_RETURN_ENUM_AS_STRING(NO_TYPE);
GNC_RETURN_ENUM_AS_STRING(BANK);
--- 1778,1784 ----
#define GNC_RETURN_ENUM_AS_STRING(x) case (x): return #x;
char *
! xaccAccountTypeEnumAsString(GNCAccountType type) {
switch(type) {
GNC_RETURN_ENUM_AS_STRING(NO_TYPE);
GNC_RETURN_ENUM_AS_STRING(BANK);
Index: gnucash/src/engine/Account.h
diff -c gnucash/src/engine/Account.h:1.67 gnucash/src/engine/Account.h:1.68
*** gnucash/src/engine/Account.h:1.67 Mon Apr 23 01:07:57 2001
--- gnucash/src/engine/Account.h Thu May 10 11:12:02 2001
***************
*** 110,116 ****
/* Conversion routines for the account types to/from strings.
Critical for the text communication mechanisms. i.e. INCOME ->
"INCOME". */
! char * xaccAccountTypeEnumAsString (int type);
gboolean xaccAccountStringToType (const char* str, int *type);
GNCAccountType xaccAccountStringToEnum (const char* str);
--- 110,116 ----
/* Conversion routines for the account types to/from strings.
Critical for the text communication mechanisms. i.e. INCOME ->
"INCOME". */
! char * xaccAccountTypeEnumAsString (GNCAccountType type);
gboolean xaccAccountStringToType (const char* str, int *type);
GNCAccountType xaccAccountStringToEnum (const char* str);
***************
*** 129,134 ****
--- 129,135 ----
* (by calling xaccAccountBeginEdit()) before calling this routine.
*/
Account *xaccMallocAccount (void);
+ Account * xaccCloneAccountSimple(const Account *from);
void xaccAccountBeginEdit (Account *account);
void xaccAccountCommitEdit (Account *account);
void xaccAccountDestroy (Account *account);
Index: gnucash/src/engine/Group.c
diff -c gnucash/src/engine/Group.c:1.79 gnucash/src/engine/Group.c:1.80
*** gnucash/src/engine/Group.c:1.79 Wed Apr 25 18:37:56 2001
--- gnucash/src/engine/Group.c Thu May 10 11:12:28 2001
***************
*** 1295,1303 ****
}
gpointer
! xaccGroupForEachAccountDeeply (AccountGroup *grp,
! gpointer (*thunk)(Account *a, gpointer data),
! gpointer data)
{
GList *node;
--- 1295,1304 ----
}
gpointer
! xaccGroupForEachAccount (AccountGroup *grp,
! gpointer (*thunk)(Account *a, gpointer data),
! gpointer data,
! gboolean deeply)
{
GList *node;
***************
*** 1312,1318 ****
if (result)
return(result);
! result = xaccGroupForEachAccountDeeply (account->children, thunk, data);
if (result)
return(result);
--- 1313,1321 ----
if (result)
return(result);
! if(deeply)
! result = xaccGroupForEachAccount (account->children,
! thunk, data, TRUE);
if (result)
return(result);
Index: gnucash/src/engine/Group.h
diff -c gnucash/src/engine/Group.h:1.44 gnucash/src/engine/Group.h:1.45
*** gnucash/src/engine/Group.h:1.44 Wed Apr 18 06:11:02 2001
--- gnucash/src/engine/Group.h Thu May 10 11:12:28 2001
***************
*** 211,220 ****
gpointer (*thunk)(Account *a, gpointer data),
gpointer data);
! gpointer xaccGroupForEachAccountDeeply(AccountGroup *grp,
! gpointer (*thunk)(Account *a,
! gpointer data),
! gpointer data);
gboolean xaccGroupEqual(AccountGroup *a, AccountGroup *b,
gboolean check_guids);
--- 211,221 ----
gpointer (*thunk)(Account *a, gpointer data),
gpointer data);
! gpointer xaccGroupForEachAccount (AccountGroup *grp,
! gpointer (*thunk) (Account *a,
! gpointer data),
! gpointer data,
! gboolean deeply);
gboolean xaccGroupEqual(AccountGroup *a, AccountGroup *b,
gboolean check_guids);
Index: gnucash/src/engine/gnc-book.c
diff -c gnucash/src/engine/gnc-book.c:1.33 gnucash/src/engine/gnc-book.c:1.34
*** gnucash/src/engine/gnc-book.c:1.33 Tue Apr 17 04:32:03 2001
--- gnucash/src/engine/gnc-book.c Thu May 10 11:12:52 2001
***************
*** 197,204 ****
void
gnc_book_set_group (GNCBook *book, AccountGroup *grp)
{
! if (!book) return;
! book->topgroup = grp;
}
/* ---------------------------------------------------------------------- */
--- 197,205 ----
void
gnc_book_set_group (GNCBook *book, AccountGroup *grp)
{
! if(!book) return;
! if(book->topgroup) xaccFreeAccountGroup(book->topgroup);
! book->topgroup = grp;
}
/* ---------------------------------------------------------------------- */
Index: gnucash/src/engine/gnc-book.h
diff -c gnucash/src/engine/gnc-book.h:1.16 gnucash/src/engine/gnc-book.h:1.17
*** gnucash/src/engine/gnc-book.h:1.16 Thu Mar 22 02:02:47 2001
--- gnucash/src/engine/gnc-book.h Thu May 10 11:12:52 2001
***************
*** 120,125 ****
--- 120,126 ----
AccountGroup *gnc_book_get_group (GNCBook *book);
+ void gnc_book_set_group(GNCBook *book, AccountGroup *group);
GNCPriceDB *gnc_book_get_pricedb (GNCBook *book);
guint gnc_book_count_transactions(GNCBook *book);
Index: gnucash/src/engine/rpc/RpcUtils.c
diff -c gnucash/src/engine/rpc/RpcUtils.c:1.4 gnucash/src/engine/rpc/RpcUtils.c:1.5
*** gnucash/src/engine/rpc/RpcUtils.c:1.4 Tue Apr 17 04:32:05 2001
--- gnucash/src/engine/rpc/RpcUtils.c Thu May 10 11:13:13 2001
***************
*** 609,615 ****
ENTER ("ag=%p", ag);
listinfo.end = &alist;
listinfo.count = 0;
! xaccGroupForEachAccountDeeply (ag, add_acctlist_cb, (void *) &listinfo);
LEAVE ("%d accts", listinfo.count);
return alist;
}
--- 609,615 ----
ENTER ("ag=%p", ag);
listinfo.end = &alist;
listinfo.count = 0;
! xaccGroupForEachAccount (ag, add_acctlist_cb, (void *) &listinfo, TRUE);
LEAVE ("%d accts", listinfo.count);
return alist;
}
***************
*** 739,745 ****
listinfo.copyguid = copyguid;
listinfo.count = 0;
! xaccGroupForEachAccountDeeply (ag, add_acctvers_cb, (void *) &listinfo);
LEAVE ("%d accts", listinfo.count);
return vlist;
--- 739,745 ----
listinfo.copyguid = copyguid;
listinfo.count = 0;
! xaccGroupForEachAccount (ag, add_acctvers_cb, (void *) &listinfo, TRUE);
LEAVE ("%d accts", listinfo.count);
return vlist;
Index: gnucash/src/engine/sql/PostgresBackend.c
diff -c gnucash/src/engine/sql/PostgresBackend.c:1.37 gnucash/src/engine/sql/PostgresBackend.c:1.39
*** gnucash/src/engine/sql/PostgresBackend.c:1.37 Wed May 9 19:12:45 2001
--- gnucash/src/engine/sql/PostgresBackend.c Thu May 10 11:49:44 2001
***************
*** 62,69 ****
/* hack alert -- this is the query buffer size, it can be overflowed.
* Ideally, its dynamically resized. On the other hand, Postgres
! * rejects queries longer than 8192 bytes,(according to the
! * documentation) so theres not much point in getting fancy ...
*/
#define QBUFSIZE 16350
--- 62,69 ----
/* hack alert -- this is the query buffer size, it can be overflowed.
* Ideally, its dynamically resized. On the other hand, Postgres
! * rejects queries longer than 8192 bytes, (according to the
! * documentation) so there's not much point in getting fancy ...
*/
#define QBUFSIZE 16350
***************
*** 366,372 ****
{
if (!grp) return;
! xaccGroupForEachAccountDeeply (grp, restore_cb, be);
}
/* ============================================================= */
--- 366,372 ----
{
if (!grp) return;
! xaccGroupForEachAccount (grp, restore_cb, be, TRUE);
}
/* ============================================================= */
***************
*** 1247,1258 ****
/* ============================================================= */
/* The pgendGetAllTransactions() routine sucks *all* of the
! * transactions out of the database. This is a potential
! * CPU and memory-burner; its use is not suggested for anything
! * but single-user mode.
*
! * To add injury to insult, this routine fetches in a rather
! * inefficient manner, in particular, the account query.
*/
static void
--- 1247,1258 ----
/* ============================================================= */
/* The pgendGetAllTransactions() routine sucks *all* of the
! * transactions out of the database. This is a potential
! * CPU and memory-burner; its use is not suggested for anything
! * but single-user mode.
*
! * To add injury to insult, this routine fetches in a rather
! * inefficient manner, in particular, the account query.
*/
static void
***************
*** 1524,1537 ****
}
/* ============================================================= */
! /* In single file mode, we treat 'sync' as 'file save'.
! * We start by deleting *everything*, and then writing
! * everything out. This is rather nasty, ugly and dangerous,
! * but that's the nature of single-file mode. Note: we
! * have to delete everything because in this mode, there is
! * no other way of finding out that an account, transaction
! * or split was deleted. i.e. there's no other way to delete.
! * So start with a clean slate.
*/
static void
--- 1524,1542 ----
}
/* ============================================================= */
! /* The pgendSyncSingleFile() routine syncs the engine and database.
! * In single file mode, we treat 'sync' as 'file save'.
! * We start by deleting *everything*, and then writing
! * everything out. This is rather nasty, ugly and dangerous,
! * but that's the nature of single-file mode. Note: we
! * have to delete everything because in this mode, there is
! * no other way of finding out that an account, transaction
! * or split was deleted. i.e. there's no other way to delete.
! * So start with a clean slate.
! *
! * The use of this routine/this mode is 'depricated'.
! * Its handy for testing, sanity-checking, and as a failsafe,
! * but its use shouldn't be encouraged.
*/
static void
***************
*** 1604,1620 ****
}
/* ============================================================= */
! /* Determine whether we can start a session of the desired type.
! * The logic used is as follows:
! * -- if there is any session at all, and we want single
! * (exclusive) access, then fail.
! * -- if we want any kind of session, and there is a single
! * (exclusive) session going, then fail.
! * -- otherwise, suceed.
! * Return TRUE if we can get a session.
*
! * This routine does not lock, but may be used inside a
! * test-n-set atomic operation.
*/
static gpointer
--- 1609,1626 ----
}
/* ============================================================= */
! /* The get_session_cb() routine can determine whether we can start
! * a session of the desired type.
! * The logic used is as follows:
! * -- if there is any (other) session at all, and we want single
! * (exclusive) access, then fail.
! * -- if we want any kind of session, and there is a single
! * (exclusive) session going, then fail.
! * -- otherwise, suceed.
! * Return TRUE if we can get a session.
*
! * This routine does not lock, but may be used inside a
! * test-n-set atomic operation.
*/
static gpointer
***************
*** 1694,1702 ****
/* ============================================================= */
/* The pgendSessionValidate() routine determines whether a valid
! * session could be obtained.
! * Return TRUE if we have a session.
! * This routine is implemented attomically as a test-n-set.
*/
static gpointer
--- 1700,1710 ----
/* ============================================================= */
/* The pgendSessionValidate() routine determines whether a valid
! * session could be obtained. It checks to see if:
! * 1) Database appers to have gnucash data in it
! * 2) the session table can be locked and updated to start
! * a session. The update is handled as an atomic test-n-set.
! * Return TRUE if we have a session.
*/
static gpointer
***************
*** 1737,1747 ****
SEND_QUERY (be,p, FALSE);
FINISH_QUERY(be->connection);
! /* check to see if we can start a session of the desired type. */
if (FALSE == pgendSessionCanStart (be, break_lock))
{
! /* this error should be treated just like the
! * file-lock error from the GUI perspective */
be->be.book_load = pgend_book_load_single_lockerr;
xaccBackendSetError (&be->be, ERR_BACKEND_LOCKED);
retval = FALSE;
--- 1745,1757 ----
SEND_QUERY (be,p, FALSE);
FINISH_QUERY(be->connection);
! /* Check to see if we can start a session of the desired type. */
if (FALSE == pgendSessionCanStart (be, break_lock))
{
! /* This error should be treated just like the
! * file-lock error from the GUI perspective:
! * (The GUI allows users to break the lock, if desired).
! */
be->be.book_load = pgend_book_load_single_lockerr;
xaccBackendSetError (&be->be, ERR_BACKEND_LOCKED);
retval = FALSE;
***************
*** 1763,1769 ****
}
/* ============================================================= */
! /* log end of session in the database. */
static void
pgendSessionEnd (PGBackend *be)
--- 1773,1781 ----
}
/* ============================================================= */
! /* The pgendSessionEnd() routine will log the end of session in
! * the session table of the database.
! */
static void
pgendSessionEnd (PGBackend *be)
***************
*** 1785,1790 ****
--- 1797,1807 ----
}
/* ============================================================= */
+ /* The pgend_session_end() routine is the main entrypoint into
+ * this backend for terminating a session. It logs the
+ * end of the session into the gncsession table, disconnects
+ * from the database, and finally frees all malloced memory.
+ */
static void
pgend_session_end (Backend *bend)
***************
*** 1827,1834 ****
}
/* ============================================================= */
! /* the poll & event style load only loads accounts, never the
! * transactions. */
static AccountGroup *
pgend_book_load_poll (Backend *bend)
--- 1844,1854 ----
}
/* ============================================================= */
! /* The pgend_book_load_poll() routine loads account info from
! * the database into the engine. Its to be used only for
! * the poll & event style load, where only the accounts,
! * and never the transactions, need to be loaded.
! */
static AccountGroup *
pgend_book_load_poll (Backend *bend)
***************
*** 1853,1860 ****
}
/* ============================================================= */
! /* The single-user mode loads all transactions. Doesn't bother
! * with checkpoints */
static AccountGroup *
pgend_book_load_single (Backend *bend)
--- 1873,1884 ----
}
/* ============================================================= */
! /* The pgend_book_load_single() routine loads the engine with
! * data from the database. Used only in single-user mode,
! * it loads account *and* transaction data. Single-user
! * mode doesn't require balance checkpoingts, to these are
! * not handled.
! */
static AccountGroup *
pgend_book_load_single (Backend *bend)
***************
*** 1879,1884 ****
--- 1903,1919 ----
}
/* ============================================================= */
+ /* The pgend_session_begin() routine implements the main entrypoint
+ * into the SQL backend code.
+ *
+ * 1) It parses the URL to find the database, username, password, etc.
+ * 2) It makes the first contact to the database, and tries to
+ * initiate a user session.
+ * 3) It creates the GnuCash tables for the first time, if these
+ * need to be created.
+ * 4) It logs the user session in the database (gncsession table).
+ * 5) loads data from the database into the engine.
+ */
static void
pgend_session_begin (GNCBook *sess, const char * sessionid,
***************
*** 2277,2282 ****
--- 2312,2320 ----
}
/* ============================================================= */
+ /* The pgendInit() routine initializes the backend private
+ * structures, mallocs any needed memory, etc.
+ */
static void
pgendInit (PGBackend *be)
Index: gnucash/src/gnome/dialog-column-view.c
diff -c gnucash/src/gnome/dialog-column-view.c:1.9 gnucash/src/gnome/dialog-column-view.c:1.10
*** gnucash/src/gnome/dialog-column-view.c:1.9 Wed May 2 06:01:02 2001
--- gnucash/src/gnome/dialog-column-view.c Thu May 10 17:30:38 2001
***************
*** 51,56 ****
--- 51,69 ----
int contents_selected;
};
+ static void
+ gnc_column_view_set_option(GNCOptionDB * odb, char * section, char * name,
+ SCM new_value) {
+ GNCOption * option =
+ gnc_option_db_get_option_by_name(odb, section, name);
+
+ if(option) {
+ gnc_option_db_set_option(odb, section, name, new_value);
+ /* set_option doesn't do this */
+ option->changed = TRUE;
+ }
+ }
+
static void
gnc_column_view_edit_destroy(gnc_column_view_edit * view) {
gnc_options_dialog_destroy(view->optwin);
***************
*** 168,173 ****
--- 181,187 ----
gnc_column_view_edit * win = user_data;
if(!win) return;
+ printf("calling option_db_commit\n");
gnc_option_db_commit(win->odb);
gh_call2(dirty_report, win->view, SCM_BOOL_T);
}
***************
*** 176,189 ****
gnc_column_view_edit_close_cb(GNCOptionWin * win, gpointer user_data) {
gnc_column_view_edit * r = user_data;
SCM set_editor = gh_eval_str("gnc:report-set-editor-widget!");
- SCM get_windows = gh_eval_str("gnc:report-display-list");
- SCM windows;
-
- for(windows = gh_call1(get_windows, r->view);
- !gh_null_p(windows); windows = gh_cdr(windows)) {
- gnc_report_window_remove_edited_report(gw_wcp_get_ptr(gh_car(windows)),
- r->view);
- }
gh_call2(set_editor, r->view, SCM_BOOL_F);
gnc_column_view_edit_destroy(r);
--- 190,195 ----
***************
*** 262,292 ****
}
}
-
void
gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) {
gnc_column_view_edit * r =
gtk_object_get_data(GTK_OBJECT(user_data), "view_edit_struct");
SCM make_report = gh_eval_str("gnc:make-report");
SCM find_report = gh_eval_str("gnc:find-report");
- SCM add_child = gh_eval_str("gnc:report-add-child-by-id!");
- SCM set_parent = gh_eval_str("gnc:report-set-parent!");
SCM template_name;
SCM set_value = gh_eval_str("gnc:option-set-value");
SCM new_report;
SCM newlist = SCM_EOL;
SCM oldlist = r->contents_list;
int count;
int oldlength;
!
if(gh_list_p(r->available_list) &&
(gh_length(r->available_list) > r->available_selected)) {
template_name = gh_list_ref(r->available_list,
gh_int2scm(r->available_selected));
new_report = gh_call1(make_report, template_name);
! gh_call2(add_child, r->view, new_report);
! gh_call2(set_parent, gh_call1(find_report, new_report), r->view);
!
oldlength = gh_length(r->contents_list);
if(oldlength > r->contents_selected) {
--- 268,295 ----
}
}
void
gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) {
gnc_column_view_edit * r =
gtk_object_get_data(GTK_OBJECT(user_data), "view_edit_struct");
SCM make_report = gh_eval_str("gnc:make-report");
+ SCM mark_report = gh_eval_str("gnc:report-set-needs-save?!");
SCM find_report = gh_eval_str("gnc:find-report");
SCM template_name;
SCM set_value = gh_eval_str("gnc:option-set-value");
SCM new_report;
+ SCM report_obj;
SCM newlist = SCM_EOL;
SCM oldlist = r->contents_list;
int count;
int oldlength;
!
if(gh_list_p(r->available_list) &&
(gh_length(r->available_list) > r->available_selected)) {
template_name = gh_list_ref(r->available_list,
gh_int2scm(r->available_selected));
new_report = gh_call1(make_report, template_name);
! gh_call2(mark_report, gh_call1(find_report, new_report), SCM_BOOL_T);
oldlength = gh_length(r->contents_list);
if(oldlength > r->contents_selected) {
***************
*** 294,310 ****
newlist = gh_cons(gh_car(oldlist), newlist);
oldlist = gh_cdr(oldlist);
}
! newlist = gh_append2(gh_reverse(gh_cons(SCM_LIST3(new_report,
gh_int2scm(1),
! gh_int2scm(1)),
newlist)),
oldlist);
}
else {
newlist = gh_append2(oldlist,
! SCM_LIST1(SCM_LIST3(new_report,
gh_int2scm(1),
! gh_int2scm(1))));
r->contents_selected = oldlength;
}
--- 297,315 ----
newlist = gh_cons(gh_car(oldlist), newlist);
oldlist = gh_cdr(oldlist);
}
! newlist = gh_append2(gh_reverse(gh_cons(SCM_LIST4(new_report,
! gh_int2scm(1),
gh_int2scm(1),
! SCM_BOOL_F),
newlist)),
oldlist);
}
else {
newlist = gh_append2(oldlist,
! SCM_LIST1(SCM_LIST4(new_report,
gh_int2scm(1),
! gh_int2scm(1),
! SCM_BOOL_F)));
r->contents_selected = oldlength;
}
***************
*** 312,320 ****
r->contents_list = newlist;
scm_protect_object(r->contents_list);
! gnc_option_db_set_option(r->odb, "__general", "report-list",
! r->contents_list);
!
gnc_options_dialog_changed (r->optwin);
}
--- 317,324 ----
r->contents_list = newlist;
scm_protect_object(r->contents_list);
! gnc_column_view_set_option(r->odb, "__general", "report-list",
! r->contents_list);
gnc_options_dialog_changed (r->optwin);
}
***************
*** 350,357 ****
r->contents_list = newlist;
scm_protect_object(r->contents_list);
! gnc_option_db_set_option(r->odb, "__general", "report-list",
! r->contents_list);
gnc_options_dialog_changed (r->optwin);
}
--- 354,361 ----
r->contents_list = newlist;
scm_protect_object(r->contents_list);
! gnc_column_view_set_option(r->odb, "__general", "report-list",
! r->contents_list);
gnc_options_dialog_changed (r->optwin);
}
***************
*** 386,394 ****
r->contents_selected = r->contents_selected - 1;
! gnc_option_db_set_option(r->odb, "__general", "report-list",
! r->contents_list);
!
gnc_options_dialog_changed (r->optwin);
update_display_lists(r);
--- 390,398 ----
r->contents_selected = r->contents_selected - 1;
! gnc_column_view_set_option(r->odb, "__general", "report-list",
! r->contents_list);
!
gnc_options_dialog_changed (r->optwin);
update_display_lists(r);
***************
*** 422,429 ****
r->contents_selected = r->contents_selected + 1;
! gnc_option_db_set_option(r->odb, "__general", "report-list",
! r->contents_list);
gnc_options_dialog_changed (r->optwin);
--- 426,433 ----
r->contents_selected = r->contents_selected + 1;
! gnc_column_view_set_option(r->odb, "__general", "report-list",
! r->contents_list);
gnc_options_dialog_changed (r->optwin);
Index: gnucash/src/gnome/gnc-html-guppi.c
diff -c gnucash/src/gnome/gnc-html-guppi.c:1.14 gnucash/src/gnome/gnc-html-guppi.c:1.15
*** gnucash/src/gnome/gnc-html-guppi.c:1.14 Wed May 9 03:27:03 2001
--- gnucash/src/gnome/gnc-html-guppi.c Thu May 10 17:30:38 2001
***************
*** 63,68 ****
--- 63,77 ----
guppi_tank_shutdown();
}
+ static void
+ gnc_html_guppi_print_cb(GtkHTMLEmbedded * eb, GnomePrintContext * pc,
+ gpointer data) {
+ GtkWidget * w = data;
+ GuppiObject * o = gtk_object_get_user_data(GTK_OBJECT(w));
+
+ guppi_object_print(o, pc);
+ }
+
/* the handlers for pie. bar, and scatter charts */
static int
handle_piechart(gnc_html * html, GtkHTMLEmbedded * eb, gpointer data) {
***************
*** 70,76 ****
--- 79,91 ----
int retval;
widg = gnc_html_embedded_piechart(html, eb->width, eb->height,
eb->params);
+
if(widg) {
+ if(gtk_signal_lookup("draw_print", gtk_html_embedded_get_type())) {
+ gtk_signal_connect(GTK_OBJECT(eb), "draw_print", gnc_html_guppi_print_cb,
+ widg);
+ }
+
gtk_widget_show_all(widg);
gtk_container_add(GTK_CONTAINER(eb), widg);
gtk_widget_set_usize(GTK_WIDGET(eb), eb->width, eb->height);
***************
*** 89,94 ****
--- 104,114 ----
widg = gnc_html_embedded_barchart(html, eb->width, eb->height,
eb->params);
if(widg) {
+ if(gtk_signal_lookup("draw_print", gtk_html_embedded_get_type())) {
+ gtk_signal_connect(GTK_OBJECT(eb), "draw_print", gnc_html_guppi_print_cb,
+ widg);
+ }
+
gtk_widget_show_all(widg);
gtk_container_add(GTK_CONTAINER(eb), widg);
gtk_widget_set_usize(GTK_WIDGET(eb), eb->width, eb->height);
***************
*** 107,112 ****
--- 127,137 ----
widg = gnc_html_embedded_scatter(html, eb->width, eb->height,
eb->params);
if(widg) {
+ if(gtk_signal_lookup("draw_print", gtk_html_embedded_get_type())) {
+ gtk_signal_connect(GTK_OBJECT(eb), "draw_print", gnc_html_guppi_print_cb,
+ widg);
+ }
+
gtk_widget_show_all(widg);
gtk_container_add(GTK_CONTAINER(eb), widg);
gtk_widget_set_usize(GTK_WIDGET(eb), eb->width, eb->height);
***************
*** 536,543 ****
free_strings(labels, datasize);
free_strings(colors, datasize);
! if(chart)
return chart->widget;
else
return NULL;
}
--- 561,570 ----
free_strings(labels, datasize);
free_strings(colors, datasize);
! if(chart) {
! gtk_object_set_user_data(GTK_OBJECT(chart->widget), chart->guppiobject);
return chart->widget;
+ }
else
return NULL;
}
***************
*** 782,789 ****
free_strings(row_labels, datarows);
free_strings(col_colors, datacols);
! if(chart)
return chart->widget;
else
return NULL;
}
--- 809,818 ----
free_strings(row_labels, datarows);
free_strings(col_colors, datacols);
! if(chart) {
! gtk_object_set_user_data(GTK_OBJECT(chart->widget), chart->guppiobject);
return chart->widget;
+ }
else
return NULL;
}
***************
*** 884,891 ****
g_free(x_data);
g_free(y_data);
! if(chart)
return chart->widget;
else
return NULL;
}
--- 913,922 ----
g_free(x_data);
g_free(y_data);
! if(chart) {
! gtk_object_set_user_data(GTK_OBJECT(chart->widget), chart->guppiobject);
return chart->widget;
+ }
else
return NULL;
}
Index: gnucash/src/gnome/gnc-html.c
diff -c gnucash/src/gnome/gnc-html.c:1.33 gnucash/src/gnome/gnc-html.c:1.34
*** gnucash/src/gnome/gnc-html.c:1.33 Sat Apr 21 05:36:58 2001
--- gnucash/src/gnome/gnc-html.c Thu May 10 17:30:38 2001
***************
*** 658,685 ****
}
- #ifdef USE_GUPPI
- static void
- gnc_html_guppi_print_cb(GtkHTMLEmbedded * eb, GnomePrintContext * pc,
- gpointer data) {
- GtkWidget * w = data;
- GuppiObject * o = gtk_object_get_user_data(GTK_OBJECT(w));
-
- /* this is a magical scaling factor (gtkhtml and guppi assume different
- * screen resolutions) */
- gnome_print_scale(pc, 0.6944, 0.6944);
- guppi_object_print(o, pc);
- }
-
- static void
- gnc_html_guppi_redraw_cb(GtkHTMLEmbedded * eb,
- GdkPixmap * pix, GdkGC * gc, gint x, gint y,
- gpointer data) {
- /* nothing special to do */
- }
- #endif /* USE_GUPPI */
-
-
/********************************************************************
* gnc_html_object_requested_cb - called when an applet needs to be
* loaded.
--- 658,663 ----
Index: gnucash/src/gnome/new-user-callbacks.c
diff -c gnucash/src/gnome/new-user-callbacks.c:1.5 gnucash/src/gnome/new-user-callbacks.c:1.6
*** gnucash/src/gnome/new-user-callbacks.c:1.5 Fri Apr 13 01:54:25 2001
--- gnucash/src/gnome/new-user-callbacks.c Thu May 10 11:15:07 2001
***************
*** 28,33 ****
--- 28,34 ----
#include <gnome.h>
+ #include "gnc-book.h"
#include "new-user-callbacks.h"
#include "new-user-interface.h"
#include "gnc-commodity-edit.h"
***************
*** 36,46 ****
--- 37,60 ----
#include "gnc-ui-util.h"
#include "gnc-dir.h"
#include "io-example-account.h"
+ #include "FileDialog.h"
#include <guile/gh.h>
static int commodEditAdded = 0;
+ static AccountGroup *our_final_group = NULL;
+
static void
+ delete_our_final_group(void)
+ {
+ if(our_final_group != NULL)
+ {
+ xaccFreeAccountGroup(our_final_group);
+ our_final_group = NULL;
+ }
+ }
+
+ static void
set_first_startup(int first_startup)
{
gchar *todo;
***************
*** 88,95 ****
--- 102,116 ----
/* now we need to load all the accounts into the program */
gh_eval_str("(gnc:show-main-window)");
+ gh_eval_str("(gnc:hook-run-danglers gnc:*book-opened-hook* #f)");
set_first_startup(0);
+
+ if(our_final_group)
+ {
+ xaccGroupConcatGroup(gnc_book_get_group(gncGetCurrentBook()),
+ our_final_group);
+ }
}
***************
*** 114,119 ****
--- 135,142 ----
"newAccountCancelDialog_RunAgainToggle")));
set_first_startup(keepshowing);
+
+ delete_our_final_group();
gnc_ui_delete_new_user_window();
gnc_ui_delete_nu_cancel_dialog();
***************
*** 121,129 ****
gh_eval_str("(gnc:default-ui-start)");
gh_eval_str("(gnc:show-main-window)");
}
-
void
on_newAccountCurrencyChoosePage_prepare (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
--- 144,152 ----
gh_eval_str("(gnc:default-ui-start)");
gh_eval_str("(gnc:show-main-window)");
+ gh_eval_str("(gnc:hook-run-danglers gnc:*book-opened-hook* #f)");
}
void
on_newAccountCurrencyChoosePage_prepare (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
***************
*** 131,151 ****
{
/* need to load currency info here. In fact drop a
gnc-commodity-edit widget here */
- GtkWidget *commodityWid;
- GtkWidget *vbox;
-
if(!commodEditAdded)
{
commodEditAdded = 1;
- commodityWid = gnc_commodity_edit_new();
- gtk_widget_show(commodityWid);
- gnc_commodity_edit_set_commodity(GNC_COMMODITY_EDIT(commodityWid),
- gnc_locale_default_currency());
-
- vbox = lookup_widget(GTK_WIDGET(gnomedruidpage),
- "newAccountCurrencyChooser_vbox");
! gtk_box_pack_start(GTK_BOX(vbox), commodityWid, FALSE, FALSE, 0);
}
}
--- 154,167 ----
{
/* need to load currency info here. In fact drop a
gnc-commodity-edit widget here */
if(!commodEditAdded)
{
commodEditAdded = 1;
! gtk_box_pack_start(
! GTK_BOX(lookup_widget(GTK_WIDGET(gnomedruidpage),
! "newAccountCurrencyChooser_vbox")),
! GTK_WIDGET(gnc_get_new_user_commodity_editor()), FALSE, FALSE, 0);
}
}
***************
*** 172,177 ****
--- 188,194 ----
gpointer arg1,
gpointer user_data)
{
+ static gboolean addedAccountLists = 0;
GSList *list;
GtkCList *clist;
***************
*** 179,191 ****
list = gnc_load_example_account_list(GNC_ACCOUNTS_DIR "/C");
! clist = GTK_CLIST(lookup_widget(GTK_WIDGET(gnomedruidpage),
! "newAccountTypesList"));
gtk_clist_freeze(clist);
gtk_clist_set_sort_column(clist, 0);
! g_slist_foreach(list, add_each_gea_to_clist, (gpointer)clist);
gtk_clist_sort(clist);
gtk_clist_thaw(clist);
--- 196,212 ----
list = gnc_load_example_account_list(GNC_ACCOUNTS_DIR "/C");
! clist = gnc_new_user_get_clist();
!
gtk_clist_freeze(clist);
gtk_clist_set_sort_column(clist, 0);
! if(!addedAccountLists)
! {
! g_slist_foreach(list, add_each_gea_to_clist, (gpointer)clist);
! addedAccountLists = 1;
! }
gtk_clist_sort(clist);
gtk_clist_thaw(clist);
***************
*** 204,210 ****
--- 225,263 ----
/* need to fill up the account list info here */
}
+ static gpointer
+ add_to_tree_account(Account* toadd, gpointer data)
+ {
+ GtkWidget *item;
+ GtkTree *tree = GTK_TREE(data);
+
+ if(!toadd)
+ {
+ return NULL;
+ }
+
+ item = gtk_tree_item_new_with_label(xaccAccountGetName(toadd));
+ gtk_tree_insert(tree, item, 0);
+ gtk_widget_show(item);
+ if(xaccGroupGetNumSubAccounts(xaccAccountGetChildren(toadd)) > 0)
+ {
+ GtkWidget *subtree = gtk_tree_new();
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
+ gtk_tree_item_expand(GTK_TREE_ITEM(item));
+ xaccGroupForEachAccount(xaccAccountGetChildren(toadd),
+ add_to_tree_account, subtree, FALSE);
+ }
+
+ return NULL;
+ }
+
+ static void
+ add_to_tree(GtkTree *tree, AccountGroup *grp)
+ {
+ xaccGroupForEachAccount(grp, add_to_tree_account, tree, FALSE);
+ }
+
void
on_newAccountTypesList_select_row (GtkCList *clist,
gint row,
***************
*** 212,218 ****
GdkEvent *event,
gpointer user_data)
{
! /* need to fill in useful data on a select row */
}
--- 265,293 ----
GdkEvent *event,
gpointer user_data)
{
! GtkText *datext =
! GTK_TEXT(gnc_new_user_get_widget("newAccountTypesDescription"));
! GtkTree *datree =
! GTK_TREE(gnc_new_user_get_widget("newAccountListTree"));
! GncExampleAccount *gea =
! (GncExampleAccount*)gtk_clist_get_row_data(clist, row);
!
! gtk_text_freeze(datext);
! gtk_text_set_point(datext, 0);
! gtk_text_forward_delete(datext, gtk_text_get_length(datext));
! if(gea->long_description != NULL)
! {
! gtk_text_set_editable(datext, TRUE);
! gtk_text_insert(datext, NULL, NULL, NULL, gea->long_description, -1);
! gtk_text_set_editable(datext, FALSE);
! }
! gtk_text_thaw(datext);
!
! gtk_tree_clear_items(datree, 0, 1000);
! add_to_tree(datree, gea->group);
!
! printf("%s", "");
!
}
***************
*** 231,237 ****
on_newAccountSelectAllButton_clicked (GtkButton *button,
gpointer user_data)
{
-
}
--- 306,311 ----
***************
*** 258,281 ****
(GtkButton *button,
gpointer user_data)
{
!
}
-
void
! on_ctree1_select_row (GtkCList *clist,
! gint row,
! gint column,
! GdkEvent *event,
gpointer user_data)
{
}
void
on_finalAccountDruidPage_prepare (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
gpointer user_data)
{
--- 332,452 ----
(GtkButton *button,
gpointer user_data)
{
! gtk_clist_select_all(gnc_new_user_get_clist());
}
void
! on_newAccountsTypeList_ClearAllButton_clicked
! (GtkButton *button,
gpointer user_data)
{
+ gtk_clist_unselect_all(gnc_new_user_get_clist());
+ }
+
+ struct FinalInsertData_struct
+ {
+ GtkCTree *tree;
+ GtkCTreeNode *node;
+ GtkCTreeNode *sibling;
+ };
+ typedef struct FinalInsertData_struct FinalInsertData;
+
+ static gchar**
+ generate_account_titles(Account *act)
+ {
+ gchar **ret;
+
+ ret = g_new(gchar *, 3);
+
+ ret[0] = (gchar*)xaccAccountGetName(act);
+ ret[1] = xaccAccountTypeEnumAsString(xaccAccountGetType(act));
+ ret[2] = "";
+
+ return ret;
+ }
+
+ static void
+ free_account_titles(gchar **tofree)
+ {
+ g_free(tofree);
+ }
+
+ static gpointer
+ add_to_ctree_final_account(Account* toadd, gpointer data)
+ {
+ FinalInsertData *topdata = (FinalInsertData*)data;
+ GtkCTreeNode *node;
+ gchar **titles;
+
+ titles = generate_account_titles (toadd);
+
+ node = gtk_ctree_insert_node(topdata->tree, topdata->node,
+ topdata->sibling,
+ titles, 0,
+ NULL, NULL, NULL, NULL,
+ FALSE, TRUE);
+ /* don't know if this is safe, so commented out at the moment. FIXME! */
+ /* free_account_titles(titles); */
+
+ if(xaccGroupGetNumAccounts(xaccAccountGetChildren(toadd)) > 0)
+ {
+ FinalInsertData nextdata;
+ nextdata.tree = topdata->tree;
+ nextdata.node = node;
+ nextdata.sibling = NULL;
+
+ xaccGroupForEachAccount(xaccAccountGetChildren(toadd),
+ add_to_ctree_final_account, &nextdata, FALSE);
+ }
+ topdata->sibling = node;
+
+ return NULL;
}
+ void
+ gnc_new_user_insert_final_accounts(GtkCTree *tree, AccountGroup *group)
+ {
+ FinalInsertData data;
+ data.tree = tree;
+ data.node = NULL;
+ data.sibling = NULL;
+
+ xaccGroupForEachAccount(group, add_to_ctree_final_account, &data, FALSE);
+ }
void
on_finalAccountDruidPage_prepare (GnomeDruidPage *gnomedruidpage,
gpointer arg1,
+ gpointer user_data)
+ {
+ GList *dalist;
+ GSList *actlist = NULL;
+ GtkCList *clist = gnc_new_user_get_clist();
+
+ gtk_clist_clear(GTK_CLIST(gnc_new_user_get_widget("finalAccountCTree")));
+
+ for(dalist = clist->selection; dalist; dalist = dalist->next)
+ {
+ int row = GPOINTER_TO_INT(dalist->data);
+ actlist = g_slist_append(actlist, gtk_clist_get_row_data(clist, row));
+ }
+
+ delete_our_final_group();
+ our_final_group = gnc_new_user_merge_groups(actlist);
+
+ gnc_new_user_insert_final_accounts(
+ GTK_CTREE(gnc_new_user_get_widget("finalAccountCTree")),
+ our_final_group);
+ }
+
+
+
+ void
+ on_finalAccountCTree_select_row (GtkCList *clist,
+ gint row,
+ gint column,
+ GdkEvent *event,
gpointer user_data)
{
Index: gnucash/src/gnome/new-user-callbacks.h
diff -c gnucash/src/gnome/new-user-callbacks.h:1.5 gnucash/src/gnome/new-user-callbacks.h:1.6
*** gnucash/src/gnome/new-user-callbacks.h:1.5 Fri Apr 13 01:54:25 2001
--- gnucash/src/gnome/new-user-callbacks.h Thu May 10 11:15:07 2001
***************
*** 80,88 ****
GdkEvent *event,
gpointer user_data);
-
- #endif /* _NEW_USER_CALLBACKS_H_ */
-
void
on_newAccountSelectAllButton_clicked (GtkButton *button,
gpointer user_data);
--- 80,85 ----
***************
*** 108,121 ****
(GtkButton *button,
gpointer user_data);
void
! on_ctree1_select_row (GtkCList *clist,
gint row,
gint column,
GdkEvent *event,
gpointer user_data);
! void
! on_finalAccountDruidPage_prepare (GnomeDruidPage *gnomedruidpage,
! gpointer arg1,
! gpointer user_data);
--- 105,126 ----
(GtkButton *button,
gpointer user_data);
+ void
+ on_finalAccountDruidPage_prepare (GnomeDruidPage *gnomedruidpage,
+ gpointer arg1,
+ gpointer user_data);
+ void
+ on_newAccountsTypeList_ClearAllButton_clicked
+ (GtkButton *button,
+ gpointer user_data);
+
void
! on_finalAccountCTree_select_row (GtkCList *clist,
gint row,
gint column,
GdkEvent *event,
gpointer user_data);
! #endif /* _NEW_USER_CALLBACKS_H_ */
!
!
Index: gnucash/src/gnome/new-user-funs.c
diff -c gnucash/src/gnome/new-user-funs.c:1.4 gnucash/src/gnome/new-user-funs.c:1.5
*** gnucash/src/gnome/new-user-funs.c:1.4 Fri Mar 2 20:14:18 2001
--- gnucash/src/gnome/new-user-funs.c Thu May 10 11:15:07 2001
***************
*** 30,42 ****
--- 30,159 ----
#include "new-user-callbacks.h"
#include "new-user-interface.h"
#include "new-user-funs.h"
+ #include "glade-support.h"
+ #include "gnc-currency-edit.h"
+ #include "gnc-ui-util.h"
+ #include "Group.h"
+ #include "io-example-account.h"
+ #include "Account.h"
+ #include "AccountP.h"
+
#include <guile/gh.h>
static GtkWidget *newUserDialog = NULL;
static GtkWidget *cancelDialog = NULL;
static GtkWidget *accountList = NULL;
+ static Account*
+ clone_account(const Account* from, gnc_commodity *com)
+ {
+ Account *ret;
+
+ ret = xaccCloneAccountSimple(from);
+ ret->currency = com;
+
+ return ret;
+ }
+
+ GNCCommodityEdit *
+ gnc_get_new_user_commodity_editor(void)
+ {
+ static GNCCommodityEdit *cur_editor = NULL;
+ if(!cur_editor)
+ {
+ cur_editor = GNC_COMMODITY_EDIT(gnc_commodity_edit_new());
+ gtk_widget_set_name (GTK_WIDGET(cur_editor),
+ "newAccountCurrencyChooser");
+ gtk_widget_show(GTK_WIDGET(cur_editor));
+ gnc_commodity_edit_set_commodity(cur_editor,
+ gnc_locale_default_currency());
+ }
+ return cur_editor;
+ }
+
+ struct add_group_data_struct
+ {
+ AccountGroup *to;
+ gnc_commodity *com;
+ };
+
+ static gpointer
+ add_groups_for_each(Account *toadd, gpointer data)
+ {
+ struct add_group_data_struct *dadata =
+ (struct add_group_data_struct*)data;
+ Account *foundact;
+
+ foundact = xaccGetAccountFromName(dadata->to, xaccAccountGetName(toadd));
+
+ if(!foundact)
+ {
+ foundact = clone_account(toadd, dadata->com);
+
+ xaccGroupInsertAccount(dadata->to, foundact);
+ }
+
+ {
+ AccountGroup *addgrp = xaccAccountGetChildren(toadd);
+
+ if(xaccGroupGetNumAccounts(addgrp) > 0)
+ {
+ struct add_group_data_struct downdata;
+ downdata.to = xaccAccountGetChildren(foundact);
+ downdata.com = dadata->com;
+ xaccGroupForEachAccount(addgrp, add_groups_for_each,
+ &downdata, FALSE);
+ }
+ }
+ return NULL;
+ }
+
+ static void
+ add_groups_to_with_random_guids(AccountGroup *into, AccountGroup *from,
+ gnc_commodity *com)
+ {
+ struct add_group_data_struct data;
+ data.to = into;
+ data.com = com;
+
+ xaccGroupForEachAccount(from, add_groups_for_each, &data, FALSE);
+ }
+
+
+ AccountGroup*
+ gnc_new_user_merge_groups(GSList *dalist)
+ {
+ GSList *mark;
+ gnc_commodity *com;
+ AccountGroup *ret = xaccMallocAccountGroup();
+
+ com = gnc_commodity_edit_get_commodity(
+ gnc_get_new_user_commodity_editor());
+
+ for(mark = dalist; mark; mark = mark->next)
+ {
+ add_groups_to_with_random_guids(
+ ret, ((GncExampleAccount*)mark->data)->group, com);
+ }
+
+ return ret;
+ }
+
+ GtkWidget*
+ gnc_new_user_get_widget(const char *name)
+ {
+ return lookup_widget(newUserDialog, name);
+ }
+
+ GtkCList*
+ gnc_new_user_get_clist(void)
+ {
+ return GTK_CLIST(gnc_new_user_get_widget("newAccountTypesList"));
+ }
+
+
+ /***********************************************************************/
static int
createit(GtkWidget*(*creator)(), GtkWidget** placetoput)
{
Index: gnucash/src/gnome/new-user-funs.h
diff -c gnucash/src/gnome/new-user-funs.h:1.2 gnucash/src/gnome/new-user-funs.h:1.3
*** gnucash/src/gnome/new-user-funs.h:1.2 Fri Mar 2 20:14:18 2001
--- gnucash/src/gnome/new-user-funs.h Thu May 10 11:15:07 2001
***************
*** 23,28 ****
--- 23,33 ----
#ifndef _NEW_USER_FUNS_H_
#define _NEW_USER_FUNS_H_
+ #include <glib.h>
+
+ #include "gnc-commodity-edit.h"
+ #include "Group.h"
+
int gnc_ui_show_new_user_window(void);
int gnc_ui_delete_new_user_window(void);
***************
*** 31,35 ****
--- 36,45 ----
int gnc_ui_show_nu_account_list(void);
int gnc_ui_delete_nu_account_list(void);
+
+ GtkCList* gnc_new_user_get_clist(void);
+ GtkWidget* gnc_new_user_get_widget(const char *name);
+ AccountGroup* gnc_new_user_merge_groups(GSList *dalist);
+ GNCCommodityEdit * gnc_get_new_user_commodity_editor(void);
#endif /* NEW_USER_FUNS_H */
Index: gnucash/src/gnome/new-user-interface.c
diff -c gnucash/src/gnome/new-user-interface.c:1.8 gnucash/src/gnome/new-user-interface.c:1.9
*** gnucash/src/gnome/new-user-interface.c:1.8 Thu May 3 02:56:47 2001
--- gnucash/src/gnome/new-user-interface.c Thu May 10 11:15:07 2001
***************
*** 46,52 ****
GtkWidget *newAccountTypesList_DescriptionLabel;
GtkWidget *hbox1;
GtkWidget *scrolledwindow2;
! GtkWidget *accountTypesDescription;
GtkWidget *scrolledwindow3;
GtkWidget *viewport1;
GtkWidget *newAccountListTree;
--- 46,52 ----
GtkWidget *newAccountTypesList_DescriptionLabel;
GtkWidget *hbox1;
GtkWidget *scrolledwindow2;
! GtkWidget *newAccountTypesDescription;
GtkWidget *scrolledwindow3;
GtkWidget *viewport1;
GtkWidget *newAccountListTree;
***************
*** 58,67 ****
GdkColor finalAccountDruidPage_logo_bg_color = { 0, 65535, 65535, 65535 };
GdkColor finalAccountDruidPage_title_color = { 0, 65535, 65535, 65535 };
GtkWidget *druid_vbox3;
! GtkWidget *label6;
GtkWidget *hbox4;
GtkWidget *scrolledwindow4;
! GtkWidget *ctree1;
GtkWidget *checkAccountList_AccountNameLabel;
GtkWidget *checkAccountList_TypeLabel;
GtkWidget *checkAccountList_StartBalanceLabel;
--- 58,67 ----
GdkColor finalAccountDruidPage_logo_bg_color = { 0, 65535, 65535, 65535 };
GdkColor finalAccountDruidPage_title_color = { 0, 65535, 65535, 65535 };
GtkWidget *druid_vbox3;
! GtkWidget *finalAccountLabel;
GtkWidget *hbox4;
GtkWidget *scrolledwindow4;
! GtkWidget *finalAccountCTree;
GtkWidget *checkAccountList_AccountNameLabel;
GtkWidget *checkAccountList_TypeLabel;
GtkWidget *checkAccountList_StartBalanceLabel;
***************
*** 80,85 ****
--- 80,86 ----
gtk_object_set_data (GTK_OBJECT (newUserDialog), "newUserDialog", newUserDialog);
gtk_widget_set_usize (newUserDialog, 540, 370);
gtk_window_set_title (GTK_WINDOW (newUserDialog), _("New User Account setup"));
+ gtk_window_set_position (GTK_WINDOW (newUserDialog), GTK_WIN_POS_MOUSE);
gtk_window_set_default_size (GTK_WINDOW (newUserDialog), 640, 480);
accountChooseDruidPage = gnome_druid_new ();
***************
*** 222,236 ****
gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow2, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
! accountTypesDescription = gtk_text_new (NULL, NULL);
! gtk_widget_set_name (accountTypesDescription, "accountTypesDescription");
! gtk_widget_ref (accountTypesDescription);
! gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "accountTypesDescription", accountTypesDescription,
! (GtkDestroyNotify) gtk_widget_unref);
! gtk_widget_show (accountTypesDescription);
! gtk_container_add (GTK_CONTAINER (scrolledwindow2), accountTypesDescription);
! gtk_widget_set_sensitive (accountTypesDescription, FALSE);
! GTK_WIDGET_UNSET_FLAGS (accountTypesDescription, GTK_CAN_FOCUS);
scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_name (scrolledwindow3, "scrolledwindow3");
--- 223,236 ----
gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow2, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
! newAccountTypesDescription = gtk_text_new (NULL, NULL);
! gtk_widget_set_name (newAccountTypesDescription, "newAccountTypesDescription");
! gtk_widget_ref (newAccountTypesDescription);
! gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "newAccountTypesDescription", newAccountTypesDescription,
! (GtkDestroyNotify) gtk_widget_unref);
! gtk_widget_show (newAccountTypesDescription);
! gtk_container_add (GTK_CONTAINER (scrolledwindow2), newAccountTypesDescription);
! GTK_WIDGET_UNSET_FLAGS (newAccountTypesDescription, GTK_CAN_FOCUS);
scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_name (scrolledwindow3, "scrolledwindow3");
***************
*** 256,262 ****
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (newAccountListTree);
gtk_container_add (GTK_CONTAINER (viewport1), newAccountListTree);
- gtk_widget_set_sensitive (newAccountListTree, FALSE);
hbox3 = gtk_hbox_new (FALSE, 0);
gtk_widget_set_name (hbox3, "hbox3");
--- 256,261 ----
***************
*** 301,317 ****
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (druid_vbox3);
! label6 = gtk_label_new (_("If you would like the accounts to have a starting balance click on the account line and enter the starting balance in the text entry box on the right."));
! gtk_widget_set_name (label6, "label6");
! gtk_widget_ref (label6);
! gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "label6", label6,
! (GtkDestroyNotify) gtk_widget_unref);
! gtk_widget_show (label6);
! gtk_box_pack_start (GTK_BOX (druid_vbox3), label6, FALSE, FALSE, 0);
! gtk_label_set_justify (GTK_LABEL (label6), GTK_JUSTIFY_FILL);
! gtk_label_set_line_wrap (GTK_LABEL (label6), TRUE);
! gtk_misc_set_alignment (GTK_MISC (label6), 0.0800003, 0.08);
! gtk_misc_set_padding (GTK_MISC (label6), 1, 1);
hbox4 = gtk_hbox_new (FALSE, 0);
gtk_widget_set_name (hbox4, "hbox4");
--- 300,316 ----
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (druid_vbox3);
! finalAccountLabel = gtk_label_new (_("If you would like the accounts to have a starting balance click on the account line and enter the starting balance in the text entry box on the right."));
! gtk_widget_set_name (finalAccountLabel, "finalAccountLabel");
! gtk_widget_ref (finalAccountLabel);
! gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "finalAccountLabel", finalAccountLabel,
! (GtkDestroyNotify) gtk_widget_unref);
! gtk_widget_show (finalAccountLabel);
! gtk_box_pack_start (GTK_BOX (druid_vbox3), finalAccountLabel, FALSE, FALSE, 0);
! gtk_label_set_justify (GTK_LABEL (finalAccountLabel), GTK_JUSTIFY_FILL);
! gtk_label_set_line_wrap (GTK_LABEL (finalAccountLabel), TRUE);
! gtk_misc_set_alignment (GTK_MISC (finalAccountLabel), 0.0800003, 0.08);
! gtk_misc_set_padding (GTK_MISC (finalAccountLabel), 1, 1);
hbox4 = gtk_hbox_new (FALSE, 0);
gtk_widget_set_name (hbox4, "hbox4");
***************
*** 329,345 ****
gtk_widget_show (scrolledwindow4);
gtk_box_pack_start (GTK_BOX (hbox4), scrolledwindow4, TRUE, TRUE, 0);
! ctree1 = gtk_ctree_new (3, 0);
! gtk_widget_set_name (ctree1, "ctree1");
! gtk_widget_ref (ctree1);
! gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "ctree1", ctree1,
! (GtkDestroyNotify) gtk_widget_unref);
! gtk_widget_show (ctree1);
! gtk_container_add (GTK_CONTAINER (scrolledwindow4), ctree1);
! gtk_clist_set_column_width (GTK_CLIST (ctree1), 0, 285);
! gtk_clist_set_column_width (GTK_CLIST (ctree1), 1, 118);
! gtk_clist_set_column_width (GTK_CLIST (ctree1), 2, 80);
! gtk_clist_column_titles_show (GTK_CLIST (ctree1));
checkAccountList_AccountNameLabel = gtk_label_new (_("Account Name"));
gtk_widget_set_name (checkAccountList_AccountNameLabel, "checkAccountList_AccountNameLabel");
--- 328,344 ----
gtk_widget_show (scrolledwindow4);
gtk_box_pack_start (GTK_BOX (hbox4), scrolledwindow4, TRUE, TRUE, 0);
! finalAccountCTree = gtk_ctree_new (3, 0);
! gtk_widget_set_name (finalAccountCTree, "finalAccountCTree");
! gtk_widget_ref (finalAccountCTree);
! gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "finalAccountCTree", finalAccountCTree,
! (GtkDestroyNotify) gtk_widget_unref);
! gtk_widget_show (finalAccountCTree);
! gtk_container_add (GTK_CONTAINER (scrolledwindow4), finalAccountCTree);
! gtk_clist_set_column_width (GTK_CLIST (finalAccountCTree), 0, 285);
! gtk_clist_set_column_width (GTK_CLIST (finalAccountCTree), 1, 118);
! gtk_clist_set_column_width (GTK_CLIST (finalAccountCTree), 2, 80);
! gtk_clist_column_titles_show (GTK_CLIST (finalAccountCTree));
checkAccountList_AccountNameLabel = gtk_label_new (_("Account Name"));
gtk_widget_set_name (checkAccountList_AccountNameLabel, "checkAccountList_AccountNameLabel");
***************
*** 347,353 ****
gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "checkAccountList_AccountNameLabel", checkAccountList_AccountNameLabel,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkAccountList_AccountNameLabel);
! gtk_clist_set_column_widget (GTK_CLIST (ctree1), 0, checkAccountList_AccountNameLabel);
checkAccountList_TypeLabel = gtk_label_new (_("Type"));
gtk_widget_set_name (checkAccountList_TypeLabel, "checkAccountList_TypeLabel");
--- 346,352 ----
gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "checkAccountList_AccountNameLabel", checkAccountList_AccountNameLabel,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkAccountList_AccountNameLabel);
! gtk_clist_set_column_widget (GTK_CLIST (finalAccountCTree), 0, checkAccountList_AccountNameLabel);
checkAccountList_TypeLabel = gtk_label_new (_("Type"));
gtk_widget_set_name (checkAccountList_TypeLabel, "checkAccountList_TypeLabel");
***************
*** 355,361 ****
gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "checkAccountList_TypeLabel", checkAccountList_TypeLabel,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkAccountList_TypeLabel);
! gtk_clist_set_column_widget (GTK_CLIST (ctree1), 1, checkAccountList_TypeLabel);
checkAccountList_StartBalanceLabel = gtk_label_new (_("Starting Balance"));
gtk_widget_set_name (checkAccountList_StartBalanceLabel, "checkAccountList_StartBalanceLabel");
--- 354,360 ----
gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "checkAccountList_TypeLabel", checkAccountList_TypeLabel,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkAccountList_TypeLabel);
! gtk_clist_set_column_widget (GTK_CLIST (finalAccountCTree), 1, checkAccountList_TypeLabel);
checkAccountList_StartBalanceLabel = gtk_label_new (_("Starting Balance"));
gtk_widget_set_name (checkAccountList_StartBalanceLabel, "checkAccountList_StartBalanceLabel");
***************
*** 363,369 ****
gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "checkAccountList_StartBalanceLabel", checkAccountList_StartBalanceLabel,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkAccountList_StartBalanceLabel);
! gtk_clist_set_column_widget (GTK_CLIST (ctree1), 2, checkAccountList_StartBalanceLabel);
vbox5 = gtk_vbox_new (FALSE, 0);
gtk_widget_set_name (vbox5, "vbox5");
--- 362,368 ----
gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "checkAccountList_StartBalanceLabel", checkAccountList_StartBalanceLabel,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkAccountList_StartBalanceLabel);
! gtk_clist_set_column_widget (GTK_CLIST (finalAccountCTree), 2, checkAccountList_StartBalanceLabel);
vbox5 = gtk_vbox_new (FALSE, 0);
gtk_widget_set_name (vbox5, "vbox5");
***************
*** 435,445 ****
gtk_signal_connect (GTK_OBJECT (newAccountsTypeList_SelectAllButton), "clicked",
GTK_SIGNAL_FUNC (on_newAccountsTypeList_SelectAllButton_clicked),
NULL);
gtk_signal_connect (GTK_OBJECT (finalAccountDruidPage), "prepare",
GTK_SIGNAL_FUNC (on_finalAccountDruidPage_prepare),
NULL);
! gtk_signal_connect (GTK_OBJECT (ctree1), "select_row",
! GTK_SIGNAL_FUNC (on_ctree1_select_row),
NULL);
gtk_signal_connect (GTK_OBJECT (newUserDruidFinishPage), "finish",
GTK_SIGNAL_FUNC (on_newUserDruidFinishPage_finish),
--- 434,447 ----
gtk_signal_connect (GTK_OBJECT (newAccountsTypeList_SelectAllButton), "clicked",
GTK_SIGNAL_FUNC (on_newAccountsTypeList_SelectAllButton_clicked),
NULL);
+ gtk_signal_connect (GTK_OBJECT (newAccountsTypeList_ClearAllButton), "clicked",
+ GTK_SIGNAL_FUNC (on_newAccountsTypeList_ClearAllButton_clicked),
+ NULL);
gtk_signal_connect (GTK_OBJECT (finalAccountDruidPage), "prepare",
GTK_SIGNAL_FUNC (on_finalAccountDruidPage_prepare),
NULL);
! gtk_signal_connect (GTK_OBJECT (finalAccountCTree), "select_row",
! GTK_SIGNAL_FUNC (on_finalAccountCTree_select_row),
NULL);
gtk_signal_connect (GTK_OBJECT (newUserDruidFinishPage), "finish",
GTK_SIGNAL_FUNC (on_newUserDruidFinishPage_finish),
Index: gnucash/src/gnome/new-user.glade
diff -c gnucash/src/gnome/new-user.glade:1.8 gnucash/src/gnome/new-user.glade:1.9
*** gnucash/src/gnome/new-user.glade:1.8 Thu May 3 02:56:47 2001
--- gnucash/src/gnome/new-user.glade Thu May 10 11:15:08 2001
***************
*** 29,35 ****
<height>370</height>
<title>New User Account setup</title>
<type>GTK_WINDOW_TOPLEVEL</type>
! <position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<default_width>640</default_width>
<default_height>480</default_height>
--- 29,35 ----
<height>370</height>
<title>New User Account setup</title>
<type>GTK_WINDOW_TOPLEVEL</type>
! <position>GTK_WIN_POS_MOUSE</position>
<modal>False</modal>
<default_width>640</default_width>
<default_height>480</default_height>
***************
*** 259,266 ****
<widget>
<class>GtkText</class>
! <name>accountTypesDescription</name>
! <sensitive>False</sensitive>
<editable>False</editable>
<text></text>
</widget>
--- 259,265 ----
<widget>
<class>GtkText</class>
! <name>newAccountTypesDescription</name>
<editable>False</editable>
<text></text>
</widget>
***************
*** 287,293 ****
<widget>
<class>GtkTree</class>
<name>newAccountListTree</name>
- <sensitive>False</sensitive>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<view_mode>GTK_TREE_VIEW_LINE</view_mode>
<view_line>True</view_line>
--- 286,291 ----
***************
*** 329,334 ****
--- 327,337 ----
<class>GtkButton</class>
<name>newAccountsTypeList_ClearAllButton</name>
<can_focus>True</can_focus>
+ <signal>
+ <name>clicked</name>
+ <handler>on_newAccountsTypeList_ClearAllButton_clicked</handler>
+ <last_modification_time>Thu, 19 Apr 2001 14:27:32 GMT</last_modification_time>
+ </signal>
<label>Clear All</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
***************
*** 368,374 ****
<widget>
<class>GtkLabel</class>
! <name>label6</name>
<label>If you would like the accounts to have a starting balance click on the account line and enter the starting balance in the text entry box on the right.</label>
<justify>GTK_JUSTIFY_FILL</justify>
<wrap>True</wrap>
--- 371,377 ----
<widget>
<class>GtkLabel</class>
! <name>finalAccountLabel</name>
<label>If you would like the accounts to have a starting balance click on the account line and enter the starting balance in the text entry box on the right.</label>
<justify>GTK_JUSTIFY_FILL</justify>
<wrap>True</wrap>
***************
*** 409,420 ****
<widget>
<class>GtkCTree</class>
! <name>ctree1</name>
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
! <handler>on_ctree1_select_row</handler>
! <last_modification_time>Thu, 12 Apr 2001 22:48:53 GMT</last_modification_time>
</signal>
<columns>3</columns>
<column_widths>285,118,80</column_widths>
--- 412,423 ----
<widget>
<class>GtkCTree</class>
! <name>finalAccountCTree</name>
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
! <handler>on_finalAccountCTree_select_row</handler>
! <last_modification_time>Thu, 19 Apr 2001 17:26:51 GMT</last_modification_time>
</signal>
<columns>3</columns>
<column_widths>285,118,80</column_widths>
Index: gnucash/src/gnome/top-level.c
diff -c gnucash/src/gnome/top-level.c:1.83 gnucash/src/gnome/top-level.c:1.84
*** gnucash/src/gnome/top-level.c:1.83 Tue Apr 24 18:11:07 2001
--- gnucash/src/gnome/top-level.c Thu May 10 17:55:02 2001
***************
*** 123,129 ****
/* ============================================================== */
! int
gnucash_ui_is_running(void)
{
return gnome_is_running;
--- 123,129 ----
/* ============================================================== */
! gboolean
gnucash_ui_is_running(void)
{
return gnome_is_running;
***************
*** 131,137 ****
/* ============================================================== */
! int
gnucash_ui_is_terminating(void)
{
return gnome_is_terminating;
--- 131,137 ----
/* ============================================================== */
! gboolean
gnucash_ui_is_terminating(void)
{
return gnome_is_terminating;
***************
*** 467,477 ****
/* ============================================================== */
! int
gnucash_ui_open_file(const char name[])
{
! gncFileOpenFile(name);
! return 1;
}
/* ============================================================== */
--- 467,476 ----
/* ============================================================== */
! gboolean
gnucash_ui_open_file(const char name[])
{
! return gncFileOpenFile(name);
}
/* ============================================================== */
Index: gnucash/src/gnome/top-level.h
diff -c gnucash/src/gnome/top-level.h:1.4 gnucash/src/gnome/top-level.h:1.5
*** gnucash/src/gnome/top-level.h:1.4 Thu Apr 12 18:03:35 2001
--- gnucash/src/gnome/top-level.h Thu May 10 17:55:03 2001
***************
*** 23,34 ****
#ifndef __TOP_LEVEL_H__
#define __TOP_LEVEL_H__
#include "window-main.h"
! int gnucash_ui_is_running(void);
! int gnucash_ui_is_terminating(void);
int gnucash_ui_init(void);
! int gnucash_ui_open_file(const char * name);
int gnucash_ui_select_file(void);
GNCMainInfo * gnc_ui_get_data(void);
--- 23,36 ----
#ifndef __TOP_LEVEL_H__
#define __TOP_LEVEL_H__
+ #include <glib.h>
+
#include "window-main.h"
! gboolean gnucash_ui_is_running(void);
! gboolean gnucash_ui_is_terminating(void);
int gnucash_ui_init(void);
! gboolean gnucash_ui_open_file(const char * name);
int gnucash_ui_select_file(void);
GNCMainInfo * gnc_ui_get_data(void);
Index: gnucash/src/gnome/window-main.c
diff -c gnucash/src/gnome/window-main.c:1.121 gnucash/src/gnome/window-main.c:1.122
*** gnucash/src/gnome/window-main.c:1.121 Sat May 5 14:39:40 2001
--- gnucash/src/gnome/window-main.c Thu May 10 17:30:39 2001
***************
*** 174,180 ****
}
static void
! gnc_childwin_set_title (GNCMainChildInfo *childwin)
{
GNCBook *book;
const char *filename;
--- 174,180 ----
}
static void
! gnc_main_window_child_set_title (GNCMainChildInfo *childwin)
{
GNCBook *book;
const char *filename;
***************
*** 224,230 ****
childwin = gtk_object_get_user_data (GTK_OBJECT (child));
if (!childwin) return;
! gnc_childwin_set_title (childwin);
}
static void
--- 224,230 ----
childwin = gtk_object_get_user_data (GTK_OBJECT (child));
if (!childwin) return;
! gnc_main_window_child_set_title (childwin);
}
static void
***************
*** 339,345 ****
}
/* set the window title */
! gnc_childwin_set_title (childwin);
/* install menu hints if relevant */
if(mdi->active_child) {
--- 339,345 ----
}
/* set the window title */
! gnc_main_window_child_set_title (childwin);
/* install menu hints if relevant */
if(mdi->active_child) {
***************
*** 400,506 ****
* MDI session restore time
********************************************************************/
- static void
- gfec_create_child_error (const char *error_string)
- {
- g_warning ("error creating mdi child\n\n%s",
- error_string ? error_string : "(null)");
- }
-
GnomeMDIChild *
gnc_main_window_create_child(const gchar * configstring) {
GnomeMDIChild *child;
URLType type;
char * location;
char * label;
- char * url;
- SCM scm;
if (!configstring)
return NULL;
-
- scm = gfec_eval_string(configstring, gfec_create_child_error);
- if (!gh_string_p(scm))
- return NULL;
-
- url = gh_scm2newstr(scm, NULL);
- if (!url)
- return NULL;
! type = gnc_html_parse_url(NULL, url, &location, &label);
g_free(location);
g_free(label);
switch(type) {
case URL_TYPE_REPORT:
! child = gnc_report_window_create_child(url);
break;
case URL_TYPE_ACCTTREE:
! child = gnc_acct_tree_window_create_child(url);
break;
default:
child = NULL;
}
- free (url);
-
return child;
}
/********************************************************************
* gnc_main_window_child_save_func()
- * save a Scheme form that will allow the child to be restored. This
- * is called at MDI session save time.
********************************************************************/
static char *
gnc_main_window_child_save_func(GnomeMDIChild * child, gpointer user_data) {
!
! GNCMainChildInfo * mc = gtk_object_get_user_data(GTK_OBJECT(child));
! SCM save_report = gh_eval_str("gnc:report-generate-restore-forms-complete");
! SCM save_acctree = gh_eval_str("gnc:acct-tree-generate-restore-forms");
! URLType type;
! char * location;
! char * label;
!
! type = gnc_html_parse_url(NULL, child->name, &location, &label);
! g_free(location);
! g_free(label);
!
! switch(type) {
! case URL_TYPE_REPORT: {
! gnc_report_window * win = mc->user_data;
! SCM report = gnc_report_window_get_report(win);
! if(report != SCM_BOOL_F) {
! return gh_scm2newstr(gh_call1(save_report, report), NULL);
! }
! else {
! return NULL;
! }
! break;
! }
!
! case URL_TYPE_ACCTTREE: {
! GNCAcctTreeWin * win = mc->user_data;
! SCM options = gnc_acct_tree_window_get_options(win);
! int options_id = gnc_acct_tree_window_get_id(win);
!
! if(options != SCM_BOOL_F) {
! return gh_scm2newstr(gh_call2(save_acctree, options,
! gh_int2scm(options_id)), NULL);
! }
! else {
! return NULL;
! }
! break;
! }
!
! default:
! return NULL;
! }
}
--- 400,443 ----
* MDI session restore time
********************************************************************/
GnomeMDIChild *
gnc_main_window_create_child(const gchar * configstring) {
GnomeMDIChild *child;
URLType type;
char * location;
char * label;
if (!configstring)
return NULL;
! type = gnc_html_parse_url(NULL, configstring, &location, &label);
g_free(location);
g_free(label);
switch(type) {
case URL_TYPE_REPORT:
! child = gnc_report_window_create_child(configstring);
break;
case URL_TYPE_ACCTTREE:
! child = gnc_acct_tree_window_create_child(configstring);
break;
default:
child = NULL;
}
return child;
}
/********************************************************************
* gnc_main_window_child_save_func()
********************************************************************/
static char *
gnc_main_window_child_save_func(GnomeMDIChild * child, gpointer user_data) {
! return g_strdup(child->name);
}
***************
*** 673,679 ****
/* pesky child_set_name tries to change the window title... set
* it back. */
if((gnc_ui_get_data()->mdi->active_child == child->child) && child->app) {
! gnc_childwin_set_title (child);
}
}
--- 610,616 ----
/* pesky child_set_name tries to change the window title... set
* it back. */
if((gnc_ui_get_data()->mdi->active_child == child->child) && child->app) {
! gnc_main_window_child_set_title (child);
}
}
Index: gnucash/src/gnome/window-report.c
diff -c gnucash/src/gnome/window-report.c:1.43 gnucash/src/gnome/window-report.c:1.44
*** gnucash/src/gnome/window-report.c:1.43 Tue Apr 24 04:12:34 2001
--- gnucash/src/gnome/window-report.c Thu May 10 17:30:40 2001
***************
*** 52,61 ****
GNCMainChildInfo * mc;
GtkWidget * container;
! SCM scm_report;
! SCM name_change_callback_id;
!
! GNCOptionDB * odb; /* used to get callbacks from parameter edit */
SCM edited_reports;
gnc_html * html;
--- 52,70 ----
GNCMainChildInfo * mc;
GtkWidget * container;
! /* the report that's currently being shown. For any option change
! * we need to rerun the report */
! SCM cur_report;
! GNCOptionDB * cur_odb;
! SCM option_change_cb_id;
!
! /* initial_report is special; it's the one that's saved and
! * restored. The name_change_callback only gets called when
! * the initial_report name is changed. */
! SCM initial_report;
! GNCOptionDB * initial_odb;
! SCM name_change_cb_id;
!
SCM edited_reports;
gnc_html * html;
***************
*** 89,97 ****
if(rwin) {
report = rwin->user_data;
! if(report->scm_report != SCM_BOOL_F) {
name = gh_scm2newstr(gh_call1(get_name,
! report->scm_report),
NULL);
}
else {
--- 98,106 ----
if(rwin) {
report = rwin->user_data;
! if(report->initial_report != SCM_BOOL_F) {
name = gh_scm2newstr(gh_call1(get_name,
! report->initial_report),
NULL);
}
else {
***************
*** 303,315 ****
gboolean do_html;
get_export_thunk = gh_eval_str ("gnc:report-export-thunk");
! export_thunk = gh_call1 (get_export_thunk, report->scm_report);
if (gh_procedure_p (export_thunk))
{
SCM result;
! result = gh_call1 (export_thunk, report->scm_report);
if (gh_symbol_p (result))
{
--- 312,324 ----
gboolean do_html;
get_export_thunk = gh_eval_str ("gnc:report-export-thunk");
! export_thunk = gh_call1 (get_export_thunk, report->cur_report);
if (gh_procedure_p (export_thunk))
{
SCM result;
! result = gh_call1 (export_thunk, report->cur_report);
if (gh_symbol_p (result))
{
***************
*** 336,345 ****
static int
gnc_report_window_params_cb(GtkWidget * w, gpointer data) {
gnc_report_window * report = data;
SCM start_editor = gh_eval_str("gnc:report-edit-options");
!
! if(report->scm_report != SCM_BOOL_F) {
! if(gh_call1(start_editor, report->scm_report) == SCM_BOOL_F) {
gnc_warning_dialog("There are no options for this report.");
}
}
--- 345,356 ----
static int
gnc_report_window_params_cb(GtkWidget * w, gpointer data) {
gnc_report_window * report = data;
+ SCM window_type = gh_eval_str("<gnc:report-window*>");
SCM start_editor = gh_eval_str("gnc:report-edit-options");
! SCM window = gw_wcp_assimilate_ptr(report, window_type);
!
! if(report->cur_report != SCM_BOOL_F) {
! if(gh_call1(start_editor, report->cur_report) == SCM_BOOL_F) {
gnc_warning_dialog("There are no options for this report.");
}
}
***************
*** 351,358 ****
gnc_report_window * report = data;
SCM dirty_report = gh_eval_str("gnc:report-set-dirty?!");
! if(report->scm_report != SCM_BOOL_F) {
! gh_call2(dirty_report, report->scm_report, SCM_BOOL_T);
gnc_html_reload(report->html);
}
return TRUE;
--- 362,369 ----
gnc_report_window * report = data;
SCM dirty_report = gh_eval_str("gnc:report-set-dirty?!");
! if(report->cur_report != SCM_BOOL_F) {
! gh_call2(dirty_report, report->cur_report, SCM_BOOL_T);
gnc_html_reload(report->html);
}
return TRUE;
***************
*** 391,396 ****
--- 402,418 ----
gnc_html_reload(win->html);
}
+ static void
+ gnc_report_window_option_change_cb(gpointer data) {
+ gnc_report_window * report = data;
+ SCM dirty_report = gh_eval_str("gnc:report-set-dirty?!");
+
+ if(report->cur_report != SCM_BOOL_F) {
+ /* it's probably already dirty, but make sure */
+ gh_call2(dirty_report, report->cur_report, SCM_BOOL_T);
+ gnc_html_reload(report->html);
+ }
+ }
/********************************************************************
* gnc_report_window_load_cb
***************
*** 406,419 ****
SCM find_report = gh_eval_str("gnc:find-report");
SCM get_options = gh_eval_str("gnc:report-options");
SCM get_editor = gh_eval_str("gnc:report-options-editor");
! SCM show_report = gh_eval_str("gnc:report-register-display");
! SCM unshow_report = gh_eval_str("gnc:report-unregister-display");
! SCM scm_wintype = gh_eval_str("<gnc:report-window*>");
SCM inst_report;
SCM inst_options;
SCM inst_options_ed;
! if(location && (strlen(location) > 3) &&
!strncmp("id=", location, 3)) {
sscanf(location+3, "%d", &report_id);
}
--- 428,439 ----
SCM find_report = gh_eval_str("gnc:find-report");
SCM get_options = gh_eval_str("gnc:report-options");
SCM get_editor = gh_eval_str("gnc:report-options-editor");
! SCM set_needs_save = gh_eval_str("gnc:report-set-needs-save?!");
SCM inst_report;
SCM inst_options;
SCM inst_options_ed;
! if((type == URL_TYPE_REPORT) && location && (strlen(location) > 3) &&
!strncmp("id=", location, 3)) {
sscanf(location+3, "%d", &report_id);
}
***************
*** 428,461 ****
return;
}
! /* unregister ourselves as a "displayer" of the current report */
! if(win->scm_report != SCM_BOOL_F) {
! gh_call2(unshow_report, win->scm_report,
! gw_wcp_assimilate_ptr(win, scm_wintype));
! }
!
! if(win->odb) {
! gnc_option_db_unregister_change_callback_id(win->odb,
! win->name_change_callback_id);
! gnc_option_db_destroy(win->odb);
! }
! win->odb = gnc_option_db_new(gh_call1(get_options, inst_report));
!
! win->name_change_callback_id =
! gnc_option_db_register_change_callback(win->odb,
! gnc_main_window_child_refresh,
! win->mc,
! "General", "Report name");
!
! scm_unprotect_object(win->scm_report);
! win->scm_report = inst_report;
! scm_protect_object(win->scm_report);
!
! if(win->scm_report != SCM_BOOL_F) {
! gh_call2(show_report, win->scm_report,
! gw_wcp_assimilate_ptr(win, scm_wintype));
! }
if(gnc_html_history_forward_p(gnc_html_get_history(win->html))) {
gnc_report_window_set_fwd_button(win, TRUE);
}
--- 448,485 ----
return;
}
! if(win->initial_report == SCM_BOOL_F) {
! scm_unprotect_object(win->initial_report);
! win->initial_report = inst_report;
! scm_protect_object(win->initial_report);
!
! gh_call2(set_needs_save, inst_report, SCM_BOOL_T);
+ win->initial_odb = gnc_option_db_new(gh_call1(get_options, inst_report));
+ win->name_change_cb_id =
+ gnc_option_db_register_change_callback(win->initial_odb,
+ gnc_main_window_child_refresh,
+ win->mc,
+ "General", "Report name");
+ }
+
+ if((win->cur_report != SCM_BOOL_F) && (win->cur_odb != NULL)) {
+ gnc_option_db_unregister_change_callback_id(win->cur_odb,
+ win->option_change_cb_id);
+ gnc_option_db_destroy(win->cur_odb);
+ win->cur_odb = NULL;
+ }
+
+ scm_unprotect_object(win->cur_report);
+ win->cur_report = inst_report;
+ scm_protect_object(win->cur_report);
+
+ win->cur_odb = gnc_option_db_new(gh_call1(get_options, inst_report));
+ win->option_change_cb_id =
+ gnc_option_db_register_change_callback(win->cur_odb,
+ gnc_report_window_option_change_cb,
+ win, NULL, NULL);
+
if(gnc_html_history_forward_p(gnc_html_get_history(win->html))) {
gnc_report_window_set_fwd_button(win, TRUE);
}
***************
*** 541,551 ****
report->mc = mc;
report->html = gnc_html_new();
! report->scm_report = SCM_BOOL_F;
report->edited_reports = SCM_EOL;
! report->name_change_callback_id = SCM_BOOL_F;
! scm_protect_object(report->scm_report);
scm_protect_object(report->edited_reports);
gnc_html_history_set_node_destroy_cb(gnc_html_get_history(report->html),
--- 565,577 ----
report->mc = mc;
report->html = gnc_html_new();
! report->cur_report = SCM_BOOL_F;
! report->initial_report = SCM_BOOL_F;
report->edited_reports = SCM_EOL;
! report->name_change_cb_id = SCM_BOOL_F;
! scm_protect_object(report->cur_report);
! scm_protect_object(report->initial_report);
scm_protect_object(report->edited_reports);
gnc_html_history_set_node_destroy_cb(gnc_html_get_history(report->html),
***************
*** 678,695 ****
void
gnc_report_window_destroy(gnc_report_window * win) {
- SCM scm_wintype = gh_eval_str("<gnc:report-window*>");
- SCM unshow_report = gh_eval_str("gnc:report-unregister-display");
SCM get_editor = gh_eval_str("gnc:report-editor-widget");
SCM set_editor = gh_eval_str("gnc:report-set-editor-widget!");
SCM disp_list;
SCM edited, editor;
- if(win->scm_report != SCM_BOOL_F) {
- gh_call2(unshow_report, win->scm_report,
- gw_wcp_assimilate_ptr(win, scm_wintype));
- }
-
/* close any open editors */
for(edited = scm_list_copy(win->edited_reports); !gh_null_p(edited);
edited = gh_cdr(edited)) {
--- 704,714 ----
***************
*** 700,711 ****
}
}
! if(win->odb) {
! gnc_option_db_unregister_change_callback_id(win->odb,
! win->name_change_callback_id);
! gnc_option_db_destroy(win->odb);
! win->odb = NULL;
}
gnc_html_destroy(win->html);
--- 719,730 ----
}
}
! if(win->initial_odb) {
! gnc_option_db_unregister_change_callback_id(win->initial_odb,
! win->name_change_cb_id);
! gnc_option_db_destroy(win->initial_odb);
! win->initial_odb = NULL;
}
gnc_html_destroy(win->html);
***************
*** 713,719 ****
win->container = NULL;
win->html = NULL;
! scm_unprotect_object(win->scm_report);
scm_unprotect_object(win->edited_reports);
g_free(win);
--- 732,738 ----
win->container = NULL;
win->html = NULL;
! scm_unprotect_object(win->cur_report);
scm_unprotect_object(win->edited_reports);
g_free(win);
***************
*** 731,737 ****
SCM
gnc_report_window_get_report(gnc_report_window * report) {
! return report->scm_report;
}
void
--- 750,756 ----
SCM
gnc_report_window_get_report(gnc_report_window * report) {
! return report->cur_report;
}
void
***************
*** 776,782 ****
GNCOptionWin * win;
GNCOptionDB * db;
SCM scm_options;
! SCM scm_report;
};
--- 795,801 ----
GNCOptionWin * win;
GNCOptionDB * db;
SCM scm_options;
! SCM cur_report;
};
***************
*** 788,794 ****
if(!win) return;
gnc_option_db_commit(win->db);
! gh_call2(dirty_report, win->scm_report, SCM_BOOL_T);
}
static void
--- 807,813 ----
if(!win) return;
gnc_option_db_commit(win->db);
! gh_call2(dirty_report, win->cur_report, SCM_BOOL_T);
}
static void
***************
*** 802,817 ****
gpointer user_data) {
struct report_default_params_data * win = user_data;
SCM set_editor = gh_eval_str("gnc:report-set-editor-widget!");
- SCM get_windows = gh_eval_str("gnc:report-display-list");
- SCM windows;
-
- for(windows = gh_call1(get_windows, win->scm_report);
- !gh_null_p(windows); windows = gh_cdr(windows)) {
- gnc_report_window_remove_edited_report(gw_wcp_get_ptr(gh_car(windows)),
- win->scm_report);
- }
! gh_call2(set_editor, win->scm_report, SCM_BOOL_F);
gnc_option_db_destroy(win->db);
scm_unprotect_object(win->scm_options);
gnc_options_dialog_destroy(win->win);
--- 821,828 ----
gpointer user_data) {
struct report_default_params_data * win = user_data;
SCM set_editor = gh_eval_str("gnc:report-set-editor-widget!");
! gh_call2(set_editor, win->cur_report, SCM_BOOL_F);
gnc_option_db_destroy(win->db);
scm_unprotect_object(win->scm_options);
gnc_options_dialog_destroy(win->win);
***************
*** 823,829 ****
gnc_report_window_default_params_editor(SCM options, SCM report) {
SCM get_editor = gh_eval_str("gnc:report-editor-widget");
SCM set_editor = gh_eval_str("gnc:report-set-editor-widget!");
- SCM ptr_type = gh_eval_str("<gnc:UIWidget>");
SCM ptr;
SCM new_edited;
--- 834,839 ----
***************
*** 838,849 ****
g_new0(struct report_default_params_data, 1);
prm->scm_options = options;
! prm->scm_report = report;
prm->db = gnc_option_db_new(prm->scm_options);
prm->win = gnc_options_dialog_new(TRUE);
scm_protect_object(prm->scm_options);
! scm_protect_object(prm->scm_report);
gnc_build_options_dialog_contents(prm->win, prm->db);
gnc_option_db_clean(prm->db);
--- 848,859 ----
g_new0(struct report_default_params_data, 1);
prm->scm_options = options;
! prm->cur_report = report;
prm->db = gnc_option_db_new(prm->scm_options);
prm->win = gnc_options_dialog_new(TRUE);
scm_protect_object(prm->scm_options);
! scm_protect_object(prm->cur_report);
gnc_build_options_dialog_contents(prm->win, prm->db);
gnc_option_db_clean(prm->db);
Index: gnucash/src/guile/gnc.gwp
diff -c gnucash/src/guile/gnc.gwp:1.93 gnucash/src/guile/gnc.gwp:1.95
*** gnucash/src/guile/gnc.gwp:1.93 Wed May 9 19:12:47 2001
--- gnucash/src/guile/gnc.gwp Thu May 10 17:55:05 2001
***************
*** 544,549 ****
--- 544,550 ----
"#include <window-help.h>\n"
"#include <window-report.h>\n"
"#include <window-main.h>\n"
+ "#include <gnc-html.h>\n"
"#include <dialog-find-transactions.h>\n")))
(let ((nnt (gw:wrap-non-native-type
***************
*** 2120,2126 ****
(gw:wrap-function
mod
'gnc:ui-open-file
! '<gw:int>
"gnucash_ui_open_file"
'(((<gw:m-chars-caller-owned> gw:const) filename))
"Open filename.")
--- 2121,2127 ----
(gw:wrap-function
mod
'gnc:ui-open-file
! '<gw:bool>
"gnucash_ui_open_file"
'(((<gw:m-chars-caller-owned> gw:const) filename))
"Open filename.")
***************
*** 3695,3699 ****
--- 3696,3706 ----
"timespecCanonicalDayTime" '((<gnc:time-pair> tp))
"Convert a timepair on a certain day (localtime) to\
the timepair representing midday on that day")
+
+ (gw:wrap-function
+ mod
+ 'gnc:html-encode-string
+ '<glib:g-chars-caller-owned>
+ "gnc_html_encode_string" '(((<gw:m-chars-caller-owned> gw:const) bookname)))
)
Index: gnucash/src/scm/html-utilities.scm
diff -c gnucash/src/scm/html-utilities.scm:1.36 gnucash/src/scm/html-utilities.scm:1.37
*** gnucash/src/scm/html-utilities.scm:1.36 Thu May 10 03:24:35 2001
--- gnucash/src/scm/html-utilities.scm Thu May 10 17:30:42 2001
***************
*** 73,80 ****
" No such option: " (car l) (cadr l)))))
optionlist)
(let ((id (gnc:make-report reportname options)))
- (gnc:report-add-child-by-id! src-report id)
- (gnc:report-set-parent! (gnc:find-report id) src-report)
(gnc:report-anchor-text id)))
(warn "gnc:make-report-anchor: No such report: " reportname))))
--- 73,78 ----
Index: gnucash/src/scm/main-window.scm
diff -c gnucash/src/scm/main-window.scm:1.4 gnucash/src/scm/main-window.scm:1.6
*** gnucash/src/scm/main-window.scm:1.4 Thu Apr 26 01:33:23 2001
--- gnucash/src/scm/main-window.scm Thu May 10 17:55:07 2001
***************
*** 110,126 ****
(simple-format
#f " \"gnc-acct-tree:id=~S\")" id)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; book open and close hooks for mdi
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (gnc:main-window-book-close-handler book-url)
! (gnc:main-window-save (gnc:get-ui-data) book-url))
(define (gnc:main-window-book-open-handler book-url)
! (gnc:main-window-restore (gnc:get-ui-data) book-url))
(gnc:hook-add-dangler gnc:*book-opened-hook*
gnc:main-window-book-open-handler)
(gnc:hook-add-dangler gnc:*book-closed-hook*
gnc:main-window-book-close-handler)
--- 110,180 ----
(simple-format
#f " \"gnc-acct-tree:id=~S\")" id)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; book open and close hooks for mdi
+ ;;
+ ;; we need to save all the active report and acct tree info during
+ ;; book close.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (gnc:main-window-book-close-handler book-url)
! (let* ((conf-file-name (gnc:html-encode-string book-url))
! (file-dir (build-path (getenv "HOME") ".gnucash" "books"))
! (book-path #f))
! ;; make sure the books directory is there
! (if (not (access? file-dir X_OK)) (mkdir file-dir #o700))
!
! (if conf-file-name
! (let ((book-path (build-path (getenv "HOME") ".gnucash" "books"
! conf-file-name)))
! (with-output-to-port (open-output-file book-path)
! (lambda ()
! (hash-fold
! (lambda (k v p)
! (if (gnc:report-needs-save? v)
! (display
! (gnc:report-generate-restore-forms v))))
! #t *gnc:_reports_*)
!
! (hash-fold
! (lambda (k v p)
! (display (gnc:acct-tree-generate-restore-forms v k)) #t)
! #t gnc:*acct-tree-options*)))))
! (gnc:main-window-save (gnc:get-ui-data) book-url)
!
! (let ((dead-reports '()))
! ;; get a list of the reports we'll be needing to nuke
! (hash-fold
! (lambda (k v p)
! (set! dead-reports (cons k dead-reports)) #t) #t *gnc:_reports_*)
+ ;; actually remove them (if they're being displayed, the
+ ;; window's reference will keep the report alive until the
+ ;; window is destroyed, but find-report will fail)
+ (for-each
+ (lambda (dr)
+ (hash-remove! *gnc:_reports_* dr))
+ dead-reports))))
+
(define (gnc:main-window-book-open-handler book-url)
! (define (try-load file-suffix)
! (let ((file (build-path (getenv "HOME") ".gnucash" "books" file-suffix)))
! ;; make sure the books directory is there
! (if (access? file F_OK)
! (if (not (false-if-exception (primitive-load file)))
! (begin
! (gnc:warn "failure loading " file)
! #f))
! #f)))
! (let ((conf-file-name (gnc:html-encode-string book-url))
! (dead-reports '()))
! (if conf-file-name
! (try-load conf-file-name))
! (gnc:main-window-restore (gnc:get-ui-data) book-url)))
(gnc:hook-add-dangler gnc:*book-opened-hook*
gnc:main-window-book-open-handler)
(gnc:hook-add-dangler gnc:*book-closed-hook*
gnc:main-window-book-close-handler)
+
Index: gnucash/src/scm/main.scm
diff -c gnucash/src/scm/main.scm:1.41 gnucash/src/scm/main.scm:1.43
*** gnucash/src/scm/main.scm:1.41 Fri May 4 03:16:46 2001
--- gnucash/src/scm/main.scm Thu May 10 17:55:08 2001
***************
*** 108,115 ****
(define (gnc:load-account-file)
(let ((file (gnc:account-file-to-load)))
! (if file
! (gnc:ui-open-file file)
(gnc:hook-run-danglers gnc:*book-opened-hook* #f))))
(define (gnc:main)
--- 108,116 ----
(define (gnc:load-account-file)
(let ((file (gnc:account-file-to-load)))
! (if file
! (and (not (gnc:ui-open-file file))
! (gnc:hook-run-danglers gnc:*book-opened-hook* #f))
(gnc:hook-run-danglers gnc:*book-opened-hook* #f))))
(define (gnc:main)
***************
*** 162,170 ****
(gnc:lookup-global-option "__new_user" "first_startup")))
1))
(begin
- (gnc:default-ui-start)
- (gnc:show-main-window)
- (gnc:hook-run-danglers gnc:*book-opened-hook* #f)
(gnc:show-new-user-window)
(gnc:start-ui-event-loop))
(begin
--- 163,168 ----
Index: gnucash/src/scm/options.scm
diff -c gnucash/src/scm/options.scm:1.38 gnucash/src/scm/options.scm:1.39
*** gnucash/src/scm/options.scm:1.38 Thu May 3 03:47:24 2001
--- gnucash/src/scm/options.scm Thu May 10 17:30:42 2001
***************
*** 930,940 ****
(callback))))))))
(if options-changed
! (hash-for-each run-callback callback-hash))
(clear-changes))
!
(define default-section #f)
(define (set-default-section section-name)
(set! default-section section-name))
--- 930,953 ----
(callback))))))))
(if options-changed
! (let ((cblist '()))
! (hash-for-each
! (lambda (k v) (set! cblist (cons (cons k v) cblist)))
! callback-hash)
! (set! cblist (sort cblist
! (lambda (a b)
! (< (car a) (car b)))))
! (for-each
! (lambda (elt) (run-callback (car elt) (cdr elt)))
! cblist)))
(clear-changes))
!
(define default-section #f)
+ (define (touch)
+ (set! options-changed #t)
+ (run-callbacks))
+
(define (set-default-section section-name)
(set! default-section section-name))
***************
*** 950,955 ****
--- 963,969 ----
((for-each) options-for-each)
((for-each-general) options-for-each-general)
((generate-restore-forms) generate-restore-forms)
+ ((touch) touch)
((clear-changes) clear-changes)
((run-callbacks) run-callbacks)
((set-default-section) set-default-section)
***************
*** 985,990 ****
--- 999,1007 ----
(define (gnc:options-clear-changes options)
((options 'clear-changes)))
+
+ (define (gnc:options-touch options)
+ ((options 'touch)))
(define (gnc:options-run-callbacks options)
((options 'run-callbacks)))
Index: gnucash/src/scm/report.scm
diff -c gnucash/src/scm/report.scm:1.46 gnucash/src/scm/report.scm:1.47
*** gnucash/src/scm/report.scm:1.46 Mon Apr 30 02:32:02 2001
--- gnucash/src/scm/report.scm Thu May 10 17:30:43 2001
***************
*** 129,135 ****
(define <report-template>
(make-record-type "<report-template>"
;; The data items in a report record
! '(version name options-generator options-editor
renderer in-menu? menu-path menu-name
menu-tip export-thunk)))
--- 129,137 ----
(define <report-template>
(make-record-type "<report-template>"
;; The data items in a report record
! '(version name
! options-generator options-editor
! options-cleanup-cb options-changed-cb
renderer in-menu? menu-path menu-name
menu-tip export-thunk)))
***************
*** 147,152 ****
--- 149,156 ----
#f ;; name
#f ;; options-generator
gnc:default-options-editor ;; options-editor
+ #f ;; options-cleanup-cb
+ #f ;; options-changed-cb
#f ;; renderer
#t ;; in-menu?
#f ;; menu-path
***************
*** 182,187 ****
--- 186,195 ----
(record-accessor <report-template> 'options-generator))
(define gnc:report-template-options-editor
(record-accessor <report-template> 'options-editor))
+ (define gnc:report-template-options-cleanup-cb
+ (record-accessor <report-template> 'options-cleanup-cb))
+ (define gnc:report-template-options-changed-cb
+ (record-accessor <report-template> 'options-changed-cb))
(define gnc:report-template-renderer
(record-accessor <report-template> 'renderer))
(define gnc:report-template-in-menu?
***************
*** 234,241 ****
(define <report>
(make-record-type "<report>"
! '(type id options parent children
! dirty? display-list editor-widget ctext)))
(define gnc:report-type
(record-accessor <report> 'type))
--- 242,248 ----
(define <report>
(make-record-type "<report>"
! '(type id options dirty? needs-save? editor-widget ctext)))
(define gnc:report-type
(record-accessor <report> 'type))
***************
*** 255,309 ****
(define gnc:report-set-options!
(record-modifier <report> 'options))
! (define gnc:report-children
! (record-accessor <report> 'children))
! (define gnc:report-set-parent-by-id!
! (record-modifier <report> 'parent))
- (define (gnc:report-set-parent! report parent)
- (gnc:report-set-parent-by-id! report (gnc:report-id parent)))
-
- (define gnc:report-parent
- (record-accessor <report> 'parent))
-
- (define gnc:report-set-children!
- (record-modifier <report> 'children))
-
- (define (gnc:report-add-child! report child)
- (gnc:report-set-children!
- report (cons (gnc:report-id child) (gnc:report-children report))))
-
- (define (gnc:report-add-child-by-id! report child)
- (gnc:report-set-children!
- report (cons child (gnc:report-children report))))
-
(define gnc:report-dirty?
(record-accessor <report> 'dirty?))
! (define gnc:report-set-dirty?-internal!
(record-modifier <report> 'dirty?))
- (define (gnc:report-set-dirty?! report val)
- (gnc:report-set-dirty?-internal! report val)
- (if val
- (begin
- (if (gnc:report-parent report)
- (gnc:report-set-dirty?!
- (gnc:find-report (gnc:report-parent report)) val))
-
- ;; reload the window
- (for-each
- (lambda (win)
- (gnc:report-window-reload win))
- (gnc:report-display-list report)))))
-
- (define gnc:report-display-list
- (record-accessor <report> 'display-list))
-
- (define gnc:report-set-display-list!
- (record-modifier <report> 'display-list))
-
(define gnc:report-editor-widget
(record-accessor <report> 'editor-widget))
--- 262,279 ----
(define gnc:report-set-options!
(record-modifier <report> 'options))
! (define gnc:report-needs-save?
! (record-accessor <report> 'needs-save?))
! (define gnc:report-set-needs-save?!
! (record-modifier <report> 'needs-save?))
(define gnc:report-dirty?
(record-accessor <report> 'dirty?))
! (define gnc:report-set-dirty?!
(record-modifier <report> 'dirty?))
(define gnc:report-editor-widget
(record-accessor <report> 'editor-widget))
***************
*** 316,355 ****
(define gnc:report-set-ctext!
(record-modifier <report> 'ctext))
- (define (gnc:report-register-display report window)
- (if (and window report
- (not (member window (gnc:report-display-list report))))
- (begin
- (gnc:report-set-display-list!
- report
- (cons window (gnc:report-display-list report)))
- (for-each
- (lambda (rep)
- (gnc:report-register-display (gnc:find-report rep) window))
- (gnc:report-children report))
-
- (let ((parent (gnc:find-report (gnc:report-parent report))))
- (if parent
- (gnc:report-register-display parent window))))))
-
- (define (gnc:report-unregister-display report window)
- (if (and report window
- (member window (gnc:report-display-list report)))
- (begin
- (gnc:report-set-display-list!
- report
- (delete window (gnc:report-display-list report)))
- (for-each
- (lambda (rep)
- (gnc:report-unregister-display (gnc:find-report rep) window))
- (gnc:report-children report))
- (let ((parent (gnc:find-report (gnc:report-parent report))))
- (if parent
- (gnc:report-unregister-display parent window))))))
-
(define (gnc:report-edit-options report)
! (let* ((editor-widg (gnc:report-editor-widget report))
! (displist (gnc:report-display-list report)))
(if editor-widg
(gnc:report-raise-editor report)
(begin
--- 286,293 ----
(define gnc:report-set-ctext!
(record-modifier <report> 'ctext))
(define (gnc:report-edit-options report)
! (let* ((editor-widg (gnc:report-editor-widget report)))
(if editor-widg
(gnc:report-raise-editor report)
(begin
***************
*** 359,382 ****
((gnc:report-options-editor report)
(gnc:report-options report)
report))
! (gnc:report-set-editor-widget! report editor-widg)
! (if (and editor-widg (not (null? displist)))
! (for-each
! (lambda (repwin)
! (gnc:report-window-add-edited-report repwin report))
! displist)))
(gnc:warning-dialog "This report has no options."))))))
-
(define (gnc:make-report template-name . rest)
(let ((r ((record-constructor <report>)
template-name ;; type
#f ;; id
#f ;; options
- #f ;; parent
- '() ;; children
#t ;; dirty
! '() ;; display-list
#f ;; editor-widget
#f ;; ctext
))
--- 297,312 ----
((gnc:report-options-editor report)
(gnc:report-options report)
report))
! (gnc:report-set-editor-widget! report editor-widg))
(gnc:warning-dialog "This report has no options."))))))
(define (gnc:make-report template-name . rest)
(let ((r ((record-constructor <report>)
template-name ;; type
#f ;; id
#f ;; options
#t ;; dirty
! #f ;; needs-save
#f ;; editor-widget
#f ;; ctext
))
***************
*** 388,401 ****
(if (not (null? rest))
(car rest)
(gnc:report-template-new-options template))))
! (gnc:report-set-options! r options))
!
(hash-set! *gnc:_reports_* (gnc:report-id r) r)
id))
! (define (gnc:restore-report id template-name parent children options)
(let ((r ((record-constructor <report>)
! template-name id options parent children #t '() #f #f)))
(if (>= id *gnc:_report-next-serial_*)
(set! *gnc:_report-next-serial_* (+ id 1)))
(hash-set! *gnc:_reports_* id r)))
--- 318,339 ----
(if (not (null? rest))
(car rest)
(gnc:report-template-new-options template))))
! (gnc:report-set-options! r options)
! (gnc:options-register-callback
! #f #f
! (lambda ()
! (gnc:report-set-dirty?! r #t)
! (let ((cb (gnc:report-template-options-changed-cb template)))
! (if cb
! (cb r))))
! options))
!
(hash-set! *gnc:_reports_* (gnc:report-id r) r)
id))
! (define (gnc:restore-report id template-name options)
(let ((r ((record-constructor <report>)
! template-name id options #t #t #f #f)))
(if (>= id *gnc:_report-next-serial_*)
(set! *gnc:_report-next-serial_* (+ id 1)))
(hash-set! *gnc:_reports_* id r)))
***************
*** 464,497 ****
(define (gnc:find-report id)
(hash-ref *gnc:_reports_* id))
- (define (gnc:report-generate-restore-forms-complete report)
- (define (find-root r)
- (let* ((pid (gnc:report-parent r))
- (p (if pid (gnc:find-report pid) #f)))
- (if (not p) r (find-root p))))
-
- (define (generate-forms/children r)
- (apply
- string-append
- (gnc:report-generate-restore-forms r)
- (map
- (lambda (c)
- (let ((child (gnc:find-report c)))
- (generate-forms/children child)))
- (gnc:report-children r))))
-
- (let ((toplevel (find-root report)))
- (string-append
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
- (simple-format #f ";; options for report ~A and all parents/children \n"
- (gnc:report-name report))
- "(let () \n"
- (generate-forms/children toplevel)
- (simple-format
- #f " \"gnc-report:id=~S\"" (gnc:report-id report))
- ")\n")))
-
(define (gnc:report-generate-restore-forms report)
(string-append
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
(simple-format #f ";; options for report ~S\n" (gnc:report-name report))
--- 402,418 ----
(define (gnc:find-report id)
(hash-ref *gnc:_reports_* id))
(define (gnc:report-generate-restore-forms report)
+ ;; clean up the options if necessary. this is only needed
+ ;; in special cases.
+ (let* ((template
+ (hash-ref *gnc:_report-templates_*
+ (gnc:report-type report)))
+ (thunk (gnc:report-template-options-cleanup-cb template)))
+ (if thunk
+ (thunk report)))
+
+ ;; save them
(string-append
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
(simple-format #f ";; options for report ~S\n" (gnc:report-name report))
***************
*** 500,509 ****
(gnc:report-type report))
(gnc:generate-restore-forms (gnc:report-options report) "options")
(simple-format
! #f " (gnc:restore-report ~S ~S ~S '~S options))\n"
! (gnc:report-id report) (gnc:report-type report)
! (gnc:report-parent report)
! (gnc:report-children report))))
(define (gnc:backtrace-if-exception proc . args)
(define (dumper key . args)
--- 421,428 ----
(gnc:report-type report))
(gnc:generate-restore-forms (gnc:report-options report) "options")
(simple-format
! #f " (gnc:restore-report ~S ~S options))\n"
! (gnc:report-id report) (gnc:report-type report))))
(define (gnc:backtrace-if-exception proc . args)
(define (dumper key . args)
***************
*** 553,561 ****
(if report
(begin
(set! html (gnc:report-render-html report #t))
! (display "total time to run report: ")
! (display (gnc:time-elapsed start-time (gettimeofday)))
! (newline)
;; (display html) (newline)
html)
#f)))))
--- 472,480 ----
(if report
(begin
(set! html (gnc:report-render-html report #t))
! ;; (display "total time to run report: ")
! ;; (display (gnc:time-elapsed start-time (gettimeofday)))
! ;; (newline)
;; (display html) (newline)
html)
#f)))))
Index: gnucash/src/scm/report/account-piecharts.scm
diff -c gnucash/src/scm/report/account-piecharts.scm:1.16 gnucash/src/scm/report/account-piecharts.scm:1.18
*** gnucash/src/scm/report/account-piecharts.scm:1.16 Wed May 2 15:14:19 2001
--- gnucash/src/scm/report/account-piecharts.scm Fri May 11 00:40:11 2001
***************
*** 281,289 ****
optname-accounts)
(map cadr finish))
(set! id (gnc:make-report reportname options))
- (gnc:report-add-child-by-id! report-obj id)
- (gnc:report-set-parent! (gnc:find-report id) report-obj)
-
;; set the URL.
(set! other-anchor (gnc:report-anchor-text id)))))
--- 281,286 ----
***************
*** 324,354 ****
(gnc:html-piechart-set-button-1-legend-urls!
chart urls))
- (gnc:html-piechart-set-title!
- chart report-title)
- (gnc:html-piechart-set-width! chart width)
- (gnc:html-piechart-set-height! chart height)
- (gnc:html-piechart-set-data! chart (unzip1 combined))
- (gnc:html-piechart-set-colors! chart
- (gnc:assign-colors (length combined)))
! (gnc:html-piechart-set-subtitle!
! chart (string-append
! (if do-intervals?
! (sprintf #f
! (_ "%s to %s")
! (gnc:timepair-to-datestring from-date-tp)
! (gnc:timepair-to-datestring to-date-tp))
! (sprintf #f
! (_ "Balance at %s")
! (gnc:timepair-to-datestring to-date-tp)))
! (if show-total?
! (let ((total (apply + (unzip1 combined))))
! (sprintf #f ": %s"
! (gnc:amount->string total print-info)))
!
! "")))
!
(let ((legend-labels
(map
(lambda (pair)
--- 321,355 ----
(gnc:html-piechart-set-button-1-legend-urls!
chart urls))
! (if
! (not (null? combined))
! (begin
! (gnc:html-piechart-set-title!
! chart report-title)
! (gnc:html-piechart-set-width! chart width)
! (gnc:html-piechart-set-height! chart height)
! (gnc:html-piechart-set-data! chart (unzip1 combined))
! (gnc:html-piechart-set-colors! chart
! (gnc:assign-colors (length combined)))
!
! (gnc:html-piechart-set-subtitle!
! chart (string-append
! (if do-intervals?
! (sprintf #f
! (_ "%s to %s")
! (gnc:timepair-to-datestring from-date-tp)
! (gnc:timepair-to-datestring to-date-tp))
! (sprintf #f
! (_ "Balance at %s")
! (gnc:timepair-to-datestring to-date-tp)))
! (if show-total?
! (let ((total (apply + (unzip1 combined))))
! (sprintf #f ": %s"
! (gnc:amount->string total print-info)))
!
! "")))
!
(let ((legend-labels
(map
(lambda (pair)
***************
*** 384,389 ****
--- 385,394 ----
(gnc:html-markup-p "Remove this text by disabling \
the global Preference \"Display Tip of the Day\".")))))
+ (gnc:html-document-add-object!
+ document
+ (gnc:html-make-empty-data-warning))))
+
(gnc:html-document-add-object!
document
(gnc:html-make-no-account-warning)))
Index: gnucash/src/scm/report/category-barchart.scm
diff -c gnucash/src/scm/report/category-barchart.scm:1.23 gnucash/src/scm/report/category-barchart.scm:1.24
*** gnucash/src/scm/report/category-barchart.scm:1.23 Wed May 9 03:27:07 2001
--- gnucash/src/scm/report/category-barchart.scm Thu May 10 17:30:44 2001
***************
*** 367,374 ****
(map car finish))
;; Set the URL to point to this report.
(set! id (gnc:make-report reportname options))
- (gnc:report-add-child-by-id! report-obj id)
- (gnc:report-set-parent! (gnc:find-report id) report-obj)
(set! other-anchor (gnc:report-anchor-text id)))))
--- 367,372 ----
Index: gnucash/src/scm/report/view-column.scm
diff -c gnucash/src/scm/report/view-column.scm:1.6 gnucash/src/scm/report/view-column.scm:1.7
*** gnucash/src/scm/report/view-column.scm:1.6 Thu Apr 19 17:47:52 2001
--- gnucash/src/scm/report/view-column.scm Thu May 10 17:30:45 2001
***************
*** 51,62 ****
(define (edit-options option-obj report-obj)
(gnc:column-view-edit-options option-obj report-obj))
(define (render-view report)
(let* ((view-doc (gnc:make-html-document))
(options (gnc:report-options report))
! (reports
! (gnc:option-value
! (gnc:lookup-option options "__general" "report-list")))
(table-width
(gnc:option-value
(gnc:lookup-option
--- 51,73 ----
(define (edit-options option-obj report-obj)
(gnc:column-view-edit-options option-obj report-obj))
+ (define (make-child-options-callback view child)
+ (let* ((view-opts (gnc:report-options view))
+ (child-opts (gnc:report-options child))
+ (id
+ (gnc:options-register-callback
+ #f #f
+ (lambda ()
+ (gnc:report-set-dirty?! child #t)
+ (gnc:options-touch view-opts))
+ child-opts)))
+ id))
+
(define (render-view report)
(let* ((view-doc (gnc:make-html-document))
(options (gnc:report-options report))
! (report-opt (gnc:lookup-option options "__general" "report-list"))
! (reports (gnc:option-value report-opt))
(table-width
(gnc:option-value
(gnc:lookup-option
***************
*** 67,72 ****
--- 78,103 ----
(current-width 0)
(current-row-num 0))
+ ;; make sure each subreport has an option change callback that
+ ;; pings the parent
+ (let ((new-reports '()))
+ (for-each
+ (lambda (report-info)
+ (let ((child (car report-info))
+ (rowspan (cadr report-info))
+ (colspan (caddr report-info))
+ (callback (cadddr report-info)))
+ (if (not callback)
+ (begin
+ (set! callback
+ (make-child-options-callback
+ report (gnc:find-report child)))
+ (set! report-info
+ (list child rowspan colspan callback))))
+ (set! new-reports (cons report-info new-reports))))
+ reports)
+ (gnc:option-set-value report-opt (reverse new-reports)))
+
;; we really would rather do something smart here with the
;; report's cached text if possible. For the moment, we'll have
;; to rerun every report, every time... FIXME
***************
*** 82,87 ****
--- 113,119 ----
(let* ((subreport (gnc:find-report (car report-info)))
(colspan (cadr report-info))
(rowspan (caddr report-info))
+ (opt-callback (cadddr report-info))
(toplevel-cell (gnc:make-html-table-cell/size rowspan colspan))
(report-table (gnc:make-html-table))
(contents-cell (gnc:make-html-table-cell)))
***************
*** 153,163 ****
(gnc:html-document-add-object! view-doc column-tab)
;; and we're done.
view-doc))
!
;; define the view now.
(gnc:define-report
'version 1
'name (N_ "Multicolumn View")
'renderer render-view
'options-generator make-options
! 'options-editor edit-options))
--- 185,225 ----
(gnc:html-document-add-object! view-doc column-tab)
;; and we're done.
view-doc))
!
! (define (options-changed-cb report)
! (let* ((options (gnc:report-options report))
! (reports
! (gnc:option-value
! (gnc:lookup-option options "__general" "report-list"))))
! (simple-format #t "view options changed cb\n")
! (for-each
! (lambda (child)
! (gnc:report-set-dirty?! (gnc:find-report (car child)) #t))
! reports)))
!
! (define (cleanup-options report)
! (let* ((options (gnc:report-options report))
! (report-opt (gnc:lookup-option options "__general" "report-list"))
! (reports (gnc:option-value report-opt))
! (new-reports '()))
! (for-each
! (lambda (report-info)
! (let ((rep (car report-info))
! (rowspan (cadr report-info))
! (colspan (caddr report-info)))
! (set! report-info
! (list rep rowspan colspan #f))
! (set! new-reports (cons report-info new-reports))))
! reports)
! (gnc:option-set-value report-opt (reverse new-reports))))
!
;; define the view now.
(gnc:define-report
'version 1
'name (N_ "Multicolumn View")
'renderer render-view
'options-generator make-options
! 'options-editor edit-options
! 'options-cleanup-cb cleanup-options
! 'options-changed-cb options-changed-cb))
!
Index: gnucash/src/scm/report/welcome-to-gnucash.scm
diff -c gnucash/src/scm/report/welcome-to-gnucash.scm:1.2 gnucash/src/scm/report/welcome-to-gnucash.scm:1.3
*** gnucash/src/scm/report/welcome-to-gnucash.scm:1.2 Tue Apr 24 18:11:15 2001
--- gnucash/src/scm/report/welcome-to-gnucash.scm Thu May 10 17:30:45 2001
***************
*** 36,58 ****
(gnc:option-set-value
(gnc:lookup-option options section name) value))
- (for-each
- (lambda (child)
- (gnc:report-add-child! (gnc:find-report view)
- (gnc:find-report child))
- (gnc:report-set-parent! (gnc:find-report child)
- (gnc:find-report view)))
- (list sub-welcome sub-accounts sub-expense-pie sub-income-pie sub-bar))
-
(set! options (gnc:report-options (gnc:find-report view)))
(set-option! "General" "Report name" "Welcome to GnuCash 1.6")
(set-option! "General" "Number of columns" 2)
(set-option! "__general" "report-list"
! (list (list sub-welcome 1 1)
! (list sub-accounts 1 1)
! (list sub-expense-pie 1 1)
! (list sub-income-pie 1 1)
! (list sub-bar 2 1)))
(set! options (gnc:report-options (gnc:find-report sub-expense-pie)))
(set-option! "Display" "Plot Width" 400)
--- 36,50 ----
(gnc:option-set-value
(gnc:lookup-option options section name) value))
(set! options (gnc:report-options (gnc:find-report view)))
(set-option! "General" "Report name" "Welcome to GnuCash 1.6")
(set-option! "General" "Number of columns" 2)
(set-option! "__general" "report-list"
! (list (list sub-welcome 1 1 #f)
! (list sub-accounts 1 1 #f)
! (list sub-expense-pie 1 1 #f)
! (list sub-income-pie 1 1 #f)
! (list sub-bar 2 1 #f)))
(set! options (gnc:report-options (gnc:find-report sub-expense-pie)))
(set-option! "Display" "Plot Width" 400)