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:
parent
bca91ffad0
commit
07bdb19028
@ -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>
|
2007-12-29 Douglas S. Blank <dblank@saliva.brynmawr.edu>
|
||||||
* src/DataViews/MyGrampsView.py: fixme's are fixed
|
* src/DataViews/MyGrampsView.py: fixme's are fixed
|
||||||
* src/DataViews/EventView.py: added quick report popup
|
* src/DataViews/EventView.py: added quick report popup
|
||||||
|
@ -42,6 +42,7 @@ import PageView
|
|||||||
import ManagedWindow
|
import ManagedWindow
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import Utils
|
import Utils
|
||||||
|
from QuickReports import run_quick_report_by_name
|
||||||
|
|
||||||
AVAILABLE_GADGETS = {}
|
AVAILABLE_GADGETS = {}
|
||||||
GADGET_FILENAME = os.path.join(const.HOME_DIR,"gadgets.ini")
|
GADGET_FILENAME = os.path.join(const.HOME_DIR,"gadgets.ini")
|
||||||
@ -340,6 +341,12 @@ class Gadget(object):
|
|||||||
self.gui.dbstate.change_active_person(person)
|
self.gui.dbstate.change_active_person(person)
|
||||||
return True # handled event
|
return True # handled event
|
||||||
elif link_type == 'Surname':
|
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 True
|
||||||
return False # did not handle event
|
return False # did not handle event
|
||||||
|
|
||||||
|
@ -110,6 +110,21 @@ def by_menu_name(first, second):
|
|||||||
|
|
||||||
def make_quick_report_callback(lst, category, dbstate, uistate, handle):
|
def make_quick_report_callback(lst, category, dbstate, uistate, handle):
|
||||||
return lambda x: run_report(dbstate, uistate, category, handle, lst[0])
|
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):
|
def run_report(dbstate, uistate, category,handle,func):
|
||||||
from TextBufDoc import TextBufDoc
|
from TextBufDoc import TextBufDoc
|
||||||
@ -131,9 +146,9 @@ def run_report(dbstate, uistate, category,handle,func):
|
|||||||
obj = dbstate.db.get_place_from_handle(handle)
|
obj = dbstate.db.get_place_from_handle(handle)
|
||||||
elif category == CATEGORY_QR_REPOSITORY :
|
elif category == CATEGORY_QR_REPOSITORY :
|
||||||
obj = dbstate.db.get_repository_from_handle(handle)
|
obj = dbstate.db.get_repository_from_handle(handle)
|
||||||
else :
|
else:
|
||||||
obj = None
|
obj = None
|
||||||
if obj :
|
if obj:
|
||||||
d.open("")
|
d.open("")
|
||||||
func(dbstate.db, d, obj)
|
func(dbstate.db, d, obj)
|
||||||
d.close()
|
d.close()
|
||||||
|
@ -491,6 +491,20 @@ class SimpleAccess:
|
|||||||
else:
|
else:
|
||||||
return u''
|
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):
|
def event_date(self, event):
|
||||||
"""
|
"""
|
||||||
Returns a string indicating the date of the event
|
Returns a string indicating the date of the event
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
from DataViews import register, Gadget
|
|
||||||
from BasicUtils import name_displayer
|
|
||||||
import DateHandler
|
|
||||||
import gen.lib
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -9,6 +5,12 @@ import time
|
|||||||
import string
|
import string
|
||||||
import urllib
|
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
|
# Hello World, in Gramps Gadgets
|
||||||
#
|
#
|
||||||
@ -74,9 +76,10 @@ class CalendarGadget(Gadget):
|
|||||||
self.gui.calendar.clear_marks()
|
self.gui.calendar.clear_marks()
|
||||||
year, month, day = self.gui.calendar.get_date()
|
year, month, day = self.gui.calendar.get_date()
|
||||||
for date in self.dates:
|
for date in self.dates:
|
||||||
if date[1] != 0 and date[1] == month + 1:
|
if ((date[0] == year) and
|
||||||
if date[2] > 0 and date[2] <= day:
|
(date[1] == month + 1) and
|
||||||
self.gui.calendar.mark_day(date[2])
|
(date[2] > 0 and date[2] <= day)):
|
||||||
|
self.gui.calendar.mark_day(date[2])
|
||||||
self.gui.calendar.thaw()
|
self.gui.calendar.thaw()
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
@ -98,13 +101,19 @@ class CalendarGadget(Gadget):
|
|||||||
month = birth_date.get_month()
|
month = birth_date.get_month()
|
||||||
day = birth_date.get_day()
|
day = birth_date.get_day()
|
||||||
#age = self.year - year
|
#age = self.year - year
|
||||||
self.dates[(year, month, day)] = 1
|
self.dates[(year, month, day)] = birth_event.handle
|
||||||
cnt += 1
|
cnt += 1
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def double_click(self, obj):
|
def double_click(self, obj):
|
||||||
# bring up events on this day
|
# 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):
|
class LogGadget(Gadget):
|
||||||
def db_changed(self):
|
def db_changed(self):
|
||||||
@ -180,12 +189,14 @@ class TopSurnamesGadget(Gadget):
|
|||||||
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 = {}
|
||||||
cnt = 0
|
cnt = 0
|
||||||
for person_handle in people:
|
for person_handle in people:
|
||||||
person = self.dbstate.db.get_person_from_handle(person_handle)
|
person = self.dbstate.db.get_person_from_handle(person_handle)
|
||||||
if person:
|
if person:
|
||||||
surname = person.get_primary_name().get_surname().strip()
|
surname = person.get_primary_name().get_surname().strip()
|
||||||
surnames[surname] = surnames.get(surname, 0) + 1
|
surnames[surname] = surnames.get(surname, 0) + 1
|
||||||
|
representative_handle[surname] = person_handle
|
||||||
if cnt % 350 == 0:
|
if cnt % 350 == 0:
|
||||||
yield True
|
yield True
|
||||||
cnt += 1
|
cnt += 1
|
||||||
@ -206,7 +217,7 @@ class TopSurnamesGadget(Gadget):
|
|||||||
self.set_text("")
|
self.set_text("")
|
||||||
for (count, surname) in surname_sort:
|
for (count, surname) in surname_sort:
|
||||||
self.append_text(" %d. " % (line + 1))
|
self.append_text(" %d. " % (line + 1))
|
||||||
self.link(surname, 'Surname', surname)
|
self.link(surname, 'Surname', representative_handle[surname])
|
||||||
self.append_text(", %d%% (%d)\n" %
|
self.append_text(", %d%% (%d)\n" %
|
||||||
(int((float(count)/total) * 100), count))
|
(int((float(count)/total) * 100), count))
|
||||||
line += 1
|
line += 1
|
||||||
|
@ -39,6 +39,8 @@ def run(database, document, main_event):
|
|||||||
"""
|
"""
|
||||||
Loops through the families that the person is a child in, and display
|
Loops through the families that the person is a child in, and display
|
||||||
the information about the other children.
|
the information about the other children.
|
||||||
|
|
||||||
|
Takes an Event handle
|
||||||
"""
|
"""
|
||||||
# setup the simple access functions
|
# setup the simple access functions
|
||||||
sdb = SimpleAccess(database)
|
sdb = SimpleAccess(database)
|
||||||
@ -50,7 +52,7 @@ def run(database, document, main_event):
|
|||||||
main_date = main_event.get_date_object()
|
main_date = main_event.get_date_object()
|
||||||
|
|
||||||
# display the title
|
# 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("")
|
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"))
|
||||||
|
@ -64,7 +64,7 @@ def run(database, document, person):
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
register_quick_report(
|
register_quick_report(
|
||||||
name = 'surnames',
|
name = 'samesurnames',
|
||||||
category = CATEGORY_QR_PERSON,
|
category = CATEGORY_QR_PERSON,
|
||||||
run_func = run,
|
run_func = run,
|
||||||
translated_name = _("Same Surnames"),
|
translated_name = _("Same Surnames"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user