diff --git a/src/gui/clipboard.py b/src/gui/clipboard.py index 7bea1c2fe..5184a43ec 100644 --- a/src/gui/clipboard.py +++ b/src/gui/clipboard.py @@ -133,18 +133,18 @@ def obj2class(target): } return d[target] if target in d else None -def obj2target(target): - d = {"Person": 'person-link', - "Family": 'family-link', - 'Source': 'source-link', - 'Citation': 'citation-link', - 'Repository': 'repo-link', - 'Event': 'pevent', - 'Media': 'mediaobj', - 'Place': 'place-link', - 'Note': 'note-link', +OBJ2TARGET = {"Person": Gdk.atom_intern('person-link', False), + "Family": Gdk.atom_intern('family-link', False), + 'Source': Gdk.atom_intern('source-link', False), + 'Citation': Gdk.atom_intern('citation-link', False), + 'Repository': Gdk.atom_intern('repo-link', False), + 'Event': Gdk.atom_intern('pevent', False), + 'Media': Gdk.atom_intern('mediaobj', False), + 'Place': Gdk.atom_intern('place-link', False), + 'Note': Gdk.atom_intern('note-link', False), } - return d[target] if target in d else None +def obj2target(target): + return OBJ2TARGET[target] if target in OBJ2TARGET else None def model_contains(model, data): """ @@ -857,7 +857,7 @@ class ClipDropHandleList(ClipDropList): retval = [] for (objclass, handle) in self._obj_list: _class = obj2class(objclass) - target = obj2target(objclass) + target = obj2target(objclass).name() # outgoing: # (drag_type, idval, self._handle, val) = pickle.loads(self._obj) data = (target, id(self), handle, 0) diff --git a/src/gui/views/pageview.py b/src/gui/views/pageview.py index 9795185d1..7fb930881 100644 --- a/src/gui/views/pageview.py +++ b/src/gui/views/pageview.py @@ -249,11 +249,17 @@ class PageView(DbGUIElement): class Selection(object): def __init__(self, data): self.data = data + def get_data(self): + return self.data class Context(object): targets = [drag_type] action = 1 + def list_targets(self): + return Context.targets + def get_actions(self): + return Context.action # eg: ('person-link', 23767, '27365123671', 0) - data = (drag_type, id(self), handle, 0) + data = (drag_type.name(), id(self), handle, 0) clipboard.object_list.object_drag_data_received( clipboard.object_list._widget, # widget Context(), # drag type and action @@ -271,7 +277,7 @@ class PageView(DbGUIElement): The code creates the Clipboard if it does not already exist. """ - from gui.clipboard import ClipboardWindow, obj2target + from gui.clipboard import ClipboardWindow clipboard = None for widget in self.uistate.gwm.window_tree: if isinstance(widget, ClipboardWindow):