3 from rox
.Menu
import Menu
6 (_('/Add Memo...'), 'new_memo', "<StockItem>", "", g
.STOCK_ADD
),
7 (_('/Show All...'), 'show_all_memos', '<StockItem>', "", g
.STOCK_EDIT
),
11 (_('/Options...'), 'show_options', "<StockItem>", "", g
.STOCK_PREFERENCES
),
12 (_('/Help'), 'show_help', "<StockItem>", "", g
.STOCK_HELP
),
13 (_('/Quit'), 'quit', "<StockItem>", "", g
.STOCK_QUIT
),
16 SEPARATOR
= ('/', '', '<Separator>')
18 class MenuWindow( object ):
19 def __init__(self
, attach
=True, full
=True, additions
=None):
20 """Initializes the menu for this window.
21 'full' decides whether the whole menu (actions and main) or just the
22 actions menu is shown.
23 'additions' is an optional dictionary as follows:
24 { 'topActions': [ Menu items to attach before the 'actions' menu ],
25 'bottomActions': [ Menu items to attach after the 'actions' menu ],
26 'topMain': [ Menu items to attach before the 'main' menu ],
27 'bottomMain': [ Menu items to attach after the 'main' menu ] }
29 self
.additions
= { 'topActions': [],
34 self
.show_all_box
= None
37 if additions
is not None:
38 self
.addAdditions( additions
)
42 def addAdditions(self
, additions
):
44 for (key
, list) in self
.additions
.items():
45 if additions
.has_key(key
):
47 list.extend(additions
[key
])
51 def removeAdditions(self
, additions
):
53 for (key
, list) in self
.additions
.items():
54 if additions
.has_key(key
):
55 toRemove
= additions
[key
]
61 # If they're not already in the list, that's okay
66 def popup_menu(self
, event
, position
=None):
67 self
.menu
.popup(self
, event
, position
)
69 def set_menu(self
, attach
=None, full
=None):
70 if attach
is not None:
78 menuList
.extend(self
.additions
['topActions'])
79 menuList
.extend( actionsMenu
)
80 menuList
.extend(self
.additions
['bottomActions'])
83 menuList
.append( SEPARATOR
)
84 menuList
.extend(self
.additions
['topMain'])
85 menuList
.extend( mainMenu
)
86 menuList
.extend(self
.additions
['bottomMain'])
87 self
.menu
= Menu(menuName
, menuList
)
89 self
.menu
.attach(self
, self
)
91 def new_memo(self
, widget
=None):
92 from EditBox
import EditBox
95 def show_all_memos(self
, widget
=None):
97 self
.show_all_box
.present()
99 def destroyed(widget
): self
.show_all_box
= None
100 from ShowAll
import ShowAll
101 self
.show_all_box
= ShowAll()
102 self
.show_all_box
.connect('destroy', destroyed
)
103 self
.show_all_box
.show()
105 def show_options(self
, widget
=None):
108 def show_help(self
, widget
=None):
109 from rox
import filer
110 filer
.open_dir(rox
.app_dir
+ '/Help')
112 def quit(self
, widget
=None):