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

* src/DataViews/MyGrampsView.py: show matching surnames
	* src/plugins/OnThisDay.py: refinement
	* src/plugins/SameSurnames.py: changed name
	* src/plugins/DefaultGadgets.py: calendar calls quickreport
	* src/QuickReports.py: new function to call qr directly
	* src/Simple/_SimpleAccess.py: new func to format dates



svn: r9633
This commit is contained in:
Doug Blank 2007-12-30 03:46:39 +00:00
parent bca91ffad0
commit 07bdb19028
7 changed files with 71 additions and 14 deletions

View File

@ -1,3 +1,11 @@
2007-12-29 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/DataViews/MyGrampsView.py: show matching surnames
* src/plugins/OnThisDay.py: refinement
* src/plugins/SameSurnames.py: changed name
* src/plugins/DefaultGadgets.py: calendar calls quickreport
* src/QuickReports.py: new function to call qr directly
* src/Simple/_SimpleAccess.py: new func to format dates
2007-12-29 Douglas S. Blank <dblank@saliva.brynmawr.edu>
* src/DataViews/MyGrampsView.py: fixme's are fixed
* src/DataViews/EventView.py: added quick report popup

View File

@ -42,6 +42,7 @@ import PageView
import ManagedWindow
import ConfigParser
import Utils
from QuickReports import run_quick_report_by_name
AVAILABLE_GADGETS = {}
GADGET_FILENAME = os.path.join(const.HOME_DIR,"gadgets.ini")
@ -340,6 +341,12 @@ class Gadget(object):
self.gui.dbstate.change_active_person(person)
return True # handled event
elif link_type == 'Surname':
if event.button == 1: # left mouse
if event.type == gtk.gdk._2BUTTON_PRESS: # double
run_quick_report_by_name(self.gui.dbstate,
self.gui.uistate,
'samesurnames',
handle)
return True
return False # did not handle event

View File

@ -111,6 +111,21 @@ def by_menu_name(first, second):
def make_quick_report_callback(lst, category, dbstate, uistate, handle):
return lambda x: run_report(dbstate, uistate, category, handle, lst[0])
def run_quick_report_by_name(dbstate, uistate, report_name, handle):
from PluginUtils import quick_report_list
# [0] - function
# [1] - translated name
# [2] - category
# [3] - name
# [5] - status
report = None
for item in quick_report_list:
if item[3] == report_name:
report = item
break
if report:
run_report(dbstate, uistate, report[2], handle, report[0])
def run_report(dbstate, uistate, category,handle,func):
from TextBufDoc import TextBufDoc
from Simple import make_basic_stylesheet

View File

@ -491,6 +491,20 @@ class SimpleAccess:
else:
return u''
def date_string(self, date_obj):
"""
Returns a string representation a date_obj
@param date_obj: Date object
@type date_obj: L{gen.lib.Date}
@return: Returns a string representation a date_obj
@rtype: unicode
"""
if date_obj:
return DateHandler.displayer.display(date_obj)
else:
return u''
def event_date(self, event):
"""
Returns a string indicating the date of the event

View File

@ -1,7 +1,3 @@
from DataViews import register, Gadget
from BasicUtils import name_displayer
import DateHandler
import gen.lib
import sys
import os
import re
@ -9,6 +5,12 @@ import time
import string
import urllib
import gen.lib
from DataViews import register, Gadget
from BasicUtils import name_displayer
from QuickReports import run_quick_report_by_name
import DateHandler
#
# Hello World, in Gramps Gadgets
#
@ -74,8 +76,9 @@ class CalendarGadget(Gadget):
self.gui.calendar.clear_marks()
year, month, day = self.gui.calendar.get_date()
for date in self.dates:
if date[1] != 0 and date[1] == month + 1:
if date[2] > 0 and date[2] <= day:
if ((date[0] == year) and
(date[1] == month + 1) and
(date[2] > 0 and date[2] <= day)):
self.gui.calendar.mark_day(date[2])
self.gui.calendar.thaw()
@ -98,13 +101,19 @@ class CalendarGadget(Gadget):
month = birth_date.get_month()
day = birth_date.get_day()
#age = self.year - year
self.dates[(year, month, day)] = 1
self.dates[(year, month, day)] = birth_event.handle
cnt += 1
self.refresh()
def double_click(self, obj):
# bring up events on this day
pass
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)])
class LogGadget(Gadget):
def db_changed(self):
@ -180,12 +189,14 @@ class TopSurnamesGadget(Gadget):
self.set_text("Processing...\n")
people = self.dbstate.db.get_person_handles(sort_handles=False)
surnames = {}
representative_handle = {}
cnt = 0
for person_handle in people:
person = self.dbstate.db.get_person_from_handle(person_handle)
if person:
surname = person.get_primary_name().get_surname().strip()
surnames[surname] = surnames.get(surname, 0) + 1
representative_handle[surname] = person_handle
if cnt % 350 == 0:
yield True
cnt += 1
@ -206,7 +217,7 @@ class TopSurnamesGadget(Gadget):
self.set_text("")
for (count, surname) in surname_sort:
self.append_text(" %d. " % (line + 1))
self.link(surname, 'Surname', surname)
self.link(surname, 'Surname', representative_handle[surname])
self.append_text(", %d%% (%d)\n" %
(int((float(count)/total) * 100), count))
line += 1

View File

@ -39,6 +39,8 @@ 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.
Takes an Event handle
"""
# setup the simple access functions
sdb = SimpleAccess(database)
@ -50,7 +52,7 @@ def run(database, document, main_event):
main_date = main_event.get_date_object()
# display the title
sdoc.title(_("Events of %s") % sdb.event_date(main_event))
sdoc.title(_("Events of %s") % sdb.date_string(main_date))
sdoc.paragraph("")
stab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
yeartab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))

View File

@ -64,7 +64,7 @@ def run(database, document, person):
#
#------------------------------------------------------------------------
register_quick_report(
name = 'surnames',
name = 'samesurnames',
category = CATEGORY_QR_PERSON,
run_func = run,
translated_name = _("Same Surnames"),