5
class MenuSetting(gtk.Menu):
6
def __init__(self, button, webview):
7
super(MenuSetting, self).__init__()
10
self.web = web(webview)
12
"""add the menu items"""
15
def append_items(self):
16
view = self.web.get_current_view()
18
for item in self.get_children():
21
print_cb = gtk.ImageMenuItem(gtk.STOCK_PRINT, "Add page to bookmark")
22
print_cb.connect("activate", lambda w: self.web.print_cb(print_cb, self.web))
26
if view.get_view_source_mode() == False:
27
code = gtk.ImageMenuItem("Show page source code")
28
code.connect("activate", self.web.code_view)
32
code = gtk.ImageMenuItem("Show the web content")
33
code.connect("activate", self.web.code_view)
37
sep = gtk.SeparatorMenuItem()
41
properties = gtk.ImageMenuItem(gtk.STOCK_PROPERTIES)
42
#properties.connect("activate", self.)
43
self.append(properties)
46
self.connect("deactivate", lambda w: self.btn.set_sensitive(True))
48
"""general function to get the menu"""
52
"""function to get where the window put the menu"""
53
def menu_position(self, menu, data=None):
54
widget = menu.get_attach_widget()
55
allocation = widget.get_allocation()
56
window_pos = widget.window.get_position()
57
x = window_pos[0] + allocation.x
58
y = window_pos[1] + allocation.y + allocation.height
63
if not self.get_attach_widget():
64
self.attach_to_widget(self.btn, None)
65
self.popup(None, None, self.menu_position, 1, gtk.get_current_event_time())
66
self.select_first(True)
67
self.btn.set_sensitive(False)