mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
[gnome-utils] add gnc:gui-warn/error/msg global functions
gnc:gui-[warn|error|msg] are new global functions. By default they mirror gnc:warn/error/msg. However then gnome is available, they will display appropriate warn/error/info dialog in addition to outputting to console.
This commit is contained in:
parent
65bfeaf5de
commit
a731c9ed9a
@ -647,11 +647,15 @@ gnc_ui_start_event_loop (void)
|
||||
id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 10000, /* 10 secs */
|
||||
gnc_ui_check_events, NULL, NULL);
|
||||
|
||||
scm_call_1(scm_c_eval_string("gnc:set-ui-status"), SCM_BOOL_T);
|
||||
|
||||
/* Enter gnome event loop */
|
||||
gtk_main ();
|
||||
|
||||
g_source_remove (id);
|
||||
|
||||
scm_call_1(scm_c_eval_string("gnc:set-ui-status"), SCM_BOOL_F);
|
||||
|
||||
gnome_is_running = FALSE;
|
||||
gnome_is_terminating = FALSE;
|
||||
|
||||
|
@ -41,3 +41,27 @@
|
||||
|
||||
(load-from-path "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
|
||||
;; gnc:ui-warn/error/msg tracefile routines to display dialog messages
|
||||
;; in addition to tracefile logging.
|
||||
(define-public gnc:set-ui-status
|
||||
(let ((save-warn gnc:gui-warn)
|
||||
(save-error gnc:gui-error)
|
||||
(save-msg gnc:gui-msg))
|
||||
(lambda (status)
|
||||
(cond
|
||||
(status
|
||||
(set! gnc:gui-warn (lambda (constr guistr)
|
||||
(save-warn constr guistr)
|
||||
(gnc-warning-dialog '() guistr)))
|
||||
(set! gnc:gui-error (lambda (constr guistr)
|
||||
(save-error constr guistr)
|
||||
(gnc-error-dialog '() guistr)))
|
||||
(set! gnc:gui-msg (lambda (constr guistr)
|
||||
(save-msg constr guistr)
|
||||
(gnc-info-dialog '() guistr))))
|
||||
(else
|
||||
(set! gnc:gui-warn save-warn)
|
||||
(set! gnc:gui-error save-error)
|
||||
(set! gnc:gui-msg save-msg))))))
|
||||
|
@ -72,6 +72,13 @@
|
||||
(define (gnc:debug . items)
|
||||
(gnc-scm-log-debug (strify items)))
|
||||
|
||||
;; the following functions are initialized to log message to tracefile
|
||||
;; and will be redefined in UI initialization to display dialog
|
||||
;; messages
|
||||
(define-public (gnc:gui-warn str1 str2) (gnc:warn str1))
|
||||
(define-public (gnc:gui-error str1 str2) (gnc:error str1))
|
||||
(define-public (gnc:gui-msg str1 str2) (gnc:msg str1))
|
||||
|
||||
(define-syntax addto!
|
||||
(syntax-rules ()
|
||||
((addto! alist element)
|
||||
|
Loading…
Reference in New Issue
Block a user