Add drag support to parents in EditFamily (when set) and move drop capability if parent already set
This commit is contained in:
parent
1797b66f48
commit
b7ab556393
@ -564,9 +564,33 @@ class EditFamily(EditPrimary):
|
||||
#allow for a context menu
|
||||
self.set_contexteventbox(self.top.get_object("eventboxtop"))
|
||||
|
||||
def _update_parent_dnd_handler(self, event_box, parent_handle, on_drag_data_get, on_drag_data_received):
|
||||
"""
|
||||
Set the drag action from the label of father when he exists
|
||||
"""
|
||||
if parent_handle:
|
||||
# Allow drag
|
||||
if not event_box.drag_source_get_target_list():
|
||||
event_box.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
|
||||
[],
|
||||
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_source_set_target_list(tglist)
|
||||
event_box.drag_source_set_icon_stock('gramps-person')
|
||||
event_box.connect('drag_data_get', on_drag_data_get)
|
||||
#Disallow drop:
|
||||
if event_box.drag_dest_get_target_list():
|
||||
event_box.drag_dest_unset()
|
||||
else:
|
||||
# Disallow drag
|
||||
if event_box.drag_source_get_target_list():
|
||||
event_box.drag_source_unset()
|
||||
#allow for drop:
|
||||
ftable = self.top.get_object('ftable')
|
||||
ftable.drag_dest_set(Gtk.DestDefaults.MOTION |
|
||||
if not event_box.drag_dest_get_target_list():
|
||||
event_box.drag_dest_set(Gtk.DestDefaults.MOTION |
|
||||
Gtk.DestDefaults.DROP,
|
||||
[],
|
||||
Gdk.DragAction.COPY)
|
||||
@ -574,19 +598,18 @@ class EditFamily(EditPrimary):
|
||||
tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
|
||||
DdTargets.PERSON_LINK.target_flags,
|
||||
DdTargets.PERSON_LINK.app_id)
|
||||
ftable.drag_dest_set_target_list(tglist)
|
||||
ftable.connect('drag_data_received', self.on_drag_fatherdata_received)
|
||||
mtable = self.top.get_object('mtable')
|
||||
mtable.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)
|
||||
mtable.drag_dest_set_target_list(tglist)
|
||||
mtable.connect('drag_data_received', self.on_drag_motherdata_received)
|
||||
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):
|
||||
self.define_ok_button(self.top.get_object('ok'), self.save)
|
||||
@ -720,12 +743,20 @@ class EditFamily(EditPrimary):
|
||||
self.fdeath, self.fdeath_label,
|
||||
self.fbutton_index, self.fbutton_add,
|
||||
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):
|
||||
self.load_parent(handle, self.mname, self.mbirth, self.mbirth_label,
|
||||
self.mdeath, self.mdeath_label,
|
||||
self.mbutton_index, self.mbutton_add,
|
||||
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):
|
||||
person = Person()
|
||||
|
@ -84,6 +84,7 @@
|
||||
<child>
|
||||
<object class="GtkEventBox" id="eventboxtop">
|
||||
<property name="visible">True</property>
|
||||
<property name="visible-window">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox">
|
||||
@ -95,6 +96,10 @@
|
||||
<object class="GtkHBox" id="hbox121">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEventBox" id="ftable_event_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="visible-window">False</property>
|
||||
<child>
|
||||
<object class="GtkTable" id="ftable">
|
||||
<property name="width_request">132</property>
|
||||
@ -353,6 +358,8 @@
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
@ -362,6 +369,10 @@
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEventBox" id="mtable_event_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="visible-window">False</property>
|
||||
<child>
|
||||
<object class="GtkTable" id="mtable">
|
||||
<property name="width_request">132</property>
|
||||
@ -651,6 +662,8 @@
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user