-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyindicator.py
More file actions
executable file
·97 lines (73 loc) · 2.77 KB
/
yindicator.py
File metadata and controls
executable file
·97 lines (73 loc) · 2.77 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/python
#Some bits of code thanks to Alex Simenduev <shamil.si@gmail.com> (via Indicator-PLaces)
import gtk
import appindicator
import os
import signal
import dbus
def item_run(w, yitem):
if yitem == "_yppa" :
os.system("/usr/bin/y-ppa-manager")
elif yitem == "_yppa_search":
os.system("/usr/bin/y-ppa-cmd search")
elif yitem == "_yppa_add":
os.system("gksu -S -m 'Y PPA Manager requires admin privileges for this task' /usr/bin/y-ppa-cmd add")
elif yitem == "_yppa_rem":
os.system("gksu -S -m 'Y PPA Manager requires admin privileges for this task' /usr/bin/y-ppa-cmd remove")
elif yitem == "_yppa_list":
os.system("/usr/bin/y-ppa-cmd list")
elif yitem == "_yppa_adv":
os.system("/usr/bin/y-ppa-cmd advanced")
elif yitem == "_yppa_set":
os.system("/usr/bin/y-ppa-cmd settings")
class IndicatorY:
def __init__(self):
if dbus.SessionBus().request_name('instance.y-ppa-manager') != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
print "application already running"
exit(0)
self.ind = appindicator.Indicator("y-ppa-manager", "y-ppa-manager", appindicator.CATEGORY_APPLICATION_STATUS)
self.ind.set_label("Y")
self.ind.set_status(appindicator.STATUS_ACTIVE)
self.create_menu()
def create_menu(self, widget = None, data = None):
# Create menu
menu = gtk.Menu()
self.ind.set_menu(menu)
# List items
item = gtk.MenuItem("Search")
item.connect("activate", item_run, "_yppa_search")
menu.append(item)
item = gtk.MenuItem("Add PPA")
item.connect("activate", item_run, "_yppa_add")
menu.append(item)
item = gtk.MenuItem("Remove PPA")
item.connect("activate", item_run, "_yppa_rem")
menu.append(item)
item = gtk.MenuItem("List packages")
item.connect("activate", item_run, "_yppa_list")
menu.append(item)
item = gtk.MenuItem("Advanced")
item.connect("activate", item_run, "_yppa_adv")
menu.append(item)
# Show separator
item = gtk.SeparatorMenuItem()
menu.append(item)
# More items
item = gtk.MenuItem("Settings")
item.connect("activate", item_run, "_yppa_set")
menu.append(item)
item = gtk.MenuItem("Y PPA Manager")
item.connect("activate", item_run, "_yppa")
menu.append(item)
# Quit menu item
item = gtk.MenuItem("Quit")
item.connect("activate", gtk.main_quit)
menu.append(item)
menu.show_all()
if __name__ == "__main__":
# Catch CTRL-C
signal.signal(signal.SIGINT, lambda signal, frame: gtk.main_quit())
# Run the indicator
i = IndicatorY()
# Main gtk loop
gtk.main()