From 2630bebae052ec3fa725df07dfb91b9f214c1603 Mon Sep 17 00:00:00 2001 From: Sebastian Schubert Date: Thu, 3 Sep 2015 15:01:25 +1000 Subject: [PATCH] 8061: FeatureRequest: Add citation in citationtreeview: automatically select source --- gramps/plugins/view/citationtreeview.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/gramps/plugins/view/citationtreeview.py b/gramps/plugins/view/citationtreeview.py index a0d73ab7e..42a834eff 100644 --- a/gramps/plugins/view/citationtreeview.py +++ b/gramps/plugins/view/citationtreeview.py @@ -420,19 +420,15 @@ class CitationTreeView(ListView): citation = self.dbstate.db.get_citation_from_handle(handle) if (not source and not citation) or (source and citation): raise ValueError("selection must be either source or citation") - if source: - try: - EditCitation(self.dbstate, self.uistate, [], - Citation(), source) - except WindowActiveError: - from gramps.gui.dialog import WarningDialog - WarningDialog(_("Cannot share this reference"), - self.__blocked_text()) - else: - msg = _("Cannot add citation.") - msg2 = _("In order to add a citation to an existing source, " - " you must select a source.") - ErrorDialog(msg, msg2) + if not source: + source = self.dbstate.db.get_source_from_handle(citation.get_reference_handle()) + try: + EditCitation(self.dbstate, self.uistate, [], + Citation(), source) + except WindowActiveError: + from gramps.gui.dialog import WarningDialog + WarningDialog(_("Cannot share this reference"), + self.__blocked_text()) # def remove(self, obj): self.remove_selected_objects()