updated on Sat Jan 14 12:12:45 UTC 2012
[aur-mirror.git] / menumaker-compiz / MyGTKMenu.py
blob1f3bf61dbe306f8bb403e3748cb37348f237d764
1 import os.path, MenuMaker, Prophet
6 from MenuMaker import indent, writeFullMenu
11 menuFile = "~/.mygtkmenu.txt"
16 def _map(x) :
17 for d, s in (("\'", "\""),) :
18 x = x.replace(s, d)
19 return x
24 class Sep(object) :
25 def emit(self, level) :
26 return ['%sSEPARATOR' % indent(level)]
31 class App(object) :
32 def emit(self, level) :
33 x = indent(level)
34 cmd = self.app.execmd
35 if self.app.terminal :
36 cmd = MenuMaker.terminal.runCmd(cmd)
37 return [
38 '%sitem = %s' % (x, _map(self.app.name)),
39 '%scmd = %s' % (x, cmd),
40 '%sicon = NULL' % x,
46 class Menu(object) :
47 def emit(self, level) :
48 menu = ['%sSubmenu = %s' % (indent(level), _map(self.name)),
49 '%sicon = NULL' % indent(level + 1),
52 for x in self :
53 menu += x.emit(level + 1)
54 return menu
59 class Root(object) :
60 def __init__(self, subs) :
61 if writeFullMenu :
62 subs = subs + [MenuMaker.Sep(), SysMenu()]
63 super(Root, self).__init__(subs)
64 def emit(self, level) :
65 if writeFullMenu :
66 menu = [
67 'iconsize = 25'
69 for x in self :
70 menu += x.emit(level)
71 menu.append('')
72 return menu
73 else :
74 menu = []
75 for x in self :
76 menu += x.emit(level)
77 return menu
82 class SysMenu(MenuMaker.Menu) :
83 name = "Session"
84 def __init__(self) :
85 subs = [
86 X('item = Log Out'),
87 X('cmd = killall X'),
88 X('icon = NULL')
90 super(SysMenu, self).__init__(subs)
91 self.align = MenuMaker.Entry.StickBottom
94 class X(MenuMaker.Entry) :
95 def __init__(self, x) :
96 super(X, self).__init__()
97 self.align = MenuMaker.Entry.StickBottom
98 self.x = x
99 def emit(self, level) :
100 return [indent(level) + self.x]