(in-package :alexg-custom) (use-package :oli) (let ( (*notification-browser* "Notification-Browser") (*notification-cnt* 0)) (defun hide-output-box (&rest args) (display :clear-hide)) (defun redirect-output-box (&rest args) (let ( (date-time-formated (get-date-time-formated)) (output-box-txt (sd-get-text-control-value "OUTPUT-BOX-TX"))) (when (and output-box-txt (not (string-equal "" output-box-txt))) (display :clear-hide) (let* ( (notification-node (sd-create-browsernode :tree *notification-browser* :parent *notification-root* :objPname (format nil "~a - [~a]" date-time-formated (incf *notification-cnt*)))) (node-struct (sd-get-browsernode-struct *notification-browser* notification-node))) (dolist (line (sd-string-split output-box-txt #\Newline)) (sd-create-browsernode :tree *notification-browser* :parent notification-node :objPname line)) (sd-browser-exec-cmd *notification-browser* :expand-tree 1) (sd-browser-exec-cmd *notification-browser* :set-object-expansion node-struct t) (sd-browser-exec-cmd *notification-browser* :display-tree))))) (defun create-notification-browser () (sd-create-browser-tree *notification-browser* :update-events *sd-update-screen-event* :update-func 'redirect-output-box) (setq *notification-root* (sd-create-browsernode :tree *notification-browser* :parent nil :objPname "Notifications")) (sd-create-graphical-browser *notification-browser* :tree *notification-browser* :createAsTab t :tabname "Notification-Browser" :topLabel "Notification-Browser") (sd-dock-graphical-browser *notification-browser* :show nil) ) (defun activate-notification-browser () (create-notification-browser)) (defun deactivate-notification-browser () (sd-destroy-graphical-browser *notification-browser*) (sd-destroy-browser-tree *notification-browser*)) (defun get-date-time-formated () (let (date-time-string) (multiple-value-bind (second minute hour date month year day-of-week dst-p tz) (get-decoded-time) (setq date-time-string (format nil "~d-~d-~2,'0d ~2,'0d:~2,'0d:~2,'0d" year month date hour minute second))) date-time-string)) (sd-defdialog 'irksome-notification-aid :dialog-title "Irksome Notification Aid" :toolbox-button t :variables '( (default-notifications :title "Default notifications (Outputbox)" :toggle-type :wide-toggle :value-type :boolean) (browser-notifications :title "Browser notifications" :toggle-type :wide-toggle :value-type :boolean) (no-notifications :title "No notifications" :value-type :boolean :toggle-type :wide-toggle)) :mutual-exclusion '(default-notifications no-notifications browser-notifications) :ok-action '(cond (default-notifications (progn (sd-unsubscribe-event *sd-update-screen-event* 'hide-output-box) (deactivate-notification-browser))) (browser-notifications (progn (sd-unsubscribe-event *sd-update-screen-event* 'hide-output-box) (activate-notification-browser))) (no-notifications (progn (sd-subscribe-event *sd-update-screen-event* 'hide-output-box) (deactivate-notification-browser))))))