Skip to content

Commit

Permalink
[modularise] (gnucash gnome-utils)
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Dec 8, 2020
1 parent 33dd169 commit dd4b88c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 59 deletions.
11 changes: 5 additions & 6 deletions gnucash/gnome-utils/CMakeLists.txt
Expand Up @@ -261,17 +261,16 @@ install(FILES ${gnome_utils_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gnu
set(GUILE_DEPENDS gnc-gnome-utils scm-engine scm-app-utils)

gnc_add_scheme_targets(scm-gnome-utils-1
SOURCES gnome-utils.scm
OUTPUT_DIR gnucash
DEPENDS "${GUILE_DEPENDS}")


gnc_add_scheme_targets(scm-gnome-utils-2
SOURCES gnc-menu-extensions.scm
OUTPUT_DIR "gnucash/gnome-utils"
DEPENDS "${GUILE_DEPENDS}"
MAKE_LINKS)

gnc_add_scheme_targets(scm-gnome-utils-2
SOURCES gnome-utils.scm
OUTPUT_DIR gnucash
DEPENDS "scm-gnome-utils-1")

add_custom_target(scm-gnome-utils ALL DEPENDS scm-gnome-utils-2 scm-gnome-utils-1)

set_local_dist(gnome_utils_DIST_local CMakeLists.txt ${gnome_utils_SOURCES} ${gnome_utils_HEADERS}
Expand Down
56 changes: 23 additions & 33 deletions gnucash/gnome-utils/gnc-menu-extensions.scm
Expand Up @@ -15,40 +15,30 @@
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
;; Boston, MA 02110-1301, USA gnu@gnu.org

(define (gnc:make-extension
;; The type of extension item, either 'menu, 'menu-item, or 'separator
type
;; The name of the extension in the menu
name
;; The guid of object the menu will refer to
guid
;; The tooltip
documentation-string
;; A list of names indicating the menus under which this item is
;; located. The last item indicates the item *after* which this
;; extension will go.
path
;; The script to call when the menu item is selected
script)
(vector type
name
guid
documentation-string
path
script))
(define-module (gnucash gnome-utils gnc-menu-extensions))

(define (gnc:extension-type extension)
(vector-ref extension 0))
(define (gnc:extension-name extension)
(vector-ref extension 1))
(define (gnc:extension-guid extension)
(vector-ref extension 2))
(define (gnc:extension-documentation extension)
(vector-ref extension 3))
(define (gnc:extension-path extension)
(vector-ref extension 4))
(define (gnc:extension-script extension)
(vector-ref extension 5))
(use-modules (srfi srfi-9))

(export gnc:extension-documentation)
(export gnc:extension-guid)
(export gnc:extension-name)
(export gnc:extension-path)
(export gnc:extension-script)
(export gnc:extension-type)
(export gnc:make-extension)
(export gnc:make-menu)
(export gnc:make-menu-item)
(export gnc:make-separator)

(define-record-type :extension
(gnc:make-extension type name guid documentation-string path script)
:extension?
(type gnc:extension-type)
(name gnc:extension-name)
(guid gnc:extension-guid)
(documentation-string gnc:extension-documentation)
(path gnc:extension-path)
(script gnc:extension-script))

(define (gnc:make-menu-item name guid documentation-string path script)
(gnc:make-extension 'menu-item name guid documentation-string path script))
Expand Down
26 changes: 6 additions & 20 deletions gnucash/gnome-utils/gnome-utils.scm
Expand Up @@ -19,30 +19,16 @@

(define-module (gnucash gnome-utils))

(use-modules (gnucash engine))
(use-modules (gnucash utilities))
(use-modules (gnucash app-utils))

(eval-when (compile load eval expand)
(load-extension "libgnc-gnome-utils" "scm_init_sw_gnome_utils_module"))
(use-modules (sw_gnome_utils))

; Export the swig-wrapped symbols in the public interface of this module
(let ((i (module-public-interface (current-module))))
(module-use! i (resolve-interface '(sw_gnome_utils))))

;; from gnc-menu-extensions.scm
(export gnc:extension-type)
(export gnc:extension-name)
(export gnc:extension-guid)
(export gnc:extension-documentation)
(export gnc:extension-path)
(export gnc:extension-script)
(export gnc:make-menu-item)
(export gnc:make-menu)
(export gnc:make-separator)
(use-modules (gnucash core-utils))
(use-modules (gnucash engine))
(use-modules (gnucash utilities))
(use-modules (gnucash app-utils))

(load-from-path "gnucash/gnome-utils/gnc-menu-extensions")
(load-and-reexport (sw_gnome_utils)
(gnucash gnome-utils gnc-menu-extensions))

;; this function will receive 1 boolean argument, and can be used for
;; any UI init/shutdown routines. For now it will set the
Expand Down

0 comments on commit dd4b88c

Please sign in to comment.