Start of migrating tools to Managed Windows

svn: r6294
This commit is contained in:
Don Allingham 2006-04-09 22:53:53 +00:00
parent 4cc621cc56
commit fb27b07fc1
25 changed files with 312 additions and 468 deletions

View File

@ -1,3 +1,6 @@
2006-04-09 Don Allingham <don@gramps-project.org>
* src/plugins/*: bring up to ManagedWindow
2006-04-07 Don Allingham <don@gramps-project.org>
* src/Editors/_EditFamily.py: remove empty families

View File

@ -133,6 +133,7 @@ class FamilyListView(PageView.ListView):
def family_add_loop(self,handle_list):
if self.updating:
return False
print handle_list
self.updating = True
self.row_add(handle_list)
self.updating = False

View File

@ -83,7 +83,9 @@ class FamilyView(PageView.PersonNavView):
def __init__(self, dbstate, uistate):
PageView.PersonNavView.__init__(self, 'Relationship View', dbstate, uistate)
PageView.PersonNavView.__init__(self, 'Relationship View',
dbstate, uistate)
dbstate.connect('database-changed', self.change_db)
dbstate.connect('active-changed', self.change_person)
self.show_siblings = Config.get_family_siblings()
@ -697,18 +699,8 @@ class FamilyView(PageView.PersonNavView):
if family:
person = self.dbstate.db.get_person_from_handle(self.dbstate.active.handle)
family.add_child_handle(person.handle)
person.add_parent_family_handle(
family.handle,
(RelLib.Person.CHILD_BIRTH, ''),
(RelLib.Person.CHILD_BIRTH, ''))
trans = self.dbstate.db.transaction_begin()
self.dbstate.db.commit_person(person, trans)
self.dbstate.db.commit_family(family, trans)
self.dbstate.db.transaction_commit(trans, _("Add Family"))
GrampsDb.add_child_to_family(family, child, (RelLib.Person.CHILD_BIRTH,'')
(RelLib.Person.CHILD_BIRTH,''))
def add_parent_family(self, obj, event, handle):
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:

View File

@ -33,7 +33,7 @@ class FilterError(Exception):
def messages(self):
return (self.value,self.value2)
class DatabaseError(Exception):
class DateError(Exception):
"""Error used to report Date errors"""
def __init__(self,value=""):
Exception.__init__(self)
@ -42,6 +42,15 @@ class DatabaseError(Exception):
def __str__(self):
return self.value
class DatabaseError(Exception):
"""Error used to report database errors"""
def __init__(self,value=""):
Exception.__init__(self)
self.value = value
def __str__(self):
return self.value
class ReportError(Exception):
"""Error used to report Report errors"""
def __init__(self,value,value2=""):

View File

@ -2336,6 +2336,7 @@ class GenericFilterList:
f.write('<filters>\n')
for namespace in self.filter_list:
f.write('<object "%s">\n' % "person")
print namespace
for i in namespace:
f.write(' <filter name="%s"' % self.fix(i.get_name()))
if i.get_invert():

View File

@ -21,6 +21,8 @@
# $Id: __init__.py 6086 2006-03-06 03:54:58Z dallingham $
import RelLib
def remove_family_relationships(db, family_handle, trans=None):
family = db.get_family_from_handle(family_handle)
@ -104,3 +106,24 @@ def remove_child_from_family(db, person_handle, family_handle, trans=None):
if need_commit:
db.transaction_commit(trans,_("Remove child from family"))
def add_child_to_family(db, family, child, mrel=(RelLib.Person.CHILD_BIRTH,''),
frel=(RelLib.Person.CHILD_BIRTH,''), trans=None):
family.add_child_handle(child.handle)
child.add_parent_family_handle(family.handle, mrel, frel )
if trans == None:
need_commit = True
trans = db.transaction_begin()
else:
need_commit = False
db.commit_family(family,trans)
db.commit_person(person,trans)
if need_commit:
db.transaction_commit(trans, _('Add child to family') )

View File

@ -254,7 +254,7 @@ class ManagedWindow:
event, and presenting itself when selected or attempted to create again.
"""
def __init__(self,uistate,track,obj):
def __init__(self, uistate, track, obj):
"""
Create child windows and add itself to menu, if not there already.

View File

@ -73,6 +73,7 @@ class PageView:
self.active = False
def set_active(self):
print self, self.active, self.dirty
self.active = True
if self.dirty:
self.uistate.set_busy_cursor(True)

View File

@ -84,9 +84,9 @@ class Tool:
sub-classed to create a functional tool.
"""
def __init__(self,database,person,options_class,name):
self.db = database
self.person = person
def __init__(self, dbstate, options_class, name):
self.db = dbstate.db
self.person = dbstate.active
if type(options_class) == ClassType:
self.options = options_class(name)
elif type(options_class) == InstanceType:
@ -206,8 +206,9 @@ class CommandLineTool:
#
#------------------------------------------------------------------------
# Standard GUI tool generic task
def gui_tool(database,person,tool_class,options_class,translated_name,
name,category,callback,parent):
def gui_tool(dbstate, uistate, tool_class, options_class, translated_name,
name, category, callback):
"""
tool - task starts the report. The plugin system requires that the
task be in the format of task that takes a database and a person as
@ -215,12 +216,12 @@ def gui_tool(database,person,tool_class,options_class,translated_name,
"""
try:
tool_class(database,person,options_class,name,callback,parent)
tool_class(dbstate, uistate, options_class, name, callback)
except:
log.error("Failed to start tool.", exc_info=True)
# Command-line generic task
def cli_tool(database,name,category,tool_class,options_class,options_str_dict):
def cli_tool( database,name,category,tool_class,options_class,options_str_dict):
clt = CommandLineTool(database,name,category,
options_class,options_str_dict)

View File

@ -25,7 +25,7 @@ Manages the main window and the pluggable views
"""
__author__ = "Donald N. Allingham"
__revision__ = "$Revision:$"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
@ -1076,7 +1076,7 @@ class ViewManager:
new_key = name[2].replace(' ', '-')
f.write('<menuitem action="%s"/>' % new_key)
actions.append((new_key, None, name[2], None, None,
func(name, self.state)))
func(name, self.state, self.uistate)))
f.write('</menu>')
# If there are any unsupported items we add separator
@ -1091,7 +1091,7 @@ class ViewManager:
new_key = name[2].replace(' ', '-')
f.write('<menuitem action="%s"/>' % new_key)
actions.append((new_key, None, name[2], None, None,
func(name, self.state)))
func(name, self.state, self.uistate)))
f.write('</menu>')
f.write('</menu></menubar></ui>')
@ -1147,14 +1147,14 @@ def add_gedcom_filter(chooser):
mime_filter.add_mime_type(const.app_gedcom)
chooser.add_filter(mime_filter)
def make_report_callback(lst, dbstate):
def make_report_callback(lst, dbstate, uistate):
return lambda x: Report.report(dbstate.db, dbstate.get_active_person(),
lst[0], lst[1], lst[2], lst[3], lst[4])
def make_tool_callback(lst, dbstate):
return lambda x: Tool.gui_tool(dbstate.db, dbstate.get_active_person(),
def make_tool_callback(lst, dbstate, uistate):
return lambda x: Tool.gui_tool(dbstate, uistate,
lst[0], lst[1], lst[2], lst[3], lst[4],
dbstate.db.request_rebuild, None)
dbstate.db.request_rebuild)
#-------------------------------------------------------------------------
#

View File

@ -11,7 +11,6 @@
<property name="modal">True</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">images/gramps.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -287,7 +286,6 @@
<property name="default_height">500</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">images/gramps.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -552,7 +550,6 @@
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">images/gramps.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -1153,7 +1150,6 @@
<property name="default_width">300</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">images/gramps.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>

View File

@ -11,7 +11,6 @@
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">images/gramps.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -532,7 +531,6 @@
<property name="default_height">350</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">images/gramps.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -848,7 +846,6 @@
<property name="default_height">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">images/gramps.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@ -957,7 +954,6 @@
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon">images/gramps.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>

View File

@ -148,7 +148,6 @@ class GenChart:
def display(self):
index = 0
for i in self.array:
print "%04d" % index,i
index=index+1
def not_blank(self,line):

View File

@ -46,8 +46,10 @@ import gtk.glade
#
#-------------------------------------------------------------------------
import Utils
from QuestionDialog import OkDialog
import GrampsDisplay
import ManagedWindow
from QuestionDialog import OkDialog
from PluginUtils import Tool, register_tool
#-------------------------------------------------------------------------
@ -55,26 +57,24 @@ from PluginUtils import Tool, register_tool
# ChangeNames
#
#-------------------------------------------------------------------------
class ChangeNames(Tool.Tool):
class ChangeNames(Tool.Tool, ManagedWindow,ManagedWindow):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
ManagedWindow.ManagedWindow.__init__(self, uistate, []. self)
self.cb = callback
self.parent = parent
if self.parent.child_windows.has_key(self.__class__):
self.parent.child_windows[self.__class__].present(None)
return
self.win_key = self.__class__
self.progress = Utils.ProgressMeter(_('Checking family names'),'')
self.progress.set_pass(_('Searching family names'),
len(self.db.get_surname_list()))
self.name_list = []
for name in self.db.get_surname_list():
if name != name.capitalize():
self.name_list.append(name)
if self.parent:
if uistate:
self.progress.step()
if self.name_list:
@ -91,7 +91,6 @@ class ChangeNames(Tool.Tool):
self.top = gtk.glade.XML(glade_file,"top","gramps")
self.window = self.top.get_widget('top')
self.window.set_icon(self.parent.topWindow.get_icon())
self.top.signal_autoconnect({
"destroy_passed_object" : self.close,
"on_ok_clicked" : self.on_ok_clicked,
@ -130,34 +129,18 @@ class ChangeNames(Tool.Tool):
self.progress.step()
self.progress.close()
self.add_itself_to_menu()
self.window.show()
self.show()
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-db')
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
pass
def close(self,obj):
self.remove_itself_from_menu()
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(self.label)
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def on_ok_clicked(self,obj):
self.trans = self.db.transaction_begin("",batch=True)
self.db.disable_signals()

View File

@ -45,8 +45,10 @@ import gtk.glade
#------------------------------------------------------------------------
import const
import Utils
from QuestionDialog import OkDialog
import ManagedWindow
import AutoComp
from QuestionDialog import OkDialog
from PluginUtils import Tool, register_tool
#-------------------------------------------------------------------------
@ -54,22 +56,20 @@ from PluginUtils import Tool, register_tool
#
#
#-------------------------------------------------------------------------
class ChangeTypes(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow):
if parent:
self.init_gui(parent)
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
if uistate:
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
self.init_gui()
else:
self.run_tool(cli=True)
def init_gui(self,parent):
def init_gui(self):
# Draw dialog and make it handle everything
self.parent = parent
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__)
glade_file = "%s/%s" % (base,"changetype.glade")
@ -88,7 +88,6 @@ class ChangeTypes(Tool.Tool):
self.title = _('Change Event Types')
self.window = self.glade.get_widget('top')
self.window.set_icon(self.parent.topWindow.get_icon())
Utils.set_titles(self.window,
self.glade.get_widget('title'),
self.title)
@ -99,8 +98,7 @@ class ChangeTypes(Tool.Tool):
"on_apply_clicked" : self.on_apply_clicked,
})
self.add_itself_to_menu()
self.window.show()
self.show()
def run_tool(self,cli=False):
# Run tool and return results
@ -143,25 +141,7 @@ class ChangeTypes(Tool.Tool):
return (bool(modified),msg)
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
def close(self,obj):
self.remove_itself_from_menu()
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(self.title)
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
pass
def on_apply_clicked(self,obj):
# Need to store English names for later comparison

View File

@ -56,10 +56,11 @@ import gtk.glade
import RelLib
import Utils
import const
import ManagedWindow
from PluginUtils import Tool, register_tool
from QuestionDialog import OkDialog, MissingMediaDialog
#-------------------------------------------------------------------------
#
# Low Level repair
@ -138,13 +139,14 @@ def _table_low_level(db,table):
#
#-------------------------------------------------------------------------
class Check(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
# def runTool(database,active_person,callback,parent=None):
cli = int(parent == None)
cli = uistate == None
if db.readonly:
if self.db.readonly:
# TODO: split plugin in a check and repair part to support
# checking of a read only database
return
@ -152,12 +154,12 @@ class Check(Tool.Tool):
# The low-level repair is bypassing the transaction mechanism.
# As such, we run it before starting the transaction.
# We only do this for the BSDDB backend.
if db.__class__.__name__ == 'GrampsBSDDB':
low_level(db)
if self.db.__class__.__name__ == 'GrampsBSDDB':
low_level(self.db)
trans = db.transaction_begin("",batch=True)
db.disable_signals()
checker = CheckIntegrity(db,parent,trans)
trans = self.db.transaction_begin("",batch=True)
self.db.disable_signals()
checker = CheckIntegrity(dbstate, uistate, trans)
checker.fix_encoding()
checker.cleanup_missing_photos(cli)
@ -177,13 +179,13 @@ class Check(Tool.Tool):
checker.check_events()
checker.check_place_references()
checker.check_source_references()
db.transaction_commit(trans, _("Check Integrity"))
db.enable_signals()
db.request_rebuild()
self.db.transaction_commit(trans, _("Check Integrity"))
self.db.enable_signals()
self.db.request_rebuild()
errs = checker.build_report(cli)
if errs:
Report(checker.text.getvalue(),parent)
Report(uistate, checker.text.getvalue(),parent)
#-------------------------------------------------------------------------
#
@ -192,10 +194,9 @@ class Check(Tool.Tool):
#-------------------------------------------------------------------------
class CheckIntegrity:
def __init__(self,db,parent,trans):
self.db = db
def __init__(self, dbstate, uistate, trans):
self.db = dbstate.db
self.trans = trans
self.parent = parent
self.bad_photo = []
self.replaced_photo = []
self.removed_photo = []
@ -757,8 +758,7 @@ class CheckIntegrity:
print "No errors were found: the database has passed internal checks."
else:
OkDialog(_("No errors were found"),
_('The database has passed internal checks'),
self.parent.topWindow)
_('The database has passed internal checks'))
return 0
self.text = cStringIO.StringIO()
@ -872,55 +872,30 @@ class CheckIntegrity:
# Display the results
#
#-------------------------------------------------------------------------
class Report:
def __init__(self,text,parent,cl=0):
class Report(ManagedWindow.ManagedWindow):
def __init__(self, uistate, text, cl=0):
if cl:
print text
return
self.text = text
self.parent = parent
self.win_key = self
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
base = os.path.dirname(__file__)
glade_file = base + os.sep + "summary.glade"
topDialog = gtk.glade.XML(glade_file,"summary","gramps")
topDialog.signal_autoconnect({
"destroy_passed_object" : self.close_result,
"on_result_delete_event" : self.on_result_delete_event,
})
self.title = _("Integrity Check Results")
self.window = topDialog.get_widget("summary")
self.window.set_icon(self.parent.topWindow.get_icon())
textwindow = topDialog.get_widget("textwindow")
textwindow.get_buffer().set_text(self.text)
textwindow.get_buffer().set_text(text)
Utils.set_titles(self.window,topDialog.get_widget("title"),self.title)
Utils.set_titles(topDialog.get_widget("summary"),
topDialog.get_widget("title"),
_("Integrity Check Results"))
self.add_result_to_menu()
self.window.show()
self.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.window.destroy()
def add_result_to_menu(self):
self.parent.child_windows[self.win_key] = self.window
self.result_parent_menu_item = gtk.MenuItem(self.title)
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_key]
self.result_parent_menu_item.destroy()
def present_result(self,obj):
self.window.present()
def build_menu_names(self, obj):
return (_('Check and Repair'),_('Check and Repair'))
#------------------------------------------------------------------------
#

View File

@ -46,11 +46,13 @@ import gtk.glade
# gramps modules
#
#-------------------------------------------------------------------------
from QuestionDialog import OkDialog, ErrorDialog
import GrampsDb
from PluginUtils import Tool, register_tool
import Utils
import GrampsDisplay
import ManagedWindow
from QuestionDialog import OkDialog, ErrorDialog
from PluginUtils import Tool, register_tool
#-------------------------------------------------------------------------
#
@ -103,25 +105,23 @@ retrieve_success_msg = [
# Checkpoint class
#
#-------------------------------------------------------------------------
class Checkpoint(Tool.Tool):
class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
def __init__(self, dbstate, uistate, options_class, name, callback=None):
if parent:
Tool.Tool.__init__(self, dbstate, options_class, name)
if uistate:
ManagedWindow.ManagedWindow.__init__(self, uistate, [],
Checkpoint)
self.callback = self.callback_real
self.init_gui(parent)
self.init_gui()
else:
self.callback = lambda a: None
self.run_tool(cli=True)
def init_gui(self,parent):
def init_gui(self):
# Draw dialog and make it handle everything
self.parent = parent
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__)
glade_file = "%s/%s" % (base,"checkpoint.glade")
@ -150,7 +150,6 @@ class Checkpoint(Tool.Tool):
self.title = _("Checkpoint Data")
self.window = self.glade.get_widget('top')
self.window.set_icon(self.parent.topWindow.get_icon())
Utils.set_titles(self.window,
self.glade.get_widget('title'),
self.title)
@ -163,8 +162,7 @@ class Checkpoint(Tool.Tool):
"on_help_clicked" : self.on_help_clicked,
})
self.add_itself_to_menu()
self.window.show()
self.show()
def rcs_toggled(self,obj):
self.cust_arch_cb.set_sensitive(not obj.get_active())
@ -178,23 +176,8 @@ class Checkpoint(Tool.Tool):
self.remove_itself_from_menu()
def close(self,obj):
self.remove_itself_from_menu()
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(self.title)
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def on_archive_clicked(self,obj):
self.options.handler.options_dict['cacmd'] = unicode(
self.cust_arch_cb.get_text())
@ -223,7 +206,7 @@ class Checkpoint(Tool.Tool):
communication.
"""
if not cli:
self.parent.status_text(_("Checkpointing database..."))
self.uistate.status_text(_("Checkpointing database..."))
if self.options.handler.options_dict['rcs']:
self.rcs(archive,cli)
@ -233,8 +216,8 @@ class Checkpoint(Tool.Tool):
self.custom(self.options.handler.options_dict['crcmd'],False,cli)
if not cli:
self.parent.progress.set_fraction(0)
self.parent.modify_statusbar()
self.uistate.pulse_progressbar(0)
self.uistate.modify_statusbar()
def timestamp(self):
return unicode(time.strftime('%x %X',time.localtime(time.time())))
@ -321,7 +304,7 @@ class Checkpoint(Tool.Tool):
if checkin:
# At this point, we have an existing archive file
xmlwrite = WriteXML.XmlWriter(self.db,self.callback,False,False)
xmlwrite = GrampsDb.XmlWriter(self.db,self.callback,False,False)
xmlwrite.write(archive_base)
proc = popen2.Popen3("ci %s" % archive_base,True)
@ -373,7 +356,7 @@ class Checkpoint(Tool.Tool):
Call back function for the WriteXML function that updates the
status progress bar.
"""
self.parent.progress.set_fraction(value)
self.uistate.pulse_progressbar(value)
while(gtk.events_pending()):
gtk.main_iteration()

View File

@ -61,6 +61,8 @@ import AutoComp
import ListModel
import Utils
import SelectPerson
import ManagedWindow
from PluginUtils import Tool, register_tool
#-------------------------------------------------------------------------
@ -316,28 +318,25 @@ class MyEntry(gtk.Entry):
#
#
#-------------------------------------------------------------------------
class FilterEditor:
def __init__(self,filterdb,db,parent):
self.parent = parent
if self.parent.child_windows.has_key(self.__class__):
self.parent.child_windows[self.__class__].present(None)
return
self.win_key = self.__class__
self.child_windows = {}
class FilterEditor(ManagedWindow.ManagedWindow):
def __init__(self, filterdb, db, uistate):
ManagedWindow.ManagedWindow.__init__(self, uistate, [],
FilterEditor)
self.db = db
self.filterdb = GenericFilter.GenericFilterList(filterdb)
self.filterdb.load()
self.editor = gtk.glade.XML(const.rule_glade,'filter_list',"gramps")
self.window = self.editor.get_widget('filter_list')
self.filter_list = self.editor.get_widget('filters')
self.edit = self.editor.get_widget('edit')
self.delete = self.editor.get_widget('delete')
self.test = self.editor.get_widget('test')
Utils.set_titles(self.window,self.editor.get_widget('title'),
_('User defined filters'))
self.define_top_level(self.editor.get_widget('filter_list'),
self.editor.get_widget('title'),
_('User defined filters'))
self.editor.signal_autoconnect({
'on_add_clicked' : self.add_new_filter,
@ -354,25 +353,26 @@ class FilterEditor:
self.filter_select_row,
self.edit_filter)
self.draw_filters()
self.add_itself_to_menu()
self.window.show()
self.show()
def build_menu_names(self, obj):
return (_("Custom Filter Editor"),_("Custom Filter Editor"))
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-util-cfe')
def define_top_level(self,window,title,text):
self.window = window
self.window.connect('delete-event',self.on_delete_event)
Utils.set_titles(window,title,text)
def on_delete_event(self,obj,b):
self.filterdb.save()
self.close_child_windows()
self.remove_itself_from_menu()
GenericFilter.reload_custom_filters()
GenericFilter.reload_system_filters()
self.parent.init_filters()
def close_child_windows(self):
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = {}
# self.parent.init_filters()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
@ -408,12 +408,10 @@ class FilterEditor:
def close_filter_editor(self,obj):
self.filterdb.save()
self.close_child_windows()
self.remove_itself_from_menu()
self.window.destroy()
GenericFilter.reload_custom_filters()
GenericFilter.reload_system_filters()
self.parent.init_filters()
# self.parent.init_filters()
def draw_filters(self):
self.clist.clear()
@ -515,47 +513,11 @@ class EditFilter:
help_display('gramps-manual','tools-util-cfe')
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
pass
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.window.destroy()
def close_child_windows(self):
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
if not self.filter.get_name():
label = _("New Filter")
else:
label = self.filter.get_name()
if not label.strip():
label = _("New Filter")
label = "%s: %s" % (_('Filter'),label)
self.parent_menu_item = gtk.MenuItem(label)
self.parent_menu_item.set_submenu(gtk.Menu())
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
self.winsmenu = self.parent_menu_item.get_submenu()
self.menu_item = gtk.MenuItem(_('Define Filter'))
self.menu_item.connect("activate",self.present)
self.menu_item.show()
self.winsmenu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.winsmenu.destroy()
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def filter_name_changed(self,obj):
name = unicode(self.fname.get_text())
self.ok.set_sensitive(len(name) != 0)
@ -927,10 +889,11 @@ class ShowResults:
#
#-------------------------------------------------------------------------
class CustomFilterEditor(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
def __init__(self, dbstate, uistate, options_class, name, callback=None):
FilterEditor(const.custom_filters,db,parent)
Tool.Tool.__init__(self, dbstate, options_class, name)
FilterEditor(const.custom_filters, dbstate.db, uistate)
#-------------------------------------------------------------------------
#
@ -938,10 +901,11 @@ class CustomFilterEditor(Tool.Tool):
#
#-------------------------------------------------------------------------
class SystemFilterEditor(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
def __init__(self, dbstate, uistate, options_class, name,callback=None):
FilterEditor(const.system_filters,db,parent)
Tool.Tool.__init__(self, dbstate, options_class, name)
FilterEditor(const.system_filters, dbstate.db, uistate)
#------------------------------------------------------------------------
#
@ -954,7 +918,7 @@ class FilterEditorOptions(Tool.ToolOptions):
"""
def __init__(self,name,person_id=None):
Tool.ToolOptions.__init__(self,name,person_id)
Tool.ToolOptions.__init__(self, name, person_id)
#-------------------------------------------------------------------------
#

View File

@ -37,7 +37,6 @@ from gettext import gettext as _
#-------------------------------------------------------------------------
import gtk
import gtk.glade
import GrampsDisplay
#-------------------------------------------------------------------------
#
@ -50,6 +49,9 @@ import soundex
import NameDisplay
import ListModel
import MergePeople
import GrampsDisplay
import ManagedWindow
from PluginUtils import Tool, register_tool
#-------------------------------------------------------------------------
@ -83,14 +85,11 @@ def is_initial(name):
#
#-------------------------------------------------------------------------
class Merge(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
self.parent = parent
if self.parent.child_windows.has_key(self.__class__):
self.parent.child_windows[self.__class__].present(None)
return
self.win_key = self.__class__
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
self.map = {}
self.list = []
self.index = 0
@ -129,7 +128,6 @@ class Merge(Tool.Tool):
self.menu.set_menu(my_menu)
self.window = top.get_widget('dialog')
self.window.set_icon(self.parent.topWindow.get_icon())
Utils.set_titles(self.window, top.get_widget('title'),
_('Merge people'))
@ -139,34 +137,19 @@ class Merge(Tool.Tool):
"on_help_clicked" : self.on_help_clicked,
"on_delete_merge_event" : self.on_delete_event,
})
self.add_itself_to_menu()
self.window.show()
self.show()
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-db')
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
pass
def close(self,obj):
self.remove_itself_from_menu()
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(_('Merge people'))
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def ancestors_of(self,p1_id,id_list):
if (not p1_id) or (p1_id in id_list):
return
@ -265,9 +248,9 @@ class Merge(Tool.Tool):
self.dellist = {}
def show(self):
top = gtk.glade.XML(self.glade_file,"mergelist","gramps")
self.window = top.get_widget("mergelist")
self.window.set_icon(self.parent.topWindow.get_icon())
Utils.set_titles(self.window, top.get_widget('title'),
_('Potential Merges'))
@ -286,7 +269,6 @@ class Merge(Tool.Tool):
event_func=self.on_do_merge_clicked)
self.redraw()
self.add_itself_to_menu()
self.window.show()
def redraw(self):

View File

@ -47,6 +47,8 @@ import GrampsDisplay
#
#-------------------------------------------------------------------------
import Utils
import ManagedWindow
from PluginUtils import Tool, register_tool
from QuestionDialog import OkDialog
@ -84,18 +86,13 @@ _sn_prefix_re = re.compile("^\s*(%s)\s+(.*)" % '|'.join(prefix_list),
# PatchNames
#
#-------------------------------------------------------------------------
class PatchNames(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
class PatchNames(Tool.Tool, ManagedWindow.ManagedWindow):
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
self.cb = callback
self.db = db
self.parent = parent
if self.parent.child_windows.has_key(self.__class__):
self.parent.child_windows[self.__class__].present(None)
return
self.win_key = self.__class__
self.trans = db.transaction_begin()
self.trans = self.db.transaction_begin()
self.title_list = []
self.nick_list = []
self.prefix1_list = []
@ -176,7 +173,6 @@ class PatchNames(Tool.Tool):
self.top = gtk.glade.XML(glade_file,"top","gramps")
self.window = self.top.get_widget('top')
self.window.set_icon(self.parent.topWindow.get_icon())
self.top.signal_autoconnect({
"destroy_passed_object" : self.close,
"on_ok_clicked" : self.on_ok_clicked,
@ -268,34 +264,18 @@ class PatchNames(Tool.Tool):
self.progress.step()
self.progress.close()
self.add_itself_to_menu()
self.window.show()
self.show()
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-db')
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
pass
def close(self,obj):
self.remove_itself_from_menu()
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(self.label)
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def on_ok_clicked(self,obj):
for grp in self.nick_list:
handle = self.nick_hash[grp[0]]

View File

@ -64,31 +64,33 @@ from QuestionDialog import OkDialog
#
#-------------------------------------------------------------------------
class Rebuild(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
if db.readonly:
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
if self.db.readonly:
# TODO: split plugin in a check and repair part to support
# checking of a read only database
return
db.disable_signals()
if parent:
self.db.disable_signals()
if uistate:
progress = Utils.ProgressMeter(
_('Rebuilding Secondary Indices'))
# Six indices to rebuild, and the first step is removing
# old ones
total = 7
progress.set_pass('',total)
db.rebuild_secondary(progress.step)
self.db.rebuild_secondary(progress.step)
progress.close()
OkDialog(_("Secondary indices rebuilt"),
_('All secondary indices have been rebuilt.'))
else:
print "Rebuilding Secondary Indices..."
db.rebuild_secondary(self.empty)
self.db.rebuild_secondary(self.empty)
print "All secondary indices have been rebuilt."
db.enable_signals()
self.db.enable_signals()
def empty(self):
pass

View File

@ -45,9 +45,12 @@ import gtk.glade
import RelLib
import Utils
import NameDisplay
import ManagedWindow
import ListModel
import DateHandler
import PeopleModel
from QuestionDialog import ErrorDialog
from PluginUtils import Tool, relationship_class, register_tool
column_names = [
@ -68,19 +71,25 @@ column_names = [
#
#
#-------------------------------------------------------------------------
class RelCalc(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
def __init__(self, dbstate, uistate, options_class, name, callback=None):
"""
Relationship calculator class.
"""
self.person = person
Tool.Tool.__init__(self, dbstate, options_class, name)
ManagedWindow.ManagedWindow.__init__(self, uistate, [],
RelCalc)
if not self.person:
ErrorDialog(_('Active person has not been set'),
_('You must select an active person for this '
'tool to work properly.'))
return
self.RelClass = relationship_class
self.relationship = self.RelClass(self.db)
self.parent = parent
self.win_key = self
base = os.path.dirname(__file__)
glade_file = "%s/relcalc.glade" % base
@ -90,7 +99,6 @@ class RelCalc(Tool.Tool):
self.title = _('Relationship calculator: %(person_name)s') % {
'person_name' : name }
self.window = self.glade.get_widget('relcalc')
self.window.set_icon(self.parent.topWindow.get_icon())
Utils.set_titles(self.window,
self.glade.get_widget('title'),
_('Relationship to %(person_name)s') % {
@ -127,30 +135,14 @@ class RelCalc(Tool.Tool):
"on_delete_event" : self.on_delete_event,
})
self.add_itself_to_menu()
self.window.show()
self.show()
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
pass
def close(self,obj):
self.remove_itself_from_menu()
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(self.title)
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def on_apply_clicked(self,obj):
model,node = self.tree.get_selection().get_selected()
if not node:

View File

@ -37,8 +37,6 @@ from gettext import gettext as _
#------------------------------------------------------------------------
import gtk
import gtk.glade
import GrampsDisplay
#------------------------------------------------------------------------
#
# GRAMPS modules
@ -46,22 +44,23 @@ import GrampsDisplay
#------------------------------------------------------------------------
import soundex
import Utils
import GrampsDisplay
import ManagedWindow
import AutoComp
from PluginUtils import Tool, register_tool
#-------------------------------------------------------------------------
#
#
#-------------------------------------------------------------------------
class SoundGen(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
class SoundGen(Tool.Tool, ManagedWindow.ManagedWindow):
self.parent = parent
if self.parent.child_windows.has_key(self.__class__):
self.parent.child_windows[self.__class__].present(None)
return
self.win_key = self.__class__
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
ManagedWindow.ManagedWindow.__init__(self, uistate, [],
SoundGen)
base = os.path.dirname(__file__)
glade_file = base + os.sep + "soundex.glade"
@ -74,7 +73,6 @@ class SoundGen(Tool.Tool):
})
self.window = self.glade.get_widget("soundEx")
self.window.set_icon(self.parent.topWindow.get_icon())
Utils.set_titles(self.window,
self.glade.get_widget('title'),
_('SoundEx code generator'))
@ -107,33 +105,21 @@ class SoundGen(Tool.Tool):
else:
self.name.set_text("")
self.add_itself_to_menu()
self.window.show()
self.show()
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-util-other')
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
pass
def close(self,obj):
self.remove_itself_from_menu()
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(_('SoundEx code generator tool'))
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def build_menu_names(self, obj):
return (_('SoundEx code generator tool'),
_('SoundEx code generator tool'))
def on_apply_clicked(self,obj):
try:

View File

@ -71,11 +71,11 @@ class TestcaseGenerator(Tool.Tool):
SHORT = 6
LONG = 7
def __init__(self,db,person,options_class,name,callback=None,parent=None):
if db.readonly:
def __init__(self, dbstate, uistate, options_class, name, callback=None):
if dbstate.db.readonly:
return
Tool.Tool.__init__(self,db,person,options_class,name)
Tool.Tool.__init__(self, dbstate, options_class, name)
self.person_count = 0
self.persons_todo = []
@ -90,17 +90,17 @@ class TestcaseGenerator(Tool.Tool):
self.text_serial_number = 1
# If an active persons exists the generated tree is connected to that person
if person:
if self.person:
# try to get birth and death year
try:
bh = person.get_birth_handle()
bh = self.person.get_birth_handle()
b = self.db.get_event_from_handle( bh)
do = b.get_date_object()
birth = do.get_year()
except AttributeError:
birth = None
try:
dh = person.get_death_handle()
dh = self.person.get_death_handle()
b = self.db.get_event_from_handle( dh)
do = b.get_date_object()
death = do.get_year()
@ -112,17 +112,17 @@ class TestcaseGenerator(Tool.Tool):
death = birth + randint(20,90)
if death and not birth:
birth = death - randint(20,90)
self.person_dates[person.get_handle()] = (birth,death)
self.person_dates[self.person.get_handle()] = (birth,death)
self.persons_todo.append(person.get_handle())
self.parents_todo.append(person.get_handle())
self.persons_todo.append(self.person.get_handle())
self.parents_todo.append(self.person.get_handle())
if parent:
self.init_gui(parent)
if uistate:
self.init_gui(uistate)
else:
self.run_tool(cli=True)
def init_gui(self,parent):
def init_gui(self,uistate):
title = "%s - GRAMPS" % _("Generate testcases")
self.top = gtk.Dialog(title)
self.top.set_default_size(400,150)

View File

@ -38,7 +38,6 @@ from gettext import gettext as _
#------------------------------------------------------------------------
import gtk
import gtk.glade
import GrampsDisplay
#------------------------------------------------------------------------
#
@ -47,6 +46,9 @@ import GrampsDisplay
#------------------------------------------------------------------------
import RelLib
import Utils
import GrampsDisplay
import ManagedWindow
from PluginUtils import Tool, register_tool
#-------------------------------------------------------------------------
@ -54,25 +56,21 @@ from PluginUtils import Tool, register_tool
# Actual tool
#
#-------------------------------------------------------------------------
class Verify(Tool.Tool):
class Verify(Tool.Tool, ManagedWindow.ManagedWindow):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
def __init__(self, dbstate, uistate, options_class, name,callback=None):
if parent:
self.init_gui(parent)
Tool.Tool.__init__(self, dbstate, options_class, name)
ManagedWindow.ManagedWindow.__init__(self, uistate, [], Verify)
if uistate:
self.init_gui()
else:
err_text,warn_text = self.run_tool(cli=True)
self.print_results(err_text,warn_text)
def init_gui(self,parent):
def init_gui(self):
# Draw dialog and make it handle everything
self.parent = parent
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"
@ -85,7 +83,6 @@ class Verify(Tool.Tool):
})
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'))
@ -121,30 +118,14 @@ class Verify(Tool.Tool):
self.top.get_widget("estimate").set_active(
self.options.handler.options_dict['estimate_age'])
self.add_itself_to_menu()
self.window.show()
self.show()
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
pass
def close(self,obj):
self.remove_itself_from_menu()
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(_('Database Verify'))
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-util-other')
@ -201,7 +182,7 @@ class Verify(Tool.Tool):
err_text,warn_text = self.run_tool(cli=False)
# Save options
self.options.handler.save_options()
VerifyResults(err_text,warn_text,self.parent)
VerifyResults(err_text, warn_text, self.uistate)
def run_tool(self,cli=False):
@ -241,18 +222,32 @@ class Verify(Tool.Tool):
# individual checks
total_children = 0
ageatdeath = 0
byear = self.get_year( person.get_birth_handle() )
birth_ref = person.get_birth_ref()
if birth_ref:
birth_handle = birth_ref.ref
else:
birth_ref = None
death_ref = person.get_death_ref()
if death_ref:
death_handle = death_ref.ref
else:
death_ref = None
byear = self.get_year( birth_handle )
bapyear = 0
dyear = self.get_year( person.get_death_handle() )
dyear = self.get_year( birth_handle )
buryear = 0
for event_handle in person.get_event_list():
if event_handle:
for event_ref in person.get_event_ref_list():
if event_ref:
event_handle = event_ref.ref
event = self.db.get_event_from_handle(event_handle)
event_name = event.get_name().lower()
if event.get_name() == "burial":
event_name = event.get_type()[0]
if event_name == RelLib.Event.BURIAL:
buryear = self.get_year( event.get_handle() )
elif event_name == "baptism":
elif event_name == RelLib.Event.BAPTISM:
bapyear = self.get_year( event.get_handle() )
if byear>0 and bapyear>0:
@ -398,8 +393,22 @@ class Verify(Tool.Tool):
person.get_primary_name().get_surname() == spouse.get_primary_name().get_surname():
warn.write( _("Husband and wife with the same surname: %s in family %s, and %s.\n") % (
idstr,family.get_gramps_id(), spouse.get_primary_name().get_name() ) )
sdyear = self.get_year( spouse.get_death_handle() )
sbyear = self.get_year( spouse.get_birth_handle() )
death_ref = spouse.get_death_ref()
if death_ref:
death_handle = death_ref.ref
else:
death_handle = None
birth_ref = spouse.get_birth_ref()
if birth_ref:
birth_handle = birth_ref.ref
else:
birth_handle = None
sdyear = self.get_year( death_handle )
sbyear = self.get_year( birth_handle )
if sbyear != 0 and byear != 0 and abs(sbyear-byear) > hwdif:
warn.write( _("Large age difference between husband and wife: %s in family %s, and %s.\n") % (
idstr,family.get_gramps_id(), spouse.get_primary_name().get_name() ) )
@ -407,8 +416,9 @@ class Verify(Tool.Tool):
if sdyear == 0:
sdyear = 0 # burial year
for event_handle in family.get_event_list():
if event_handle:
for event_ref in family.get_event_ref_list():
if event_ref:
event_handle = event_ref.ref
event = self.db.get_event_from_handle(event_handle)
if event.get_name() == "Marriage":
marriage_id = event_handle
@ -494,7 +504,13 @@ class Verify(Tool.Tool):
for child_handle in family.get_child_handle_list():
nkids = nkids+1
child = self.db.get_person_from_handle(child_handle)
cbyear = self.get_year( child.get_birth_handle() )
birth_ref = child.get_birth_ref()
if birth_ref:
birth_handle = birth_ref.ref
else:
birth_handle = None
cbyear = self.get_year( birth_handle )
if cbyear:
cbyears.append(cbyear)
@ -582,14 +598,14 @@ class Verify(Tool.Tool):
# Display the results
#
#-------------------------------------------------------------------------
class VerifyResults:
def __init__(self,err_text,warn_text,parent):
self.parent = parent
class VerifyResults(ManagedWindow.ManagedWindow):
def __init__(self, err_text, warn_text, uistate):
ManagedWindow.ManagedWindow.__init__(self, uistate, [], VerifyResults)
self.err_text = err_text
self.warn_text = warn_text
self.win_key = self
base = os.path.dirname(__file__)
self.glade_file = base + os.sep + "verify.glade"
@ -601,40 +617,19 @@ class VerifyResults:
self.top.signal_autoconnect({
"destroy_passed_object" : self.close_result,
"on_result_delete_event" : self.on_result_delete_event,
})
self.window = self.top.get_widget("verify_result")
self.window.set_icon(self.parent.topWindow.get_icon())
err_window = self.top.get_widget("err_window")
warn_window = self.top.get_widget("warn_window")
err_window.get_buffer().set_text(self.err_text)
warn_window.get_buffer().set_text(self.warn_text)
self.add_result_to_menu()
self.window.show()
def on_result_delete_event(self,obj,b):
self.remove_result_from_menu()
self.show()
def close_result(self,obj):
self.remove_result_from_menu()
self.window.destroy()
def add_result_to_menu(self):
self.parent.child_windows[self.win_key] = self.window
self.result_parent_menu_item = gtk.MenuItem(self.title)
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_key]
self.result_parent_menu_item.destroy()
def present_result(self,obj):
self.window.present()
#------------------------------------------------------------------------
#
#