From 03855427b7d8c7ba7618141d61b54d7c62a8e654 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Mon, 10 Sep 2012 20:13:32 +0000 Subject: [PATCH] Feature: all drop on family father/mother to set svn: r20360 --- src/gui/editors/editfamily.py | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) 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