mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Refactor options url handler.
Refactor report menu setup. Fix missing gnc:make-welcome report export. Fix missing slib use-module. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5368 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
5320af963f
commit
e657b59b2c
@ -863,30 +863,6 @@ gnc_html_submit_cb(GtkHTML * html, const gchar * method,
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_html_open_options
|
||||
* open an editor for report parameters
|
||||
********************************************************************/
|
||||
|
||||
static void
|
||||
gnc_html_open_options(gnc_html * html, const gchar * location) {
|
||||
int report_id;
|
||||
SCM find_report = gh_eval_str("gnc:find-report");
|
||||
SCM start_editor = gh_eval_str("gnc:report-edit-options");
|
||||
SCM report;
|
||||
|
||||
/* href="gnc-options:report-id=2676" */
|
||||
if(!strncmp("report-id=", location, 10)) {
|
||||
sscanf(location+10, "%d", &report_id);
|
||||
report = gh_call1(find_report, gh_int2scm(report_id));
|
||||
gh_call1(start_editor, report);
|
||||
}
|
||||
else {
|
||||
gnc_warning_dialog(_("Badly formed options URL."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_html_open_help
|
||||
* open a help window
|
||||
@ -1033,10 +1009,6 @@ gnc_html_show_url(gnc_html * html, URLType type,
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case URL_TYPE_OPTIONS:
|
||||
gnc_html_open_options(html, location);
|
||||
break;
|
||||
|
||||
case URL_TYPE_HELP:
|
||||
gnc_html_open_help(html, location, label, new_window);
|
||||
break;
|
||||
@ -1080,8 +1052,7 @@ gnc_html_show_url(gnc_html * html, URLType type,
|
||||
|
||||
case URL_TYPE_ACTION:
|
||||
gnc_html_history_append(html->history,
|
||||
gnc_html_history_node_new(type,
|
||||
location, label));
|
||||
gnc_html_history_node_new(type, location, label));
|
||||
gnc_html_submit_cb(GTK_HTML(html->html), "get",
|
||||
gnc_build_url(type, location, label), NULL,
|
||||
(gpointer)html);
|
||||
|
@ -325,6 +325,54 @@ gnc_html_report_url_cb (const char *location, const char *label,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_html_options_url_cb (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult *result)
|
||||
{
|
||||
SCM find_report = gh_eval_str ("gnc:find-report");
|
||||
SCM start_editor = gh_eval_str ("gnc:report-edit-options");
|
||||
SCM report;
|
||||
int report_id;
|
||||
|
||||
g_return_val_if_fail (location != NULL, FALSE);
|
||||
g_return_val_if_fail (result != NULL, FALSE);
|
||||
|
||||
result->load_to_stream = FALSE;
|
||||
|
||||
/* href="gnc-options:report-id=2676" */
|
||||
if (strncmp ("report-id=", location, 10) == 0)
|
||||
{
|
||||
if (sscanf (location + 10, "%d", &report_id) != 1)
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly formed options URL: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
report = gh_call1 (find_report, gh_int2scm (report_id));
|
||||
if (report == SCM_UNDEFINED ||
|
||||
report == SCM_BOOL_F)
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly report id: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gh_call1 (start_editor, report);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly formed options URL: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
/* These gnucash_ui_init and gnucash_ui functions are just hacks to get
|
||||
@ -473,8 +521,8 @@ gnucash_ui_init(void)
|
||||
|
||||
gnc_html_register_url_handler (URL_TYPE_REGISTER,
|
||||
gnc_html_register_url_cb);
|
||||
|
||||
gnc_html_register_url_handler (URL_TYPE_REPORT, gnc_html_report_url_cb);
|
||||
gnc_html_register_url_handler (URL_TYPE_OPTIONS, gnc_html_options_url_cb);
|
||||
|
||||
/* initialize gnome MDI and set up application window defaults */
|
||||
app = gnc_main_window_new();
|
||||
|
@ -102,6 +102,18 @@
|
||||
(export gnc:report-template-new-options/name)
|
||||
(export gnc:report-template-menu-name/name)
|
||||
(export gnc:report-template-new-options)
|
||||
(export gnc:report-template-version)
|
||||
(export gnc:report-template-name)
|
||||
(export gnc:report-template-options-generator)
|
||||
(export gnc:report-template-options-editor)
|
||||
(export gnc:report-template-options-cleanup-cb)
|
||||
(export gnc:report-template-options-changed-cb)
|
||||
(export gnc:report-template-renderer)
|
||||
(export gnc:report-template-in-menu?)
|
||||
(export gnc:report-template-menu-path)
|
||||
(export gnc:report-template-menu-name)
|
||||
(export gnc:report-template-menu-tip)
|
||||
(export gnc:report-template-export-thunk)
|
||||
(export gnc:report-type)
|
||||
(export gnc:report-set-type!)
|
||||
(export gnc:report-id)
|
||||
@ -132,6 +144,7 @@
|
||||
(export gnc:report-generate-restore-forms)
|
||||
(export gnc:report-render-html)
|
||||
(export gnc:report-run)
|
||||
(export gnc:report-templates-for-each)
|
||||
|
||||
;; html-barchart.scm
|
||||
|
||||
|
@ -47,84 +47,6 @@
|
||||
(define gnc:pagename-display (N_ "Display"))
|
||||
(define gnc:optname-reportname (N_ "Report name"))
|
||||
|
||||
(define (gnc:report-menu-setup)
|
||||
;; since this menu gets added to every child window, we say it
|
||||
;; comes after the "_File" menu.
|
||||
(define menu (gnc:make-menu gnc:menuname-reports (list "_File")))
|
||||
(define menu-namer (gnc:new-menu-namer))
|
||||
(define tax-menu (gnc:make-menu gnc:menuname-taxes
|
||||
(list gnc:menuname-reports "")))
|
||||
(define income-expense-menu
|
||||
(gnc:make-menu gnc:menuname-income-expense
|
||||
(list gnc:menuname-reports "")))
|
||||
(define asset-liability-menu
|
||||
(gnc:make-menu gnc:menuname-asset-liability
|
||||
(list gnc:menuname-reports "")))
|
||||
(define utility-menu
|
||||
(gnc:make-menu gnc:menuname-utility
|
||||
(list gnc:menuname-reports "")))
|
||||
(define menu-hash (make-hash-table 23))
|
||||
|
||||
(define (add-report-menu-item name report)
|
||||
(if (gnc:report-template-in-menu? report)
|
||||
(let ((title (string-append (_ "Report") ": " (_ name)))
|
||||
(menu-path (gnc:report-template-menu-path report))
|
||||
(menu-name (gnc:report-template-menu-name report))
|
||||
(menu-tip (gnc:report-template-menu-tip report))
|
||||
(item #f))
|
||||
|
||||
(if (not menu-path)
|
||||
(set! menu-path '(""))
|
||||
(set! menu-path
|
||||
(append menu-path '(""))))
|
||||
|
||||
(set! menu-path (append (list gnc:menuname-reports) menu-path))
|
||||
|
||||
(if menu-name (set! name menu-name))
|
||||
|
||||
(if (not menu-tip)
|
||||
(set! menu-tip
|
||||
(sprintf #f (_ "Display the %s report") (_ name))))
|
||||
|
||||
(set! item
|
||||
(gnc:make-menu-item
|
||||
((menu-namer 'add-name) name)
|
||||
menu-tip
|
||||
menu-path
|
||||
(lambda ()
|
||||
(let ((rept (gnc:make-report
|
||||
(gnc:report-template-name report))))
|
||||
(gnc:main-window-open-report rept #f)))))
|
||||
(gnc:add-extension item))))
|
||||
|
||||
(gnc:add-extension menu)
|
||||
|
||||
;; add the menu option to edit style sheets
|
||||
(gnc:add-extension
|
||||
(gnc:make-menu-item
|
||||
((menu-namer 'add-name) (_ "Style Sheets..."))
|
||||
(_ "Edit report style sheets.")
|
||||
(list "_Settings" "")
|
||||
(lambda ()
|
||||
(gnc:style-sheet-dialog-open))))
|
||||
|
||||
; (gnc:add-extension tax-menu)
|
||||
(gnc:add-extension income-expense-menu)
|
||||
(gnc:add-extension asset-liability-menu)
|
||||
(gnc:add-extension utility-menu)
|
||||
|
||||
;; push reports (new items added on top of menu)
|
||||
(hash-for-each add-report-menu-item *gnc:_report-templates_*)
|
||||
|
||||
;; the Welcome to Gnucash-1.6 extravaganza
|
||||
(gnc:add-extension
|
||||
(gnc:make-menu-item
|
||||
((menu-namer 'add-name) (_ "Welcome Extravaganza"))
|
||||
(_ "Welcome-to-GnuCash screen")
|
||||
(list gnc:menuname-reports gnc:menuname-utility "")
|
||||
(lambda ()
|
||||
(gnc:make-welcome-report)))))
|
||||
|
||||
(define <report-template>
|
||||
(make-record-type "<report-template>"
|
||||
;; The data items in a report record
|
||||
@ -486,4 +408,6 @@
|
||||
html)
|
||||
#f)))))
|
||||
|
||||
(gnc:hook-add-dangler gnc:*ui-startup-hook* gnc:report-menu-setup)
|
||||
(define (gnc:report-templates-for-each thunk)
|
||||
(hash-for-each (lambda (name template) (thunk name template))
|
||||
*gnc:_report-templates_*))
|
||||
|
@ -12,3 +12,4 @@
|
||||
(use-modules (gnucash report view-column))
|
||||
(use-modules (gnucash report welcome-to-gnucash))
|
||||
|
||||
(export gnc:make-welcome-report)
|
||||
|
@ -28,6 +28,9 @@
|
||||
|
||||
(define-module (gnucash report view-column))
|
||||
|
||||
(use-modules (ice-9 slib))
|
||||
(require 'printf)
|
||||
|
||||
(use-modules (gnucash gnc-module))
|
||||
(gnc:module-load "gnucash/report/report-system" 0)
|
||||
|
||||
|
@ -34,6 +34,84 @@
|
||||
val)))
|
||||
(setenv pathname new-value)))
|
||||
|
||||
(define (gnc:report-menu-setup)
|
||||
;; since this menu gets added to every child window, we say it
|
||||
;; comes after the "_File" menu.
|
||||
(define menu (gnc:make-menu gnc:menuname-reports (list "_File")))
|
||||
(define menu-namer (gnc:new-menu-namer))
|
||||
(define tax-menu (gnc:make-menu gnc:menuname-taxes
|
||||
(list gnc:menuname-reports "")))
|
||||
(define income-expense-menu
|
||||
(gnc:make-menu gnc:menuname-income-expense
|
||||
(list gnc:menuname-reports "")))
|
||||
(define asset-liability-menu
|
||||
(gnc:make-menu gnc:menuname-asset-liability
|
||||
(list gnc:menuname-reports "")))
|
||||
(define utility-menu
|
||||
(gnc:make-menu gnc:menuname-utility
|
||||
(list gnc:menuname-reports "")))
|
||||
(define menu-hash (make-hash-table 23))
|
||||
|
||||
(define (add-template-menu-item name template)
|
||||
(if (gnc:report-template-in-menu? template)
|
||||
(let ((title (string-append (_ "Report") ": " (_ name)))
|
||||
(menu-path (gnc:report-template-menu-path template))
|
||||
(menu-name (gnc:report-template-menu-name template))
|
||||
(menu-tip (gnc:report-template-menu-tip template))
|
||||
(item #f))
|
||||
|
||||
(if (not menu-path)
|
||||
(set! menu-path '(""))
|
||||
(set! menu-path
|
||||
(append menu-path '(""))))
|
||||
|
||||
(set! menu-path (append (list gnc:menuname-reports) menu-path))
|
||||
|
||||
(if menu-name (set! name menu-name))
|
||||
|
||||
(if (not menu-tip)
|
||||
(set! menu-tip
|
||||
(sprintf #f (_ "Display the %s report") (_ name))))
|
||||
|
||||
(set! item
|
||||
(gnc:make-menu-item
|
||||
((menu-namer 'add-name) name)
|
||||
menu-tip
|
||||
menu-path
|
||||
(lambda ()
|
||||
(let ((report (gnc:make-report
|
||||
(gnc:report-template-name template))))
|
||||
(gnc:main-window-open-report report #f)))))
|
||||
(gnc:add-extension item))))
|
||||
|
||||
(gnc:add-extension menu)
|
||||
|
||||
;; add the menu option to edit style sheets
|
||||
(gnc:add-extension
|
||||
(gnc:make-menu-item
|
||||
((menu-namer 'add-name) (_ "Style Sheets..."))
|
||||
(_ "Edit report style sheets.")
|
||||
(list "_Settings" "")
|
||||
(lambda ()
|
||||
(gnc:style-sheet-dialog-open))))
|
||||
|
||||
; (gnc:add-extension tax-menu)
|
||||
(gnc:add-extension income-expense-menu)
|
||||
(gnc:add-extension asset-liability-menu)
|
||||
(gnc:add-extension utility-menu)
|
||||
|
||||
;; push reports (new items added on top of menu)
|
||||
(gnc:report-templates-for-each add-template-menu-item)
|
||||
|
||||
;; the Welcome to Gnucash-1.6 extravaganza
|
||||
(gnc:add-extension
|
||||
(gnc:make-menu-item
|
||||
((menu-namer 'add-name) (_ "Welcome Extravaganza"))
|
||||
(_ "Welcome-to-GnuCash screen")
|
||||
(list gnc:menuname-reports gnc:menuname-utility "")
|
||||
(lambda ()
|
||||
(gnc:make-welcome-report)))))
|
||||
|
||||
(define (gnc:startup)
|
||||
(gnc:debug "starting up.")
|
||||
(gnc:setup-debugging)
|
||||
@ -90,6 +168,8 @@
|
||||
;; Clear the change flags caused by loading the configs
|
||||
(gnc:global-options-clear-changes)
|
||||
|
||||
(gnc:report-menu-setup)
|
||||
|
||||
(gnc:hook-run-danglers gnc:*startup-hook*)
|
||||
|
||||
;; Initialize the C side options code. Must come after the scheme
|
||||
|
Loading…
Reference in New Issue
Block a user