mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2001-04-24 Bill Gribble <grib@billgribble.com>
* src/FileDialog.c: call book-opened-hook and book-closed-hook where appropriate * src/gnome/dialog-column-view.c: change to single-parent model * src/gnome/top-level.c: don't do MID state saving and restoring here... do it in the book save/load hooks. * src/gnome/window-main.c: the configstring stored in MDI is now a Scheme form which restores the window state. save/restore it. Also, change the MDI session name to encode the book URL (have to encode it to escape some chars, notably /, which MDI doesn't like in section names) * src/scm/main-window.scm: new file. get the main-window save/restore functions out of prefs.scm * src/scm/report/scm: only one parent per report; write save routines to save all parents and children. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4039 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
22
ChangeLog
22
ChangeLog
@@ -1,3 +1,25 @@
|
||||
2001-04-24 Bill Gribble <grib@billgribble.com>
|
||||
|
||||
* src/FileDialog.c: call book-opened-hook and book-closed-hook
|
||||
where appropriate
|
||||
|
||||
* src/gnome/dialog-column-view.c: change to single-parent model
|
||||
|
||||
* src/gnome/top-level.c: don't do MID state saving and restoring
|
||||
here... do it in the book save/load hooks.
|
||||
|
||||
* src/gnome/window-main.c: the configstring stored in MDI is now a
|
||||
Scheme form which restores the window state. save/restore it.
|
||||
Also, change the MDI session name to encode the book URL
|
||||
(have to encode it to escape some chars, notably /, which MDI
|
||||
doesn't like in section names)
|
||||
|
||||
* src/scm/main-window.scm: new file. get the main-window
|
||||
save/restore functions out of prefs.scm
|
||||
|
||||
* src/scm/report/scm: only one parent per report; write save
|
||||
routines to save all parents and children.
|
||||
|
||||
2001-04-24 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/gnome/window-register.c: add additional warnings when
|
||||
|
||||
@@ -227,6 +227,10 @@ gncFileNew (void)
|
||||
* disable events so we don't get spammed by redraws. */
|
||||
gnc_engine_suspend_events ();
|
||||
|
||||
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
||||
gh_eval_str("gnc:*book-closed-hook*"),
|
||||
gh_str02scm(gnc_book_get_url(book)));
|
||||
|
||||
gnc_book_destroy (book);
|
||||
current_book = NULL;
|
||||
|
||||
@@ -235,6 +239,10 @@ gncFileNew (void)
|
||||
/* start a new book */
|
||||
gncGetCurrentBook ();
|
||||
|
||||
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
||||
gh_eval_str("gnc:*book-opened-hook*"),
|
||||
gh_str02scm(gnc_book_get_url(current_book)));
|
||||
|
||||
gnc_engine_resume_events ();
|
||||
gnc_gui_refresh_all ();
|
||||
}
|
||||
@@ -302,6 +310,10 @@ gncPostFileOpen (const char * filename)
|
||||
|
||||
/* -------------- BEGIN CORE SESSION CODE ------------- */
|
||||
/* -- this code is almost identical in FileOpen and FileSaveAs -- */
|
||||
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;
|
||||
|
||||
@@ -354,7 +366,7 @@ gncPostFileOpen (const char * filename)
|
||||
|
||||
new_group = gnc_book_get_group (new_book);
|
||||
if (uh_oh) new_group = NULL;
|
||||
|
||||
|
||||
/* Umm, came up empty-handed, but no error:
|
||||
* The backend forgot to set an error. So make one up. */
|
||||
if (!uh_oh && !new_group)
|
||||
@@ -389,20 +401,16 @@ gncPostFileOpen (const char * filename)
|
||||
/* 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. */
|
||||
gncAddHistory (new_book);
|
||||
|
||||
/* run a file-opened hook. For now, the main thing it will do
|
||||
* is notice if legacy currencies are being imported. */
|
||||
if (newfile)
|
||||
{
|
||||
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
||||
gh_eval_str("gnc:*file-opened-hook*"),
|
||||
gh_str02scm(newfile));
|
||||
}
|
||||
g_free (newfile);
|
||||
|
||||
gnc_engine_resume_events ();
|
||||
@@ -620,6 +628,10 @@ gncFileQuit (void)
|
||||
* transactions during shutdown would cause massive redraws */
|
||||
gnc_engine_suspend_events ();
|
||||
|
||||
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
||||
gh_eval_str("gnc:*book-closed-hook*"),
|
||||
gh_str02scm(gnc_book_get_url(book)));
|
||||
|
||||
gnc_book_destroy (book);
|
||||
current_book = NULL;
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) {
|
||||
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 add_parent = gh_eval_str("gnc:report-add-parent!");
|
||||
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;
|
||||
@@ -246,7 +246,7 @@ gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) {
|
||||
gh_int2scm(r->available_selected));
|
||||
new_report = gh_call1(make_report, template_name);
|
||||
gh_call2(add_child, r->view, new_report);
|
||||
gh_call2(add_parent, gh_call1(find_report, new_report), r->view);
|
||||
gh_call2(set_parent, gh_call1(find_report, new_report), r->view);
|
||||
|
||||
oldlength = gh_length(r->contents_list);
|
||||
|
||||
|
||||
@@ -336,13 +336,8 @@ static gboolean hasstarted = FALSE;
|
||||
void
|
||||
gnc_default_ui_start(void) {
|
||||
if(!hasstarted) {
|
||||
if(!gnome_mdi_restore_state(app->mdi, "/GnuCash/MDI Session",
|
||||
gnc_main_window_create_child) ||
|
||||
app->children == NULL) {
|
||||
gnc_main_window_open_accounts(FALSE);
|
||||
gh_eval_str("(gnc:make-welcome-report)");
|
||||
}
|
||||
hasstarted = TRUE;
|
||||
gncGetCurrentBook();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +349,7 @@ gnc_ui_shutdown (void)
|
||||
if (gnome_is_running && !gnome_is_terminating)
|
||||
{
|
||||
gnome_is_terminating = TRUE;
|
||||
gnc_main_window_save(app);
|
||||
/* gnc_main_window_save(app); */
|
||||
gnc_main_window_destroy(app);
|
||||
app = NULL;
|
||||
gtk_main_quit();
|
||||
|
||||
@@ -203,10 +203,10 @@ gnc_acct_tree_view_new(GnomeMDIChild * child, gpointer user_data) {
|
||||
********************************************************************/
|
||||
|
||||
GnomeMDIChild *
|
||||
gnc_acct_tree_window_create_child(const gchar * configstring) {
|
||||
gnc_acct_tree_window_create_child(const gchar * url) {
|
||||
GNCMainInfo * maininfo = gnc_ui_get_data();
|
||||
GnomeMDIGenericChild * accountchild =
|
||||
gnome_mdi_generic_child_new(configstring);
|
||||
gnome_mdi_generic_child_new(url);
|
||||
|
||||
gnome_mdi_generic_child_set_label_func(accountchild,
|
||||
gnc_acct_tree_view_labeler,
|
||||
@@ -1048,6 +1048,15 @@ gnc_acct_tree_window_get_widget(GNCAcctTreeWin * win) {
|
||||
return win->account_tree;
|
||||
}
|
||||
|
||||
SCM
|
||||
gnc_acct_tree_window_get_options(GNCAcctTreeWin * w) {
|
||||
return w->options;
|
||||
}
|
||||
|
||||
int
|
||||
gnc_acct_tree_window_get_id(GNCAcctTreeWin * w) {
|
||||
return w->options_id;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* parameter editor handling
|
||||
|
||||
@@ -37,5 +37,7 @@ void gnc_acct_tree_window_create_toolbar(GNCAcctTreeWin * win,
|
||||
GNCMainChildInfo * child);
|
||||
Account * gnc_acct_tree_window_get_current_account(GNCAcctTreeWin * w);
|
||||
GnomeMDIChild * gnc_acct_tree_window_create_child(const gchar * url);
|
||||
void gnc_main_window_open_accounts(gint toplevel);
|
||||
void gnc_main_window_open_accounts(gint toplevel);
|
||||
SCM gnc_acct_tree_window_get_options(GNCAcctTreeWin * win);
|
||||
int gnc_acct_tree_window_get_id(GNCAcctTreeWin * win);
|
||||
#endif
|
||||
|
||||
@@ -129,8 +129,9 @@ gnc_main_window_app_created_cb(GnomeMDI * mdi, GnomeApp * app,
|
||||
*/
|
||||
|
||||
GtkWidget *item;
|
||||
item = gnome_dock_item_new( "Summary Bar",
|
||||
GNOME_DOCK_ITEM_BEH_EXCLUSIVE|GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL);
|
||||
item = gnome_dock_item_new("Summary Bar",
|
||||
GNOME_DOCK_ITEM_BEH_EXCLUSIVE |
|
||||
GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL);
|
||||
gtk_container_add( GTK_CONTAINER (item), summarybar );
|
||||
|
||||
if( app->layout )
|
||||
@@ -392,18 +393,21 @@ gnc_main_window_create_child(const gchar * configstring) {
|
||||
URLType type;
|
||||
char * location;
|
||||
char * label;
|
||||
|
||||
type = gnc_html_parse_url(NULL, configstring, &location, &label);
|
||||
char * url;
|
||||
|
||||
url = gh_scm2newstr(gh_eval_str(configstring), NULL);
|
||||
|
||||
type = gnc_html_parse_url(NULL, url, &location, &label);
|
||||
g_free(location);
|
||||
g_free(label);
|
||||
|
||||
switch(type) {
|
||||
case URL_TYPE_REPORT:
|
||||
return gnc_report_window_create_child(configstring);
|
||||
return gnc_report_window_create_child(url);
|
||||
break;
|
||||
|
||||
case URL_TYPE_ACCTTREE:
|
||||
return gnc_acct_tree_window_create_child(configstring);
|
||||
return gnc_acct_tree_window_create_child(url);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -412,6 +416,105 @@ gnc_main_window_create_child(const gchar * configstring) {
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_main_window_save()
|
||||
* save the status of the MDI session
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_main_window_save(GNCMainInfo * wind, char * filename) {
|
||||
char * session_name = g_strdup_printf("/GnuCash/MDI : %s",
|
||||
gnc_html_encode_string(filename));
|
||||
if(filename) {
|
||||
gnome_mdi_save_state(GNOME_MDI(wind->mdi), session_name);
|
||||
}
|
||||
g_free(session_name);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_main_window_restore()
|
||||
* save the status of the MDI session
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_main_window_restore(GNCMainInfo * wind, char * filename) {
|
||||
char * session_name = g_strdup_printf("/GnuCash/MDI : %s",
|
||||
gnc_html_encode_string(filename));
|
||||
GList * old_children = g_list_copy(wind->mdi->children);
|
||||
GList * c;
|
||||
|
||||
if(!filename || !gnome_mdi_restore_state(GNOME_MDI(wind->mdi), session_name,
|
||||
gnc_main_window_create_child)) {
|
||||
gnc_main_window_open_accounts(0);
|
||||
}
|
||||
g_free(session_name);
|
||||
|
||||
for(c = old_children; c ; c = c->next) {
|
||||
gnome_mdi_remove_child(wind->mdi, GNOME_MDI_CHILD(c->data), TRUE);
|
||||
}
|
||||
g_list_free(old_children);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_main_window_close_children(GNCMainInfo * wind) {
|
||||
gnome_mdi_remove_all(wind->mdi, FALSE);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_main_window_new()
|
||||
* initialize the Gnome MDI system
|
||||
@@ -463,11 +566,6 @@ gnc_main_window_new(void) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
static char *
|
||||
gnc_main_window_child_save_func(GnomeMDIChild * child, gpointer user_data) {
|
||||
return g_strdup(child->name);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_main_window_add_child()
|
||||
********************************************************************/
|
||||
@@ -504,18 +602,6 @@ gnc_main_window_destroy(GNCMainInfo * wind) {
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_main_window_save()
|
||||
* save the status of the MDI session
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_main_window_save(GNCMainInfo * wind) {
|
||||
gnome_mdi_save_state(GNOME_MDI(wind->mdi),
|
||||
"/GnuCash/MDI Session");
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_main_window_child_refresh(GNCMainChildInfo * child)
|
||||
* send an update event to the child
|
||||
|
||||
@@ -53,7 +53,8 @@ typedef struct {
|
||||
|
||||
GNCMainInfo * gnc_main_window_new(void);
|
||||
void gnc_main_window_destroy(GNCMainInfo * wind);
|
||||
void gnc_main_window_save(GNCMainInfo * wind);
|
||||
void gnc_main_window_save(GNCMainInfo * wind, char * session);
|
||||
void gnc_main_window_restore(GNCMainInfo * wind, char * session);
|
||||
GtkWidget * gnc_main_window_get_toplevel(GNCMainInfo * wind);
|
||||
void gnc_main_window_create_child_toolbar(GNCMainInfo * mi,
|
||||
GNCMainChildInfo * child);
|
||||
@@ -63,5 +64,6 @@ void gnc_main_window_remove_child(GNCMainInfo * main,
|
||||
GNCMainChildInfo * child);
|
||||
void gnc_main_window_child_refresh(gpointer data);
|
||||
GnomeMDIChild * gnc_main_window_create_child(const gchar * configstring);
|
||||
void gnc_main_window_close_children(GNCMainInfo * main);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -56,9 +56,9 @@ GnomeMDIChild * gnc_report_window_create_child(const gchar * url);
|
||||
void reportWindow(int id);
|
||||
void gnc_print_report (int report_id);
|
||||
|
||||
void gnc_report_window_add_edited_report(gnc_report_window * win,
|
||||
SCM report);
|
||||
void gnc_report_window_remove_edited_report(gnc_report_window * win,
|
||||
SCM report);
|
||||
void gnc_report_raise_editor(SCM report);
|
||||
void gnc_report_window_add_edited_report(gnc_report_window * win,
|
||||
SCM report);
|
||||
void gnc_report_window_remove_edited_report(gnc_report_window * win,
|
||||
SCM report);
|
||||
void gnc_report_raise_editor(SCM report);
|
||||
#endif
|
||||
|
||||
@@ -34,6 +34,7 @@ gnc_regular_scm_files = \
|
||||
html-utilities.scm \
|
||||
iso-4217-currencies.scm \
|
||||
main.scm \
|
||||
main-window.scm \
|
||||
options.scm \
|
||||
options-utilities.scm \
|
||||
path.scm \
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
"GNC_LEGACY_CURRENCIES")
|
||||
(gnc:import-legacy-commodities from-filename)))
|
||||
|
||||
(gnc:hook-add-dangler gnc:*file-opened-hook* import-old-currencies)
|
||||
(gnc:hook-add-dangler gnc:*book-opened-hook* import-old-currencies)
|
||||
|
||||
|
||||
|
||||
@@ -95,11 +95,15 @@
|
||||
'ui-shutdown-hook
|
||||
"Functions to run at ui shutdown. Hook args: ()"))
|
||||
|
||||
(define gnc:*file-opened-hook*
|
||||
(define gnc:*book-opened-hook*
|
||||
(gnc:hook-define
|
||||
'file-opened-hook
|
||||
"Run on file open. Hook args: none."))
|
||||
'book-opened-hook
|
||||
"Run after book open. Hook args: book URL."))
|
||||
|
||||
(define gnc:*book-closed-hook*
|
||||
(gnc:hook-define
|
||||
'book-closed-hook
|
||||
"Run before file close. Hook args: book URL"))
|
||||
|
||||
;;(let ((hook (gnc:hook-lookup 'startup-hook)))
|
||||
;; (display (gnc:hook-name-get hook))
|
||||
|
||||
124
src/scm/main-window.scm
Normal file
124
src/scm/main-window.scm
Normal file
@@ -0,0 +1,124 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; main-window.scm : utilities for dealing with main window
|
||||
;; Copyright 2001 Bill Gribble <grib@gnumatic.com>
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of
|
||||
;; the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; if not, contact:
|
||||
;;
|
||||
;; Free Software Foundation Voice: +1-617-542-5942
|
||||
;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652
|
||||
;; Boston, MA 02111-1307, USA gnu@gnu.org
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(gnc:support "gnc:main-window.scm")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; account tree options
|
||||
;; like reports, we have an integer tree id that is the index into a
|
||||
;; global hash table, and URLs of the form gnc-acct-tree:id=%d will
|
||||
;; open to the right window.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define gnc:*acct-tree-options* (make-hash-table 11))
|
||||
(define gnc:*acct-tree-id* 0)
|
||||
|
||||
(define (gnc:find-acct-tree-window-options id)
|
||||
(hash-ref gnc:*acct-tree-options* id))
|
||||
|
||||
(define (gnc:make-acct-tree-window-options)
|
||||
(let* ((options (gnc:new-options))
|
||||
(add-option
|
||||
(lambda (opt)
|
||||
(gnc:register-option options opt))))
|
||||
(add-option
|
||||
(gnc:make-string-option
|
||||
(N_ "Account Tree") (N_ "Name of account view")
|
||||
"a" (N_ "If you keep multiple account views open, it may be helpful
|
||||
to give each one a descriptive name") (N_ "Accounts")))
|
||||
(add-option
|
||||
(gnc:make-simple-boolean-option
|
||||
(N_ "Account Tree") (N_ "Double click expands parent accounts")
|
||||
"a" (N_ "Double clicking on an account with children expands \
|
||||
the account instead of opening a register.") #f))
|
||||
(add-option
|
||||
(gnc:make-list-option
|
||||
(N_ "Account Tree") (N_ "Account types to display")
|
||||
"b" ""
|
||||
(list 'bank 'cash 'credit 'asset 'liability 'stock
|
||||
'mutual 'currency 'income 'expense 'equity)
|
||||
(list (list->vector (list 'bank (N_ "Bank") ""))
|
||||
(list->vector (list 'cash (N_ "Cash") ""))
|
||||
(list->vector (list 'credit (N_ "Credit") ""))
|
||||
(list->vector (list 'asset (N_ "Asset") ""))
|
||||
(list->vector (list 'liability (N_ "Liability") ""))
|
||||
(list->vector (list 'stock (N_ "Stock") ""))
|
||||
(list->vector (list 'mutual (N_ "Mutual Fund") ""))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'income (N_ "Income") ""))
|
||||
(list->vector (list 'expense (N_ "Expense") ""))
|
||||
(list->vector (list 'equity (N_ "Equity") "")))))
|
||||
|
||||
(add-option
|
||||
(gnc:make-list-option
|
||||
(N_ "Account Tree") (N_ "Account fields to display")
|
||||
"c" ""
|
||||
(list 'description 'total)
|
||||
(list (list->vector (list 'type (N_ "Type") ""))
|
||||
(list->vector (list 'code (N_ "Code") ""))
|
||||
(list->vector (list 'description (N_ "Description") ""))
|
||||
(list->vector (list 'notes (N_ "Notes") ""))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'security (N_ "Security") ""))
|
||||
(list->vector (list 'balance (N_ "Balance") ""))
|
||||
(list->vector (list 'total (N_ "Total") ""))
|
||||
(list->vector (list 'tax-info (N_ "Tax Info") "")))))
|
||||
|
||||
options))
|
||||
|
||||
(define (gnc:make-new-acct-tree-window)
|
||||
(let ((options (gnc:make-acct-tree-window-options))
|
||||
(id gnc:*acct-tree-id*))
|
||||
(hash-set! gnc:*acct-tree-options* id options)
|
||||
(set! gnc:*acct-tree-id* (+ 1 id))
|
||||
(cons options id)))
|
||||
|
||||
(define (gnc:free-acct-tree-window id)
|
||||
(hash-remove! gnc:*acct-tree-options* id))
|
||||
|
||||
|
||||
(define (gnc:acct-tree-generate-restore-forms optobj id)
|
||||
(string-append
|
||||
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
|
||||
(simple-format #f ";; options for account tree id=~S\n" id)
|
||||
"(let ((options (gnc:make-acct-tree-window-options)))\n"
|
||||
(gnc:generate-restore-forms optobj "options")
|
||||
(simple-format
|
||||
#f " (hash-set! gnc:*acct-tree-options* ~A options)\n" id)
|
||||
(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)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
(gnc:depend "extensions.scm")
|
||||
(gnc:depend "text-export.scm")
|
||||
(gnc:depend "report.scm")
|
||||
(gnc:depend "main-window.scm")
|
||||
(gnc:depend "commodity-import.scm")
|
||||
(gnc:depend "report/report-list.scm")
|
||||
(gnc:depend "qif-import/qif-import.scm")
|
||||
@@ -104,7 +105,8 @@
|
||||
(car gnc:*command-line-remaining*)
|
||||
(gnc:history-get-last))))
|
||||
(if (and ok (string? file))
|
||||
(gnc:ui-open-file file))))
|
||||
(gnc:ui-open-file file)
|
||||
(gnc:hook-run-danglers gnc:*book-opened-hook* #f))))
|
||||
|
||||
(define (gnc:main)
|
||||
|
||||
|
||||
@@ -77,29 +77,10 @@
|
||||
;; hook should probably revert back to just save-global-options.
|
||||
(define (gnc:save-all-options)
|
||||
(gnc:save-global-options)
|
||||
(gnc:save-report-options)
|
||||
(gnc:save-acct-tree-options)
|
||||
; (gnc:save-report-options)
|
||||
; (gnc:save-acct-tree-options)
|
||||
(gnc:save-style-sheet-options))
|
||||
|
||||
(define (gnc:save-acct-tree-options)
|
||||
(let ((port (open gnc:current-config-auto
|
||||
(logior O_WRONLY O_CREAT O_APPEND)))
|
||||
(maxid 0))
|
||||
(hash-fold
|
||||
(lambda (id optobj p)
|
||||
(let ((code
|
||||
(string-append
|
||||
"(let ((options (gnc:make-acct-tree-window-options)))\n"
|
||||
(gnc:generate-restore-forms optobj "options")
|
||||
(simple-format
|
||||
#f " (hash-set! gnc:*acct-tree-options* ~A options))\n"
|
||||
id))))
|
||||
(display code port)
|
||||
(if (> id maxid) (set! maxid id)))
|
||||
#f) #f gnc:*acct-tree-options*)
|
||||
(format port " (set! gnc:*acct-tree-id* ~A)\n\n" (+ 1 maxid))
|
||||
(close port)))
|
||||
|
||||
(define (gnc:save-global-options)
|
||||
(gnc:make-home-dir)
|
||||
(gnc:save-options gnc:*options-entries*
|
||||
@@ -523,82 +504,6 @@ transaction.") #t))
|
||||
"d" (N_ "Host to connect to for user registration and support services")
|
||||
"www.gnumatic.com"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; account tree options
|
||||
;; these are here because they used to be global preferences;
|
||||
;; they should probably move elsewhere.
|
||||
;;
|
||||
;; like reports, we have an integer tree id that is the index into a
|
||||
;; global hash table, and URLs of the form gnc-acct-tree:id=%d will
|
||||
;; open to the right window.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define gnc:*acct-tree-options* (make-hash-table 11))
|
||||
(define gnc:*acct-tree-id* 0)
|
||||
|
||||
(define (gnc:find-acct-tree-window-options id)
|
||||
(hash-ref gnc:*acct-tree-options* id))
|
||||
|
||||
(define (gnc:make-acct-tree-window-options)
|
||||
(let* ((options (gnc:new-options))
|
||||
(add-option
|
||||
(lambda (opt)
|
||||
(gnc:register-option options opt))))
|
||||
(add-option
|
||||
(gnc:make-string-option
|
||||
(N_ "Account Tree") (N_ "Name of account view")
|
||||
"a" (N_ "If you keep multiple account views open, it may be helpful
|
||||
to give each one a descriptive name") (N_ "Accounts")))
|
||||
(add-option
|
||||
(gnc:make-simple-boolean-option
|
||||
(N_ "Account Tree") (N_ "Double click expands parent accounts")
|
||||
"a" (N_ "Double clicking on an account with children expands \
|
||||
the account instead of opening a register.") #f))
|
||||
(add-option
|
||||
(gnc:make-list-option
|
||||
(N_ "Account Tree") (N_ "Account types to display")
|
||||
"b" ""
|
||||
(list 'bank 'cash 'credit 'asset 'liability 'stock
|
||||
'mutual 'currency 'income 'expense 'equity)
|
||||
(list (list->vector (list 'bank (N_ "Bank") ""))
|
||||
(list->vector (list 'cash (N_ "Cash") ""))
|
||||
(list->vector (list 'credit (N_ "Credit") ""))
|
||||
(list->vector (list 'asset (N_ "Asset") ""))
|
||||
(list->vector (list 'liability (N_ "Liability") ""))
|
||||
(list->vector (list 'stock (N_ "Stock") ""))
|
||||
(list->vector (list 'mutual (N_ "Mutual Fund") ""))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'income (N_ "Income") ""))
|
||||
(list->vector (list 'expense (N_ "Expense") ""))
|
||||
(list->vector (list 'equity (N_ "Equity") "")))))
|
||||
|
||||
(add-option
|
||||
(gnc:make-list-option
|
||||
(N_ "Account Tree") (N_ "Account fields to display")
|
||||
"c" ""
|
||||
(list 'description 'total)
|
||||
(list (list->vector (list 'type (N_ "Type") ""))
|
||||
(list->vector (list 'code (N_ "Code") ""))
|
||||
(list->vector (list 'description (N_ "Description") ""))
|
||||
(list->vector (list 'notes (N_ "Notes") ""))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'security (N_ "Security") ""))
|
||||
(list->vector (list 'balance (N_ "Balance") ""))
|
||||
(list->vector (list 'total (N_ "Total") ""))
|
||||
(list->vector (list 'tax-info (N_ "Tax Info") "")))))
|
||||
|
||||
options))
|
||||
|
||||
(define (gnc:make-new-acct-tree-window)
|
||||
(let ((options (gnc:make-acct-tree-window-options))
|
||||
(id gnc:*acct-tree-id*))
|
||||
(hash-set! gnc:*acct-tree-options* id options)
|
||||
(set! gnc:*acct-tree-id* (+ 1 id))
|
||||
(cons options id)))
|
||||
|
||||
(define (gnc:free-acct-tree-window id)
|
||||
(hash-remove! gnc:*acct-tree-options* id))
|
||||
|
||||
;;; Configuation variables
|
||||
|
||||
(define gnc:*arg-show-version*
|
||||
|
||||
@@ -126,18 +126,6 @@
|
||||
(lambda ()
|
||||
(gnc:make-welcome-report)))))
|
||||
|
||||
|
||||
(define (gnc:save-report-options)
|
||||
(let ((port (open gnc:current-config-auto
|
||||
(logior O_WRONLY O_CREAT O_APPEND))))
|
||||
(hash-fold
|
||||
(lambda (id report-obj p)
|
||||
(if (not (null? (gnc:report-display-list report-obj)))
|
||||
(let ((code (gnc:report-generate-restore-forms report-obj)))
|
||||
(display code port)))
|
||||
#f) #f *gnc:_reports_*)
|
||||
(close port)))
|
||||
|
||||
(define <report-template>
|
||||
(make-record-type "<report-template>"
|
||||
;; The data items in a report record
|
||||
@@ -246,7 +234,7 @@
|
||||
|
||||
(define <report>
|
||||
(make-record-type "<report>"
|
||||
'(type id options parents children
|
||||
'(type id options parent children
|
||||
dirty? display-list editor-widget ctext)))
|
||||
|
||||
(define gnc:report-type
|
||||
@@ -270,11 +258,14 @@
|
||||
(define gnc:report-children
|
||||
(record-accessor <report> 'children))
|
||||
|
||||
(define gnc:report-set-parents!
|
||||
(record-modifier <report> 'parents))
|
||||
(define gnc:report-set-parent-by-id!
|
||||
(record-modifier <report> 'parent))
|
||||
|
||||
(define gnc:report-parents
|
||||
(record-accessor <report> 'parents))
|
||||
(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))
|
||||
@@ -287,10 +278,6 @@
|
||||
(gnc:report-set-children!
|
||||
report (cons child (gnc:report-children report))))
|
||||
|
||||
(define (gnc:report-add-parent! report parent)
|
||||
(gnc:report-set-parents!
|
||||
report (cons (gnc:report-id parent) (gnc:report-parents report))))
|
||||
|
||||
(define gnc:report-dirty?
|
||||
(record-accessor <report> 'dirty?))
|
||||
|
||||
@@ -301,12 +288,10 @@
|
||||
(gnc:report-set-dirty?-internal! report val)
|
||||
(if val
|
||||
(begin
|
||||
;; mark the parents as dirty
|
||||
(for-each
|
||||
(lambda (parent)
|
||||
(gnc:report-set-dirty?! (gnc:find-report parent) val))
|
||||
(gnc:report-parents report))
|
||||
|
||||
(if (gnc:report-parent report)
|
||||
(gnc:report-set-dirty?!
|
||||
(gnc:find-report (gnc:report-parent report)) val))
|
||||
|
||||
;; reload the window
|
||||
(for-each
|
||||
(lambda (win)
|
||||
@@ -342,10 +327,10 @@
|
||||
(lambda (rep)
|
||||
(gnc:report-register-display (gnc:find-report rep) window))
|
||||
(gnc:report-children report))
|
||||
(for-each
|
||||
(lambda (rep)
|
||||
(gnc:report-register-display (gnc:find-report rep) window))
|
||||
(gnc:report-parents 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
|
||||
@@ -358,11 +343,10 @@
|
||||
(lambda (rep)
|
||||
(gnc:report-unregister-display (gnc:find-report rep) window))
|
||||
(gnc:report-children report))
|
||||
(for-each
|
||||
(lambda (rep)
|
||||
(gnc:report-unregister-display (gnc:find-report rep) window))
|
||||
(gnc:report-parents 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)))
|
||||
@@ -389,7 +373,7 @@
|
||||
template-name ;; type
|
||||
#f ;; id
|
||||
#f ;; options
|
||||
'() ;; parents
|
||||
#f ;; parent
|
||||
'() ;; children
|
||||
#t ;; dirty
|
||||
'() ;; display-list
|
||||
@@ -409,9 +393,9 @@
|
||||
(hash-set! *gnc:_reports_* (gnc:report-id r) r)
|
||||
id))
|
||||
|
||||
(define (gnc:restore-report id template-name parents children options)
|
||||
(define (gnc:restore-report id template-name parent children options)
|
||||
(let ((r ((record-constructor <report>)
|
||||
template-name id options parents children #t '() #f #f)))
|
||||
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)))
|
||||
@@ -480,17 +464,45 @@
|
||||
(define (gnc:find-report id)
|
||||
(hash-ref *gnc:_reports_* id))
|
||||
|
||||
(define (gnc:report-generate-restore-forms-complete report)
|
||||
(define (find-root r)
|
||||
(let ((p (gnc:report-parent r)))
|
||||
(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))
|
||||
(simple-format
|
||||
#f "(let ((options (gnc:report-template-new-options/name ~S)))\n"
|
||||
(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-parents report)
|
||||
(gnc:report-children 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)
|
||||
|
||||
@@ -279,7 +279,7 @@ balance at a given time"))
|
||||
(map cadr finish))
|
||||
(set! id (gnc:make-report reportname options))
|
||||
(gnc:report-add-child-by-id! report-obj id)
|
||||
(gnc:report-add-parent! (gnc:find-report id) report-obj)
|
||||
(gnc:report-set-parent! (gnc:find-report id) report-obj)
|
||||
|
||||
;; set the URL.
|
||||
(set! other-anchor (gnc:report-anchor-text id)))))
|
||||
|
||||
@@ -359,7 +359,7 @@ developing over time"))
|
||||
;; 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-add-parent! (gnc:find-report id) report-obj)
|
||||
(gnc:report-set-parent! (gnc:find-report id) report-obj)
|
||||
(set! other-anchor (gnc:report-anchor-text id)))))
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
(lambda (child)
|
||||
(gnc:report-add-child! (gnc:find-report view)
|
||||
(gnc:find-report child))
|
||||
(gnc:report-add-parent! (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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user