Mercurial > libervia-backend
comparison frontends/src/primitivus/notify.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | ca13633d3b6b |
children | beaf6bec2fcd |
comparison
equal
deleted
inserted
replaced
586:6a718ede8be1 | 587:952322b1d490 |
---|---|
21 | 21 |
22 import dbus | 22 import dbus |
23 | 23 |
24 class Notify: | 24 class Notify: |
25 """Used to send notification and detect if we have focus""" | 25 """Used to send notification and detect if we have focus""" |
26 | 26 |
27 def __init__(self): | 27 def __init__(self): |
28 | 28 |
29 #X11 stuff | 29 #X11 stuff |
30 self.display = None | 30 self.display = None |
31 self.X11_id = -1 | 31 self.X11_id = -1 |
32 | 32 |
33 try: | 33 try: |
34 from Xlib import display as X_display | 34 from Xlib import display as X_display |
35 self.display = X_display.Display() | 35 self.display = X_display.Display() |
36 self.X11_id = self.getFocus() | 36 self.X11_id = self.getFocus() |
37 except: | 37 except: |
42 bus = dbus.SessionBus() | 42 bus = dbus.SessionBus() |
43 db_object = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') | 43 db_object = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') |
44 self.freedesktop_int = dbus.Interface(db_object, dbus_interface='org.freedesktop.Notifications') | 44 self.freedesktop_int = dbus.Interface(db_object, dbus_interface='org.freedesktop.Notifications') |
45 except: | 45 except: |
46 self.freedesktop_int = None | 46 self.freedesktop_int = None |
47 | 47 |
48 | 48 |
49 def getFocus(self): | 49 def getFocus(self): |
50 if not self.display: | 50 if not self.display: |
51 return 0 | 51 return 0 |
52 return self.display.get_input_focus().focus.id | 52 return self.display.get_input_focus().focus.id |
60 def sendNotification(self, summ_mess, body_mess=""): | 60 def sendNotification(self, summ_mess, body_mess=""): |
61 """Send notification to the user if possible""" | 61 """Send notification to the user if possible""" |
62 #TODO: check options before sending notifications | 62 #TODO: check options before sending notifications |
63 if self.freedesktop_int: | 63 if self.freedesktop_int: |
64 self.sendFDNotification(summ_mess, body_mess) | 64 self.sendFDNotification(summ_mess, body_mess) |
65 | 65 |
66 def sendFDNotification(self, summ_mess, body_mess=""): | 66 def sendFDNotification(self, summ_mess, body_mess=""): |
67 """Send notification with the FreeDesktop D-Bus API""" | 67 """Send notification with the FreeDesktop D-Bus API""" |
68 if self.freedesktop_int: | 68 if self.freedesktop_int: |
69 app_name = "Primitivus" | 69 app_name = "Primitivus" |
70 replaces_id = 0 | 70 replaces_id = 0 |
71 app_icon = "" | 71 app_icon = "" |
72 summary = summ_mess | 72 summary = summ_mess |
73 body = body_mess | 73 body = body_mess |
74 actions = dbus.Array(signature='s') | 74 actions = dbus.Array(signature='s') |
75 hints = dbus.Dictionary(signature='sv') | 75 hints = dbus.Dictionary(signature='sv') |
76 expire_timeout = -1 | 76 expire_timeout = -1 |
77 | 77 |
78 self.freedesktop_int.Notify(app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout) | 78 self.freedesktop_int.Notify(app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout) |