Aller à la documentation de ce fichier.00001
00002
00003
00004
00005 licence={}
00006 licence['en']="""
00007 file notification.py
00008 this file is part of the project scolasync
00009
00010 Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
00011
00012 This program is free software: you can redistribute it and/or modify
00013 it under the terms of the GNU General Public License as published by
00014 the Free Software Foundation, either version3 of the License, or
00015 (at your option) any later version.
00016
00017 This program is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 GNU General Public License for more details.
00021
00022 You should have received a copy of the GNU General Public License
00023 along with this program. If not, see <http://www.gnu.org/licenses/>.
00024 """
00025
00026 import dbus
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class Notification:
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 def __init__(self, app_name ="", replaces_id=0, app_icon="",
00052 summary="", body="", actions=[], hints={},
00053 expire_timeout=1000):
00054 self.app_name = app_name
00055 self.replaces_id = replaces_id
00056 self.app_icon = app_icon
00057 self.summary = summary
00058 self.body = body
00059 self.actions = actions
00060 self.hints = hints
00061 self.expire_timeout = expire_timeout
00062
00063 try:
00064 session_bus = dbus.SessionBus()
00065 obj = session_bus.get_object("org.freedesktop.Notifications","/org/freedesktop/Notifications")
00066 self.interface = dbus.Interface(obj, "org.freedesktop.Notifications")
00067 except Exception:
00068 self.interface = None
00069
00070 def notify(self):
00071 self.interface.Notify(self.app_name, self.replaces_id, self.app_icon, self.summary, self.body, self.actions, self.hints, self.expire_timeout)
00072
00073
00074 if __name__=="__main__":
00075 notif = Notification(app_name="AppliTest",
00076 summary="Notification de test",
00077 body="Voici le corps de la notification",
00078 app_icon="/usr/share/pixmaps/vlc.png",
00079 expire_timeout=7000)
00080 notif.notify()
00081