@@ -1465,29 +1465,40 @@ def format_name_override(f):
14651465 })
14661466 return different
14671467
1468- def popup_in_pane (self , pane , event ):
1469- if event :
1470- button = event .button
1471- time = event .time
1472- else :
1473- button = 0
1474- time = Gtk .get_current_event_time ()
1475- self .popup_menu .popup (None , None , None , None , button , time )
1476-
14771468 def on_treeview_popup_menu (self , treeview ):
1478- self .popup_in_pane (self .treeview .index (treeview ), None )
1469+ cursor_path , cursor_col = treeview .get_cursor ()
1470+ if not cursor_path :
1471+ self .popup_menu .popup_at_pointer (None )
1472+ return True
1473+
1474+ # We always want to pop up to the right of the first column,
1475+ # ignoring the actual cursor column location.
1476+ rect = treeview .get_background_area (
1477+ cursor_path , treeview .get_column (0 ))
1478+
1479+ self .popup_menu .popup_at_rect (
1480+ treeview .get_bin_window (),
1481+ rect ,
1482+ Gdk .Gravity .SOUTH_EAST ,
1483+ Gdk .Gravity .NORTH_WEST ,
1484+ None ,
1485+ )
14791486 return True
14801487
14811488 def on_treeview_button_press_event (self , treeview , event ):
14821489 # Unselect any selected files in other panes
14831490 for t in [v for v in self .treeview [:self .num_panes ] if v != treeview ]:
14841491 t .get_selection ().unselect_all ()
14851492
1486- if event .button == 3 :
1493+ if (event .triggers_context_menu () and
1494+ event .type == Gdk .EventType .BUTTON_PRESS ):
1495+
14871496 treeview .grab_focus ()
1497+
14881498 path = treeview .get_path_at_pos (int (event .x ), int (event .y ))
14891499 if path is None :
14901500 return False
1501+
14911502 selection = treeview .get_selection ()
14921503 model , rows = selection .get_selected_rows ()
14931504
@@ -1496,7 +1507,7 @@ def on_treeview_button_press_event(self, treeview, event):
14961507 selection .select_path (path [0 ])
14971508 treeview .set_cursor (path [0 ])
14981509
1499- self .popup_in_pane ( self . treeview . index ( treeview ), event )
1510+ self .popup_menu . popup_at_pointer ( event )
15001511 return True
15011512 return False
15021513
0 commit comments