From 2c47e2bfb2d11c119f47c26b014ad9ca238812d1 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 24 Mar 2005 03:27:02 +0000 Subject: [PATCH] * src/plugins/Verify.py (VerifyResults): Add class for displaying results; help for the settings window; single instance of the tool. * src/plugins/verify.glade: HIG compliance, break things into tabs. svn: r4229 --- gramps2/ChangeLog | 4 + gramps2/src/plugins/Verify.py | 124 ++- gramps2/src/plugins/verify.glade | 1555 +++++++++++++++--------------- 3 files changed, 887 insertions(+), 796 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 41642e88a..945639c08 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -10,6 +10,10 @@ (MediaRef,Url,Witness,SourceRef): Remove unneeded privacy methods. * src/ImageSelect.py (GlobalMediaProperties.display_refs): Typos. + * src/plugins/Verify.py (VerifyResults): Add class for displaying + results; help for the settings window; single instance of the tool. + * src/plugins/verify.glade: HIG compliance, break things into tabs. + 2005-03-22 Alex Roitman * src/RelLib.py (MediaBase): Add base class for media references; (BaseObject): Add has_handle_reference, remove_handle_references, diff --git a/gramps2/src/plugins/Verify.py b/gramps2/src/plugins/Verify.py index 6c608632a..0b5a768ad 100644 --- a/gramps2/src/plugins/Verify.py +++ b/gramps2/src/plugins/Verify.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2004 Donald N. Allingham +# Copyright (C) 2000-2005 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,11 +18,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# -# Modified by Alex Roitman to enable translation of warnings and errors. -# Modified further to use cStringIO object. -# - # $Id$ "View/Verify" @@ -34,6 +29,7 @@ #------------------------------------------------------------------------ import os import cStringIO +from gettext import gettext as _ #------------------------------------------------------------------------ # @@ -42,6 +38,7 @@ import cStringIO #------------------------------------------------------------------------ import gtk import gtk.glade +from gnome import help_display #------------------------------------------------------------------------ # @@ -52,33 +49,36 @@ import RelLib import Utils import Date -from gettext import gettext as _ - - def runTool(database,active_person,callback,parent=None): Verify(database,active_person,parent) #------------------------------------------------------------------------- # +# Actual tool # #------------------------------------------------------------------------- class Verify: def __init__(self,database,active_person,parent): self.db = database self.parent = parent - self.win_key = self + if self.parent.child_windows.has_key(self.__class__): + self.parent.child_windows[self.__class__].present(None) + return + self.win_key = self.__class__ base = os.path.dirname(__file__) self.glade_file = base + os.sep + "verify.glade" self.top = gtk.glade.XML(self.glade_file,"verify_settings","gramps") self.top.signal_autoconnect({ - "destroy_passed_object" : self.close, - "on_verify_delete_event" : self.on_delete_event, - "on_verify_ok_clicked" : self.on_apply_clicked + "destroy_passed_object" : self.close, + "on_verify_delete_event": self.on_delete_event, + "on_help_clicked" : self.on_help_clicked, + "on_verify_ok_clicked" : self.on_apply_clicked }) self.window = self.top.get_widget('verify_settings') + self.window.set_icon(self.parent.topWindow.get_icon()) Utils.set_titles(self.window, self.top.get_widget('title'), _('Database Verify')) @@ -107,6 +107,10 @@ class Verify: def present(self,obj): self.window.present() + def on_help_clicked(self,obj): + """Display the relevant portion of GRAMPS manual""" + help_display('gramps-manual','tools-util') + def get_year(self,event_handle): """ Returns the year of an event (by its id) or 0 if no event_handle @@ -126,18 +130,22 @@ class Verify: personList = self.db.get_person_handles(sort_handles=False) - oldage = int(self.top.get_widget("oldage").get_text()) - hwdif = int(self.top.get_widget("hwdif").get_text()) - cspace = int(self.top.get_widget("cspace").get_text()) - cbspan = int(self.top.get_widget("cbspan").get_text()) - yngmar = int(self.top.get_widget("yngmar").get_text()) - oldmar = int(self.top.get_widget("oldmar").get_text()) - oldmom = int(self.top.get_widget("oldmom").get_text()) - yngmom = int(self.top.get_widget("yngmom").get_text()) - olddad = int(self.top.get_widget("olddad").get_text()) - yngdad = int(self.top.get_widget("yngdad").get_text()) - wedder = int(self.top.get_widget("wedder").get_text()) - lngwdw = int(self.top.get_widget("lngwdw").get_text()) + oldage = self.top.get_widget("oldage").get_value_as_int() + hwdif = self.top.get_widget("hwdif").get_value_as_int() + cspace = self.top.get_widget("cspace").get_value_as_int() + cbspan = self.top.get_widget("cbspan").get_value_as_int() + yngmar = self.top.get_widget("yngmar").get_value_as_int() + oldmar = self.top.get_widget("oldmar").get_value_as_int() + oldmom = self.top.get_widget("oldmom").get_value_as_int() + yngmom = self.top.get_widget("yngmom").get_value_as_int() + olddad = self.top.get_widget("olddad").get_value_as_int() + yngdad = self.top.get_widget("yngdad").get_value_as_int() + wedder = self.top.get_widget("wedder").get_value_as_int() + lngwdw = self.top.get_widget("lngwdw").get_value_as_int() + mxchildmom = self.top.get_widget("mxchildmom").get_value_as_int() + mxchilddad = self.top.get_widget("mxchilddad").get_value_as_int() + lngwdw = self.top.get_widget("lngwdw").get_value_as_int() + estimate_age = self.top.get_widget("estimate").get_active() oldunm = 99 # maximum age at death for unmarried person @@ -150,6 +158,7 @@ class Verify: idstr = "%s (%s)" % (person.get_primary_name().get_name(),person.get_gramps_id()) # individual checks + total_children = 0 ageatdeath = 0 byear = self.get_year( person.get_birth_handle() ) bapyear = 0 @@ -398,6 +407,8 @@ class Verify: nkids = 0 cbyears = [] + + total_children = total_children + len(family.get_child_handle_list()) for child_handle in family.get_child_handle_list(): nkids = nkids+1 child = self.db.get_person_from_handle(child_handle) @@ -455,53 +466,78 @@ class Verify: if max(cby_diff) > cspace: warn.write(_("Large age differences between children: family %s.\n") % family.get_gramps_id() ) + if (person.get_gender() == RelLib.Person.MALE + and total_children > mxchilddad) \ + or (person.get_gender() == RelLib.Person.FEMALE + and total_children > mxchildmom): + warn.write(_("Too many children (%(num_children)d) for %(person_name)s.\n") % { + 'num_children' : total_children, 'person_name' : idstr }) + text = "" - if error: - text = _("ERRORS:\n") + error.getvalue() + "\n" - if warn: - text = text + _("WARNINGS:\n") + warn.getvalue() + err_text = error.getvalue() + warn_text = warn.getvalue() + if err_text.strip(): + text = _("ERRORS:\n") + err_text + "\n" + if warn_text.strip(): + text = text + _("WARNINGS:\n") + warn_text error.close() warn.close() + VerifyResults(text,self.parent) - top = gtk.glade.XML(self.glade_file,"verify_result","gramps") - Utils.set_titles(top.get_widget('verify_result'), - top.get_widget('title'), - _('Database Verify')) +#------------------------------------------------------------------------- +# +# Display the results +# +#------------------------------------------------------------------------- +class VerifyResults: + def __init__(self,text,parent): + self.parent = parent + self.text = text + + self.win_key = self + + base = os.path.dirname(__file__) + self.glade_file = base + os.sep + "verify.glade" + + self.top = gtk.glade.XML(self.glade_file,"verify_result","gramps") + Utils.set_titles(self.top.get_widget('verify_result'), + self.top.get_widget('title'), + _('Database Verification Results')) - top.signal_autoconnect({ + self.top.signal_autoconnect({ "destroy_passed_object" : self.close_result, "on_result_delete_event" : self.on_result_delete_event, }) - self.topwin = top.get_widget("verify_result") - self.win_result_key = self.topwin - textwindow = top.get_widget("textwindow") - textwindow.get_buffer().set_text(text) + self.window = self.top.get_widget("verify_result") + self.window.set_icon(self.parent.topWindow.get_icon()) + textwindow = self.top.get_widget("textwindow") + textwindow.get_buffer().set_text(self.text) self.add_result_to_menu() - self.topwin.show() + self.window.show() def on_result_delete_event(self,obj,b): self.remove_result_from_menu() def close_result(self,obj): self.remove_result_from_menu() - self.topwin.destroy() + self.window.destroy() def add_result_to_menu(self): - self.parent.child_windows[self.win_result_key] = self.topwin - self.result_parent_menu_item = gtk.MenuItem(_('Database Verify results')) + self.parent.child_windows[self.win_key] = self.window + self.result_parent_menu_item = gtk.MenuItem(_('Database Verification Results')) self.result_parent_menu_item.connect("activate",self.present_result) self.result_parent_menu_item.show() self.parent.winsmenu.append(self.result_parent_menu_item) def remove_result_from_menu(self): - del self.parent.child_windows[self.win_result_key] + del self.parent.child_windows[self.win_key] self.result_parent_menu_item.destroy() def present_result(self,obj): - self.topwin.present() + self.window.present() #------------------------------------------------------------------------- # diff --git a/gramps2/src/plugins/verify.glade b/gramps2/src/plugins/verify.glade index 632a0642d..0a23b3bb8 100644 --- a/gramps2/src/plugins/verify.glade +++ b/gramps2/src/plugins/verify.glade @@ -4,7 +4,7 @@ - + True GTK_WINDOW_TOPLEVEL @@ -15,19 +15,74 @@ True False False - GDK_WINDOW_TYPE_HINT_NORMAL + GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - + True + - - - 12 + + True False 0 + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + True + -11 + + + + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + 0 + + + + + + + True + True + True + _Run + True + GTK_RELIEF_NORMAL + True + 0 + + + + + + 0 + False + True + GTK_PACK_END + + + - + True False 0 @@ -54,385 +109,423 @@ - - 12 + True - 18 - 3 - False - 6 - 12 + True + True + True + GTK_POS_TOP + False + False - + + 12 True - Maximum age - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 + 9 + 2 + False + 6 + 6 + + + + True + Maximum number of _spouses for a person + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + wedder + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 90 0 150 1 10 10 + + + 1 + 2 + 0 + 1 + expand|shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 30 0 100 1 10 10 + + + 1 + 2 + 1 + 2 + expand|shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 17 0 100 1 10 10 + + + 1 + 2 + 2 + 3 + expand|shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 50 0 150 1 10 10 + + + 1 + 2 + 3 + 4 + expand|shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 3 0 100 1 10 10 + + + 1 + 2 + 4 + 5 + expand|shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 30 0 100 1 10 10 + + + 1 + 2 + 5 + 6 + expand|shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 8 0 100 1 10 10 + + + 1 + 2 + 6 + 7 + expand|shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 25 0 100 1 10 10 + + + 1 + 2 + 7 + 8 + expand|shrink|fill + + + + + + + True + Maximum number of consecutive years of _widowhood + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + lngwdw + + + 0 + 1 + 5 + 6 + + + + + + + True + Maximum number of years _between children + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + cspace + + + 0 + 1 + 6 + 7 + + + + + + + True + Maximum span _of years for all children + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + cbspan + + + 0 + 1 + 7 + 8 + + + + + + + True + True + _Estimate missing dates + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 2 + 8 + 9 + + + + + + + True + Maximum _age + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + oldage + + + 0 + 1 + 0 + 1 + + + + + + + True + Maximum husband-wife age _difference + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + hwdif + + + 0 + 1 + 1 + 2 + + + + + + + True + Mi_nimum age to marry + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + yngmar + + + 0 + 1 + 2 + 3 + + + + + + + True + Ma_ximum age to marry + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + oldmar + + + 0 + 1 + 3 + 4 + + + - 1 - 2 - 1 - 2 - fill - + False + True - - True - Maximum husband-wife age difference - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - Minimum age to marry - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 3 - 4 - fill - - - - - - - True - Maximum age to marry - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 4 - 5 - fill - - - - - - - True - Maximum number of spouses for a person - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 5 - 6 - fill - - - - - - - True - Maximum number of consecutive years of widowhood - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 6 - 7 - fill - - - - - - - True - Maximum number of years between children - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 7 - 8 - fill - - - - - - - True - Maximum span of years for all children - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 8 - 9 - fill - - - - - - - True - True - True - True - 0 - 90 - True - * - False - - - 2 - 3 - 1 - 2 - - - - - - - - True - True - True - True - 0 - 30 - True - * - False - - - 2 - 3 - 2 - 3 - - - - - - - - True - True - True - True - 0 - 17 - True - * - False - - - 2 - 3 - 3 - 4 - - - - - - - - True - True - True - True - 0 - 50 - True - * - False - - - 2 - 3 - 4 - 5 - - - - - - - - True - True - True - True - 0 - 3 - True - * - False - - - 2 - 3 - 5 - 6 - - - - - - - - True - True - True - True - 0 - 30 - True - * - False - - - 2 - 3 - 6 - 7 - - - - - - - - True - True - True - True - 0 - 8 - True - * - False - - - 2 - 3 - 7 - 8 - - - - - - - - True - True - True - True - 0 - 25 - True - * - False - - - 2 - 3 - 8 - 9 - - - - - - - + True <b>General</b> False @@ -446,12 +539,161 @@ 0 - 0 - 3 - 0 - 1 - fill - + tab + + + + + + 12 + True + 3 + 2 + False + 6 + 6 + + + + True + Mi_nimum age to bear a child + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 2 + 2 + yngmom + + + 0 + 1 + 0 + 1 + + + + + + + True + Ma_ximum age to bear a child + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 2 + 2 + oldmom + + + 0 + 1 + 1 + 2 + + + + + + + True + Maximum number of c_hildren + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 2 + 2 + mxchildmom + + + 0 + 1 + 2 + 3 + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 17 0 100 1 10 10 + + + 1 + 2 + 0 + 1 + shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 48 0 100 1 10 10 + + + 1 + 2 + 1 + 2 + shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 12 0 100 1 10 10 + + + 1 + 2 + 2 + 3 + shrink|fill + + + + + + False + True @@ -470,150 +712,161 @@ 0 - 0 - 3 - 10 - 11 - fill - + tab - + + 12 True - Minimum age to bear a child - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 2 - 2 - - - 1 - 2 - 11 - 12 - fill - - - + 3 + 2 + False + 6 + 6 - - - True - True - True - True - 0 - 17 - True - * - False - - - 2 - 3 - 11 - 12 - - - - + + + True + Mi_nimum age to father a child + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 2 + 2 + yngdad + + + 0 + 1 + 0 + 1 + + + - - - True - Maximum age to bear a child - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 2 - 2 - - - 1 - 2 - 12 - 13 - fill - - - + + + True + Ma_ximum age to father a child + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 2 + 2 + olddad + + + 0 + 1 + 1 + 2 + + + - - - True - Maximum number of children - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 2 - 2 - - - 1 - 2 - 13 - 14 - fill - - - + + + True + Maximum number of c_hildren + True + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 2 + 2 + mxchilddad + + + 0 + 1 + 2 + 3 + + + - - - True - True - True - True - 0 - 49 - True - * - False - - - 2 - 3 - 12 - 13 - - - - + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 15 0 100 1 10 10 + + + 1 + 2 + 2 + 3 + shrink|fill + + + - - - True - True - True - True - 0 - 11 - True - * - False + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 65 0 150 1 10 10 + + + 1 + 2 + 1 + 2 + shrink|fill + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 18 0 100 1 10 10 + + + 1 + 2 + 0 + 1 + shrink|fill + + + - 2 - 3 - 13 - 14 - - + False + True @@ -632,172 +885,7 @@ 0 - 0 - 3 - 14 - 15 - fill - - - - - - - True - Minimum age to father a child - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 2 - 2 - - - 1 - 2 - 15 - 16 - fill - - - - - - - True - True - True - True - 0 - 18 - True - * - False - - - 2 - 3 - 15 - 16 - - - - - - - - True - Maximum age to father a child - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 2 - 2 - - - 1 - 2 - 16 - 17 - fill - - - - - - - True - Maximum number of children - False - False - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 2 - 2 - - - 1 - 2 - 17 - 18 - fill - - - - - - - True - True - True - True - 0 - 65 - True - * - False - - - 2 - 3 - 16 - 17 - - - - - - - - True - True - True - True - 0 - 15 - True - * - False - - - 2 - 3 - 17 - 18 - - - - - - - - True - True - Estimate missing dates - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 1 - 3 - 9 - 10 - fill - + tab @@ -814,36 +902,50 @@ True + + + - - + + True + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 500 + 300 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False + + + + + True + False + 0 + + + True GTK_BUTTONBOX_END - 30 - + True True True - gtk-cancel + gtk-close True GTK_RELIEF_NORMAL True - - - - - - - True - True - True - _Run - True - GTK_RELIEF_NORMAL - True - + -7 + @@ -851,35 +953,9 @@ 0 False True + GTK_PACK_END - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 500 - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - - - - - 6 - True - False - 0 @@ -910,6 +986,7 @@ + 12 True True GTK_POLICY_AUTOMATIC @@ -950,32 +1027,6 @@ True - - - - True - GTK_BUTTONBOX_END - 0 - - - - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - True - - - - - - 6 - False - True - -