From de3648df39f3f68397745076e8561ada4635b870 Mon Sep 17 00:00:00 2001 From: Matthias Kemmer Date: Fri, 6 Nov 2020 08:51:11 +0100 Subject: [PATCH] Add a note gramplet for NoteView --- gramps/plugins/gramplet/gramplet.gpr.py | 15 +++++++++++++++ gramps/plugins/gramplet/notes.py | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gramps/plugins/gramplet/gramplet.gpr.py b/gramps/plugins/gramplet/gramplet.gpr.py index 412159e00..33479adfb 100644 --- a/gramps/plugins/gramplet/gramplet.gpr.py +++ b/gramps/plugins/gramplet/gramplet.gpr.py @@ -5,6 +5,7 @@ # Copyright (C) 2009 Benny Malengier # Copyright (C) 2011 Nick Hall # Copyright (C) 2011 Tim G L Lyons +# Copyright (C) 2020 Matthias Kemmer # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -772,6 +773,20 @@ register(GRAMPLET, navtypes=["Media"], ) +register(GRAMPLET, + id="Note Notes", + name=_("Notes"), + description = _("Gramplet showing the selected note"), + version="1.0.0", + gramps_target_version=MODULE_VERSION, + status = STABLE, + fname="notes.py", + height=200, + gramplet = 'NoteNotes', + gramplet_title=_("Notes"), + navtypes=["Note"], + ) + register(GRAMPLET, id="Person Citations", name=_("Person Citations"), diff --git a/gramps/plugins/gramplet/notes.py b/gramps/plugins/gramplet/notes.py index 2d68953ad..f3673b398 100644 --- a/gramps/plugins/gramplet/notes.py +++ b/gramps/plugins/gramplet/notes.py @@ -1,7 +1,8 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2011 Nick Hall -# Copyright (C) 2011 Tim G L Lyons +# Copyright (C) 2011 Tim G L Lyons +# Copyright (C) 2020 Matthias Kemmer # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -369,3 +370,19 @@ class MediaNotes(Notes): self.set_has_data(False) else: self.set_has_data(False) + +class NoteNotes(Notes): + """ + Display a single note in NoteView. + """ + def db_changed(self): + self.connect(self.dbstate.db, 'note-update', self.update) + self.connect_signal('Note', self.update) + + def main(self): + self.clear_text() + active_handle = self.get_active('Note') + if active_handle: + active = self.dbstate.db.get_note_from_handle(active_handle) + if active: + self.texteditor.set_text(active.get_styledtext())