diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 81f1d373c..cce938cc7 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,6 @@ 2006-03-22 Don Allingham + * src/ScratchPad.py: handle repositories + * * src/DataViews/_SourceView.py: handle drag and drop * src/DataViews/_PersonView.py: handle drag and drop * src/ViewManager.py: pychecker fixes diff --git a/gramps2/src/DataViews/_RepositoryView.py b/gramps2/src/DataViews/_RepositoryView.py index bc5ced87a..8228ae1d9 100644 --- a/gramps2/src/DataViews/_RepositoryView.py +++ b/gramps2/src/DataViews/_RepositoryView.py @@ -38,6 +38,7 @@ import DisplayModels import const import Utils from Editors import EditRepository, DelRepositoryQuery +from DdTargets import DdTargets from QuestionDialog import QuestionDialog, ErrorDialog @@ -83,6 +84,8 @@ class RepositoryView(PageView.ListView): DisplayModels.RepositoryModel, signal_map) + def drag_info(self): + return DdTargets.REPO_LINK def define_actions(self): PageView.ListView.define_actions(self) diff --git a/gramps2/src/DdTargets.py b/gramps2/src/DdTargets.py index 5d6a0ad66..f4ef15593 100644 --- a/gramps2/src/DdTargets.py +++ b/gramps2/src/DdTargets.py @@ -113,6 +113,7 @@ class _DdTargets(object): self.ADDRESS = _DdType(self,'paddr') self.SOURCEREF = _DdType(self,'srcref') self.REPOREF = _DdType(self,'reporef') + self.REPO_LINK = _DdType(self,'repo-link') self.NAME = _DdType(self,'name') self.MEDIAOBJ = _DdType(self,'mediaobj') self.DATA = _DdType(self,'data_tuple') @@ -136,6 +137,8 @@ class _DdTargets(object): self.SOURCEREF, self.EVENTREF, self.NAME, + self.REPO_LINK, + self.REPOREF, self.MEDIAOBJ, self.PERSON_LINK, self.PERSON_LINK_LIST] diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index 55290fd61..34d165cf5 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -1482,6 +1482,7 @@ class RepoEmbedList(EmbeddedList): _HANDLE_COL = 4 _DND_TYPE = DdTargets.REPOREF + _DND_EXTRA = DdTargets.REPO_LINK _column_names = [ (_('ID'), 0, 75), @@ -1505,12 +1506,12 @@ class RepoEmbedList(EmbeddedList): return ((1,0),(1,1),(1,2),(1,3)) def add_button_clicked(self,obj): - from Editors import EditRepositoryRef + from Editors import EditRepoRef ref = RelLib.RepoRef() repo = RelLib.Repository() try: - EditRepositoryRef( + EditRepoRef.EditRepoRef( self.dbstate, self.uistate, self.track, repo, ref, self.add_callback) except Errors.WindowActiveError: diff --git a/gramps2/src/GrampsDb/_GrampsBSDDB.py b/gramps2/src/GrampsDb/_GrampsBSDDB.py index d4dfdc7f7..115635eaf 100644 --- a/gramps2/src/GrampsDb/_GrampsBSDDB.py +++ b/gramps2/src/GrampsDb/_GrampsBSDDB.py @@ -198,7 +198,7 @@ class GrampsBSDDB(GrampsDbBase): return GrampsBSDDBCursor(self.media_map,self.txn) def get_repository_cursor(self): - return GrampsBSDDBAssocCursor(self.repository_map,self.txn) + return GrampsBSDDBCursor(self.repository_map,self.txn) def has_person_handle(self,handle): """ diff --git a/gramps2/src/ScratchPad.py b/gramps2/src/ScratchPad.py index 2db385dfa..41915734d 100644 --- a/gramps2/src/ScratchPad.py +++ b/gramps2/src/ScratchPad.py @@ -183,7 +183,7 @@ class ScratchPadEvent(ScratchPadWrapper): def __init__(self,dbstate,obj): ScratchPadWrapper.__init__(self,dbstate,obj) - self._type = _("Event") + self._type = _("Event Link") (drag_type, idval, handle, val) = pickle.loads(obj) @@ -383,6 +383,28 @@ class ScratchPadSourceRef(ScratchPadGrampsTypeWrapper): return s +class ScratchPadRepoRef(ScratchPadGrampsTypeWrapper): + + DROP_TARGETS = [DdTargets.REPOREF] + DRAG_TARGET = DdTargets.REPOREF + ICON = BLANK_PIC + + def __init__(self,dbstate,obj): + ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) + self._type = _("Repository Reference") + + base = self._db.get_repository_from_handle(self._obj.ref) + self._title = base.get_name() + + value = base.get_type() + if value == RelLib.Repository.CUSTOM: + self._value = value[1] + else: + self._value = Utils.repository_types[value[0]] + + def tooltip(self): + return "" + class ScratchPadEventRef(ScratchPadGrampsTypeWrapper): DROP_TARGETS = [DdTargets.EVENTREF] @@ -551,6 +573,29 @@ class ScratchSourceLink(ScratchPadWrapper): def tooltip(self): return "" +class ScratchRepositoryLink(ScratchPadWrapper): + + DROP_TARGETS = [DdTargets.REPO_LINK] + DRAG_TARGET = DdTargets.REPO_LINK + ICON = LINK_PIC + + def __init__(self,dbstate,obj): + ScratchPadWrapper.__init__(self,dbstate,obj) + self._type = _("Repository Link") + + (drag_type, idval, handle, val) = pickle.loads(obj) + + source = self._db.get_repository_from_handle(handle) + self._title = source.get_name() + value = source.get_type() + if value == RelLib.Repository.CUSTOM: + self._value = value[1] + else: + self._value = Utils.repository_types[value[0]] + + def tooltip(self): + return "" + #------------------------------------------------------------------------- # # Wrapper classes to deal with lists of objects @@ -707,7 +752,8 @@ class ScratchPadListView: self.register_wrapper_class(ScratchPadAttribute) self.register_wrapper_class(ScratchPadFamilyAttribute) self.register_wrapper_class(ScratchPadName) - self.register_wrapper_class(ScratchPadText) + self.register_wrapper_class(ScratchPadRepoRef) + self.register_wrapper_class(ScratchRepositoryLink) self.register_wrapper_class(ScratchMediaObj) self.register_wrapper_class(ScratchSourceLink) self.register_wrapper_class(ScratchPersonLink)