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