[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r107526: Avoid superfluous registerin
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r107526: Avoid superfluous registering of signals. (Bug#10807) |
Date: |
Wed, 07 Mar 2012 08:48:16 +0100 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 107526
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Wed 2012-03-07 08:48:16 +0100
message:
Avoid superfluous registering of signals. (Bug#10807)
* notifications.el (notifications-on-action-object)
(notifications-on-close-object): New defvars.
(notifications-on-action-signal, notifications-on-closed-signal):
Unregister the signal if not needed any longer.
(notifications-notify): Register `notifications-action-signal' or
`notifications-closed-signal', if :on-action or :on-close has been
passed as argument.
modified:
lisp/ChangeLog
lisp/notifications.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-03-07 05:53:51 +0000
+++ b/lisp/ChangeLog 2012-03-07 07:48:16 +0000
@@ -1,3 +1,15 @@
+2012-03-07 Michael Albinus <address@hidden>
+
+ Avoid superfluous registering of signals. (Bug#10807)
+
+ * notifications.el (notifications-on-action-object)
+ (notifications-on-close-object): New defvars.
+ (notifications-on-action-signal, notifications-on-closed-signal):
+ Unregister the signal if not needed any longer.
+ (notifications-notify): Register `notifications-action-signal' or
+ `notifications-closed-signal', if :on-action or :on-close has been
+ passed as argument.
+
2012-03-07 Chong Yidong <address@hidden>
* cus-start.el: Avoid x-select-enable-clipboard-manager warning on
=== modified file 'lisp/notifications.el'
--- a/lisp/notifications.el 2012-03-04 14:12:18 +0000
+++ b/lisp/notifications.el 2012-03-07 07:48:16 +0000
@@ -88,25 +88,26 @@
(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)
- (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))
+ (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,16 +119,11 @@
(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))
+ (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,10 +283,29 @@
(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)))
+ (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))))
+ (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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r107526: Avoid superfluous registering of signals. (Bug#10807),
Michael Albinus <=