* src/Editors/_EditFamily.py: handle drag-n-drop for childrefs

separately


svn: r6927
This commit is contained in:
Don Allingham 2006-06-20 21:18:49 +00:00
parent fe75f503e0
commit fcd6deacd0
3 changed files with 37 additions and 2 deletions

View File

@ -1,4 +1,6 @@
2006-06-20 Don Allingham <don@gramps-project.org>
* 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

View File

@ -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)

View File

@ -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: