6307: Bug fixes for To Do gramplets

svn: r21071
This commit is contained in:
Nick Hall 2013-01-11 19:23:38 +00:00
parent d9c1a330f3
commit 3dbd69ad31
3 changed files with 73 additions and 57 deletions

View File

@ -257,15 +257,15 @@ register(GRAMPLET,
) )
register(GRAMPLET, register(GRAMPLET,
id="TODO", id="To Do",
name=_("TODO"), name=_("To Do"),
description = _("Gramplet for generic notes"), description = _("Gramplet for displaying a To Do list"),
status = STABLE, status = STABLE,
fname="todogramplet.py", fname="todogramplet.py",
height=300, height=300,
expand=True, expand=True,
gramplet = 'TODOGramplet', gramplet = 'ToDoGramplet',
gramplet_title=_("TODO List"), gramplet_title=_("To Do"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
) )
@ -1078,113 +1078,113 @@ register(GRAMPLET,
) )
register(GRAMPLET, register(GRAMPLET,
id="Person ToDo", id="Person To Do",
name=_("Person ToDo"), name=_("Person To Do"),
description = _("Gramplet showing the ToDo notes for a person"), description = _("Gramplet showing the To Do notes for a person"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
status = STABLE, status = STABLE,
fname="todo.py", fname="todo.py",
height=200, height=200,
gramplet = 'PersonToDo', gramplet = 'PersonToDo',
gramplet_title=_("ToDo"), gramplet_title=_("To Do"),
navtypes=["Person"], navtypes=["Person"],
) )
register(GRAMPLET, register(GRAMPLET,
id="Event ToDo", id="Event To Do",
name=_("Event ToDo"), name=_("Event To Do"),
description = _("Gramplet showing the ToDo notes for an event"), description = _("Gramplet showing the To Do notes for an event"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
status = STABLE, status = STABLE,
fname="todo.py", fname="todo.py",
height=200, height=200,
gramplet = 'EventToDo', gramplet = 'EventToDo',
gramplet_title=_("ToDo"), gramplet_title=_("To Do"),
navtypes=["Event"], navtypes=["Event"],
) )
register(GRAMPLET, register(GRAMPLET,
id="Family ToDo", id="Family To Do",
name=_("Family ToDo"), name=_("Family To Do"),
description = _("Gramplet showing the ToDo notes for a family"), description = _("Gramplet showing the To Do notes for a family"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
status = STABLE, status = STABLE,
fname="todo.py", fname="todo.py",
height=200, height=200,
gramplet = 'FamilyToDo', gramplet = 'FamilyToDo',
gramplet_title=_("ToDo"), gramplet_title=_("To Do"),
navtypes=["Family"], navtypes=["Family"],
) )
register(GRAMPLET, register(GRAMPLET,
id="Place ToDo", id="Place To Do",
name=_("Place ToDo"), name=_("Place To Do"),
description = _("Gramplet showing the ToDo notes for a place"), description = _("Gramplet showing the To Do notes for a place"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
status = STABLE, status = STABLE,
fname="todo.py", fname="todo.py",
height=200, height=200,
gramplet = 'PlaceToDo', gramplet = 'PlaceToDo',
gramplet_title=_("ToDo"), gramplet_title=_("To Do"),
navtypes=["Place"], navtypes=["Place"],
) )
register(GRAMPLET, register(GRAMPLET,
id="Source ToDo", id="Source To Do",
name=_("Source ToDo"), name=_("Source To Do"),
description = _("Gramplet showing the ToDo notes for a source"), description = _("Gramplet showing the To Do notes for a source"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
status = STABLE, status = STABLE,
fname="todo.py", fname="todo.py",
height=200, height=200,
gramplet = 'SourceToDo', gramplet = 'SourceToDo',
gramplet_title=_("ToDo"), gramplet_title=_("To Do"),
navtypes=["Source"], navtypes=["Source"],
) )
register(GRAMPLET, register(GRAMPLET,
id="Citation ToDo", id="Citation To Do",
name=_("Citation ToDo"), name=_("Citation To Do"),
description = _("Gramplet showing the ToDo notes for a citation"), description = _("Gramplet showing the To Do notes for a citation"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
status = STABLE, status = STABLE,
fname="todo.py", fname="todo.py",
height=200, height=200,
gramplet = 'CitationToDo', gramplet = 'CitationToDo',
gramplet_title=_("ToDo"), gramplet_title=_("To Do"),
navtypes=["Citation"], navtypes=["Citation"],
) )
register(GRAMPLET, register(GRAMPLET,
id="Repository ToDo", id="Repository To Do",
name=_("Repository ToDo"), name=_("Repository To Do"),
description = _("Gramplet showing the ToDo notes for a repository"), description = _("Gramplet showing the To Do notes for a repository"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
status = STABLE, status = STABLE,
fname="todo.py", fname="todo.py",
height=200, height=200,
gramplet = 'RepositoryToDo', gramplet = 'RepositoryToDo',
gramplet_title=_("ToDo"), gramplet_title=_("To Do"),
navtypes=["Repository"], navtypes=["Repository"],
) )
register(GRAMPLET, register(GRAMPLET,
id="Media ToDo", id="Media To Do",
name=_("Media ToDo"), name=_("Media To Do"),
description = _("Gramplet showing the ToDo notes for a media object"), description = _("Gramplet showing the To Do notes for a media object"),
version="1.0.0", version="1.0.0",
gramps_target_version="4.1", gramps_target_version="4.1",
status = STABLE, status = STABLE,
fname="todo.py", fname="todo.py",
height=200, height=200,
gramplet = 'MediaToDo', gramplet = 'MediaToDo',
gramplet_title=_("ToDo"), gramplet_title=_("To Do"),
navtypes=["Media"], navtypes=["Media"],
) )

View File

@ -29,7 +29,7 @@ from gi.repository import Gtk
class ToDo(Gramplet): class ToDo(Gramplet):
""" """
Displays the ToDo notes for an object. Displays the To Do notes for an object.
""" """
def init(self): def init(self):
self.gui.WIDGET = self.build_gui() self.gui.WIDGET = self.build_gui()
@ -45,14 +45,19 @@ class ToDo(Gramplet):
hbox = Gtk.HBox() hbox = Gtk.HBox()
self.left = SimpleButton(Gtk.STOCK_GO_BACK, self.left_clicked) self.left = SimpleButton(Gtk.STOCK_GO_BACK, self.left_clicked)
self.left.set_tooltip_text(_('Previous To Do note'))
self.left.set_sensitive(False) self.left.set_sensitive(False)
hbox.pack_start(self.left, False, False, 0) hbox.pack_start(self.left, False, False, 0)
self.right = SimpleButton(Gtk.STOCK_GO_FORWARD, self.right_clicked) self.right = SimpleButton(Gtk.STOCK_GO_FORWARD, self.right_clicked)
self.right.set_tooltip_text(_('Next To Do note'))
self.right.set_sensitive(False) self.right.set_sensitive(False)
hbox.pack_start(self.right, False, False, 0) hbox.pack_start(self.right, False, False, 0)
self.edit = SimpleButton(Gtk.STOCK_EDIT, self.edit_clicked) self.edit = SimpleButton(Gtk.STOCK_EDIT, self.edit_clicked)
self.edit.set_tooltip_text(_('Edit the selected To Do note'))
self.edit.set_sensitive(False)
hbox.pack_start(self.edit, False, False, 0) hbox.pack_start(self.edit, False, False, 0)
self.new = SimpleButton(Gtk.STOCK_NEW, self.new_clicked) self.new = SimpleButton(Gtk.STOCK_NEW, self.new_clicked)
self.new.set_tooltip_text(_('Add a new To Do note'))
hbox.pack_start(self.new, False, False, 0) hbox.pack_start(self.new, False, False, 0)
self.page = Gtk.Label() self.page = Gtk.Label()
hbox.pack_end(self.page, False, False, 10) hbox.pack_end(self.page, False, False, 10)
@ -72,7 +77,7 @@ class ToDo(Gramplet):
def get_note_list(self, obj): def get_note_list(self, obj):
""" """
Get a list of ToDo notes for the current object. Get a list of To Do notes for the current object.
""" """
note_list = [] note_list = []
for note_handle in obj.get_note_list(): for note_handle in obj.get_note_list():
@ -83,16 +88,18 @@ class ToDo(Gramplet):
def get_notes(self, obj): def get_notes(self, obj):
""" """
Display the ToDo notes for the current object. Display the To Do notes for the current object.
""" """
self.obj = obj self.obj = obj
self.left.set_sensitive(False) self.left.set_sensitive(False)
self.right.set_sensitive(False) self.right.set_sensitive(False)
self.edit.set_sensitive(False)
self.texteditor.set_text(StyledText()) self.texteditor.set_text(StyledText())
self.note_list = self.get_note_list(obj) self.note_list = self.get_note_list(obj)
self.page.set_text('') self.page.set_text('')
if len(self.note_list) > 0: if len(self.note_list) > 0:
self.set_has_data(True) self.set_has_data(True)
self.edit.set_sensitive(True)
if len(self.note_list) > 1: if len(self.note_list) > 1:
self.right.set_sensitive(True) self.right.set_sensitive(True)
self.current = 0 self.current = 0
@ -103,6 +110,7 @@ class ToDo(Gramplet):
def clear_text(self): def clear_text(self):
self.left.set_sensitive(False) self.left.set_sensitive(False)
self.right.set_sensitive(False) self.right.set_sensitive(False)
self.edit.set_sensitive(False)
self.texteditor.set_text(StyledText()) self.texteditor.set_text(StyledText())
self.page.set_text('') self.page.set_text('')
self.current = 0 self.current = 0
@ -152,7 +160,7 @@ class ToDo(Gramplet):
def edit_clicked(self, obj): def edit_clicked(self, obj):
""" """
Edit current ToDo note. Edit current To Do note.
""" """
from gramps.gui.editors import EditNote from gramps.gui.editors import EditNote
note_handle = self.note_list[self.current] note_handle = self.note_list[self.current]
@ -164,7 +172,7 @@ class ToDo(Gramplet):
def new_clicked(self, obj): def new_clicked(self, obj):
""" """
Create a new ToDo note. Create a new To Do note.
""" """
from gramps.gui.editors import EditNote from gramps.gui.editors import EditNote
note = Note() note = Note()
@ -176,7 +184,7 @@ class ToDo(Gramplet):
class PersonToDo(ToDo): class PersonToDo(ToDo):
""" """
Displays the ToDo notes for a person. Displays the To Do notes for a person.
""" """
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('person-update', self.update) self.dbstate.db.connect('person-update', self.update)
@ -205,7 +213,7 @@ class PersonToDo(ToDo):
class EventToDo(ToDo): class EventToDo(ToDo):
""" """
Displays the ToDo notes for an event. Displays the To Do notes for an event.
""" """
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('event-update', self.update) self.dbstate.db.connect('event-update', self.update)
@ -232,7 +240,7 @@ class EventToDo(ToDo):
class FamilyToDo(ToDo): class FamilyToDo(ToDo):
""" """
Displays the ToDo notes for a family. Displays the To Do notes for a family.
""" """
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('family-update', self.update) self.dbstate.db.connect('family-update', self.update)
@ -259,7 +267,7 @@ class FamilyToDo(ToDo):
class PlaceToDo(ToDo): class PlaceToDo(ToDo):
""" """
Displays the ToDo notes for a place. Displays the To Do notes for a place.
""" """
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('place-update', self.update) self.dbstate.db.connect('place-update', self.update)
@ -286,7 +294,7 @@ class PlaceToDo(ToDo):
class SourceToDo(ToDo): class SourceToDo(ToDo):
""" """
Displays the ToDo notes for a source. Displays the To Do notes for a source.
""" """
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('source-update', self.update) self.dbstate.db.connect('source-update', self.update)
@ -313,7 +321,7 @@ class SourceToDo(ToDo):
class CitationToDo(ToDo): class CitationToDo(ToDo):
""" """
Displays the ToDo notes for a Citation. Displays the To Do notes for a Citation.
""" """
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('citation-update', self.update) self.dbstate.db.connect('citation-update', self.update)
@ -340,7 +348,7 @@ class CitationToDo(ToDo):
class RepositoryToDo(ToDo): class RepositoryToDo(ToDo):
""" """
Displays the ToDo notes for a repository. Displays the To Do notes for a repository.
""" """
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('repository-update', self.update) self.dbstate.db.connect('repository-update', self.update)
@ -367,7 +375,7 @@ class RepositoryToDo(ToDo):
class MediaToDo(ToDo): class MediaToDo(ToDo):
""" """
Displays the ToDo notes for a media object. Displays the To Do notes for a media object.
""" """
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('media-update', self.update) self.dbstate.db.connect('media-update', self.update)

View File

@ -30,9 +30,9 @@ from gramps.gen.db import DbTxn
from gramps.gen.ggettext import gettext as _ from gramps.gen.ggettext import gettext as _
from gi.repository import Gtk from gi.repository import Gtk
class TODOGramplet(Gramplet): class ToDoGramplet(Gramplet):
""" """
Displays all the ToDo notes in the database. Displays all the To Do notes in the database.
""" """
def init(self): def init(self):
self.gui.WIDGET = self.build_gui() self.gui.WIDGET = self.build_gui()
@ -48,14 +48,19 @@ class TODOGramplet(Gramplet):
hbox = Gtk.HBox() hbox = Gtk.HBox()
self.left = SimpleButton(Gtk.STOCK_GO_BACK, self.left_clicked) self.left = SimpleButton(Gtk.STOCK_GO_BACK, self.left_clicked)
self.left.set_tooltip_text(_('Previous To Do note'))
self.left.set_sensitive(False) self.left.set_sensitive(False)
hbox.pack_start(self.left, False, False, 0) hbox.pack_start(self.left, False, False, 0)
self.right = SimpleButton(Gtk.STOCK_GO_FORWARD, self.right_clicked) self.right = SimpleButton(Gtk.STOCK_GO_FORWARD, self.right_clicked)
self.right.set_tooltip_text(_('Next To Do note'))
self.right.set_sensitive(False) self.right.set_sensitive(False)
hbox.pack_start(self.right, False, False, 0) hbox.pack_start(self.right, False, False, 0)
self.edit = SimpleButton(Gtk.STOCK_EDIT, self.edit_clicked) self.edit = SimpleButton(Gtk.STOCK_EDIT, self.edit_clicked)
self.edit.set_tooltip_text(_('Edit the selected To Do note'))
self.edit.set_sensitive(False)
hbox.pack_start(self.edit, False, False, 0) hbox.pack_start(self.edit, False, False, 0)
self.new = SimpleButton(Gtk.STOCK_NEW, self.new_clicked) self.new = SimpleButton(Gtk.STOCK_NEW, self.new_clicked)
self.new.set_tooltip_text(_('Add a new To Do note'))
hbox.pack_start(self.new, False, False, 0) hbox.pack_start(self.new, False, False, 0)
self.page = Gtk.Label() self.page = Gtk.Label()
hbox.pack_end(self.page, False, False, 10) hbox.pack_end(self.page, False, False, 10)
@ -83,7 +88,7 @@ class TODOGramplet(Gramplet):
def get_note_list(self): def get_note_list(self):
""" """
Get a list of all ToDo notes. Get a list of all To Do notes.
""" """
all_notes = self.dbstate.db.get_note_handles() all_notes = self.dbstate.db.get_note_handles()
FilterClass = GenericFilterFactory('Note') FilterClass = GenericFilterFactory('Note')
@ -94,16 +99,18 @@ class TODOGramplet(Gramplet):
def get_notes(self): def get_notes(self):
""" """
Display all the ToDo notes. Display all the To Do notes.
""" """
self.left.set_sensitive(False) self.left.set_sensitive(False)
self.right.set_sensitive(False) self.right.set_sensitive(False)
self.edit.set_sensitive(False)
self.texteditor.set_text(StyledText()) self.texteditor.set_text(StyledText())
self.note_list = self.get_note_list() self.note_list = self.get_note_list()
self.page.set_text('') self.page.set_text('')
self.title.set_text('') self.title.set_text('')
if len(self.note_list) > 0: if len(self.note_list) > 0:
self.set_has_data(True) self.set_has_data(True)
self.edit.set_sensitive(True)
if len(self.note_list) > 1: if len(self.note_list) > 1:
self.right.set_sensitive(True) self.right.set_sensitive(True)
self.current = 0 self.current = 0
@ -114,6 +121,7 @@ class TODOGramplet(Gramplet):
def clear_text(self): def clear_text(self):
self.left.set_sensitive(False) self.left.set_sensitive(False)
self.right.set_sensitive(False) self.right.set_sensitive(False)
self.edit.set_sensitive(False)
self.texteditor.set_text(StyledText()) self.texteditor.set_text(StyledText())
self.page.set_text('') self.page.set_text('')
self.title.set_text('') self.title.set_text('')
@ -130,7 +138,7 @@ class TODOGramplet(Gramplet):
name, obj = navigation_label(self.dbstate.db, obj[0][0], obj[0][1]) name, obj = navigation_label(self.dbstate.db, obj[0][0], obj[0][1])
self.title.set_text(name) self.title.set_text(name)
else: else:
self.title.set_text("Unattached") self.title.set_text(_("Unattached"))
self.texteditor.set_text(note.get_styledtext()) self.texteditor.set_text(note.get_styledtext())
self.page.set_text(_('%(current)d of %(total)d') % self.page.set_text(_('%(current)d of %(total)d') %
{'current': self.current + 1, {'current': self.current + 1,
@ -168,7 +176,7 @@ class TODOGramplet(Gramplet):
def edit_clicked(self, obj): def edit_clicked(self, obj):
""" """
Edit current ToDo note. Edit current To Do note.
""" """
from gramps.gui.editors import EditNote from gramps.gui.editors import EditNote
note_handle = self.note_list[self.current] note_handle = self.note_list[self.current]
@ -180,7 +188,7 @@ class TODOGramplet(Gramplet):
def new_clicked(self, obj): def new_clicked(self, obj):
""" """
Create a new ToDo note. Create a new To Do note.
""" """
from gramps.gui.editors import EditNote from gramps.gui.editors import EditNote
note = Note() note = Note()