diff --git a/xdot.py b/xdot.py index 0c870c6..d3297c6 100755 --- a/xdot.py +++ b/xdot.py @@ -2013,7 +2013,7 @@ def __init__(self, command_line_files, widget=None): # Connect the Button click event of the drawing menu, in order # to display a file menu - self.widget.connect("button-press-event", self.on_file_menu) + self.dotwidget.connect("button-press-event", self.on_file_menu) self.connect('key-press-event', self.on_key_press_event) @@ -2158,21 +2158,25 @@ def on_go_back(self, action = None): self.open_file(self.open_files[self.open_file_idx]) def on_file_menu(self, widget, event): - if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: - menu = gtk.Menu() + if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3: + menu = Gtk.Menu() for filename in self.open_files: label = os.path.basename(filename) - item = gtk.MenuItem(label) - menu.append(item) + item = Gtk.MenuItem() + item.set_label(label) item.connect("activate", lambda _, f: self.open_file(f), filename) - item.show() - menu.popup(None, None, None, 3, event.time) + menu.append(item) + menu.show_all() + self.menu = menu + menu.popup(None, None, None, None, + event.button, event.time) + return True def on_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.bracketleft: + if event.keyval == Gdk.KEY_bracketleft: self.on_go_back() return True - if event.keyval == gtk.keysyms.bracketright: + if event.keyval == Gdk.KEY_bracketright: self.on_go_forward() return True