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

View File

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