Регистрация | Войти
Lisp — программируемый язык программирования
icon.scm
Автор: motopeh - 2013-06-04T00:08:13.000000+04:00
(use-modules (system foreign))
(use-modules (ice-9 threads))
(use-modules (srfi srfi-1))

(define *icon-drawer-lib-path*
  (string-append (getenv "HOME")
                 "/.mu/modules/iconka/"
)
)


(define *icon-conditions*
  '((cond1 "mailbox1_is_128.png")
    (cond2 "mailbox2_empty_128.png")
    (cond3 "mailbox_blocked_128.png")
)
)


(define libicon
  (dynamic-link (string-append *icon-drawer-lib-path*
                               "libicon2.so"
)
)
)


(define cdraw-icon-in-tray
  (pointer->procedure void
                      (dynamic-func "draw_icon" libicon)
                      (list int '*)
)
)


(define cchange-icon-image
  (pointer->procedure int
                      (dynamic-func "change_icon" libicon)
                      (list '*)
)
)


(define *icon-drew?*
  (if (defined? '*icon-drew?*)
      *icon-drew?*
      #f
)
)


(define (draw-icon-in-tray)
  (unless *icon-drew?*
          (make-thread (cdraw-icon-in-tray 0 %null-pointer))
          (set! *icon-drew?* #t)
)
)


(define (change-icon-image path)
  (when (string? path)
        (cchange-icon-image (string->pointer
                             (string-append *icon-drawer-lib-path*
                                            "icons/"
                                            path
)
)
)
)
)


(define (set-icon icon)
  (when *icon-drew?*
        (let ((rule (find (lambda (x)
                            (eq? (car x)
                                 icon
)
)

                          *icon-conditions*
)
)
)

          (when rule
                (change-icon-image (cadr rule))
)
)
)
)


(use-modules (ice-9 readline))
(activate-readline)
@2009-2013 lisper.ru