From f9dc4c6d9a76f4fad025c447e61326c757d1d0ba Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 20 Jun 2006 21:18:49 +0000 Subject: [PATCH] * src/Editors/_EditFamily.py: handle drag-n-drop for childrefs separately svn: r6927 --- ChangeLog | 2 ++ src/DisplayTabs/_EmbeddedList.py | 2 +- src/Editors/_EditFamily.py | 35 +++++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9213b53c7..a258ccf90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 2006-06-20 Don Allingham + * src/Editors/_EditFamily.py: handle drag-n-drop for childrefs + separately * src/Editors/_EditEvent.py: focus on date on open * src/Editors/_EditEventRef.py: focus on date on open * src/UndoHistory.py: don't attempt to unregister with the window diff --git a/src/DisplayTabs/_EmbeddedList.py b/src/DisplayTabs/_EmbeddedList.py index a39328447..a9a5bd2a3 100644 --- a/src/DisplayTabs/_EmbeddedList.py +++ b/src/DisplayTabs/_EmbeddedList.py @@ -169,7 +169,7 @@ class EmbeddedList(ButtonTab): return # pickle the data, and build the tuple to be passed - value = (self._DND_TYPE.drag_type, id(self), obj,self.find_index(obj)) + value = (self._DND_TYPE.drag_type, id(self), obj, self.find_index(obj)) data = pickle.dumps(value) # pass as a string (8 bits) diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index f5da43b1e..6167d530a 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -26,6 +26,7 @@ # #------------------------------------------------------------------------- from gettext import gettext as _ +import pickle #------------------------------------------------------------------------- # @@ -124,7 +125,8 @@ class ChildEmbedList(EmbeddedList): """ returns the index of the object within the associated data """ - return self.family.get_child_ref_list().index(obj) + reflist = [ref.ref for ref in self.family.get_child_ref_list()] + return reflist.index(obj) def _find_row(self,x,y): row = self.tree.get_path_at_pos(x,y) @@ -259,6 +261,37 @@ class ChildEmbedList(EmbeddedList): ref, self.child_ref_edited) break + def drag_data_received(self, widget, context, x, y, sel_data, info, time): + """ + Handle the standard gtk interface for drag_data_received. + + If the selection data is define, extract the value from sel_data.data, + and decide if this is a move or a reorder. + """ + if sel_data and sel_data.data: + (mytype, selfid, obj, row_from) = pickle.loads(sel_data.data) + + # make sure this is the correct DND type for this object + if mytype == self._DND_TYPE.drag_type: + + # determine the destination row + row = self._find_row(x, y) + + # if the is same object, we have a move, otherwise, + # it is a standard drag-n-drop + + if id(self) == selfid: + obj = self.get_data().get_child_ref_list()[row_from] + self._move(row_from, row, obj) + else: + handle = obj + obj = RelLib.ChildRef() + obj.ref = handle + self._handle_drag(row, obj) + self.rebuild() + elif self._DND_EXTRA and mytype == self._DND_EXTRA.drag_type: + self.handle_extra_type(mytype, obj) + def north_american(self): father_handle = self.family.get_father_handle() if father_handle: