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
##
29
#
30
# Une classe pour afficher des notifications à l'écran. Doit
31
# fonctionner avec tous les gestionnaires de bureau qui adhèrent aux
32
# standards de freedesktop.org.
33
# Cette classe est basée sur la documentation disponible à
34
# http://www.galago-project.org/specs/notification/0.9/x408.html
35
#
36
class
Notification
:
37
38
##
39
#
40
# Le constructeur
41
# @param app_name nom d'une application, valeur par défaut =""
42
# @param replaces_id identifiant d'une notification à remplacer valeur par défaut=0
43
# @param app_icon nom d'un fichier servant pour l'icône valeur par défaut=""
44
# @param summary description brève de la notification valeur par défaut =""
45
# @param body le texte de la notification, valeur pa défaut=""
46
# @param actions une liste de paires représeantant des actions, valeur par défaut=[]
47
# @param hints un dictionnaire de suggestions, valeur par défaut={},
48
# @param expire_timeout durée maximale d'affichage en millisecondes, valeur par défaut=1000
49
#
50
def
__init__
(self, app_name ="", replaces_id=0, app_icon="",
51
summary=
""
, body=
""
, actions=[], hints={},
52
expire_timeout=1000):
53
self.
app_name
= app_name
54
self.
replaces_id
= replaces_id
55
self.
app_icon
= app_icon
56
self.
summary
= summary
57
self.
body
= body
58
self.
actions
= actions
59
self.
hints
= hints
60
self.
expire_timeout
= expire_timeout
61
62
try
:
63
session_bus = dbus.SessionBus()
64
obj = session_bus.get_object(
"org.freedesktop.Notifications"
,
"/org/freedesktop/Notifications"
)
65
self.
interface
= dbus.Interface(obj,
"org.freedesktop.Notifications"
)
66
except
Exception:
67
self.
interface
=
None
68
69
def
notify
(self):
70
self.interface.Notify(self.
app_name
, self.
replaces_id
, self.
app_icon
, self.
summary
, self.
body
, self.
actions
, self.
hints
, self.
expire_timeout
)
71
72
73
if
__name__==
"__main__"
:
74
notif =
Notification
(app_name=
"AppliTest"
,
75
summary=
"Notification de test"
,
76
body=
"Voici le corps de la notification"
,
77
app_icon=
"/usr/share/pixmaps/vlc.png"
,
78
expire_timeout=7000)
79
notif.notify()
src.notification.Notification.app_icon
app_icon
Definition:
notification.py:55
src.notification.Notification.app_name
app_name
Definition:
notification.py:53
src.notification.Notification
Une classe pour afficher des notifications à l'écran.
Definition:
notification.py:36
src.notification.Notification.hints
hints
Definition:
notification.py:59
src.notification.Notification.replaces_id
replaces_id
Definition:
notification.py:54
src.notification.Notification.notify
def notify(self)
Definition:
notification.py:69
src.notification.Notification.body
body
Definition:
notification.py:57
src.notification.Notification.interface
interface
Definition:
notification.py:65
src.notification.Notification.summary
summary
Definition:
notification.py:56
src.notification.Notification.actions
actions
Definition:
notification.py:58
src.notification.Notification.expire_timeout
expire_timeout
Definition:
notification.py:60
src.notification.Notification.__init__
def __init__
Le constructeur.
Definition:
notification.py:52
src
notification.py
Généré par
1.8.9.1