[Gnucash-changes] 2004-06-18 Christian Stimming <stimming@tuhh.de> *

Christian Stimming cstim at cvs.gnucash.org
Fri Jun 18 17:25:28 EDT 2004


Log Message:
-----------
2004-06-18  Christian Stimming  <stimming at tuhh.de>

	* src/scm/main-window.scm, src/scm/main.scm: Added example Menu
	item "File -> Save all reports" that will call the new report
	saving function for all reports. This would need more work so that
	not all reports are saved but only the currently selected one --
	any volunteer may feel free to add that.

	* src/report/report-system/report.scm, report-system.scm: Added
	gnc:report-generate-saved-forms that will generate the scheme code
	necessary to create a new report from the saved options of an old
	report.

Tags:
----
gnucash-1-8-branch

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/scm:
        main-window.scm
        main.scm
    gnucash/src/report/report-system:
        report-system.scm
        report.scm

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1461.2.338
retrieving revision 1.1461.2.339
diff -LChangeLog -LChangeLog -u -r1.1461.2.338 -r1.1461.2.339
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,16 @@
+2004-06-18  Christian Stimming  <stimming at tuhh.de>
+
+	* src/scm/main-window.scm, src/scm/main.scm: Added example Menu
+	item "File -> Save all reports" that will call the new report
+	saving function for all reports. This would need more work so that
+	not all reports are saved but only the currently selected one --
+	any volunteer may feel free to add that.
+
+	* src/report/report-system/report.scm, report-system.scm: Added
+	gnc:report-generate-saved-forms that will generate the scheme code
+	necessary to create a new report from the saved options of an old
+	report.
+
 2004-06-18  Derek Atkins  <derek at ihtfp.com>
 
 	* src/scm/paths.scm: create gnc:current-saved-reports, as
Index: main.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/scm/main.scm,v
retrieving revision 1.107.2.5
retrieving revision 1.107.2.6
diff -Lsrc/scm/main.scm -Lsrc/scm/main.scm -u -r1.107.2.5 -r1.107.2.6
--- src/scm/main.scm
+++ src/scm/main.scm
@@ -77,6 +77,7 @@
 (export gnc:make-new-acct-tree-window)  
 (export gnc:free-acct-tree-window)
 (export gnc:main-window-save-state)
+(export gnc:main-window-save-report)
 
 ;; from printing/print-check.scm
 (export make-print-check-format)
@@ -496,6 +497,15 @@
     (lambda ()
       (gnc:main-window-open-report (gnc:make-welcome-report) #f))))
 
+  ;; The "save current report" entry
+  (gnc:add-extension
+   (gnc:make-menu-item
+    (N_ "_Save all current reports")
+    (N_ "Save all the current report in ~/.gnucash/saved-reports-1.8 so that they are accessible as menu entries in the report menu.")
+    (list gnc:window-name-main "_File" "_Export")
+    (lambda ()
+      (gnc:main-window-save-report))))
+
   (gnc:hook-run-danglers gnc:*startup-hook*)
 
   (if (gnc:config-var-value-get gnc:*loglevel*)
Index: main-window.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/scm/main-window.scm,v
retrieving revision 1.22.2.4
retrieving revision 1.22.2.5
diff -Lsrc/scm/main-window.scm -Lsrc/scm/main-window.scm -u -r1.22.2.4 -r1.22.2.5
--- src/scm/main-window.scm
+++ src/scm/main-window.scm
@@ -162,6 +162,18 @@
               (force-output)))
           (gnc:mdi-save (gnc:mdi-get-current) book-url)))))
 
+(define (gnc:main-window-save-report)
+  (let ((conf-file-name gnc:current-saved-reports))
+    ;;(display conf-file-name)
+    (with-output-to-port (open-output-file conf-file-name)
+      (lambda ()
+	(hash-fold
+	 (lambda (k v p)
+	   (display
+	    (gnc:report-generate-saved-forms v)))
+	 #t *gnc:_reports_*)
+	(force-output)))))
+
 (define (gnc:main-window-book-close-handler session)
     (gnc:main-window-save-state session)
 
Index: report-system.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/report-system/report-system.scm,v
retrieving revision 1.20.2.1
retrieving revision 1.20.2.2
diff -Lsrc/report/report-system/report-system.scm -Lsrc/report/report-system/report-system.scm -u -r1.20.2.1 -r1.20.2.2
--- src/report/report-system/report-system.scm
+++ src/report/report-system/report-system.scm
@@ -105,6 +105,7 @@
 (export *gnc:_reports_*)
 (export gnc:report-template-new-options/name)
 (export gnc:report-template-menu-name/name)
+(export gnc:report-template-renderer/name)
 (export gnc:report-template-new-options)
 (export gnc:report-template-version)
 (export gnc:report-template-name)
@@ -146,6 +147,7 @@
 (export gnc:find-report)
 (export gnc:find-report-template)
 (export gnc:report-generate-restore-forms)
+(export gnc:report-generate-saved-forms)
 (export gnc:report-render-html)
 (export gnc:report-run)
 (export gnc:report-templates-for-each)
Index: report.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/report-system/report.scm,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -Lsrc/report/report-system/report.scm -Lsrc/report/report-system/report.scm -u -r1.12 -r1.12.2.1
--- src/report/report-system/report.scm
+++ src/report/report-system/report.scm
@@ -135,6 +135,12 @@
 	    (gnc:report-template-name templ))
         #f)))
 
+(define (gnc:report-template-renderer/name template-name)
+  (let ((templ (hash-ref *gnc:_report-templates_* template-name)))
+    (if templ
+	(gnc:report-template-renderer templ)
+        #f)))
+
 (define (gnc:report-template-new-options report-template)
   (let ((generator (gnc:report-template-options-generator report-template))
         (namer 
@@ -353,6 +359,31 @@
     #f "  (gnc:restore-report ~S ~S options))\n"
     (gnc:report-id report) (gnc:report-type report))))
 
+(define (gnc:report-generate-saved-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 saved report ~S, based on template ~S\n"
+		  (gnc:report-name report) (gnc:report-type report))
+   (simple-format
+    #f "(let ()\n (define (options-gen)\n  (let ((options (gnc:report-template-new-options/name ~S)))\n"
+    (gnc:report-type report))
+   (gnc:generate-restore-forms (gnc:report-options report) "options")
+   "  options))\n"
+   (simple-format 
+    #f " (gnc:define-report \n  'version 1\n  'name ~S\n  'options-generator options-gen\n  'renderer (gnc:report-template-renderer/name ~S)))\n\n"
+    (gnc:report-name report)
+    (gnc:report-type report))))
+
 (define (gnc:report-render-html report headers?)
   (if (and (not (gnc:report-dirty? report))
            (gnc:report-ctext report))


More information about the gnucash-changes mailing list