aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2012-03-04 12:21:31 +0100
committerMichael Albinus2012-03-04 12:21:31 +0100
commitebeabff47e793ca13a0c54b1442d87060f709227 (patch)
treee7ef67e8bd64634242b35733ae1011d1c7c03af3
parente24b21b447b84731acf38d90e3f1e8a5094a0cc7 (diff)
downloademacs-ebeabff47e793ca13a0c54b1442d87060f709227.tar.gz
emacs-ebeabff47e793ca13a0c54b1442d87060f709227.zip
* notifications.el (notifications-unique-name): New defvar.
(notifications-on-action-signal, notifications-on-closed-signal): Check for unique service name of incoming event. (top): Register for signals with wildcard service name. (notifications-notify): Remember daemon unique service name.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/notifications.el21
2 files changed, 25 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c1edff57656..5392e197d9f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-03-04 Michael Albinus <michael.albinus@gmx.de>
2
3 * notifications.el (notifications-unique-name): New defvar.
4 (notifications-on-action-signal, notifications-on-closed-signal):
5 Check for unique service name of incoming event.
6 (top): Register for signals with wildcard service name.
7 (notifications-notify): Remember daemon unique service name.
8
12012-03-04 Chong Yidong <cyd@gnu.org> 92012-03-04 Chong Yidong <cyd@gnu.org>
2 10
3 * cus-start.el: Make x-select-enable-clipboard-manager 11 * cus-start.el: Make x-select-enable-clipboard-manager
diff --git a/lisp/notifications.el b/lisp/notifications.el
index 9f7576b3f5d..e0817631140 100644
--- a/lisp/notifications.el
+++ b/lisp/notifications.el
@@ -91,17 +91,24 @@
91(defvar notifications-on-close-map nil 91(defvar notifications-on-close-map nil
92 "Mapping between notification and close callback functions.") 92 "Mapping between notification and close callback functions.")
93 93
94(defvar notifications-unique-name ""
95 "Unique service name of notification daemon.
96This must be kept, because the notification daemon could be
97restarted, and the registered signals cannot be identified anymore.")
98
94(defun notifications-on-action-signal (id action) 99(defun notifications-on-action-signal (id action)
95 "Dispatch signals to callback functions from `notifications-on-action-map'." 100 "Dispatch signals to callback functions from `notifications-on-action-map'."
96 (let ((entry (assoc id notifications-on-action-map))) 101 (let ((entry (assoc id notifications-on-action-map)))
97 (when entry 102 (when (and entry
103 (string-equal notifications-unique-name
104 (dbus-event-service-name last-input-event)))
98 (funcall (cadr entry) id action) 105 (funcall (cadr entry) id action)
99 (remove entry 'notifications-on-action-map)))) 106 (remove entry 'notifications-on-action-map))))
100 107
101(when (fboundp 'dbus-register-signal) 108(when (fboundp 'dbus-register-signal)
102 (dbus-register-signal 109 (dbus-register-signal
103 :session 110 :session
104 notifications-service 111 nil
105 notifications-path 112 notifications-path
106 notifications-interface 113 notifications-interface
107 notifications-action-signal 114 notifications-action-signal
@@ -113,7 +120,9 @@
113 ;; make it optional, and assume `undefined' as default. 120 ;; make it optional, and assume `undefined' as default.
114 (let ((entry (assoc id notifications-on-close-map)) 121 (let ((entry (assoc id notifications-on-close-map))
115 (reason (or reason 4))) 122 (reason (or reason 4)))
116 (when entry 123 (when (and entry
124 (string-equal notifications-unique-name
125 (dbus-event-service-name last-input-event)))
117 (funcall (cadr entry) 126 (funcall (cadr entry)
118 id (cadr (assoc reason notifications-closed-reason))) 127 id (cadr (assoc reason notifications-closed-reason)))
119 (remove entry 'notifications-on-close-map)))) 128 (remove entry 'notifications-on-close-map))))
@@ -121,7 +130,7 @@
121(when (fboundp 'dbus-register-signal) 130(when (fboundp 'dbus-register-signal)
122 (dbus-register-signal 131 (dbus-register-signal
123 :session 132 :session
124 notifications-service 133 nil
125 notifications-path 134 notifications-path
126 notifications-interface 135 notifications-interface
127 notifications-closed-signal 136 notifications-closed-signal
@@ -277,6 +286,10 @@ used to manipulate the notification item with
277 (or hints '(:array :signature "{sv}")) 286 (or hints '(:array :signature "{sv}"))
278 :int32 (or timeout -1))) 287 :int32 (or timeout -1)))
279 288
289 ;; Remember daemon unique service name.
290 (setq notifications-unique-name
291 (dbus-get-name-owner :session notifications-service))
292
280 ;; Register close/action callback function 293 ;; Register close/action callback function
281 (let ((on-action (plist-get params :on-action)) 294 (let ((on-action (plist-get params :on-action))
282 (on-close (plist-get params :on-close))) 295 (on-close (plist-get params :on-close)))