Add notifications.py
[platform/upstream/ibus.git] / ibus / notifications.py
1 # vim:set et sts=4 sw=4:
2 #
3 # ibus - The Input Bus
4 #
5 # Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
6 #
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2 of the License, or (at your option) any later version.
11 #
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this program; if not, write to the
19 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 # Boston, MA  02111-1307  USA
21
22 __all__ = (
23         "NotificationsBase",
24         "IBUS_NOTIFICATIONS_NAME",
25         "IBUS_NOTIFICATIONS_PATH"
26     )
27
28 IBUS_NOTIFICATIONS_NAME = "org.freedesktop.ibus.Notifications"
29 IBUS_NOTIFICATIONS_PATH = "/org/freedesktop/ibus/Notifications"
30
31 import ibus
32 from ibus import interface
33
34 class NotificationsBase(ibus.Object):
35     def __init__(self, bus):
36         super(NotificationsBase, self).__init__()
37         self.__proxy = NotificationsProxy(self, bus.get_dbusconn())
38
39     def notify(self, replaces_id, app_icon, summary, body, actions, expire_timeout):
40         pass
41
42     def close_notification(self, id):
43         pass
44
45     def notification_closed(self, id, reason):
46         self.__proxy.NotificationClosed(id, reason)
47
48     def action_invoked(self, id, action_key):
49         self.__proxy.ActionInvoked(id, action_key)
50
51 class NotificationsProxy(interface.INotifications):
52     def __init__ (self, notify, dbusconn):
53         super(NotificationsProxy, self).__init__(dbusconn, IBUS_NOTIFICATIONS_PATH)
54         self.__dbusconn = dbusconn
55         self.__notify = notify
56     
57     def Notify(self, replaces_id, app_icon, summary, body, actions, expire_timeout):
58         return self.__notify.notify(replaces_id, app_icon, summary, body, actions, expire_timout)
59     
60     def CloseNotification(self, id):
61         return self.__notify.close_notification(id)