Skip to content

Commit

Permalink
Fixup menu for GTK3
Browse files Browse the repository at this point in the history
  • Loading branch information
stettberger committed Aug 11, 2015
1 parent 598af3e commit f0ab15f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions xdot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit f0ab15f

Please sign in to comment.