From 40f6ede615cc5d068b68d0d27e391a2e413d144e Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Mon, 1 Jul 2002 23:01:12 +0000 Subject: [PATCH] * Convert all (well, most all) HTML URL-generators to use gnc_build_url() (or gnc:html-build-url in scheme) instead of assuming the HTML prototype string. Unfortunately the help-window-index.scm cannot be fixed. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7060 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 6 ++++ src/gnome-utils/window-help.c | 4 +-- src/gnome/window-acct-tree.c | 5 ++- src/report/report-gnome/window-report.c | 4 ++- src/report/report-system/html-utilities.scm | 37 +++++++++++---------- src/report/report-system/report-system.scm | 1 + src/report/utility-reports/hello-world.scm | 12 ++++--- src/report/utility-reports/view-column.scm | 13 ++++++-- src/scm/help-topics-index.scm | 2 +- src/scm/main-window.scm | 5 +-- 10 files changed, 59 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9112782d8e..be341d720b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-07-01 Derek Atkins + * Convert all (well, most all) HTML URL-generators to use + gnc_build_url() (or gnc:html-build-url in scheme) instead of + assuming the HTML prototype string. Unfortunately the + help-window-index.scm cannot be fixed. + 2002-07-01 Joshua Sled * src/gnome-utils/gnc-dense-cal.c (gnc_dense_cal_mark_remove): diff --git a/src/gnome-utils/window-help.c b/src/gnome-utils/window-help.c index 7aee01297d..fcef7a2160 100644 --- a/src/gnome-utils/window-help.c +++ b/src/gnome-utils/window-help.c @@ -186,7 +186,7 @@ gnc_help_show_topic (gnc_help_window *help, const char * location) { char *help_loc; - help_loc = g_strconcat ("gnc-help:", location, NULL); + help_loc = gnc_build_url (URL_TYPE_HELP, location, NULL); if (safe_strcmp (help_loc, node_loc) != 0) node = NULL; g_free (help_loc); @@ -200,7 +200,7 @@ gnc_help_show_topic (gnc_help_window *help, const char * location) if (!node) { - char *help_loc = g_strconcat ("gnc-help:", location, NULL); + char *help_loc = gnc_build_url (URL_TYPE_HELP, location, NULL); node = gtk_ctree_find_by_row_data_custom (ctree, NULL, help_loc, compare_locations); g_free (help_loc); diff --git a/src/gnome/window-acct-tree.c b/src/gnome/window-acct-tree.c index 61b2ba37e0..37afa8559c 100644 --- a/src/gnome/window-acct-tree.c +++ b/src/gnome/window-acct-tree.c @@ -226,6 +226,7 @@ gnc_acct_tree_view_new(GnomeMDIChild * child, gpointer user_data) GNCMDIChildInfo * mc = g_new0(GNCMDIChildInfo, 1); GNCAcctTreeWin * win = gnc_acct_tree_window_new(child->name); GtkWidget * popup; + char * name_id; char * name; mc->contents = gnc_acct_tree_window_get_widget(win); @@ -242,8 +243,10 @@ gnc_acct_tree_view_new(GnomeMDIChild * child, gpointer user_data) gtk_object_set_user_data(GTK_OBJECT(child), mc); /* set the child name that will get used to save app state */ - name = g_strdup_printf("gnc-acct-tree:id=%d", win->options_id); + name_id = g_strdup_printf("id=%d", win->options_id); + name = gnc_build_url (URL_TYPE_ACCTTREE, name_id, NULL); gnome_mdi_child_set_name(mc->child, name); + g_free (name_id); g_free (name); gtk_signal_connect(GTK_OBJECT(child), "destroy", diff --git a/src/report/report-gnome/window-report.c b/src/report/report-gnome/window-report.c index 580378be7b..ee74cdf1b8 100644 --- a/src/report/report-gnome/window-report.c +++ b/src/report/report-gnome/window-report.c @@ -228,7 +228,9 @@ gnc_report_window_create_child(const gchar * configstring) { void gnc_main_window_open_report(int report_id, gint toplevel) { - char * child_name = g_strdup_printf("gnc-report:id=%d", report_id); + char * id_name = g_strdup_printf("id=%d", report_id); + char * child_name = gnc_build_url (URL_TYPE_REPORT, id_name, NULL); + g_free (id_name); gnc_main_window_open_report_url(child_name, toplevel); } diff --git a/src/report/report-system/html-utilities.scm b/src/report/report-system/html-utilities.scm index 57af3d2ced..5fd7688e76 100644 --- a/src/report/report-system/html-utilities.scm +++ b/src/report/report-system/html-utilities.scm @@ -26,30 +26,27 @@ (cons #f (gnc:html-make-empty-cells (- n 1))) '())) +(define (register-guid guid) + (gnc:html-build-url gnc:url-type-register (string-append "guid=" guid) #f)) + (define (gnc:account-anchor-text acct) - (string-append - "gnc-register:guid=" - (gnc:account-get-guid acct))) + (register-guid (gnc:account-get-guid acct))) (define (gnc:split-anchor-text split) - (string-append - "gnc-register:guid=" - (gnc:split-get-guid split))) + (register-guid (gnc:split-get-guid split))) (define (gnc:transaction-anchor-text trans) - (string-append - "gnc-register:guid=" - (gnc:transaction-get-guid trans))) + (register-guid (gnc:transaction-get-guid trans))) (define (gnc:report-anchor-text report-id) - (string-append - "gnc-report:id=" - (number->string report-id))) + (gnc:html-build-url gnc:url-type-report + (string-append "id=" (number->string report-id)) + #f)) (define (gnc:price-anchor-text price) - (string-append - "gnc-price:guid=" - (gnc:price-get-guid price))) + (gnc:html-build-url gnc:url-type-price + (string-append "guid=" (gnc:price-get-guid price)) + #f)) ;; Make a new report and return the anchor to it. The new report of ;; type 'reportname' will have the option values copied from @@ -722,7 +719,10 @@ p (gnc:html-markup-p (gnc:html-markup-anchor - (sprintf #f "gnc-options:report-id=%a" report-id) + (gnc:html-build-url gnc:url-type-options + (string-append "report-id=" + (sprintf #f "%a" report-id)) + #f) (_ "Edit report options"))))) p)) @@ -741,6 +741,9 @@ p (gnc:html-markup-p (gnc:html-markup-anchor - (sprintf #f "gnc-options:report-id=%a" report-id) + (gnc:html-build-url gnc:url-type-options + (string-append "report-id" + (sprintf #f "%a" report-id)) + #f) (_ "Edit report options"))))) p)) diff --git a/src/report/report-system/report-system.scm b/src/report/report-system/report-system.scm index 407f3d2936..f6f7b30e57 100644 --- a/src/report/report-system/report-system.scm +++ b/src/report/report-system/report-system.scm @@ -21,6 +21,7 @@ (gnc:module-load "gnucash/engine" 0) (gnc:module-load "gnucash/app-utils" 0) +(gnc:module-load "gnucash/gnome-utils" 0) ; for the html routines ;; commodity-utilities.scm (export gnc:commodity-is-currency?) diff --git a/src/report/utility-reports/hello-world.scm b/src/report/utility-reports/hello-world.scm index 73f86da635..7b56c03261 100644 --- a/src/report/utility-reports/hello-world.scm +++ b/src/report/utility-reports/hello-world.scm @@ -12,6 +12,7 @@ (debug-enable 'backtrace) (gnc:module-load "gnucash/report/report-system" 0) +(gnc:module-load "gnucash/gnome-utils" 0) ;for gnc:html-build-url ;; This function will generate a set of options that GnuCash ;; will use to display a dialog where the user can select @@ -429,7 +430,8 @@ new, totally cool report, consult the mailing list %s.") ;; need to do is pass the HREF "gnc-register:account=My ;; Account Name" to html-markup-anchor. The account name ;; passed must be the "full" account name that you get from - ;; gnc:account-get-full-name. + ;; gnc:account-get-full-name. You should build this url using + ;; (gnc:html-build-url ...) ;; ;; html-markup-anchor takes the link to jump to as its first ;; arg and then puts the remaining args in the body of the @@ -445,9 +447,11 @@ new, totally cool report, consult the mailing list %s.") (map (lambda (acct) (gnc:html-markup-anchor - (string-append - "gnc-register:account=" - (gnc:account-get-full-name acct)) + (gnc:html-build-url gnc:url-type-register + (string-append "account=" + (gnc:account-get-full-name + acct)) + #f) (gnc:account-get-name acct))) accounts)))) (gnc:html-document-add-object! diff --git a/src/report/utility-reports/view-column.scm b/src/report/utility-reports/view-column.scm index e4692babd4..545cb678b5 100644 --- a/src/report/utility-reports/view-column.scm +++ b/src/report/utility-reports/view-column.scm @@ -34,6 +34,7 @@ (require 'printf) (gnc:module-load "gnucash/report/report-system" 0) +(gnc:module-load "gnucash/gnome-utils" 0) ;for gnc:html-build-url (define (make-options) (let* ((options (gnc:new-options)) @@ -153,11 +154,19 @@ report-table (list (gnc:make-html-text (gnc:html-markup-anchor - (sprintf #f "gnc-options:report-id=%a" (car report-info)) + (gnc:html-build-url + gnc:url-type-options + (string-append "report-id=" + (sprintf #f "%a" (car report-info))) + #f) (_ "Edit Options")) " " (gnc:html-markup-anchor - (sprintf #f "gnc-report:id=%a" (car report-info)) + (gnc:html-build-url + gnc:url-type-report + (string-append "id=" + (sprintf #f "%a" (car report-info))) + #f) (_ "Single Report"))))) ;; add the report-table to the toplevel-cell diff --git a/src/scm/help-topics-index.scm b/src/scm/help-topics-index.scm index f1b148a292..091fc5b60d 100644 --- a/src/scm/help-topics-index.scm +++ b/src/scm/help-topics-index.scm @@ -1,4 +1,4 @@ -(((N_ "GnuCash Manual") "gnc-help:index.html" +(((N_ "GnuCash Manual") "gnc-help:index.html" (((N_ "Getting Started") "" (((N_ "Welcome") "gnc-help:xacc-quickstart.html" #f) ((N_ "Remedial Accounting 101") diff --git a/src/scm/main-window.scm b/src/scm/main-window.scm index 4f9554d1a0..612f248365 100644 --- a/src/scm/main-window.scm +++ b/src/scm/main-window.scm @@ -106,8 +106,9 @@ the account instead of opening a register.") #f)) (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\")\n\n" id))) + " \"" + (gnc:html-build-url gnc:url-type-accttree (sprintf #f "%a" id) #f) + "\")\n\n")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;