Add drag support to parents in EditFamily (when set) and move drop capability if parent already set
This commit is contained in:
committed by
Nick Hall
parent
1797b66f48
commit
b7ab556393
@ -563,30 +563,53 @@ class EditFamily(EditPrimary):
|
|||||||
|
|
||||||
#allow for a context menu
|
#allow for a context menu
|
||||||
self.set_contexteventbox(self.top.get_object("eventboxtop"))
|
self.set_contexteventbox(self.top.get_object("eventboxtop"))
|
||||||
|
|
||||||
#allow for drop:
|
def _update_parent_dnd_handler(self, event_box, parent_handle, on_drag_data_get, on_drag_data_received):
|
||||||
ftable = self.top.get_object('ftable')
|
"""
|
||||||
ftable.drag_dest_set(Gtk.DestDefaults.MOTION |
|
Set the drag action from the label of father when he exists
|
||||||
Gtk.DestDefaults.DROP,
|
"""
|
||||||
[],
|
if parent_handle:
|
||||||
Gdk.DragAction.COPY)
|
# Allow drag
|
||||||
tglist = Gtk.TargetList.new([])
|
if not event_box.drag_source_get_target_list():
|
||||||
tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
|
event_box.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
|
||||||
DdTargets.PERSON_LINK.target_flags,
|
[],
|
||||||
DdTargets.PERSON_LINK.app_id)
|
Gdk.DragAction.COPY)
|
||||||
ftable.drag_dest_set_target_list(tglist)
|
tglist = Gtk.TargetList.new([])
|
||||||
ftable.connect('drag_data_received', self.on_drag_fatherdata_received)
|
tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
|
||||||
mtable = self.top.get_object('mtable')
|
DdTargets.PERSON_LINK.target_flags,
|
||||||
mtable.drag_dest_set(Gtk.DestDefaults.MOTION |
|
DdTargets.PERSON_LINK.app_id)
|
||||||
Gtk.DestDefaults.DROP,
|
event_box.drag_source_set_target_list(tglist)
|
||||||
[],
|
event_box.drag_source_set_icon_stock('gramps-person')
|
||||||
Gdk.DragAction.COPY)
|
event_box.connect('drag_data_get', on_drag_data_get)
|
||||||
tglist = Gtk.TargetList.new([])
|
#Disallow drop:
|
||||||
tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
|
if event_box.drag_dest_get_target_list():
|
||||||
DdTargets.PERSON_LINK.target_flags,
|
event_box.drag_dest_unset()
|
||||||
DdTargets.PERSON_LINK.app_id)
|
else:
|
||||||
mtable.drag_dest_set_target_list(tglist)
|
# Disallow drag
|
||||||
mtable.connect('drag_data_received', self.on_drag_motherdata_received)
|
if event_box.drag_source_get_target_list():
|
||||||
|
event_box.drag_source_unset()
|
||||||
|
#allow for drop:
|
||||||
|
if not event_box.drag_dest_get_target_list():
|
||||||
|
event_box.drag_dest_set(Gtk.DestDefaults.MOTION |
|
||||||
|
Gtk.DestDefaults.DROP,
|
||||||
|
[],
|
||||||
|
Gdk.DragAction.COPY)
|
||||||
|
tglist = Gtk.TargetList.new([])
|
||||||
|
tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
|
||||||
|
DdTargets.PERSON_LINK.target_flags,
|
||||||
|
DdTargets.PERSON_LINK.app_id)
|
||||||
|
event_box.drag_dest_set_target_list(tglist)
|
||||||
|
event_box.connect('drag_data_received', on_drag_data_received)
|
||||||
|
|
||||||
|
def on_drag_fatherdata_get(self, widget, context, sel_data, info, time):
|
||||||
|
if info == DdTargets.PERSON_LINK.app_id:
|
||||||
|
data = (DdTargets.PERSON_LINK.drag_type, id(self), self.obj.get_father_handle(), 0)
|
||||||
|
sel_data.set(DdTargets.PERSON_LINK.atom_drag_type, 8, pickle.dumps(data))
|
||||||
|
|
||||||
|
def on_drag_motherdata_get(self, widget, context, sel_data, info, time):
|
||||||
|
if info == DdTargets.PERSON_LINK.app_id:
|
||||||
|
data = (DdTargets.PERSON_LINK.drag_type, id(self), self.obj.get_mother_handle(), 0)
|
||||||
|
sel_data.set(DdTargets.PERSON_LINK.atom_drag_type, 8, pickle.dumps(data))
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
self.define_ok_button(self.top.get_object('ok'), self.save)
|
self.define_ok_button(self.top.get_object('ok'), self.save)
|
||||||
@ -720,12 +743,20 @@ class EditFamily(EditPrimary):
|
|||||||
self.fdeath, self.fdeath_label,
|
self.fdeath, self.fdeath_label,
|
||||||
self.fbutton_index, self.fbutton_add,
|
self.fbutton_index, self.fbutton_add,
|
||||||
self.fbutton_del, self.fbutton_edit)
|
self.fbutton_del, self.fbutton_edit)
|
||||||
|
self._update_parent_dnd_handler(self.top.get_object('ftable_event_box'),
|
||||||
|
self.obj.get_father_handle(),
|
||||||
|
self.on_drag_fatherdata_get,
|
||||||
|
self.on_drag_fatherdata_received)
|
||||||
|
|
||||||
def update_mother(self, handle):
|
def update_mother(self, handle):
|
||||||
self.load_parent(handle, self.mname, self.mbirth, self.mbirth_label,
|
self.load_parent(handle, self.mname, self.mbirth, self.mbirth_label,
|
||||||
self.mdeath, self.mdeath_label,
|
self.mdeath, self.mdeath_label,
|
||||||
self.mbutton_index, self.mbutton_add,
|
self.mbutton_index, self.mbutton_add,
|
||||||
self.mbutton_del, self.mbutton_edit)
|
self.mbutton_del, self.mbutton_edit)
|
||||||
|
self._update_parent_dnd_handler(self.top.get_object('mtable_event_box'),
|
||||||
|
self.obj.get_mother_handle(),
|
||||||
|
self.on_drag_motherdata_get,
|
||||||
|
self.on_drag_motherdata_received)
|
||||||
|
|
||||||
def add_mother_clicked(self, obj):
|
def add_mother_clicked(self, obj):
|
||||||
person = Person()
|
person = Person()
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user