From: Michael Albinus <michael.albinus@gmx.de>
To: "Peter Münster" <pmlists@free.fr>
Cc: help-gnu-emacs@gnu.org
Subject: Re: notifications-notify resets idle-time
Date: Tue, 06 Mar 2012 11:34:08 +0100 [thread overview]
Message-ID: <87wr6yvx0f.fsf@gmx.de> (raw)
In-Reply-To: 87fwdogiv5.fsf@micropit.couberia.bzh
Peter Münster <pmlists@free.fr> writes:
Hi Peter,
> It seems, that I rather need dbus-unregister-object, because I only want
> to unregister the closed-signal, not the action-signal. So I patched
> notifications.el:
I have generalized your patch. It is not needed anymore to call
`dbus-unregister-object' in your code.
Could you, please, check whether it fits your needs? Note that this
patch is based on notifications.el as I have committed to the trunk two
days ago,
--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs/lisp/notifications.el.~107516~ 2012-03-06 11:18:32.000000000 +0100
--- /home/albinus/src/emacs/lisp/notifications.el 2012-03-06 11:18:32.000000000 +0100
***************
*** 88,112 ****
(defvar notifications-on-action-map nil
"Mapping between notification and action callback functions.")
(defvar notifications-on-close-map nil
"Mapping between notification and close callback functions.")
(defun notifications-on-action-signal (id action)
"Dispatch signals to callback functions from `notifications-on-action-map'."
(let* ((unique-name (dbus-event-service-name last-input-event))
(entry (assoc (cons unique-name id) notifications-on-action-map)))
(when entry
(funcall (cadr entry) id action)
! (remove entry notifications-on-action-map))))
!
! (when (fboundp 'dbus-register-signal)
! (dbus-register-signal
! :session
! nil
! notifications-path
! notifications-interface
! notifications-action-signal
! 'notifications-on-action-signal))
(defun notifications-on-closed-signal (id &optional reason)
"Dispatch signals to callback functions from `notifications-on-closed-map'."
--- 88,113 ----
(defvar notifications-on-action-map nil
"Mapping between notification and action callback functions.")
+ (defvar notifications-on-action-object nil
+ "Object for registered on-action signal.")
+
(defvar notifications-on-close-map nil
"Mapping between notification and close callback functions.")
+ (defvar notifications-on-close-object nil
+ "Object for registered on-close signal.")
+
(defun notifications-on-action-signal (id action)
"Dispatch signals to callback functions from `notifications-on-action-map'."
(let* ((unique-name (dbus-event-service-name last-input-event))
(entry (assoc (cons unique-name id) notifications-on-action-map)))
(when entry
(funcall (cadr entry) id action)
! (when (and (not (setq notifications-on-action-map
! (remove entry notifications-on-action-map)))
! notifications-on-action-object)
! (dbus-unregister-object notifications-on-action-object)
! (setq notifications-on-action-object nil)))))
(defun notifications-on-closed-signal (id &optional reason)
"Dispatch signals to callback functions from `notifications-on-closed-map'."
***************
*** 118,133 ****
(when entry
(funcall (cadr entry)
id (cadr (assoc reason notifications-closed-reason)))
! (remove entry notifications-on-close-map))))
!
! (when (fboundp 'dbus-register-signal)
! (dbus-register-signal
! :session
! nil
! notifications-path
! notifications-interface
! notifications-closed-signal
! 'notifications-on-closed-signal))
(defun notifications-notify (&rest params)
"Send notification via D-Bus using the Freedesktop notification protocol.
--- 119,129 ----
(when entry
(funcall (cadr entry)
id (cadr (assoc reason notifications-closed-reason)))
! (when (and (not (setq notifications-on-close-map
! (remove entry notifications-on-close-map)))
! notifications-on-close-object)
! (dbus-unregister-object notifications-on-close-object)
! (setq notifications-on-close-object nil)))))
(defun notifications-notify (&rest params)
"Send notification via D-Bus using the Freedesktop notification protocol.
***************
*** 287,296 ****
(unique-name (dbus-get-name-owner :session notifications-service)))
(when on-action
(add-to-list 'notifications-on-action-map
! (list (cons unique-name id) on-action)))
(when on-close
(add-to-list 'notifications-on-close-map
! (list (cons unique-name id) on-close))))
;; Return notification id
id))
--- 283,311 ----
(unique-name (dbus-get-name-owner :session notifications-service)))
(when on-action
(add-to-list 'notifications-on-action-map
! (list (cons unique-name id) on-action))
! (unless notifications-on-action-object
! (setq notifications-on-action-object
! (dbus-register-signal
! :session
! nil
! notifications-path
! notifications-interface
! notifications-action-signal
! 'notifications-on-action-signal))))
!
(when on-close
(add-to-list 'notifications-on-close-map
! (list (cons unique-name id) on-close))
! (unless notifications-on-close-object
! (setq notifications-on-close-object
! (dbus-register-signal
! :session
! nil
! notifications-path
! notifications-interface
! notifications-closed-signal
! 'notifications-on-closed-signal)))))
;; Return notification id
id))
--8<---------------cut here---------------end--------------->8---
If that works for you, I would be willing to commit it to the trunk,
still for Emacs 24.1. We could close then also bug#10807.
Best regards, Michael.
next prev parent reply other threads:[~2012-03-06 10:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 22:08 notifications-notify resets idle-time Peter Münster
2012-02-11 9:57 ` Michael Albinus
2012-02-11 11:38 ` Peter Münster
2012-02-11 12:40 ` Michael Albinus
2012-02-11 12:51 ` Peter Münster
2012-02-11 16:00 ` Michael Albinus
2012-02-11 16:38 ` Peter Münster
2012-02-11 17:26 ` Michael Albinus
2012-02-11 19:06 ` Peter Münster
2012-02-12 9:16 ` Michael Albinus
2012-02-12 11:09 ` Peter Münster
2012-02-12 11:59 ` Michael Albinus
2012-02-12 20:37 ` Peter Münster
2012-02-12 21:17 ` Michael Albinus
2012-02-13 8:29 ` Peter Münster
2012-02-13 11:53 ` Michael Albinus
2012-02-13 15:42 ` Peter Münster
2012-02-13 16:43 ` Michael Albinus
2012-02-13 23:13 ` Peter Münster
2012-02-14 9:45 ` Michael Albinus
2012-03-04 21:24 ` Peter Münster
2012-03-05 14:51 ` Michael Albinus
2012-03-06 10:34 ` Michael Albinus [this message]
2012-03-06 14:53 ` Peter Münster
2012-03-07 7:58 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wr6yvx0f.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=help-gnu-emacs@gnu.org \
--cc=pmlists@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.