798
798
Also sets the internal state for button pressed
800
(Taken from thunar_details_view_button_press_event() of thunar-details-view.c)
800
Taken from the following sources:
802
* thunar_details_view_button_press_event() of thunar-details-view.c
803
* MultiDragTreeView.__button_press/__button.release of quodlibet/qltk/views.py
802
805
self.button_pressed = True
803
806
selection = self.get_selection()
810
813
if e.state & gtk.accelerator_get_default_mod_mask() == 0 and not path:
811
814
selection.unselect_all()
813
# Open the context menu on right clicks
814
if e.type == gtk.gdk.BUTTON_PRESS and e.button == 3:
816
# Select the path on which the user clicked if not selected yet
817
if not selection.path_is_selected(path):
818
# We don't unselect all other items if Control is active
819
if e.state & gtk.gdk.CONTROL_MASK == 0:
820
selection.unselect_all()
822
selection.select_path(path)
824
self.menu.popup(None, None, None, e.button, e.time)
816
if path and e.type == gtk.gdk.BUTTON_PRESS:
817
# Prevent unselection of all except the clicked item on left
818
# clicks, required to preserve the selection for DnD
819
if e.button == 1 and e.state & gtk.accelerator_get_default_mod_mask() == 0 and \
820
selection.path_is_selected(path):
821
selection.set_select_function(lambda *args: False)
823
# Open the context menu on right clicks
826
# Select the path on which the user clicked if not selected yet
827
if not selection.path_is_selected(path):
828
# We don't unselect all other items if Control is active
829
if e.state & gtk.gdk.CONTROL_MASK == 0:
830
selection.unselect_all()
832
selection.select_path(path)
834
self.menu.popup(None, None, None, e.button, e.time)
828
838
return gtk.TreeView.do_button_press_event(self, e)
832
842
Unsets the internal state for button press
834
844
self.button_pressed = False
845
# Restore regular selection behavior in any case
846
self.get_selection().set_select_function(lambda *args: True)
836
848
return gtk.TreeView.do_button_release_event(self, e)