Регистрация | Войти
Lisp — программируемый язык программирования
icon.lisp
Автор: motopeh - 2013-06-04T00:00:12.000000+04:00
;; bordeaux-threads and cffi is required
(defpackage :status-icon-user
  (:use :cl)
)


(in-package :status-icon-user)

(defparameter *icon-drawer-lib-path*
  (merge-pathnames #P".mu/modules/iconka/"
                   (user-homedir-pathname)
)
)


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


(cffi:define-foreign-library (libicon :search-path *icon-drawer-lib-path*)
  (:unix "libicon2.so")
)


(defparameter *icon-drew?*
  (if (boundp '*icon-drew?*)
      *icon-drew?*
      nil
)
)


(cffi:use-foreign-library libicon)

(defun cdraw-icon-in-tray ()
  (cffi:foreign-funcall ("draw_icon" :library libicon)
                        :int 0
                        :pointer (cffi:null-pointer)
                        :int
)
)


(defun draw-icon-in-tray ()
  (unless *icon-drew?*
    (bt:make-thread
     (lambda ()
       (cdraw-icon-in-tray)
)
)

    (setf *icon-drew?* t)
)
)


(defun change-icon-image (path)
  (when (stringp path)
    (cffi:foreign-funcall ("change_icon" :library libicon)
                          :string (concatenate
                                   'string
                                   (namestring *icon-drawer-lib-path*)
                                   "icons/"
                                   path
)
)
)
)


(defun set-cond (cond)
  (when *icon-drew?*
    (let ((path (find cond
                      *icon-conditions*
                      :key #'car
)
)
)

      (when path
        (change-icon-image (cadr path))
)
)
)
)
@2009-2013 lisper.ru