diff --git a/src/gui/editors/editfamily.py b/src/gui/editors/editfamily.py index b05907e54..7c2a1c79f 100644 --- a/src/gui/editors/editfamily.py +++ b/src/gui/editors/editfamily.py @@ -550,6 +550,20 @@ class EditFamily(EditPrimary): #allow for a context menu self.set_contexteventbox(self.top.get_object("eventboxtop")) + + #allow for drop: + ftable = self.top.get_object('ftable') + ftable.drag_dest_set(gtk.DEST_DEFAULT_MOTION | + gtk.DEST_DEFAULT_DROP, + [DdTargets.PERSON_LINK.target()], + gtk.gdk.ACTION_COPY) + ftable.connect('drag_data_received', self.on_drag_fatherdata_received) + mtable = self.top.get_object('mtable') + mtable.drag_dest_set(gtk.DEST_DEFAULT_MOTION | + gtk.DEST_DEFAULT_DROP, + [DdTargets.PERSON_LINK.target()], + gtk.gdk.ACTION_COPY) + mtable.connect('drag_data_received', self.on_drag_motherdata_received) def _connect_signals(self): self.define_ok_button(self.top.get_object('ok'), self.save) @@ -896,6 +910,46 @@ class EditFamily(EditPrimary): person.family_list.append(self.obj.handle) self.db.commit_person(person, trans) + def on_drag_fatherdata_received(self, widget, context, x, y, sel_data, + info, time): + """ + Handle the standard gtk interface for drag_data_received. + """ + if self.obj.get_father_handle(): + return + for i in self.hidden: + i.set_sensitive(True) + if sel_data and sel_data.data: + (drag_type, idval, handle, val) = pickle.loads(sel_data.data) + person = self.db.get_person_from_handle(handle) + + if person: + self.check_for_existing_family(person.handle, + self.obj.get_mother_handle(), + self.obj.handle) + self.obj.set_father_handle(person.handle) + self.update_father(person.handle) + + def on_drag_motherdata_received(self, widget, context, x, y, sel_data, + info, time): + """ + Handle the standard gtk interface for drag_data_received. + """ + if self.obj.get_mother_handle(): + return + for i in self.hidden: + i.set_sensitive(True) + if sel_data and sel_data.data: + (drag_type, idval, handle, val) = pickle.loads(sel_data.data) + person = self.db.get_person_from_handle(handle) + + if person: + self.check_for_existing_family(self.obj.get_father_handle(), + person.handle, + self.obj.handle) + self.obj.set_mother_handle(person.handle) + self.update_mother(person.handle) + def object_is_empty(self): return (not self.obj.get_father_handle() and not self.obj.get_mother_handle() and