diff --git a/src/Bookmarks.py b/src/Bookmarks.py index 9f156c249..3fc0d6eb4 100644 --- a/src/Bookmarks.py +++ b/src/Bookmarks.py @@ -374,6 +374,29 @@ class CitationBookmarks(ListBookmarks) : def make_label(self, handle): return Utils.navigation_label(self.dbstate.db, 'Citation', handle) + # Override add from ListBookmarks, so that when self.bookmarks.add is called + # from ListView.add_bookmark, it will not add a Source bookmark to a + # Citation view. + def add(self, handle): + """Append the citation to the bottom of the bookmarks.""" + if self.dbstate.db.get_citation_from_handle(handle): + ListBookmarks.add(self, handle) + else: + # Probably trying to bookmark a source when the navigation type is + # citation. This can occur when in the Citation Tree View and we + # bookmark a source. + + # FIXME: See http://www.gramps-project.org/bugs/view.php?id=6352 a + # more comprehensive solution is needed in the long term. See also + # change_active in CitatinTreeView + from QuestionDialog import WarningDialog + WarningDialog(_("Cannot bookmark this reference"), + "Only Citations can be bookmarked in this view. " + "You are probably trying to bookmark a Source in the " + "Citation Tree View. In this view, only Citations " + "can be bookmarked. To bookmark a Source, switch to " + "the Source View") + def connect_signals(self): self.dbstate.db.connect('citation-delete', self.remove_handles) diff --git a/src/plugins/view/citationtreeview.py b/src/plugins/view/citationtreeview.py index b59cdd017..08de5c631 100644 --- a/src/plugins/view/citationtreeview.py +++ b/src/plugins/view/citationtreeview.py @@ -154,6 +154,17 @@ class CitationTreeView(ListView): self.additional_uis.append(self.additional_ui()) + # Override change_active from NavigationView, so that only Citations can be + # put in the history list for the CitationTreeView + def change_active(self, handle): + if self.dbstate.db.get_citation_from_handle(handle): + super(CitationTreeView, self).change_active(handle) + else: + # FIXME: See http://www.gramps-project.org/bugs/view.php?id=6352 a + # more comprehensive solution is needed in the long term. See also + # add in Bookmarks.CitationBookmarks + pass + def setup_filter(self): """ Override the setup of the default Search Bar in listview, so that only