Skip to content

Commit aaadacd

Browse files
committed
[GraphView] try to fix popup menu
1 parent 27d2303 commit aaadacd

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

GraphView/graphview.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,9 @@ def __init__(self, view, dbstate, uistate):
686686
# Gtk style context for scrollwindow to operate with theme colors
687687
self.sw_style_context = scrolled_win.get_style_context()
688688

689+
# used for popup menu, prevent destroy menu as local variable
690+
self.menu = None
691+
689692
def set_person_to_focus(self, handle):
690693
"""
691694
Set person that will focus (once) after graph rebuilding.
@@ -944,7 +947,7 @@ def button_press(self, item, target, event):
944947
return False
945948

946949
if button == 3:
947-
PopupMenu(self, kind='background').show_menu(event)
950+
self.menu = PopupMenu(self, kind='background').show_menu(event)
948951
return True
949952

950953
return False
@@ -1043,9 +1046,9 @@ def select_node(self, item, target, event):
10431046

10441047
elif button == 3 and node_class: # right mouse
10451048
if node_class == 'node':
1046-
PopupMenu(self, 'person', handle).show_menu(event)
1049+
self.menu = PopupMenu(self, 'person', handle).show_menu(event)
10471050
elif node_class == 'familynode':
1048-
PopupMenu(self, 'family', handle).show_menu(event)
1051+
self.menu = PopupMenu(self, 'family', handle).show_menu(event)
10491052

10501053
elif button == 2: # middle mouse
10511054
# to enter in scroll mode (we should change "item" to root item)
@@ -2543,10 +2546,17 @@ def show_menu(self, event=None):
25432546
"""
25442547
Show popup menu.
25452548
"""
2546-
# new from gtk 3.22:
2547-
# self.popup_at_pointer(event)
2548-
self.popup(None, None, None, None,
2549-
event.get_button()[1], event.time)
2549+
if (Gtk.MAJOR_VERSION >= 3) and (Gtk.MINOR_VERSION >= 22):
2550+
#new from gtk 3.22:
2551+
self.popup_at_pointer(event)
2552+
else:
2553+
if event:
2554+
self.popup(None, None, None, None,
2555+
event.get_button()[1], event.time)
2556+
else:
2557+
self.popup(None, None, None, None,
2558+
0, Gtk.get_current_event_time())
2559+
#self.popup(None, None, None, None, 0, 0)
25502560

25512561
def background_menu(self):
25522562
"""

0 commit comments

Comments
 (0)