From 520e7eb18bfe2fd886b166664846410093c3b26c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 3 Sep 2006 22:14:47 +0000 Subject: [PATCH] 2006-09-03 Don Allingham * src/ScratchPad.py: add dnd support for MediaRefs (bug #417) * src/DdTargets.py: add dnd support for MediaRefs (bug #417) svn: r7301 --- ChangeLog | 4 ++++ src/DdTargets.py | 6 +++--- src/ScratchPad.py | 25 +++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 163f9a90d..b36af96df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-09-03 Don Allingham + * src/ScratchPad.py: add dnd support for MediaRefs (bug #417) + * src/DdTargets.py: add dnd support for MediaRefs (bug #417) + 2006-09-02 Don Allingham * src/DisplayTabs/_EventEmbedList.py: Don't override event type on a drag-n-drop (bug #420) diff --git a/src/DdTargets.py b/src/DdTargets.py index 272a56e15..3979561cc 100644 --- a/src/DdTargets.py +++ b/src/DdTargets.py @@ -141,14 +141,14 @@ class _DdTargets(object): self.NAME, self.REPOREF, self.MEDIAOBJ, + self.MEDIAREF, self.REPO_LINK, self.SOURCE_LINK, self.PERSON_LINK, self.PERSON_LINK_LIST] - self.CHILD = _DdType(self,'child') - self.SPOUSE = _DdType(self,'spouse') - + self.CHILD = _DdType(self,'child') + self.SPOUSE = _DdType(self,'spouse') self.TEXT = _DdType(self,'TEXT',0,1) self.TEXT_MIME = _DdType(self,'text/plain',0,0) self.STRING = _DdType(self,'STRING', 0, 2) diff --git a/src/ScratchPad.py b/src/ScratchPad.py index d26b6567a..cd6aeb5ec 100644 --- a/src/ScratchPad.py +++ b/src/ScratchPad.py @@ -503,10 +503,13 @@ class ScratchMediaObj(ScratchPadWrapper): def __init__(self, db, obj): ScratchPadWrapper.__init__(self, db, obj) + + (drag_type, idval, handle, val) = pickle.loads(obj) self._type = _("Media Object") - self._title = "" - self._value = "" + obj = db.get_object_from_handle(handle) + self._title = obj.get_description() + self._value = obj.get_path() def tooltip(self): global escape @@ -514,6 +517,23 @@ class ScratchMediaObj(ScratchPadWrapper): "%s" % (_("Media Object"), escape(self._obj)) +class ScratchPadMediaRef(ScratchPadGrampsTypeWrapper): + + DROP_TARGETS = [DdTargets.MEDIAREF] + DRAG_TARGET = DdTargets.MEDIAREF + ICON = LINK_PIC + + def __init__(self, db, obj): + ScratchPadGrampsTypeWrapper.__init__(self, db, obj) + self._type = _("Media Reference") + + base = self._db.get_object_from_handle(self._obj.get_reference_handle()) + self._title = base.get_description() + self._value = base.get_path() + + def tooltip(self): + return "" + class ScratchPersonLink(ScratchPadWrapper): DROP_TARGETS = [DdTargets.PERSON_LINK] @@ -765,6 +785,7 @@ class ScratchPadListView: self.register_wrapper_class(ScratchPadName) self.register_wrapper_class(ScratchRepositoryLink) self.register_wrapper_class(ScratchMediaObj) + self.register_wrapper_class(ScratchPadMediaRef) self.register_wrapper_class(ScratchSourceLink) self.register_wrapper_class(ScratchPersonLink) self.register_wrapper_class(ScratchPersonLinkList)