-
Notifications
You must be signed in to change notification settings - Fork 0
/
wuohoy.py
executable file
·64 lines (44 loc) · 1.55 KB
/
wuohoy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
from gi.repository import Gtk
from configLoader import ConfigLoader
from widgetHandlers import WidgetHandlers
class Wuohoy:
def activate(self, widget, data=None):
Wuohoy.window.show_all()
def hide(self, widget, data=None):
Wuohoy.window.hide()
return True
def staticon_right_click(self, icon, button, time):
self.menu = Gtk.Menu()
for item in ConfigLoader.preferences['systray-menu']:
self.menuItem = Gtk.MenuItem()
self.menuItem.set_label(item['label'])
for action in item['actions']:
module = __import__(action['module'])
klazz = getattr(module, action['className'])
function = getattr(klazz(), action['command'])
self.menuItem.connect(action['name'], function)
self.menu.append(self.menuItem)
self.menu.show_all()
def pos(menu, icon):
return (Gtk.StatusIcon.position_menu(menu, icon))
self.menu.popup(None, None, pos, self.staticon, button, time)
def __init__(self):
#main-window
builder = Gtk.Builder()
builder.add_from_file("gui.glade")
builder.connect_signals(WidgetHandlers(builder));
Wuohoy.window = builder.get_object("MainWindow")
Wuohoy.window.connect('delete-event', self.hide)
ConfigLoader.configure(builder)
print "main window created"
#systray-icon
self.staticon = Gtk.StatusIcon()
self.staticon.set_from_stock(Gtk.STOCK_EXECUTE)
self.staticon.connect('activate', self.activate)
self.staticon.connect('popup-menu', self.staticon_right_click)
self.staticon.set_visible(True)
self.window = None
if __name__ == "__main__":
hwg = Wuohoy()
Gtk.main()