ScolaSync  5.1
notification.py
Aller à la documentation de ce fichier.
1 #!/usr/bin/python
2 # $Id: notification.py 29 2010-12-11 15:39:59Z georgesk $
3 
4 licence={}
5 licence['en']="""
6  file notification.py
7  this file is part of the project scolasync
8 
9  Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
10 
11  This program is free software: you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version3 of the License, or
14  (at your option) any later version.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program. If not, see <http://www.gnu.org/licenses/>.
23 """
24 
25 import dbus
26 
27 
28 # Une classe pour afficher des notifications à l'écran. Doit
29 # fonctionner avec tous les gestionnaires de bureau qui adhèrent aux
30 # standards de freedesktop.org.
31 # Cette classe est basée sur la documentation disponible à
32 # http://www.galago-project.org/specs/notification/0.9/x408.html
33 #
34 
36 
37 
47 
48  def __init__(self, app_name ="", replaces_id=0, app_icon="",
49  summary="", body="", actions=[], hints={},
50  expire_timeout=1000):
51  self.app_name = app_name
52  self.replaces_id = replaces_id
53  self.app_icon = app_icon
54  self.summary = summary
55  self.body = body
56  self.actions = actions
57  self.hints = hints
58  self.expire_timeout = expire_timeout
59 
60  try:
61  session_bus = dbus.SessionBus()
62  obj = session_bus.get_object("org.freedesktop.Notifications","/org/freedesktop/Notifications")
63  self.interface = dbus.Interface(obj, "org.freedesktop.Notifications")
64  except Exception:
65  self.interface = None
66 
67  def notify(self):
68  self.interface.Notify(self.app_name, self.replaces_id, self.app_icon, self.summary, self.body, self.actions, self.hints, self.expire_timeout)
69 
70 
71 if __name__=="__main__":
72  notif = Notification(app_name="AppliTest",
73  summary="Notification de test",
74  body="Voici le corps de la notification",
75  app_icon="/usr/share/pixmaps/vlc.png",
76  expire_timeout=7000)
77  notif.notify()
src.notification.Notification.notify
def notify(self)
Definition: notification.py:67
src.notification.Notification.app_name
app_name
Definition: notification.py:49
src.notification.Notification.__init__
def __init__(self, app_name="", replaces_id=0, app_icon="", summary="", body="", actions=[], hints={}, expire_timeout=1000)
Le constructeur.
Definition: notification.py:48
src.notification.Notification.app_icon
app_icon
Definition: notification.py:51
src.notification.Notification
Definition: notification.py:35
src.notification.Notification.body
body
Definition: notification.py:53
src.notification.Notification.summary
summary
Definition: notification.py:52
src.notification.Notification.expire_timeout
expire_timeout
Definition: notification.py:56
src.notification.Notification.actions
actions
Definition: notification.py:54
src.notification.Notification.replaces_id
replaces_id
Definition: notification.py:50
src.notification.Notification.interface
interface
Definition: notification.py:61
src.notification.Notification.hints
hints
Definition: notification.py:55