From ea3afbb35c54bc0e74d874f4830b572bed7603f7 Mon Sep 17 00:00:00 2001 From: Bastien Jacquet Date: Sun, 26 Oct 2014 10:56:38 +0100 Subject: [PATCH] Create prefilled PersonRef when drop of a Person on Association EmbeddedTab (same as ChildTab) --- .../editors/displaytabs/personrefembedlist.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gramps/gui/editors/displaytabs/personrefembedlist.py b/gramps/gui/editors/displaytabs/personrefembedlist.py index 76a989b55..85257e327 100644 --- a/gramps/gui/editors/displaytabs/personrefembedlist.py +++ b/gramps/gui/editors/displaytabs/personrefembedlist.py @@ -48,6 +48,7 @@ class PersonRefEmbedList(EmbeddedList): _HANDLE_COL = 4 _DND_TYPE = DdTargets.PERSONREF + _DND_EXTRA = DdTargets.PERSON_LINK _MSG = { 'add' : _('Create and add a new association'), @@ -127,3 +128,23 @@ class PersonRefEmbedList(EmbeddedList): ref, self.add_callback) except WindowActiveError: pass + + + def handle_extra_type(self, objtype, obj): + """ + Called when a person is dropped onto the list. objtype will be + 'person-link' and obj will contain a person handle. + """ + person = self.dbstate.db.get_person_from_handle(obj) + + from .. import EditPersonRef + try: + ref = PersonRef() + ref.rel = _('Unknown') + if person: + ref.ref = person.get_handle() + EditPersonRef( + self.dbstate, self.uistate, self.track, + ref, self.add_callback) + except WindowActiveError: + pass