annotate lisp/notifications.el @ 109668:d9a022ec322c

Remove extern declarations in .c files, .h files have them. * src/xterm.c: * src/xdisp.c: * src/process.c: * src/msdos.c: * src/image.c: * src/gtkutil.c: * src/fileio.c: * src/eval.c: Remove declarations.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 06 Aug 2010 12:07:16 -0700
parents 89ec3a7ebb87
children cc0ad61fb2a4 14e479cda1d2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1 ;;; notifications.el --- Client interface to desktop notifications.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
2
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
4
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
5 ;; Author: Julien Danjou <julien@danjou.info>
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
6 ;; Keywords: comm desktop notifications
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
7
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
9
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
13 ;; (at your option) any later version.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
14
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
18 ;; GNU General Public License for more details.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
19
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
22
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
23 ;;; Commentary:
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
24
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
25 ;; This package provides an implementation of the Desktop Notifications
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
26 ;; <http://www.galago-project.org/specs/notification/>.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
27
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
28 ;; In order to activate this package, you must add the following code
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
29 ;; into your .emacs:
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
30 ;;
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
31 ;; (require 'notifications)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
32
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
33 ;;; Code:
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
34 (eval-when-compile
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
35 (require 'cl))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
36
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
37 ;; Pacify byte-compiler. D-Bus support in the Emacs core can be
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
38 ;; disabled with configuration option "--without-dbus". Declare used
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
39 ;; subroutines and variables of `dbus' therefore.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
40 (declare-function dbus-call-method "dbusbind.c")
108920
838873812c0a * net/notifications.el (dbus-register-signal): Declare function.
Juanma Barranquero <lekktu@gmail.com>
parents: 108918
diff changeset
41 (declare-function dbus-register-signal "dbusbind.c")
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
42
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
43 (require 'dbus)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
44
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
45 (defconst notifications-application-name "Emacs"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
46 "Default application name.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
47
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
48 (defconst notifications-application-icon
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
49 (expand-file-name
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
50 "images/icons/hicolor/scalable/apps/emacs.svg"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
51 data-directory)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
52 "Default application icon.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
53
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
54 (defconst notifications-service "org.freedesktop.Notifications"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
55 "D-Bus notifications service name.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
56
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
57 (defconst notifications-path "/org/freedesktop/Notifications"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
58 "D-Bus notifications service path.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
59
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
60 (defconst notifications-interface "org.freedesktop.Notifications"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
61 "D-Bus notifications service path.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
62
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
63 (defconst notifications-notify-method "Notify"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
64 "D-Bus notifications service path.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
65
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
66 (defconst notifications-close-notification-method "CloseNotification"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
67 "D-Bus notifications service path.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
68
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
69 (defconst notifications-action-signal "ActionInvoked"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
70 "D-Bus notifications action signal.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
71
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
72 (defconst notifications-closed-signal "NotificationClosed"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
73 "D-Bus notifications closed signal.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
74
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
75 (defconst notifications-closed-reason
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
76 '((1 expired)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
77 (2 dismissed)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
78 (3 close-notification)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
79 (4 undefined))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
80 "List of reasons why a notification has been closed.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
81
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
82 (defvar notifications-on-action-map nil
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
83 "Mapping between notification and action callback functions.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
84
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
85 (defvar notifications-on-close-map nil
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
86 "Mapping between notification and close callback functions.")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
87
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
88 (defun notifications-on-action-signal (id action)
108964
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
89 "Dispatch signals to callback functions from `notifications-on-action-map'."
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
90 (let ((entry (assoc id notifications-on-action-map)))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
91 (when entry
108964
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
92 (funcall (cadr entry) id action)
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
93 (remove entry 'notifications-on-action-map))))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
94
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
95 (dbus-register-signal
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
96 :session
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
97 notifications-service
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
98 notifications-path
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
99 notifications-interface
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
100 notifications-action-signal
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
101 'notifications-on-action-signal)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
102
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
103 (defun notifications-on-closed-signal (id reason)
108964
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
104 "Dispatch signals to callback functions from `notifications-on-closed-map'."
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
105 (let ((entry (assoc id notifications-on-close-map)))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
106 (when entry
108964
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
107 (funcall (cadr entry)
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
108 id (cadr (assoc reason notifications-closed-reason)))
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
109 (remove entry 'notifications-on-close-map))))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
110
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
111 (dbus-register-signal
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
112 :session
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
113 notifications-service
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
114 notifications-path
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
115 notifications-interface
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
116 notifications-closed-signal
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
117 'notifications-on-closed-signal)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
118
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
119 (defun notifications-notify (&rest params)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
120 "Send notification via D-Bus using the Freedesktop notification protocol.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
121 Various PARAMS can be set:
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
122
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
123 :title The notification title.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
124 :body The notification body text.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
125 :app-name The name of the application sending the notification.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
126 Default to `notifications-application-name'.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
127 :replaces-id The notification ID that this notification replaces.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
128 :app-icon The notification icon.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
129 Default is `notifications-application-icon'.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
130 Set to nil if you do not want any icon displayed.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
131 :actions A list of actions in the form:
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
132 (KEY TITLE KEY TITLE ...)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
133 where KEY and TITLE are both strings.
108920
838873812c0a * net/notifications.el (dbus-register-signal): Declare function.
Juanma Barranquero <lekktu@gmail.com>
parents: 108918
diff changeset
134 The default action (usually invoked by clicking the
838873812c0a * net/notifications.el (dbus-register-signal): Declare function.
Juanma Barranquero <lekktu@gmail.com>
parents: 108918
diff changeset
135 notification) should have a key named \"default\".
108925
515ffffc30e6 * net/notifications.el (notifications-notify): Fix docstring.
Michael Albinus <albinus@detlef>
parents: 108920
diff changeset
136 The title can be anything, though implementations are free
108920
838873812c0a * net/notifications.el (dbus-register-signal): Declare function.
Juanma Barranquero <lekktu@gmail.com>
parents: 108918
diff changeset
137 not to display it.
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
138 :timeout The timeout time in milliseconds since the display
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
139 of the notification at which the notification should
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
140 automatically close.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
141 If -1, the notification's expiration time is dependent
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
142 on the notification server's settings, and may vary for
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
143 the type of notification.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
144 If 0, the notification never expires.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
145 Default value is -1.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
146 :urgency The urgency level.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
147 Either `low', `normal' or `critical'.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
148 :category The type of notification this is.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
149 :desktop-entry This specifies the name of the desktop filename representing
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
150 the calling program.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
151 :image-data This is a raw data image format which describes the width,
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
152 height, rowstride, has alpha, bits per sample, channels and
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
153 image data respectively.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
154 :sound-file The path to a sound file to play when the notification pops up.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
155 :suppress-sound Causes the server to suppress playing any sounds, if it has
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
156 that ability.
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
157 :x Specifies the X location on the screen that the notification
108920
838873812c0a * net/notifications.el (dbus-register-signal): Declare function.
Juanma Barranquero <lekktu@gmail.com>
parents: 108918
diff changeset
158 should point to. The \"y\" hint must also be specified.
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
159 :y Specifies the Y location on the screen that the notification
108920
838873812c0a * net/notifications.el (dbus-register-signal): Declare function.
Juanma Barranquero <lekktu@gmail.com>
parents: 108918
diff changeset
160 should point to. The \"x\" hint must also be specified.
108964
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
161 :on-action Function to call when an action is invoked.
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
162 The notification id and the key of the action are passed
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
163 as arguments to the function.
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
164 :on-close Function to call when the notification has been closed
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
165 by timeout or by the user.
108964
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
166 The function receive the notification id and the closing
da553d450193 * net/notifications.el (notifications-on-action-signal)
Michael Albinus <michael.albinus@gmx.de>
parents: 108925
diff changeset
167 reason as arguments:
108916
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
168 - `expired' if the notification has expired
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
169 - `dismissed' if the notification was dismissed by the user
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
170 - `close-notification' if the notification was closed
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
171 by a call to CloseNotification
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
172
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
173 This function returns a notification id, an integer, which can be
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
174 used to manipulate the notification item with
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
175 `notifications-close'."
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
176 (let ((title (plist-get params :title))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
177 (body (plist-get params :body))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
178 (app-name (plist-get params :app-name))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
179 (replaces-id (plist-get params :replaces-id))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
180 (app-icon (plist-get params :app-icon))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
181 (actions (plist-get params :actions))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
182 (timeout (plist-get params :timeout))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
183 ;; Hints
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
184 (hints '())
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
185 (urgency (plist-get params :urgency))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
186 (category (plist-get params :category))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
187 (desktop-entry (plist-get params :desktop-entry))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
188 (image-data (plist-get params :image-data))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
189 (sound-file (plist-get params :sound-file))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
190 (suppress-sound (plist-get params :suppress-sound))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
191 (x (plist-get params :x))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
192 (y (plist-get params :y))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
193 id)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
194 ;; Build hints array
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
195 (when urgency
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
196 (add-to-list 'hints `(:dict-entry
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
197 "urgency"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
198 (:variant :byte ,(case urgency
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
199 ('low 0)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
200 ('critical 2)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
201 (t 1)))) t))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
202 (when category
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
203 (add-to-list 'hints `(:dict-entry
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
204 "category"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
205 (:variant :string ,category)) t))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
206 (when desktop-entry
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
207 (add-to-list 'hints `(:dict-entry
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
208 "desktop-entry"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
209 (:variant :string ,desktop-entry)) t))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
210 (when image-data
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
211 (add-to-list 'hints `(:dict-entry
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
212 "image_data"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
213 (:variant :struct ,image-data)) t))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
214 (when sound-file
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
215 (add-to-list 'hints `(:dict-entry
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
216 "sound-file"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
217 (:variant :string ,sound-file)) t))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
218 (when suppress-sound
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
219 (add-to-list 'hints `(:dict-entry
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
220 "suppress-sound"
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
221 (:variant :boolean ,suppress-sound)) t))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
222 (when x
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
223 (add-to-list 'hints `(:dict-entry "x" (:variant :int32 ,x)) t))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
224 (when y
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
225 (add-to-list 'hints `(:dict-entry "y" (:variant :int32 ,y)) t))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
226
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
227 ;; Call Notify method
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
228 (setq id
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
229 (dbus-call-method :session
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
230 notifications-service
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
231 notifications-path
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
232 notifications-interface
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
233 notifications-notify-method
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
234 :string (or app-name
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
235 notifications-application-name)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
236 :uint32 (or replaces-id 0)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
237 :string (if app-icon
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
238 (expand-file-name app-icon)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
239 ;; If app-icon is nil because user
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
240 ;; requested it to be so, send the
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
241 ;; empty string
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
242 (if (plist-member params :app-icon)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
243 ""
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
244 ;; Otherwise send the default icon path
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
245 notifications-application-icon))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
246 :string (or title "")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
247 :string (or body "")
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
248 `(:array ,@actions)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
249 (or hints '(:array :signature "{sv}"))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
250 :int32 (or timeout -1)))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
251
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
252 ;; Register close/action callback function
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
253 (let ((on-action (plist-get params :on-action))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
254 (on-close (plist-get params :on-close)))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
255 (when on-action
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
256 (add-to-list 'notifications-on-action-map (list id on-action)))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
257 (when on-close
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
258 (add-to-list 'notifications-on-close-map (list id on-close))))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
259
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
260 ;; Return notification id
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
261 id))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
262
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
263 (defun notifications-close-notification (id)
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
264 "Close a notification with identifier ID."
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
265 (dbus-call-method :session
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
266 notifications-service
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
267 notifications-path
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
268 notifications-interface
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
269 notifications-close-notification-method
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
270 :int32 id))
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
271
f0e5fbe77b7c * notifications.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
272 (provide 'notifications)