Lines 31-39
import subprocess
Link Here
|
31 |
import signal |
31 |
import signal |
32 |
import gtk |
32 |
import gtk |
33 |
import gobject |
33 |
import gobject |
34 |
import pynotify |
|
|
35 |
if not pynotify.init("gestikk"): |
36 |
print "Libnotify daemon error!" |
37 |
|
34 |
|
38 |
import osd |
35 |
import osd |
39 |
from gestikk.tools import * |
36 |
from gestikk.tools import * |
Lines 102-127
class StatusIcon:
Link Here
|
102 |
subprocess.Popen([get_file('gestikk', 'executable'), '-c', '-q']) |
99 |
subprocess.Popen([get_file('gestikk', 'executable'), '-c', '-q']) |
103 |
|
100 |
|
104 |
|
101 |
|
105 |
class Notifier: |
|
|
106 |
""" class for notifying the user when a gesture started """ |
107 |
def __init__(self, logic, statusicon): |
108 |
self.logic = logic |
109 |
self.statusicon = statusicon |
110 |
|
111 |
def notify(self, s, gesture): |
112 |
""" Notify and display `s` |
113 |
:type s: String |
114 |
""" |
115 |
notify = pynotify.Notification(_("Notification"), s.replace('<', '<').replace('>', '>')) |
116 |
screen, rect, orient = self.statusicon.icon.get_geometry() |
117 |
notify.set_hint("x", rect.x + (rect.width / 2)) |
118 |
notify.set_hint("y", rect.y + (rect.height / 2)) |
119 |
notify.set_timeout(3000) # timeout in ms |
120 |
color = self.logic.config_get_option('OSD', 'color', '#0000FF') |
121 |
pb = pixmap_to_pixbuf(gesture_to_pixmap(gesture2py(gesture), 40, color), (255, 255, 255)) |
122 |
notify.set_icon_from_pixbuf(pb) |
123 |
notify.show() |
124 |
|
125 |
class Listener: |
102 |
class Listener: |
126 |
""" class for listening the mouse positions """ |
103 |
""" class for listening the mouse positions """ |
127 |
def __init__(self, logic, notifier, debugger): |
104 |
def __init__(self, logic, notifier, debugger): |
Lines 224-232
class Listener:
Link Here
|
224 |
if action.check_condition(): |
201 |
if action.check_condition(): |
225 |
action.do() |
202 |
action.do() |
226 |
self.debugger.debug(self.notify_string(gesture_repr)) |
203 |
self.debugger.debug(self.notify_string(gesture_repr)) |
227 |
if self.notify_method == 'balloon' or self.notify_method == 'osd': |
|
|
228 |
self.notifier.notify(action.get_formatted(), action.gesture) |
229 |
if self.notify_method == 'osd': |
204 |
if self.notify_method == 'osd': |
|
|
205 |
self.notifier.notify(action.get_formatted(), action.gesture) |
230 |
gobject.timeout_add(3000, self._osd_clear) # show it 2 sec |
206 |
gobject.timeout_add(3000, self._osd_clear) # show it 2 sec |
231 |
return self.running |
207 |
return self.running |
232 |
|
208 |
|
Lines 248-256
class Listener:
Link Here
|
248 |
self.notify_method = self.logic.config_get_option('Notification', 'type') |
224 |
self.notify_method = self.logic.config_get_option('Notification', 'type') |
249 |
if isinstance(self.notifier, osd.OSDNotifier): |
225 |
if isinstance(self.notifier, osd.OSDNotifier): |
250 |
self.notifier.destroy() |
226 |
self.notifier.destroy() |
251 |
if self.notify_method == 'balloon': |
227 |
if self.notify_method == 'osd': |
252 |
self.notifier = Notifier(self.logic, self.logic.status_icon) |
|
|
253 |
elif self.notify_method == 'osd': |
254 |
notify_colorstr = self.logic.config_get_option('Notification', 'color', 'red') |
228 |
notify_colorstr = self.logic.config_get_option('Notification', 'color', 'red') |
255 |
notify_font = self.logic.config_get_option('Notification', 'font', 'Sans') |
229 |
notify_font = self.logic.config_get_option('Notification', 'font', 'Sans') |
256 |
notify_fontsize = self.logic.config_get_option('Notification' , 'font_size', '20') |
230 |
notify_fontsize = self.logic.config_get_option('Notification' , 'font_size', '20') |
Lines 269-279
def main(debug):
Link Here
|
269 |
logic.status_icon = status # Not clean... TODO? |
243 |
logic.status_icon = status # Not clean... TODO? |
270 |
# get notifiers |
244 |
# get notifiers |
271 |
notify_m = logic.config_get_option('Notification', 'type') |
245 |
notify_m = logic.config_get_option('Notification', 'type') |
272 |
if notify_m == 'balloon': |
246 |
if notify_m == 'osd': |
273 |
debugger.debug("Using balloontip notification") |
|
|
274 |
notifier = Notifier(logic, status) |
275 |
osd_obj = False |
276 |
elif notify_m == 'osd': |
277 |
debugger.debug("Using OSD notification") |
247 |
debugger.debug("Using OSD notification") |
278 |
notify_colorstr = logic.config_get_option('Notification', 'color', 'red') |
248 |
notify_colorstr = logic.config_get_option('Notification', 'color', 'red') |
279 |
notify_font = logic.config_get_option('Notification', 'font', 'Sans') |
249 |
notify_font = logic.config_get_option('Notification', 'font', 'Sans') |