Intelligent selection of default family for family option in reports.

svn: r9966
This commit is contained in:
Brian Matherly 2008-01-31 02:55:59 +00:00
parent 6374fa2163
commit 060dbd4119
2 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,7 @@
2008-01-30 Brian Matherly <brian@gramps-project.org>
* src/PluginUtils/_GuiOptions.py:
Intelligent selection of default family for family option in reports.
2008-01-30 Raphael Ackermann <raphael.ackermann@gmail.com> 2008-01-30 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/FilterEditor/_FilterEditor.py: pylint fixes and * src/FilterEditor/_FilterEditor.py: pylint fixes and
work on 0001660: Title for all Edit Filter windows not translated correctly work on 0001660: Title for all Edit Filter windows not translated correctly

View File

@ -486,13 +486,7 @@ class GuiFamilyOption(gtk.HBox):
self.pack_start(pevt, False) self.pack_start(pevt, False)
self.pack_end(family_button, False) self.pack_end(family_button, False)
person = self.__dbstate.get_active_person() self.__initialize_family()
family_list = person.get_family_handle_list()
if not family_list:
person = self.__db.get_default_person()
family_list = person.get_family_handle_list()
family = self.__db.get_family_from_handle(family_list[0])
self.__update_family(family)
tooltip.set_tip(pevt, self.__option.get_help()) tooltip.set_tip(pevt, self.__option.get_help())
tooltip.set_tip(family_button, _('Select a different family')) tooltip.set_tip(family_button, _('Select a different family'))
@ -500,6 +494,31 @@ class GuiFamilyOption(gtk.HBox):
self.__option.connect('avail-changed', self.__update_avail) self.__option.connect('avail-changed', self.__update_avail)
self.__update_avail() self.__update_avail()
def __initialize_family(self):
"""
Find a family to initialize the option with. Any family will do, but
try to find a family that the user is likely interested in.
"""
family_list = []
# First try the family of the active person
person = self.__dbstate.get_active_person()
if person:
family_list = person.get_family_handle_list()
if not family_list:
# Next try the family of the default person in the database.
person = self.__db.get_default_person()
if person:
family_list = person.get_family_handle_list()
if not family_list:
# Finally, take any family you can find.
family_list = self.__db.get_family_handles()
family = self.__db.get_family_from_handle(family_list[0])
self.__update_family(family)
def __get_family_clicked(self, obj): # IGNORE:W0613 - obj is unused def __get_family_clicked(self, obj): # IGNORE:W0613 - obj is unused
""" """
Handle the button to choose a different family. Handle the button to choose a different family.