Add a note gramplet for NoteView

This commit is contained in:
Matthias Kemmer 2020-11-06 08:51:11 +01:00 committed by Nick Hall
parent 84da4b896b
commit de3648df39
2 changed files with 33 additions and 1 deletions

View File

@ -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"),

View File

@ -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())