Steve Borho avatar Steve Borho committed 525469f

history: handle cmenu requests on empty treeview areas

Fixes #227

Comments (0)

Files changed (1)

         self.reload_log()
         return True
 
-    def _tree_button_release(self, widget, event) :
+    def _tree_button_release(self, tree, event) :
         if event.button == 3 and not (event.state & (gtk.gdk.SHIFT_MASK |
             gtk.gdk.CONTROL_MASK)):
-            self._tree_popup_menu(widget, event.button, event.time)
+            self._tree_popup_menu(tree, event.button, event.time)
         return False
 
-    def _tree_button_press(self, widget, event):
+    def _tree_button_press(self, tree, event):
         if event.button == 3 and not (event.state & (gtk.gdk.SHIFT_MASK |
             gtk.gdk.CONTROL_MASK)):
-            crow = widget.get_path_at_pos(int(event.x), int(event.y))[0]
-            (model, pathlist) = widget.get_selection().get_selected_rows()
+            path = tree.get_path_at_pos(int(event.x), int(event.y))
+            if not path:
+                return False
+            crow = path[0]
+            (model, pathlist) = tree.get_selection().get_selected_rows()
             if pathlist == []:
                 return False
             srow = pathlist[0]
             if srow == crow:
-                self._tree_popup_menu(widget, event.button, event.time)
+                self._tree_popup_menu(tree, event.button, event.time)
             else:
-                widget.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
-                widget.get_selection().select_path(crow)
+                tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
+                tree.get_selection().select_path(crow)
                 self._orig_sel = srow
                 self._revs = (int(model[srow][treemodel.REVID]),
                         int(model[crow][treemodel.REVID]))
-                self._tree_popup_menu_diff(widget, event.button, event.time)
+                self._tree_popup_menu_diff(tree, event.button, event.time)
             return True
         return False
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.