[Gnucash-changes] r12984 - gnucash/trunk/src - Move the global
report hash-table from guile to C.
Chris Shoemaker
chris at cvs.gnucash.org
Thu Jan 26 21:12:42 EST 2006
Author: chris
Date: 2006-01-26 21:12:41 -0500 (Thu, 26 Jan 2006)
New Revision: 12984
Trac: http://svn.gnucash.org/trac/changeset/12984
Added:
gnucash/trunk/src/report/report-system/gw-report-system-spec.scm
Modified:
gnucash/trunk/src/gnome/top-level.c
gnucash/trunk/src/report/report-gnome/dialog-column-view.c
gnucash/trunk/src/report/report-gnome/dialog-style-sheet.c
gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
gnucash/trunk/src/report/report-gnome/window-report.c
gnucash/trunk/src/report/report-gnome/window-report.h
gnucash/trunk/src/report/report-system/Makefile.am
gnucash/trunk/src/report/report-system/gnc-report.c
gnucash/trunk/src/report/report-system/gnc-report.h
gnucash/trunk/src/report/report-system/html-style-sheet.scm
gnucash/trunk/src/report/report-system/report-system.scm
gnucash/trunk/src/report/report-system/report.scm
gnucash/trunk/src/report/utility-reports/view-column.scm
gnucash/trunk/src/report/utility-reports/welcome-to-gnucash.scm
gnucash/trunk/src/scm/main-window.scm
gnucash/trunk/src/scm/main.scm
Log:
Move the global report hash-table from guile to C.
Move the book-open/close hooks from guile to C.
There are several places where we do report-management from C already.
Those places no longer use libguile to access the hash-table of reports -
they can just call C functions.
For now, there's still some report-management happening in guile so guile
can access the global state through g-wrapped functions. Eventually,
all report-management should be in C and guile can just provide single
reports one-at-a-time.
Modified: gnucash/trunk/src/gnome/top-level.c
===================================================================
--- gnucash/trunk/src/gnome/top-level.c 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/gnome/top-level.c 2006-01-27 02:12:41 UTC (rev 12984)
@@ -251,6 +251,9 @@
(session ?
gw_wcp_assimilate_ptr (session, scm_c_eval_string("<gnc:Session*>")) :
SCM_BOOL_F));
+ /* At this point the reports have only been loaded into
+ memory. Now we create their ui component. */
+ gnc_reports_show_all();
#endif
LEAVE("old");
@@ -418,6 +421,12 @@
gnc_hook_add_dangler(HOOK_BOOK_CLOSED,
gnc_save_all_state, NULL);
+ /* CAS: I'm not really sure why we remove before adding. */
+ gnc_hook_remove_dangler(HOOK_BOOK_CLOSED, gnc_reports_flush_global);
+ gnc_hook_add_dangler(HOOK_BOOK_CLOSED,
+ gnc_reports_flush_global, NULL);
+
+
LEAVE(" ");
return;
}
Modified: gnucash/trunk/src/report/report-gnome/dialog-column-view.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/dialog-column-view.c 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-gnome/dialog-column-view.c 2006-01-27 02:12:41 UTC (rev 12984)
@@ -33,6 +33,7 @@
#include "option-util.h"
#include "window-report.h"
#include "guile-mappings.h"
+#include "gnc-report.h"
struct gncp_column_view_edit {
GNCOptionWin * optwin;
@@ -92,7 +93,6 @@
SCM get_names = scm_c_eval_string("gnc:all-report-template-names");
SCM template_menu_name = scm_c_eval_string("gnc:report-template-menu-name/name");
SCM report_menu_name = scm_c_eval_string("gnc:report-menu-name");
- SCM find_report = scm_c_eval_string("gnc:find-report");
SCM names = scm_call_0(get_names);
SCM contents =
gnc_option_db_lookup_option(view->odb, "__general", "report-list",
@@ -100,7 +100,7 @@
SCM this_report, this_name;
SCM selection;
char * name[3];
- int row, i;
+ int row, i, id;
/* Update the list of available reports (left selection box). */
row = view->available_selected;
@@ -153,7 +153,8 @@
if (SCM_EQUALP (SCM_CAR(contents), selection))
row = i;
- this_report = scm_call_1(find_report, SCM_CAAR(contents));
+ id = scm_num2int(SCM_CAAR(contents), SCM_ARG1, __FUNCTION__);
+ this_report = gnc_report_find(id);
/* this_name = scm_call_1(report_name, this_report); */
this_name = scm_call_1(report_menu_name, this_report);
name[0] = g_strdup(SCM_STRING_CHARS(this_name));
@@ -312,20 +313,20 @@
gnc_column_view_edit * r = user_data;
SCM make_report = scm_c_eval_string("gnc:make-report");
SCM mark_report = scm_c_eval_string("gnc:report-set-needs-save?!");
- SCM find_report = scm_c_eval_string("gnc:find-report");
SCM template_name;
SCM new_report;
SCM newlist = SCM_EOL;
SCM oldlist = r->contents_list;
int count;
- int oldlength;
+ int oldlength, id;
if(SCM_LISTP(r->available_list) &&
(scm_ilength(r->available_list) > r->available_selected)) {
template_name = scm_list_ref(r->available_list,
scm_int2num(r->available_selected));
new_report = scm_call_1(make_report, template_name);
- scm_call_2(mark_report, scm_call_1(find_report, new_report), SCM_BOOL_T);
+ id = scm_num2int(new_report, SCM_ARG1, __FUNCTION__);
+ scm_call_2(mark_report, gnc_report_find(id), SCM_BOOL_T);
oldlength = scm_ilength(r->contents_list);
if(oldlength > r->contents_selected) {
Modified: gnucash/trunk/src/report/report-gnome/dialog-style-sheet.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/dialog-style-sheet.c 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-gnome/dialog-style-sheet.c 2006-01-27 02:12:41 UTC (rev 12984)
@@ -29,6 +29,7 @@
#include "dialog-style-sheet.h"
#include "dialog-options.h"
#include "dialog-utils.h"
+#include "gnc-report.h"
#include "gnc-ui.h"
StyleSheetDialog * gnc_style_sheet_dialog = NULL;
@@ -60,13 +61,40 @@
************************************************************/
static void
+dirty_same_stylesheet(gpointer key, gpointer val, gpointer data)
+{
+ SCM dirty_ss = data;
+ SCM rep_ss = NULL;
+ SCM report = val;
+ SCM func = NULL;
+
+ func = scm_c_eval_string("gnc:report-stylesheet");
+ if (SCM_PROCEDUREP(func))
+ rep_ss = scm_call_1(func, report);
+ else
+ return;
+
+ if (SCM_NFALSEP(scm_eq_p(rep_ss, dirty_ss))) {
+ func = scm_c_eval_string("gnc:report-set-dirty?!");
+ /* This makes _me_ feel dirty! */
+ if (SCM_PROCEDUREP(func))
+ scm_call_2(func, report, SCM_BOOL_T);
+ }
+}
+
+static void
gnc_style_sheet_options_apply_cb(GNCOptionWin * propertybox,
gpointer user_data)
{
ss_info * ssi = (ss_info *)user_data;
- SCM apply_changes = scm_c_eval_string("gnc:html-style-sheet-apply-changes");
+ GHashTable *reports = NULL;
+
+ /* FIXME: shouldn't be global */
+ reports = gnc_reports_get_global();
+ if (reports)
+ g_hash_table_foreach(reports, dirty_same_stylesheet, ssi->stylesheet);
+
gnc_option_db_commit(ssi->odb);
- scm_call_1(apply_changes, ssi->stylesheet);
}
Modified: gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c 2006-01-27 02:12:41 UTC (rev 12984)
@@ -64,6 +64,7 @@
#include "gnc-window.h"
#include "guile-util.h"
#include "option-util.h"
+#include "window-report.h"
#define WINDOW_REPORT_CM_CLASS "window-report"
@@ -373,7 +374,6 @@
{
GncPluginPageReport *report = GNC_PLUGIN_PAGE_REPORT(ppage);
GncPluginPageReportPrivate *priv;
- SCM find_report = scm_c_eval_string("gnc:find-report");
SCM set_needs_save = scm_c_eval_string("gnc:report-set-needs-save?!");
SCM inst_report;
int report_id;
@@ -394,8 +394,7 @@
/* get the inst-report from the Scheme-side hash, and get its
* options and editor thunk */
- if ((inst_report = scm_call_1(find_report, scm_int2num(report_id)))
- == SCM_BOOL_F) {
+ if ((inst_report = gnc_report_find(report_id)) == SCM_BOOL_F) {
return;
}
@@ -422,7 +421,6 @@
GncPluginPageReport *report = GNC_PLUGIN_PAGE_REPORT(data);
GncPluginPageReportPrivate *priv;
int report_id;
- SCM find_report = scm_c_eval_string("gnc:find-report");
SCM get_options = scm_c_eval_string("gnc:report-options");
SCM set_needs_save = scm_c_eval_string("gnc:report-set-needs-save?!");
SCM inst_report;
@@ -446,7 +444,7 @@
&& (strlen(location) > 10)
&& !strncmp("report-id=", location, 10)) {
sscanf(location+10, "%d", &report_id);
- inst_report = scm_call_1(find_report, scm_int2num(report_id));
+ inst_report = gnc_report_find(report_id);
if (inst_report != SCM_BOOL_F) {
gnc_plugin_page_report_add_edited_report(priv, inst_report);
}
@@ -456,10 +454,9 @@
return;
}
- /* get the inst-report from the Scheme-side hash, and get its
+ /* get the inst-report from the hash, and get its
* options and editor thunk */
- if ((inst_report = scm_call_1(find_report, scm_int2num(report_id)))
- == SCM_BOOL_F) {
+ if ((inst_report = gnc_report_find(report_id)) == SCM_BOOL_F) {
LEAVE( "error getting inst_report" );
return;
}
@@ -563,15 +560,17 @@
gnc_html_reload( priv->html );
}
+/* FIXME: This function does... nothing. */
static void
gnc_plugin_page_report_history_destroy_cb(gnc_html_history_node * node,
gpointer user_data)
{
+#if 0
static SCM remover = SCM_BOOL_F;
int report_id;
-
+
if (remover == SCM_BOOL_F) {
- remover = scm_c_eval_string("gnc:report-remove-by-id");
+ remover = scm_c_eval_string("gnc:report-remove-by-id");
}
if (node
@@ -584,6 +583,7 @@
else {
return;
}
+#endif
}
/* We got a draw event. See if we need to reload the report */
@@ -626,18 +626,10 @@
GncPluginPageReportPrivate *priv;
// FIXME: cleanup other resources.
- static SCM remover = SCM_BOOL_F;
- int report_id;
PINFO("destroy widget");
- if (remover == SCM_BOOL_F) {
- remover = scm_c_eval_string("gnc:report-remove-by-id");
- }
-
priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(plugin_page);
- report_id = priv->reportId;
- PINFO("unreffing report %d and children\n", report_id);
- scm_call_1(remover, scm_int2num(report_id));
+ gnc_report_remove_by_id(priv->reportId);
}
Modified: gnucash/trunk/src/report/report-gnome/window-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/window-report.c 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-gnome/window-report.c 2006-01-27 02:12:41 UTC (rev 12984)
@@ -44,6 +44,7 @@
#include "guile-mappings.h"
#include "gnc-plugin-page-report.h"
+#include "gnc-report.h"
#define WINDOW_REPORT_CM_CLASS "window-report"
@@ -222,7 +223,6 @@
gnc_html_options_url_cb (const char *location, const char *label,
gboolean new_window, GNCURLResult *result)
{
- SCM find_report = scm_c_eval_string ("gnc:find-report");
SCM start_editor = scm_c_eval_string ("gnc:report-edit-options");
SCM report;
int report_id;
@@ -243,7 +243,7 @@
return FALSE;
}
- report = scm_call_1 (find_report, scm_int2num (report_id));
+ report = gnc_report_find(report_id);
if (report == SCM_UNDEFINED ||
report == SCM_BOOL_F)
{
@@ -317,3 +317,18 @@
gnc_html_register_url_handler (URL_TYPE_REPORT, gnc_html_report_url_cb);
gnc_html_register_url_handler (URL_TYPE_HELP, gnc_html_help_url_cb);
}
+
+static void
+show_report(gpointer key, gpointer val, gpointer data)
+{
+ gnc_main_window_open_report(GPOINTER_TO_INT(key), NULL);
+}
+
+void
+gnc_reports_show_all()
+{
+ GHashTable *reports = gnc_reports_get_global();
+
+ if (reports)
+ g_hash_table_foreach(reports, show_report, NULL);
+}
Modified: gnucash/trunk/src/report/report-gnome/window-report.h
===================================================================
--- gnucash/trunk/src/report/report-gnome/window-report.h 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-gnome/window-report.h 2006-01-27 02:12:41 UTC (rev 12984)
@@ -45,4 +45,5 @@
// module[/plugin]-init
void gnc_report_init (void);
+void gnc_reports_show_all();
#endif
Modified: gnucash/trunk/src/report/report-system/Makefile.am
===================================================================
--- gnucash/trunk/src/report/report-system/Makefile.am 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-system/Makefile.am 2006-01-27 02:12:41 UTC (rev 12984)
@@ -1,6 +1,6 @@
SUBDIRS = . test
-pkglib_LTLIBRARIES = libgncmod-report-system.la
+pkglib_LTLIBRARIES = libgncmod-report-system.la libgw-report-system.la
libgncmod_report_system_la_SOURCES = \
gncmod-report-system.c \
@@ -19,17 +19,19 @@
AM_CFLAGS = \
-I${top_srcdir}/src \
-I${top_srcdir}/src/gnc-module \
- ${GLIB_CFLAGS} ${GUILE_INCS}
+ ${GLIB_CFLAGS} ${GUILE_INCS} \
+ ${G_WRAP_COMPILE_ARGS}
if GNUCASH_SEPARATE_BUILDDIR
#For executing test cases
-SCM_FILE_LINKS = report-system.scm
+SCM_FILE_LINKS = report-system.scm gw-report-system-spec.scm
endif
.scm-links:
- rm -f gnucash report
+ rm -f gnucash report g-wrapped
ln -sf . gnucash
ln -sf . report
+ ln -sf . g-wrapped
if GNUCASH_SEPARATE_BUILDDIR
for X in ${SCM_FILE_LINKS} ; do \
ln -sf ${srcdir}/$$X . ; \
@@ -37,11 +39,18 @@
endif
touch .scm-links
+gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/report-system
+
gncscmmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/report/
gncscmmod_DATA = report-system.scm
-noinst_DATA = .scm-links
+libgw_report_system_la_SOURCES = gw-report-system.c
+gwmoddir = ${GNC_GWRAP_LIBDIR}
+gwmod_DATA = gw-report-system.scm gw-report-system-spec.scm
+
+noinst_DATA = .scm-links gw-report-system.h
+
gncscmdir = ${GNC_SHAREDIR}/scm
gncscm_DATA = \
commodity-utilities.scm \
@@ -59,6 +68,22 @@
report-utilities.scm \
report.scm
-EXTRA_DIST = ${gncscmmod_DATA} ${gncscm_DATA}
+EXTRA_DIST = ${gncscmmod_DATA} ${gncscm_DATA} ${gwmod_DATA}
CLEANFILES = ${SCM_FILE_LINKS} gnucash report .scm-links
+
+
+gw-report-system.scm gw-report-system.c gw-report-system.h: \
+ .scm-links gw-report-system-spec.scm ${top_builddir}/config.status
+ FLAVOR=gnome $(GUILE) -c \
+ "(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
+ (set! %load-path (cons \"${PWD}\" %load-path)) \
+ (set! %load-path (cons \"${top_builddir}/src/engine\" %load-path)) \
+ (set! %load-path (cons \"${top_builddir}/src/app-utils\" %load-path)) \
+ (set! %load-path (cons \"${top_builddir}/src/gnome-utils\" %load-path)) \
+ (primitive-load \"./gw-report-system-spec.scm\") \
+ (gw:generate-wrapset \"gw-report-system\")"
+
+BUILT_SOURCES = gw-report-system.scm gw-report-system.c gw-report-system.h
+DISTCLEANFILES = gnucash g-wrapped report .scm-links ${SCM_FILE_LINKS} \
+ gw-report-system.html
Modified: gnucash/trunk/src/report/report-system/gnc-report.c
===================================================================
--- gnucash/trunk/src/report/report-system/gnc-report.c 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-system/gnc-report.c 2006-01-27 02:12:41 UTC (rev 12984)
@@ -2,6 +2,7 @@
* gnc-report.c -- C functions for reports. *
* *
* Copyright (C) 2001 Linux Developers Group *
+ * Copyright (C) 2006 Chris Shoemaker <c.shoemaker at cox.net> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@@ -30,6 +31,69 @@
#include "gnc-report.h"
+/* Fow now, this is global, like it was in guile. It _should_ be per-book. */
+static GHashTable *reports = NULL;
+
+static void
+gnc_report_init_table(void)
+{
+ /* TODO: Right now the report-page handles the gc-protection, but
+ it probably makes more sense to do it here on insert and remove. */
+ if (!reports) {
+ reports = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
+ }
+}
+
+void
+gnc_report_remove_by_id(gint id)
+{
+ if (reports)
+ g_hash_table_remove(reports, &id);
+}
+
+SCM gnc_report_find(gint id)
+{
+ gpointer report = NULL;
+
+ if (reports) {
+ report = g_hash_table_lookup(reports, &id);
+ }
+
+ if (!report)
+ return SCM_BOOL_F;
+
+ return report;
+}
+
+void gnc_report_add(gint id, SCM report)
+{
+ gint *key;
+ gnc_report_init_table();
+ key = g_new(gint, 1);
+ *key = id;
+ g_hash_table_insert(reports, key, (gpointer)report);
+}
+
+static gboolean
+yes_remove(gpointer key, gpointer val, gpointer data)
+{
+ return TRUE;
+}
+
+void
+gnc_reports_flush_global()
+{
+ if (reports)
+ g_hash_table_foreach_remove(reports, yes_remove, NULL);
+}
+
+GHashTable *
+gnc_reports_get_global()
+{
+ gnc_report_init_table();
+ return reports;
+}
+
gboolean
gnc_run_report (int report_id, char ** data)
{
Modified: gnucash/trunk/src/report/report-system/gnc-report.h
===================================================================
--- gnucash/trunk/src/report/report-system/gnc-report.h 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-system/gnc-report.h 2006-01-27 02:12:41 UTC (rev 12984)
@@ -2,6 +2,7 @@
* gnc-report.h -- C functions for reports. *
* *
* Copyright (C) 2001 Linux Developers Group *
+ * Copyright (C) 2006 Chris Shoemaker <c.shoemaker at cox.net> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@@ -24,6 +25,9 @@
#ifndef GNC_REPORT_H
#define GNC_REPORT_H
+#include <glib.h>
+#include <libguile.h>
+
gboolean gnc_run_report (int report_id, char ** data);
gboolean gnc_run_report_id_string (const char * id_string, char **data);
@@ -34,4 +38,11 @@
**/
gchar* gnc_report_name( SCM report );
+SCM gnc_report_find(gint id);
+void gnc_report_remove_by_id(gint id);
+void gnc_report_add(gint id, SCM report);
+
+void gnc_reports_flush_global();
+GHashTable *gnc_reports_get_global();
+
#endif
Added: gnucash/trunk/src/report/report-system/gw-report-system-spec.scm
===================================================================
--- gnucash/trunk/src/report/report-system/gw-report-system-spec.scm 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-system/gw-report-system-spec.scm 2006-01-27 02:12:41 UTC (rev 12984)
@@ -0,0 +1,45 @@
+(define-module (g-wrapped gw-report-system-spec))
+
+(debug-set! maxdepth 100000)
+(debug-set! stack 2000000)
+
+(use-modules (g-wrap))
+
+(use-modules (g-wrap gw-standard-spec))
+(use-modules (g-wrap gw-wct-spec))
+(use-modules (g-wrap gw-glib-spec))
+
+(use-modules (g-wrapped gw-engine-spec))
+
+(let ((ws (gw:new-wrapset "gw-report-system")))
+
+ (gw:wrapset-depends-on ws "gw-standard")
+ (gw:wrapset-depends-on ws "gw-wct")
+ (gw:wrapset-depends-on ws "gw-glib")
+
+ (gw:wrapset-set-guile-module! ws '(g-wrapped gw-report-system))
+
+ (gw:wrapset-add-cs-declarations!
+ ws
+ (lambda (wrapset client-wrapset)
+ (list
+ "#include <gnc-report.h>\n"
+ )))
+
+ (gw:wrap-function
+ ws
+ 'gnc:find-report
+ '<gw:scm>
+ "gnc_report_find"
+ '((<gw:int> id))
+ "Find report by id")
+
+ (gw:wrap-function
+ ws
+ 'gnc:report-add
+ '<gw:void>
+ "gnc_report_add"
+ '((<gw:int> id) (<gw:scm> report))
+ "Add report with id")
+
+ )
Modified: gnucash/trunk/src/report/report-system/html-style-sheet.scm
===================================================================
--- gnucash/trunk/src/report/report-system/html-style-sheet.scm 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-system/html-style-sheet.scm 2006-01-27 02:12:41 UTC (rev 12984)
@@ -225,19 +225,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; html-style-sheet-apply-changes
-;; when options have been changed, rerun relevant reports
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (gnc:html-style-sheet-apply-changes ss)
- (hash-fold
- (lambda (report-name report prior)
- (if (eq? (gnc:report-stylesheet report) ss)
- (gnc:report-set-dirty?! report #t))
- #t) #t *gnc:_reports_*))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; html-style-sheet-render
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Modified: gnucash/trunk/src/report/report-system/report-system.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report-system.scm 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-system/report-system.scm 2006-01-27 02:12:41 UTC (rev 12984)
@@ -106,7 +106,6 @@
(export gnc:define-report)
(export <report>)
-(export *gnc:_reports_*)
(export gnc:report-template-new-options/name)
(export gnc:report-template-menu-name/name)
(export gnc:report-template-renderer/name)
@@ -147,8 +146,6 @@
(export gnc:report-stylesheet)
(export gnc:report-set-stylesheet!)
(export gnc:all-report-template-names)
-(export gnc:report-remove-by-id)
-(export gnc:find-report)
(export gnc:find-report-template)
(export gnc:report-generate-restore-forms)
(export gnc:report-generate-saved-forms)
Modified: gnucash/trunk/src/report/report-system/report.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report.scm 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/report-system/report.scm 2006-01-27 02:12:41 UTC (rev 12984)
@@ -21,6 +21,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-modules (gnucash main))
+(use-modules (g-wrapped gw-report-system))
;; This hash should contain all the reports available and will be used
;; to generate the reports menu whenever a new window opens and to
@@ -30,9 +31,6 @@
;; value is the report definition structure.
(define *gnc:_report-templates_* (make-hash-table 23))
-;; this is a hash of 'report ID' to instantiated report. the
-;; report id is generated at report-record creation time.
-(define *gnc:_reports_* (make-hash-table 23))
(define *gnc:_report-next-serial_* 0)
;; Define those strings here to make changes easier and avoid typos.
@@ -261,15 +259,16 @@
(cb r))))
options))
- (hash-set! *gnc:_reports_* (gnc:report-id r) r)
+ (gnc:report-add (gnc:report-id r) r)
id))
+;; This is the function that is called when saved reports are evaluated.
(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)
+ (gnc:report-add id r)
id))
@@ -335,18 +334,6 @@
'() *gnc:_report-templates_*)
string<?))
-(define (gnc:report-remove-by-id id)
- (let ((r (hash-ref *gnc:_reports_* id)))
- ;; 2005.10.02, jsled: gnc:report-children doesn't appear defined anywhere?
- ;; (for-each
- ;; (lambda (child)
- ;; (gnc:report-remove-by-id child))
- ;; (gnc:report-children r))
- (hash-remove! *gnc:_reports_* id)))
-
-(define (gnc:find-report id)
- (hash-ref *gnc:_reports_* id))
-
(define (gnc:find-report-template report-type)
(hash-ref *gnc:_report-templates_* report-type))
Modified: gnucash/trunk/src/report/utility-reports/view-column.scm
===================================================================
--- gnucash/trunk/src/report/utility-reports/view-column.scm 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/utility-reports/view-column.scm 2006-01-27 02:12:41 UTC (rev 12984)
@@ -30,6 +30,7 @@
(use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
(use-modules (ice-9 slib))
(use-modules (gnucash gnc-module))
+(use-modules (g-wrapped gw-report-system))
(require 'printf)
Modified: gnucash/trunk/src/report/utility-reports/welcome-to-gnucash.scm
===================================================================
--- gnucash/trunk/src/report/utility-reports/welcome-to-gnucash.scm 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/report/utility-reports/welcome-to-gnucash.scm 2006-01-27 02:12:41 UTC (rev 12984)
@@ -25,6 +25,7 @@
(use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
(use-modules (gnucash gnc-module))
+(use-modules (g-wrapped gw-report-system))
(gnc:module-load "gnucash/report/report-system" 0)
Modified: gnucash/trunk/src/scm/main-window.scm
===================================================================
--- gnucash/trunk/src/scm/main-window.scm 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/scm/main-window.scm 2006-01-27 02:12:41 UTC (rev 12984)
@@ -27,40 +27,7 @@
;; book close.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (gnc:main-window-save-state session)
- (let* ((book-url (gnc:session-get-url session))
- (conf-file-name (gnc:html-encode-string book-url))
- (book-path #f))
- (if conf-file-name
- (let ((book-path (gnc:build-book-path 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_*)
-
- (force-output)))
- ))))
-
-(define (gnc:main-window-book-close-handler session)
- (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 session)
(define (try-load file-suffix)
(let ((file (gnc:build-book-path file-suffix)))
@@ -71,18 +38,13 @@
(gnc:warn "failure loading " file)
#f))
#f)))
+
(let* ((book-url (gnc:session-get-url session))
(conf-file-name (gnc:html-encode-string book-url))
(dead-reports '()))
(if conf-file-name
(try-load conf-file-name))
- ;; the reports have only been created at this point; create their ui component.
- (hash-fold (lambda (key val prior-result)
- (gnc:main-window-open-report (gnc:report-id val)
- #f ;; =window: #f/null => open in first window
- ))
- #t *gnc:_reports_*)
))
(define (gnc:main-window-properties-cb)
Modified: gnucash/trunk/src/scm/main.scm
===================================================================
--- gnucash/trunk/src/scm/main.scm 2006-01-26 19:01:16 UTC (rev 12983)
+++ gnucash/trunk/src/scm/main.scm 2006-01-27 02:12:41 UTC (rev 12984)
@@ -64,7 +64,6 @@
(export gnc:load-help-topics)
;; from main-window.scm
-(export gnc:main-window-save-state)
(export gnc:main-window-properties-cb)
;; from printing/print-check.scm
@@ -238,9 +237,5 @@
(if (not (gnc:handle-command-line-args))
(gnc:shutdown 1))
- (gnc:hook-remove-dangler gnc:*book-closed-hook*
- gnc:main-window-book-close-handler)
- (gnc:hook-add-dangler gnc:*book-closed-hook*
- gnc:main-window-book-close-handler)
;;return to C
)
More information about the gnucash-changes
mailing list