xwem-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XWEM]: Re: Adding things to xwem-tray


From: Zajcev Evgeny
Subject: Re: [XWEM]: Re: Adding things to xwem-tray
Date: Fri, 09 Apr 2004 12:33:53 +0400
User-agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.5 (celery, berkeley-unix)

Steve Youngs <address@hidden> writes:

[skip]
>
> ;; Display the date in the bottom right of screen using OSD
> (require 'xwem-osd)
> (copy-face 'default 'sy-osd-face)
> (set-face-foreground 'sy-osd-face "cyan")
>
> (defun sy-show-date-osd ()
>   (let* ((fromleft 830)
>        (fromtop 740)
>        (face `sy-osd-face)
>        (text (format-time-string "%a, %b%e")))
>     (setq sy-osd (xwem-osd-create (xwem-dpy) fromleft fromtop 400 200))
>     (xwem-osd-set-color sy-osd (face-foreground-name face))
>     (xwem-osd-set-font sy-osd (face-font-name face))
>     (xwem-osd-text sy-osd text)
>     (xwem-osd-show sy-osd)))
>
> (defun sy-hide-date-osd ()
>   (xwem-osd-hide sy-osd))
>
> (defun sy-update-osd-date-maybe ()
>   (let* ((now (decode-time))
>        (cur-hour (nth 2 now))
>        (cur-min (nth 1 now))
>        (cur-comp-time (+ (* cur-hour 60) cur-min)))
>     (when (= 0 cur-comp-time)
>       (sy-hide-date-osd)
>       (sy-show-date-osd))))
>
> (add-hook 'xwem-after-init-hook 'sy-show-date-osd)
>
> (start-itimer "sy-osd-date-itimer"
>             'sy-update-osd-date-maybe
>             60 60)

Oh, i just realized that there a little problem, each time you create
OSDs, but never destroy them.

I think stuff should look like this:

  (defun sy-update-osd-date-maybe (&optional force-update)
    (let* ((now (decode-time))
           (cur-hour (nth 2 now))
           (cur-min (nth 1 now))
           (cur-comp-time (+ (* cur-hour 60) cur-min)))
      (when (or force-update (= 0 cur-comp-time))
        (xwem-osd-text sy-osd (format-time-string "%a, %b%e")))))
  
  (defun sy-show-date-osd ()
    (let* ((fromleft 830)
           (fromtop 740)
           (face `sy-osd-face)
           (xwem-osd-always-ontop t))  ; Force date to be always ontop
      (setq sy-osd (xwem-osd-create (xwem-dpy) fromleft fromtop 400 200))
      (xwem-osd-set-color sy-osd (face-foreground-name face))
      (xwem-osd-set-font sy-osd (face-font-name face))
      (sy-update-osd-date-maybe t)
      (xwem-osd-show sy-osd)

      (start-itimer "sy-osd-date-itimer"
                    'sy-update-osd-date-maybe
                    60 60)))

  (defun sy-destroy-date-osd ()
    (delete-itimer  "sy-osd-date-itimer")
    (when (xwem-osd-p sy-osd)
      (xwem-osd-destroy sy-osd)))
  
  (defun sy-hide-date-osd ()
    (xwem-osd-hide sy-osd))
  
  (add-hook 'xwem-after-init-hook 'sy-show-date-osd)

So OSD once created, reused when updating date string.

-- 
lg




reply via email to

[Prev in Thread] Current Thread [Next in Thread]