2007-12-30 Douglas S. Blank <dblank@cs.brynmawr.edu>

* src/plugins/OnThisDay.py: i18n changes
	* src/plugins/Makefile.am: added missing files
	* src/plugins/DefaultGadgets.py: i18n changes
	* src/QuickReports.py: allow callers to send obj directly
	* src/Simple/_SimpleTable.py: added support for objs
	* po/POTFILES.in: i18n changes



svn: r9640
This commit is contained in:
Doug Blank 2007-12-30 15:39:00 +00:00
parent d8304d9cc8
commit e2cb83448a
7 changed files with 125 additions and 68 deletions

View File

@ -1,3 +1,11 @@
2007-12-30 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/plugins/OnThisDay.py: i18n changes
* src/plugins/Makefile.am: added missing files
* src/plugins/DefaultGadgets.py: i18n changes
* src/QuickReports.py: allow callers to send obj directly
* src/Simple/_SimpleTable.py: added support for objs
* po/POTFILES.in: i18n changes
2007-12-30 Peter Landgren <peter.talken@telia.com> 2007-12-30 Peter Landgren <peter.talken@telia.com>
* src/plugins/rel:sv.py: Firts release * src/plugins/rel:sv.py: Firts release

View File

@ -73,6 +73,7 @@ src/DataViews/EventView.py
src/DataViews/FamilyList.py src/DataViews/FamilyList.py
src/DataViews/__init__.py src/DataViews/__init__.py
src/DataViews/MediaView.py src/DataViews/MediaView.py
src/DataViews/MyGrampsView.py
src/DataViews/NoteView.py src/DataViews/NoteView.py
src/DataViews/PedigreeView.py src/DataViews/PedigreeView.py
src/DataViews/PersonView.py src/DataViews/PersonView.py
@ -287,6 +288,7 @@ src/plugins/OnThisDay.py
src/plugins/MarkerReport.py src/plugins/MarkerReport.py
src/plugins/MediaManager.py src/plugins/MediaManager.py
src/plugins/NarrativeWeb.py src/plugins/NarrativeWeb.py
src/plugins/OnThisDay.py
src/plugins/OwnerEditor.py src/plugins/OwnerEditor.py
src/plugins/PatchNames.py src/plugins/PatchNames.py
src/plugins/ReadPkg.py src/plugins/ReadPkg.py

View File

@ -134,6 +134,7 @@ def run_report(dbstate, uistate, category,handle,func):
d = TextBufDoc(make_basic_stylesheet(), None, None) d = TextBufDoc(make_basic_stylesheet(), None, None)
d.dbstate = dbstate d.dbstate = dbstate
d.uistate = uistate d.uistate = uistate
if type(handle) in [str, unicode]: # a handle
if category == CATEGORY_QR_PERSON : if category == CATEGORY_QR_PERSON :
obj = dbstate.db.get_person_from_handle(handle) obj = dbstate.db.get_person_from_handle(handle)
elif category == CATEGORY_QR_FAMILY : elif category == CATEGORY_QR_FAMILY :
@ -148,6 +149,8 @@ def run_report(dbstate, uistate, category,handle,func):
obj = dbstate.db.get_repository_from_handle(handle) obj = dbstate.db.get_repository_from_handle(handle)
else: else:
obj = None obj = None
else: # allow caller to send object directly
obj = handle
if obj: if obj:
d.open("") d.open("")
func(dbstate.db, d, obj) func(dbstate.db, d, obj)

View File

@ -108,6 +108,7 @@ class SimpleTable:
""" """
Add a row of data. Add a row of data.
""" """
# FIXME: add data and/or linkable types for all
retval = [] retval = []
link = None link = None
for item in data: for item in data:
@ -117,16 +118,22 @@ class SimpleTable:
name = self.access.name(item) name = self.access.name(item)
retval.append(name) retval.append(name)
link = ('Person', item.handle) link = ('Person', item.handle)
elif isinstance(item, gen.lib.Family): pass elif isinstance(item, gen.lib.Family):
elif isinstance(item, gen.lib.Source): pass retval.append(_('Family'))
elif isinstance(item, gen.lib.Source):
retval.append(_('Source'))
elif isinstance(item, gen.lib.Event): elif isinstance(item, gen.lib.Event):
name = self.access.event_type(item) name = self.access.event_type(item)
retval.append(name) retval.append(name)
link = ('Event', item.handle) link = ('Event', item.handle)
elif isinstance(item, gen.lib.MediaObject): pass elif isinstance(item, gen.lib.MediaObject):
elif isinstance(item, gen.lib.Place): pass retval.append(_('Media'))
elif isinstance(item, gen.lib.Repository): pass elif isinstance(item, gen.lib.Place):
elif isinstance(item, gen.lib.Note): pass retval.append(_('Place'))
elif isinstance(item, gen.lib.Repository):
retval.append(_('Repository'))
elif isinstance(item, gen.lib.Note):
retval.append(_('Note'))
elif isinstance(item, gen.lib.Date): elif isinstance(item, gen.lib.Date):
text = DateHandler.displayer.display(item) text = DateHandler.displayer.display(item)
retval.append(text) retval.append(text)

View File

@ -109,11 +109,12 @@ class CalendarGadget(Gadget):
# bring up events on this day # bring up events on this day
year, month, day = self.gui.calendar.get_date() year, month, day = self.gui.calendar.get_date()
month += 1 month += 1
if (year, month, day) in self.dates: date = gen.lib.Date()
date.set_yr_mon_day(year, month, day)
run_quick_report_by_name(self.gui.dbstate, run_quick_report_by_name(self.gui.dbstate,
self.gui.uistate, self.gui.uistate,
'onthisday', 'onthisday',
self.dates[(year, month, day)]) date)
class LogGadget(Gadget): class LogGadget(Gadget):
def db_changed(self): def db_changed(self):
@ -135,7 +136,8 @@ class LogGadget(Gadget):
self.log_active_changed(handle) self.log_active_changed(handle)
def init(self): def init(self):
self.set_text("Log for this Session\n--------------------\n") self.set_text(_("Log for this Session"))
self.append_text("\n--------------------\n")
self.history = {} self.history = {}
def log_person_add(self, handles): def log_person_add(self, handles):
@ -165,13 +167,13 @@ class LogGadget(Gadget):
self.link(name_displayer.display(person), 'Person', self.link(name_displayer.display(person), 'Person',
person_handle) person_handle)
else: else:
self.link("Unknown", 'Person', person_handle) self.link(_("Unknown"), 'Person', person_handle)
self.append_text("\n") self.append_text("\n")
class TopSurnamesGadget(Gadget): class TopSurnamesGadget(Gadget):
def init(self): def init(self):
self.top_size = 10 # will be overwritten in load self.top_size = 10 # will be overwritten in load
self.set_text("No Family Tree loaded.") self.set_text(_("No Family Tree loaded."))
def db_changed(self): def db_changed(self):
self.dbstate.db.connect('person-add', self.update) self.dbstate.db.connect('person-add', self.update)
@ -186,7 +188,7 @@ class TopSurnamesGadget(Gadget):
self.gui.data = [self.top_size] self.gui.data = [self.top_size]
def main(self): def main(self):
self.set_text("Processing...\n") self.set_text(_("Processing...") + "\n")
people = self.dbstate.db.get_person_handles(sort_handles=False) people = self.dbstate.db.get_person_handles(sort_handles=False)
surnames = {} surnames = {}
representative_handle = {} representative_handle = {}
@ -223,8 +225,9 @@ class TopSurnamesGadget(Gadget):
line += 1 line += 1
if line >= self.top_size: if line >= self.top_size:
break break
self.append_text("\nTotal unique surnames: %d\n" % total_surnames) self.append_text(("\n" + _("Total unique surnames") + ": %d\n") %
self.append_text("Total people: %d" % total_people) total_surnames)
self.append_text((_("Total people") + ": %d") % total_people)
class StatsGadget(Gadget): class StatsGadget(Gadget):
def db_changed(self): def db_changed(self):
@ -234,10 +237,10 @@ class StatsGadget(Gadget):
self.dbstate.db.connect('family-delete', self.update) self.dbstate.db.connect('family-delete', self.update)
def init(self): def init(self):
self.set_text("No Family Tree loaded.") self.set_text(_("No Family Tree loaded."))
def main(self): def main(self):
self.set_text("Processing...") self.set_text(_("Processing..."))
database = self.dbstate.db database = self.dbstate.db
personList = database.get_person_handles(sort_handles=False) personList = database.get_person_handles(sort_handles=False)
familyList = database.get_family_handles() familyList = database.get_family_handles()
@ -385,7 +388,7 @@ class TODOGadget(Gadget):
def init(self): def init(self):
# GUI setup: # GUI setup:
self.gui.textview.set_editable(True) self.gui.textview.set_editable(True)
self.append_text("Enter your TODO list here.") self.append_text(_("Enter your TODO list here."))
def on_load(self): def on_load(self):
self.load_data_to_text() self.load_data_to_text()
@ -437,7 +440,7 @@ class NewsGadget(Gadget):
def process(self, title): def process(self, title):
#print "processing '%s'..." % title #print "processing '%s'..." % title
title = title.replace(" ", "_") title = title.replace(" ", "_")
yield True, "Reading '%s'..." % title yield True, (_("Reading") + " '%s'..." % title)
fp = urllib.urlopen(self.URL % title) fp = urllib.urlopen(self.URL % title)
text = fp.read() text = fp.read()
#text = text.replace("\n", " ") #text = text.replace("\n", " ")
@ -484,63 +487,63 @@ class NewsGadget(Gadget):
yield False, text yield False, text
register(type="gadget", register(type="gadget",
name="Top Surnames Gadget", name= _("Top Surnames Gadget"),
height=230, height=230,
content = TopSurnamesGadget, content = TopSurnamesGadget,
title="Top Surnames", title=_("Top Surnames"),
) )
register(type="gadget", register(type="gadget",
name="Stats Gadget", name=_("Statistics Gadget"),
height=230, height=230,
expand=True, expand=True,
content = StatsGadget, content = StatsGadget,
title="Stats", title=_("Statistics"),
) )
register(type="gadget", register(type="gadget",
name="Log Gadget", name=_("Session Log Gadget"),
height=230, height=230,
data=['no'], data=['no'],
content = LogGadget, content = LogGadget,
title="Session Log", title=_("Session Log"),
) )
register(type="gadget", register(type="gadget",
name="Python Gadget", name=_("Python Gadget"),
height=250, height=250,
content = PythonGadget, content = PythonGadget,
title="Python Shell", title=_("Python Shell"),
) )
register(type="gadget", register(type="gadget",
name="TODO Gadget", name=_("TODO Gadget"),
height=300, height=300,
expand=True, expand=True,
content = TODOGadget, content = TODOGadget,
title="TODO List", title=_("TODO List"),
) )
register(type="gadget", register(type="gadget",
name="Welcome Gadget", name=_("Welcome Gadget"),
height=300, height=300,
expand=True, expand=True,
content = make_welcome_content, content = make_welcome_content,
title="Welcome to GRAMPS!", title=_("Welcome to GRAMPS!"),
) )
register(type="gadget", register(type="gadget",
name="Calendar Gadget", name=_("Calendar Gadget"),
height=200, height=200,
content = CalendarGadget, content = CalendarGadget,
title="Calendar", title=_("Calendar"),
) )
register(type="gadget", register(type="gadget",
name="News Gadget", name=_("News Gadget"),
height=300, height=300,
expand=True, expand=True,
content = NewsGadget, content = NewsGadget,
title="News", title=_("News"),
) )

View File

@ -19,6 +19,7 @@ pkgdata_PYTHON = \
Checkpoint.py\ Checkpoint.py\
CountAncestors.py\ CountAncestors.py\
CustomBookText.py\ CustomBookText.py\
DefaultGadgets.py\
Desbrowser.py\ Desbrowser.py\
DescendChart.py\ DescendChart.py\
DescendReport.py\ DescendReport.py\
@ -50,6 +51,7 @@ pkgdata_PYTHON = \
MarkerReport.py\ MarkerReport.py\
MediaManager.py\ MediaManager.py\
NarrativeWeb.py\ NarrativeWeb.py\
OnThisDay.py\
OwnerEditor.py\ OwnerEditor.py\
PatchNames.py\ PatchNames.py\
ReadGrdb.py\ ReadGrdb.py\
@ -74,6 +76,7 @@ pkgdata_PYTHON = \
rel_sv.py\ rel_sv.py\
RemoveUnused.py\ RemoveUnused.py\
ReorderIds.py\ ReorderIds.py\
SameSurnames.py\
siblings.py\ siblings.py\
SimpleBookTitle.py\ SimpleBookTitle.py\
SoundGen.py\ SoundGen.py\

View File

@ -27,21 +27,39 @@ from Simple import SimpleAccess, SimpleDoc, SimpleTable
from gettext import gettext as _ from gettext import gettext as _
from PluginUtils import register_quick_report from PluginUtils import register_quick_report
from ReportBase import CATEGORY_QR_EVENT from ReportBase import CATEGORY_QR_EVENT
import gen.lib
def backlink(database, objclass, handle): def get_ref(db, objclass, handle):
"""
Looks up object in database
"""
if objclass == 'Person': if objclass == 'Person':
ref = database.get_person_from_handle(handle) ref = db.get_person_from_handle(handle)
elif objclass == 'Family':
ref = db.get_family_from_handle(handle)
elif objclass == 'Event':
ref = db.get_event_from_handle(handle)
elif objclass == 'Source':
ref = db.get_source_from_handle(handle)
elif objclass == 'Place':
ref = db.get_place_from_handle(handle)
elif objclass == 'Repository':
ref = db.get_repository_from_handle(handle)
else: else:
ref = objclass ref = objclass
return ref return ref
def run(database, document, main_event): def run(database, document, main_event):
""" """
Loops through the families that the person is a child in, and display Displays events on a specific date of an event (or date)
the information about the other children.
Takes an Event handle Takes an Event or Date object
""" """
if isinstance(main_event, gen.lib.Date):
main_date = main_event
else:
main_date = main_event.get_date_object()
# setup the simple access functions # setup the simple access functions
sdb = SimpleAccess(database) sdb = SimpleAccess(database)
sdoc = SimpleDoc(document) sdoc = SimpleDoc(document)
@ -49,10 +67,9 @@ def run(database, document, main_event):
yeartab = SimpleTable(sdb, sdoc) yeartab = SimpleTable(sdb, sdoc)
histab = SimpleTable(sdb, sdoc) histab = SimpleTable(sdb, sdoc)
main_date = main_event.get_date_object()
# display the title # display the title
sdoc.title(_("Events of %s") % sdb.date_string(main_date)) sdoc.title(_("Events of %(date)s") %
{"date": sdb.date_string(main_date)})
sdoc.paragraph("") sdoc.paragraph("")
stab.columns(_("Date"), _("Type"), _("Place"), _("Reference")) stab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
yeartab.columns(_("Date"), _("Type"), _("Place"), _("Reference")) yeartab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
@ -67,7 +84,7 @@ def run(database, document, main_event):
date.get_month() == main_date.get_month() and date.get_month() == main_date.get_month() and
date.get_day() == main_date.get_day()): date.get_day() == main_date.get_day()):
for (objclass, handle) in database.find_backlink_handles(event_handle): for (objclass, handle) in database.find_backlink_handles(event_handle):
ref = backlink(database, objclass, handle) ref = get_ref(database, objclass, handle)
stab.row(date, stab.row(date,
sdb.event_type(event), sdb.event_type(event),
sdb.event_place(event), ref) sdb.event_place(event), ref)
@ -75,32 +92,46 @@ def run(database, document, main_event):
date.get_day() == main_date.get_day() and date.get_day() == main_date.get_day() and
date.get_month() != 0): date.get_month() != 0):
for (objclass, handle) in database.find_backlink_handles(event_handle): for (objclass, handle) in database.find_backlink_handles(event_handle):
ref = backlink(database, objclass, handle) ref = get_ref(database, objclass, handle)
histab.row(date, histab.row(date,
sdb.event_type(event), sdb.event_type(event),
sdb.event_place(event), ref) sdb.event_place(event), ref)
elif (date.get_year() == main_date.get_year()): elif (date.get_year() == main_date.get_year()):
for (objclass, handle) in database.find_backlink_handles(event_handle): for (objclass, handle) in database.find_backlink_handles(event_handle):
ref = backlink(database, objclass, handle) ref = get_ref(database, objclass, handle)
yeartab.row(date, yeartab.row(date,
sdb.event_type(event), sdb.event_type(event),
sdb.event_place(event), ref) sdb.event_place(event), ref)
if stab.get_row_count() > 0:
sdoc.paragraph(_("Events on this exact date"))
stab.write() stab.write()
else:
sdoc.paragraph(_("No events on this exact date"))
sdoc.paragraph("") sdoc.paragraph("")
sdoc.paragraph("")
if histab.get_row_count() > 0: if histab.get_row_count() > 0:
sdoc.paragraph(_("Other events on this day in history")) sdoc.paragraph(_("Other events on this month/day in history"))
histab.write() histab.write()
else:
sdoc.paragraph(_("No other events on this month/day in history"))
sdoc.paragraph("") sdoc.paragraph("")
sdoc.paragraph("")
if yeartab.get_row_count() > 0: if yeartab.get_row_count() > 0:
sdoc.paragraph(_("Other events in %d") % main_date.get_year()) sdoc.paragraph(_("Other events in %(year)d") %
{"year":main_date.get_year()})
yeartab.write() yeartab.write()
else:
sdoc.paragraph(_("No other events in %(year)d") %
{"year":main_date.get_year()})
sdoc.paragraph("")
sdoc.paragraph("")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# # Register the report
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
register_quick_report( register_quick_report(