Feature: all drop on family father/mother to set

svn: r20360
This commit is contained in:
Benny Malengier 2012-09-10 20:13:32 +00:00
parent 2f28174eb0
commit 03855427b7

View File

@ -551,6 +551,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)
self.define_cancel_button(self.top.get_object('cancel'))
@ -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