diff --git a/gramps/plugins/gramplet/todo.py b/gramps/plugins/gramplet/todo.py index 2ee801980..783bd5a7a 100644 --- a/gramps/plugins/gramplet/todo.py +++ b/gramps/plugins/gramplet/todo.py @@ -32,6 +32,7 @@ from gi.repository import Gtk from gramps.gen.plug import Gramplet from gramps.gui.widgets.styledtexteditor import StyledTextEditor from gramps.gui.widgets import SimpleButton +from gramps.gui.dialog import WarningDialog from gramps.gen.lib import StyledText, Note, NoteType from gramps.gen.db import DbTxn from gramps.gen.errors import WindowActiveError @@ -185,13 +186,21 @@ class ToDo(Gramplet): """ Create a new To Do note. """ - from gramps.gui.editors import EditNote - note = Note() - note.set_type(NoteType.TODO) - try: - EditNote(self.gui.dbstate, self.gui.uistate, [], note, self.created) - except WindowActiveError: - pass + nav_type = self.uistate.viewmanager.active_page.navigation_type() + active_handle = self.get_active(nav_type) + if active_handle: + from gramps.gui.editors import EditNote + note = Note() + note.set_type(NoteType.TODO) + try: + EditNote(self.gui.dbstate, self.gui.uistate, [], note, self.created) + except WindowActiveError: + pass + else: + WarningDialog(_("No active object"), + _("First select the object to which you want to attach a note") + + _(":") + _(nav_type), + parent=self.uistate.window) class PersonToDo(ToDo): """