On Tue, Nov 29 2022, john wrote: > Is this possible? Is it documented somewhere? > > > Yes, it's possible. No, it's not documented. > > See the definition of gnc:add-report-template-menu-item at https:// > github.com/Gnucash/gnucash/blob/maint/gnucash/gnome/report-menus.scm# > L42 for example code. It's all specialized for report templates so > you'll have to copy and modify a lot of code. Note the convention > that functions starting with gnc: are written in Scheme and those > starting with gnc- or xacc are written in C and exposed to Guile via > SWIG.
Thank you. With this I was able to add a command to the Tools menu. (See the attached file, in case somebody is interested.) Can the same strategy also be used to add items to the popup menu? I'm mostly asking if I should look harder or if it is not possible because there are no Scheme bindings for the popup menu. Similarly, is there a Scheme binding for gnc_plugin_page_account_tree_get_current_account? Helmut
;; ;; This example shows how to add a menu item from Scheme. The code ;; adds the menu item "Tools/Scheme REPL" and the corresponding ;; command starts a Scheme REPL in the tty. ;; ;; Installation: ;; ;; 1.) Place this file somewhere in your file system. ;; E.g. in ~/hacking/gnucash/commands/repl.scm ;; ;; 2.) Add something like this to your ~/.config/gnucash/config-user.scm: ;; ;; (add-to-load-path "/home/helmut/hacking/gnucash/") ;; (import (only (commands repl) register-repl-command)) ;; (register-repl-command) ;; ;; 3.) Start GnuCash as usual ;; (library (commands repl) (export register-repl-command) (import (rnrs base) (only (guile) format getenv resolve-module current-module set-current-module save-module-excursion) (only (system repl repl) start-repl) (only (ice-9 readline) activate-readline write-history read-history) (only (gnucash gnome-utils) gnc-add-scm-extension) (only (gnucash gnome-utils gnc-menu-extensions) gnc:make-menu-item) (only (gnucash core-utils) G_ N_)) (define history-filename (format #f "~a/.gnucash_history" (getenv "HOME"))) (define previous-module #f) (define (repl) (save-module-excursion (lambda () (set-current-module (or previous-module (begin (activate-readline) (read-history history-filename) (resolve-module '(guile-user))))) (start-repl) (set! previous-module (current-module)) (write-history history-filename) (format #t "Goodbye~%")))) (define menuname-tools (N_ "Tools")) (define (register-repl-command) (gnc-add-scm-extension (gnc:make-menu-item "Scheme REPL" "0155032a4b41443388f6cf8effc98169" "Start a Scheme REPL in the tty" (list menuname-tools) (lambda (window) (format #t "window: ~s~%" window) (repl))))) )
_______________________________________________ gnucash-user mailing list gnucash-user@gnucash.org To update your subscription preferences or to unsubscribe: https://lists.gnucash.org/mailman/listinfo/gnucash-user ----- Please remember to CC this list on all your replies. You can do this by using Reply-To-List or Reply-All.