From e2cb83448a177246e961a4ff66a354d6664372f2 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sun, 30 Dec 2007 15:39:00 +0000 Subject: [PATCH] 2007-12-30 Douglas S. Blank * 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 --- ChangeLog | 8 +++++ po/POTFILES.in | 2 ++ src/QuickReports.py | 31 +++++++++-------- src/Simple/_SimpleTable.py | 19 ++++++---- src/plugins/DefaultGadgets.py | 65 ++++++++++++++++++----------------- src/plugins/Makefile.am | 3 ++ src/plugins/OnThisDay.py | 65 ++++++++++++++++++++++++++--------- 7 files changed, 125 insertions(+), 68 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d80e49c6..95bbb5946 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-12-30 Douglas S. Blank + * 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 * src/plugins/rel:sv.py: Firts release diff --git a/po/POTFILES.in b/po/POTFILES.in index 123bf868b..8e7fef848 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -73,6 +73,7 @@ src/DataViews/EventView.py src/DataViews/FamilyList.py src/DataViews/__init__.py src/DataViews/MediaView.py +src/DataViews/MyGrampsView.py src/DataViews/NoteView.py src/DataViews/PedigreeView.py src/DataViews/PersonView.py @@ -287,6 +288,7 @@ src/plugins/OnThisDay.py src/plugins/MarkerReport.py src/plugins/MediaManager.py src/plugins/NarrativeWeb.py +src/plugins/OnThisDay.py src/plugins/OwnerEditor.py src/plugins/PatchNames.py src/plugins/ReadPkg.py diff --git a/src/QuickReports.py b/src/QuickReports.py index d209baa3c..fa1d27cea 100644 --- a/src/QuickReports.py +++ b/src/QuickReports.py @@ -134,20 +134,23 @@ def run_report(dbstate, uistate, category,handle,func): d = TextBufDoc(make_basic_stylesheet(), None, None) d.dbstate = dbstate d.uistate = uistate - if category == CATEGORY_QR_PERSON : - obj = dbstate.db.get_person_from_handle(handle) - elif category == CATEGORY_QR_FAMILY : - obj = dbstate.db.get_family_from_handle(handle) - elif category == CATEGORY_QR_EVENT : - obj = dbstate.db.get_event_from_handle(handle) - elif category == CATEGORY_QR_SOURCE : - obj = dbstate.db.get_source_from_handle(handle) - elif category == CATEGORY_QR_PLACE : - obj = dbstate.db.get_place_from_handle(handle) - elif category == CATEGORY_QR_REPOSITORY : - obj = dbstate.db.get_repository_from_handle(handle) - else: - obj = None + if type(handle) in [str, unicode]: # a handle + if category == CATEGORY_QR_PERSON : + obj = dbstate.db.get_person_from_handle(handle) + elif category == CATEGORY_QR_FAMILY : + obj = dbstate.db.get_family_from_handle(handle) + elif category == CATEGORY_QR_EVENT : + obj = dbstate.db.get_event_from_handle(handle) + elif category == CATEGORY_QR_SOURCE : + obj = dbstate.db.get_source_from_handle(handle) + elif category == CATEGORY_QR_PLACE : + obj = dbstate.db.get_place_from_handle(handle) + elif category == CATEGORY_QR_REPOSITORY : + obj = dbstate.db.get_repository_from_handle(handle) + else: + obj = None + else: # allow caller to send object directly + obj = handle if obj: d.open("") func(dbstate.db, d, obj) diff --git a/src/Simple/_SimpleTable.py b/src/Simple/_SimpleTable.py index 2c8bd60ee..bf3fdc5dc 100644 --- a/src/Simple/_SimpleTable.py +++ b/src/Simple/_SimpleTable.py @@ -108,6 +108,7 @@ class SimpleTable: """ Add a row of data. """ + # FIXME: add data and/or linkable types for all retval = [] link = None for item in data: @@ -117,16 +118,22 @@ class SimpleTable: name = self.access.name(item) retval.append(name) link = ('Person', item.handle) - elif isinstance(item, gen.lib.Family): pass - elif isinstance(item, gen.lib.Source): pass + elif isinstance(item, gen.lib.Family): + retval.append(_('Family')) + elif isinstance(item, gen.lib.Source): + retval.append(_('Source')) elif isinstance(item, gen.lib.Event): name = self.access.event_type(item) retval.append(name) link = ('Event', item.handle) - elif isinstance(item, gen.lib.MediaObject): pass - elif isinstance(item, gen.lib.Place): pass - elif isinstance(item, gen.lib.Repository): pass - elif isinstance(item, gen.lib.Note): pass + elif isinstance(item, gen.lib.MediaObject): + retval.append(_('Media')) + elif isinstance(item, gen.lib.Place): + 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): text = DateHandler.displayer.display(item) retval.append(text) diff --git a/src/plugins/DefaultGadgets.py b/src/plugins/DefaultGadgets.py index fc052faa0..b27816353 100644 --- a/src/plugins/DefaultGadgets.py +++ b/src/plugins/DefaultGadgets.py @@ -109,11 +109,12 @@ class CalendarGadget(Gadget): # bring up events on this day year, month, day = self.gui.calendar.get_date() month += 1 - if (year, month, day) in self.dates: - run_quick_report_by_name(self.gui.dbstate, - self.gui.uistate, - 'onthisday', - self.dates[(year, month, day)]) + date = gen.lib.Date() + date.set_yr_mon_day(year, month, day) + run_quick_report_by_name(self.gui.dbstate, + self.gui.uistate, + 'onthisday', + date) class LogGadget(Gadget): def db_changed(self): @@ -135,7 +136,8 @@ class LogGadget(Gadget): self.log_active_changed(handle) 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 = {} def log_person_add(self, handles): @@ -165,13 +167,13 @@ class LogGadget(Gadget): self.link(name_displayer.display(person), 'Person', person_handle) else: - self.link("Unknown", 'Person', person_handle) + self.link(_("Unknown"), 'Person', person_handle) self.append_text("\n") class TopSurnamesGadget(Gadget): def init(self): 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): self.dbstate.db.connect('person-add', self.update) @@ -186,7 +188,7 @@ class TopSurnamesGadget(Gadget): self.gui.data = [self.top_size] def main(self): - self.set_text("Processing...\n") + self.set_text(_("Processing...") + "\n") people = self.dbstate.db.get_person_handles(sort_handles=False) surnames = {} representative_handle = {} @@ -223,8 +225,9 @@ class TopSurnamesGadget(Gadget): line += 1 if line >= self.top_size: break - self.append_text("\nTotal unique surnames: %d\n" % total_surnames) - self.append_text("Total people: %d" % total_people) + self.append_text(("\n" + _("Total unique surnames") + ": %d\n") % + total_surnames) + self.append_text((_("Total people") + ": %d") % total_people) class StatsGadget(Gadget): def db_changed(self): @@ -234,10 +237,10 @@ class StatsGadget(Gadget): self.dbstate.db.connect('family-delete', self.update) def init(self): - self.set_text("No Family Tree loaded.") + self.set_text(_("No Family Tree loaded.")) def main(self): - self.set_text("Processing...") + self.set_text(_("Processing...")) database = self.dbstate.db personList = database.get_person_handles(sort_handles=False) familyList = database.get_family_handles() @@ -385,7 +388,7 @@ class TODOGadget(Gadget): def init(self): # GUI setup: 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): self.load_data_to_text() @@ -437,7 +440,7 @@ class NewsGadget(Gadget): def process(self, title): #print "processing '%s'..." % title title = title.replace(" ", "_") - yield True, "Reading '%s'..." % title + yield True, (_("Reading") + " '%s'..." % title) fp = urllib.urlopen(self.URL % title) text = fp.read() #text = text.replace("\n", " ") @@ -484,63 +487,63 @@ class NewsGadget(Gadget): yield False, text register(type="gadget", - name="Top Surnames Gadget", + name= _("Top Surnames Gadget"), height=230, content = TopSurnamesGadget, - title="Top Surnames", + title=_("Top Surnames"), ) register(type="gadget", - name="Stats Gadget", + name=_("Statistics Gadget"), height=230, expand=True, content = StatsGadget, - title="Stats", + title=_("Statistics"), ) register(type="gadget", - name="Log Gadget", + name=_("Session Log Gadget"), height=230, data=['no'], content = LogGadget, - title="Session Log", + title=_("Session Log"), ) register(type="gadget", - name="Python Gadget", + name=_("Python Gadget"), height=250, content = PythonGadget, - title="Python Shell", + title=_("Python Shell"), ) register(type="gadget", - name="TODO Gadget", + name=_("TODO Gadget"), height=300, expand=True, content = TODOGadget, - title="TODO List", + title=_("TODO List"), ) register(type="gadget", - name="Welcome Gadget", + name=_("Welcome Gadget"), height=300, expand=True, content = make_welcome_content, - title="Welcome to GRAMPS!", + title=_("Welcome to GRAMPS!"), ) register(type="gadget", - name="Calendar Gadget", + name=_("Calendar Gadget"), height=200, content = CalendarGadget, - title="Calendar", + title=_("Calendar"), ) register(type="gadget", - name="News Gadget", + name=_("News Gadget"), height=300, expand=True, content = NewsGadget, - title="News", + title=_("News"), ) diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 6ee401af1..8509c1612 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -19,6 +19,7 @@ pkgdata_PYTHON = \ Checkpoint.py\ CountAncestors.py\ CustomBookText.py\ + DefaultGadgets.py\ Desbrowser.py\ DescendChart.py\ DescendReport.py\ @@ -50,6 +51,7 @@ pkgdata_PYTHON = \ MarkerReport.py\ MediaManager.py\ NarrativeWeb.py\ + OnThisDay.py\ OwnerEditor.py\ PatchNames.py\ ReadGrdb.py\ @@ -74,6 +76,7 @@ pkgdata_PYTHON = \ rel_sv.py\ RemoveUnused.py\ ReorderIds.py\ + SameSurnames.py\ siblings.py\ SimpleBookTitle.py\ SoundGen.py\ diff --git a/src/plugins/OnThisDay.py b/src/plugins/OnThisDay.py index 09e1e17d9..7fb484323 100644 --- a/src/plugins/OnThisDay.py +++ b/src/plugins/OnThisDay.py @@ -27,21 +27,39 @@ from Simple import SimpleAccess, SimpleDoc, SimpleTable from gettext import gettext as _ from PluginUtils import register_quick_report 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': - 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: ref = objclass return ref def run(database, document, main_event): """ - Loops through the families that the person is a child in, and display - the information about the other children. + Displays events on a specific date of an event (or date) - 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 sdb = SimpleAccess(database) sdoc = SimpleDoc(document) @@ -49,10 +67,9 @@ def run(database, document, main_event): yeartab = SimpleTable(sdb, sdoc) histab = SimpleTable(sdb, sdoc) - main_date = main_event.get_date_object() - # 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("") stab.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_day() == main_date.get_day()): for (objclass, handle) in database.find_backlink_handles(event_handle): - ref = backlink(database, objclass, handle) + ref = get_ref(database, objclass, handle) stab.row(date, sdb.event_type(event), 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_month() != 0): for (objclass, handle) in database.find_backlink_handles(event_handle): - ref = backlink(database, objclass, handle) + ref = get_ref(database, objclass, handle) histab.row(date, sdb.event_type(event), sdb.event_place(event), ref) elif (date.get_year() == main_date.get_year()): for (objclass, handle) in database.find_backlink_handles(event_handle): - ref = backlink(database, objclass, handle) + ref = get_ref(database, objclass, handle) yeartab.row(date, sdb.event_type(event), sdb.event_place(event), ref) - stab.write() - + if stab.get_row_count() > 0: + sdoc.paragraph(_("Events on this exact date")) + stab.write() + else: + sdoc.paragraph(_("No events on this exact date")) + sdoc.paragraph("") sdoc.paragraph("") + 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() - + else: + sdoc.paragraph(_("No other events on this month/day in history")) + sdoc.paragraph("") sdoc.paragraph("") + 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() + else: + sdoc.paragraph(_("No other events in %(year)d") % + {"year":main_date.get_year()}) + sdoc.paragraph("") + sdoc.paragraph("") #------------------------------------------------------------------------ # -# +# Register the report # #------------------------------------------------------------------------ register_quick_report(