Re-enable selection in MultiTreeView on a grab_broken event

As of GTK 3.18.0 a fake button release event is no longer sent when
a DnD completes:

  https://bugzilla.gnome.org/show_bug.cgi?id=749737

As a result we keep selection disabled which then means that the next
drag from the clipboard fails to select the dragged object and we wind
up trying to drop the old selection instead.
This commit is contained in:
Tom Hughes 2015-10-20 00:13:55 +01:00
parent 9e07b3e092
commit 201f4a5e51
2 changed files with 11 additions and 0 deletions

View File

@ -1477,6 +1477,7 @@ class MultiTreeView(Gtk.TreeView):
Gtk.TreeView.__init__(self) Gtk.TreeView.__init__(self)
self.connect('button_press_event', self.on_button_press) self.connect('button_press_event', self.on_button_press)
self.connect('button_release_event', self.on_button_release) self.connect('button_release_event', self.on_button_release)
self.connect('grab_broken_event', self.on_grab_broken)
self.connect('key_press_event', self.key_press_event) self.connect('key_press_event', self.key_press_event)
self.defer_select = False self.defer_select = False
@ -1578,6 +1579,11 @@ class MultiTreeView(Gtk.TreeView):
self.defer_select=False self.defer_select=False
def on_grab_broken(self, widget, event):
# re-enable selection
self.get_selection().set_select_function(lambda *ignore: True, None)
self.defer_select=False
def edit_obj(self, objclass, handle): def edit_obj(self, objclass, handle):
from .editors import (EditPerson, EditEvent, EditFamily, EditSource, from .editors import (EditPerson, EditEvent, EditFamily, EditSource,
EditPlace, EditRepository, EditNote, EditMedia, EditPlace, EditRepository, EditNote, EditMedia,

View File

@ -40,6 +40,7 @@ class MultiTreeView(Gtk.TreeView):
Gtk.TreeView.__init__(self) Gtk.TreeView.__init__(self)
self.connect('button_press_event', self.on_button_press) self.connect('button_press_event', self.on_button_press)
self.connect('button_release_event', self.on_button_release) self.connect('button_release_event', self.on_button_release)
self.connect('grab_broken_event', self.on_grab_broken)
self.connect('key_press_event', self.key_press_event) self.connect('key_press_event', self.key_press_event)
self.defer_select = False self.defer_select = False
@ -82,3 +83,7 @@ class MultiTreeView(Gtk.TreeView):
self.defer_select=False self.defer_select=False
def on_grab_broken(self, widget, event):
# re-enable selection
self.get_selection().set_select_function(lambda *ignore: True, None)
self.defer_select=False