Allow to drag a person from EditPerson (if not a unsaved person)
This commit is contained in:
parent
4e86fdafc5
commit
1797b66f48
@ -34,6 +34,11 @@ to edit information about a particular Person.
|
|||||||
from copy import copy
|
from copy import copy
|
||||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.sgettext
|
_ = glocale.translation.sgettext
|
||||||
|
import sys
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
import cPickle as pickle
|
||||||
|
else:
|
||||||
|
import pickle
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -59,6 +64,7 @@ from .. import widgets
|
|||||||
from gramps.gen.display.name import displayer as name_displayer
|
from gramps.gen.display.name import displayer as name_displayer
|
||||||
from gramps.gen.errors import WindowActiveError
|
from gramps.gen.errors import WindowActiveError
|
||||||
from ..glade import Glade
|
from ..glade import Glade
|
||||||
|
from ..ddtargets import DdTargets
|
||||||
from ..widgets.menuitem import add_menuitem
|
from ..widgets.menuitem import add_menuitem
|
||||||
|
|
||||||
from .editprimary import EditPrimary
|
from .editprimary import EditPrimary
|
||||||
@ -247,6 +253,19 @@ class EditPerson(EditPrimary):
|
|||||||
|
|
||||||
self.eventbox.connect('button-press-event',
|
self.eventbox.connect('button-press-event',
|
||||||
self._image_button_press)
|
self._image_button_press)
|
||||||
|
# allow to initiate a drag-and-drop with this person if it has a handle
|
||||||
|
if self.obj.get_handle():
|
||||||
|
tglist = Gtk.TargetList.new([])
|
||||||
|
tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
|
||||||
|
DdTargets.PERSON_LINK.target_flags,
|
||||||
|
DdTargets.PERSON_LINK.app_id)
|
||||||
|
self.contexteventbox.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
|
||||||
|
[],
|
||||||
|
Gdk.DragAction.COPY)
|
||||||
|
self.contexteventbox.drag_source_set_target_list(tglist)
|
||||||
|
self.contexteventbox.drag_source_set_icon_stock('gramps-person')
|
||||||
|
self.contexteventbox.connect('drag_data_get',
|
||||||
|
self._top_drag_data_get)
|
||||||
|
|
||||||
def _connect_db_signals(self):
|
def _connect_db_signals(self):
|
||||||
"""
|
"""
|
||||||
@ -686,6 +705,11 @@ class EditPerson(EditPrimary):
|
|||||||
|
|
||||||
return ui_top_cm, [self.all_action, self.home_action]
|
return ui_top_cm, [self.all_action, self.home_action]
|
||||||
|
|
||||||
|
def _top_drag_data_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_handle(), 0)
|
||||||
|
sel_data.set(DdTargets.PERSON_LINK.atom_drag_type, 8, pickle.dumps(data))
|
||||||
|
|
||||||
def _post_build_popup_ui(self):
|
def _post_build_popup_ui(self):
|
||||||
"""
|
"""
|
||||||
Override base class, make inactive home action if not needed.
|
Override base class, make inactive home action if not needed.
|
||||||
|
Loading…
Reference in New Issue
Block a user