* src/Plugins.py: Pass parent class to the tools.
* src/rule.glade: Define event handlers. * src/gramps_main.py: Pass parent class to the tools. * src/plugins/EventCmp.py: Window management. * src/plugins/FilterEditor.py: Window management. * src/plugins/PatchNames.py: Window management. * src/plugins/eventcmp.glade: Define event handlers. * src/plugins/patchnames.glade: Define event handlers. svn: r3150
This commit is contained in:
parent
ffda353d04
commit
e48a5e9df5
@ -7,6 +7,15 @@
|
||||
* src/plugins/Merge.py: Convert to db.
|
||||
* src/plugins/merge.glade: HIGify dialogs.
|
||||
|
||||
* src/Plugins.py: Pass parent class to the tools.
|
||||
* src/rule.glade: Define event handlers.
|
||||
* src/gramps_main.py: Pass parent class to the tools.
|
||||
* src/plugins/EventCmp.py: Window management.
|
||||
* src/plugins/FilterEditor.py: Window management.
|
||||
* src/plugins/PatchNames.py: Window management.
|
||||
* src/plugins/eventcmp.glade: Define event handlers.
|
||||
* src/plugins/patchnames.glade: Define event handlers.
|
||||
|
||||
2004-05-08 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||
* src/plugins/EventCmp.py: Convert to db.
|
||||
* src/plugins/eventcmp.glade: HIGify dialogs.
|
||||
|
@ -208,9 +208,9 @@ class PluginDialog:
|
||||
|
||||
if self.run_tool:
|
||||
if self.update:
|
||||
self.run_tool(self.db,self.active,self.update)
|
||||
self.run_tool(self.db,self.active,self.update,self.parent)
|
||||
else:
|
||||
self.run_tool(self.db,self.active)
|
||||
self.run_tool(self.db,self.active,None,self.parent)
|
||||
|
||||
def on_node_selected(self,obj):
|
||||
"""Updates the informational display on the right hand side of
|
||||
|
@ -1735,7 +1735,7 @@ class Gramps:
|
||||
def menu_tools(self,obj,task):
|
||||
"""Call the tool plugin selected from the menus"""
|
||||
if self.active_person:
|
||||
task(self.db,self.active_person,self.tool_callback)
|
||||
task(self.db,self.active_person,self.tool_callback,self)
|
||||
|
||||
def on_main_key_release_event(self,obj,event):
|
||||
"""Respond to the insert and delete buttons in the person list"""
|
||||
|
@ -124,8 +124,11 @@ class TableReport:
|
||||
#------------------------------------------------------------------------
|
||||
class EventComparison:
|
||||
|
||||
def __init__(self,database):
|
||||
def __init__(self,database,parent):
|
||||
self.db = database
|
||||
self.parent = parent
|
||||
self.win_key = self
|
||||
self.child_windows = {}
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
self.glade_file = base + os.sep + "eventcmp.glade"
|
||||
@ -136,14 +139,16 @@ class EventComparison:
|
||||
"on_apply_clicked" : self.on_apply_clicked,
|
||||
"on_editor_clicked" : self.filter_editor_clicked,
|
||||
"on_filter_list_enter" : self.filter_list_enter,
|
||||
"destroy_passed_object" : Utils.destroy_passed_object
|
||||
"on_filters_delete_event": self.on_delete_event,
|
||||
"destroy_passed_object" : self.close
|
||||
})
|
||||
|
||||
top = self.filterDialog.get_widget("filters")
|
||||
self.window = self.filterDialog.get_widget("filters")
|
||||
self.filters = self.filterDialog.get_widget("filter_list")
|
||||
self.label = _('Event comparison filter selection')
|
||||
|
||||
Utils.set_titles(top,self.filterDialog.get_widget('title'),
|
||||
_('Event comparison filter selection'))
|
||||
Utils.set_titles(self.window,self.filterDialog.get_widget('title'),
|
||||
self.label)
|
||||
|
||||
self.all = GenericFilter.GenericFilter()
|
||||
self.all.set_name(_("Entire Database"))
|
||||
@ -151,12 +156,48 @@ class EventComparison:
|
||||
|
||||
self.filter_menu = GenericFilter.build_filter_menu([self.all])
|
||||
self.filters.set_menu(self.filter_menu)
|
||||
top.show()
|
||||
|
||||
self.add_itself_to_menu()
|
||||
self.window.show()
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.close_child_windows()
|
||||
self.remove_itself_from_menu()
|
||||
|
||||
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
|
||||
self.parent_menu_item = gtk.MenuItem(_("Event Comparison tool"))
|
||||
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(_('Filter Selection'))
|
||||
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_editor_clicked(self,obj):
|
||||
import FilterEditor
|
||||
|
||||
FilterEditor.FilterEditor(const.custom_filters,self.db)
|
||||
FilterEditor.FilterEditor(const.custom_filters,self.db,self.parent)
|
||||
|
||||
def filter_list_enter(self,obj):
|
||||
self.filter_menu = GenericFilter.build_filter_menu([self.all])
|
||||
@ -170,15 +211,15 @@ class EventComparison:
|
||||
if len(plist) == 0:
|
||||
WarningDialog(_("No matches were found"))
|
||||
else:
|
||||
DisplayChart(self.db,plist)
|
||||
DisplayChart(self.db,plist,self.parent)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def runTool(database,person,callback):
|
||||
EventComparison(database)
|
||||
def runTool(database,person,callback,parent=None):
|
||||
EventComparison(database,parent)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -203,7 +244,7 @@ def fix(line):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DisplayChart:
|
||||
def __init__(self,database,people_list):
|
||||
def __init__(self,database,people_list,parent):
|
||||
self.db = database
|
||||
self.my_list = people_list
|
||||
self.row_data = []
|
||||
|
@ -228,19 +228,23 @@ class MyEntry(gtk.Entry):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class FilterEditor:
|
||||
def __init__(self,filterdb,db):
|
||||
def __init__(self,filterdb,db,parent):
|
||||
self.db = db
|
||||
self.filterdb = GenericFilter.GenericFilterList(filterdb)
|
||||
self.filterdb.load()
|
||||
|
||||
self.parent = parent
|
||||
self.win_key = self
|
||||
self.child_windows = {}
|
||||
|
||||
self.editor = gtk.glade.XML(const.filterFile,'filter_list',"gramps")
|
||||
self.editor_top = self.editor.get_widget('filter_list')
|
||||
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.editor_top,self.editor.get_widget('title'),
|
||||
Utils.set_titles(self.window,self.editor.get_widget('title'),
|
||||
_('User defined filters'))
|
||||
|
||||
self.editor.signal_autoconnect({
|
||||
@ -249,6 +253,7 @@ class FilterEditor:
|
||||
'on_test_clicked' : self.test_clicked,
|
||||
'on_close_clicked' : self.close_filter_editor,
|
||||
'on_delete_clicked' : self.delete_filter,
|
||||
'on_filter_list_delete_event' : self.on_delete_event,
|
||||
})
|
||||
|
||||
self.clist = ListModel.ListModel(self.filter_list,
|
||||
@ -256,6 +261,41 @@ class FilterEditor:
|
||||
self.filter_select_row,
|
||||
self.edit_filter)
|
||||
self.draw_filters()
|
||||
self.add_itself_to_menu()
|
||||
self.window.show()
|
||||
|
||||
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()
|
||||
|
||||
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
|
||||
self.parent_menu_item = gtk.MenuItem(_("Custom Filter Editor tool"))
|
||||
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(_('Filter List'))
|
||||
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_select_row(self,obj):
|
||||
store,iter = self.clist.get_selected()
|
||||
@ -270,7 +310,9 @@ class FilterEditor:
|
||||
|
||||
def close_filter_editor(self,obj):
|
||||
self.filterdb.save()
|
||||
self.editor_top.destroy()
|
||||
self.close_child_windows()
|
||||
self.remove_itself_from_menu()
|
||||
self.window.destroy()
|
||||
GenericFilter.reload_custom_filters()
|
||||
GenericFilter.reload_system_filters()
|
||||
|
||||
@ -281,13 +323,13 @@ class FilterEditor:
|
||||
|
||||
def add_new_filter(self,obj):
|
||||
filter = GenericFilter.GenericFilter()
|
||||
self.filter_editor(filter)
|
||||
EditFilter(self,filter)
|
||||
|
||||
def edit_filter(self,obj):
|
||||
store,iter = self.clist.get_selected()
|
||||
if iter:
|
||||
filter = self.clist.get_object(iter)
|
||||
self.filter_editor(filter)
|
||||
EditFilter(self,filter)
|
||||
|
||||
def test_clicked(self,obj):
|
||||
store,iter = self.clist.get_selected()
|
||||
@ -303,13 +345,25 @@ class FilterEditor:
|
||||
self.filterdb.get_filters().remove(filter)
|
||||
self.draw_filters()
|
||||
|
||||
def filter_editor(self,filter):
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class EditFilter:
|
||||
def __init__(self,parent,filter):
|
||||
self.filter = filter
|
||||
self.filterdb = parent.filterdb
|
||||
|
||||
self.parent = parent
|
||||
self.win_key = self
|
||||
self.child_windows = {}
|
||||
|
||||
self.glade = gtk.glade.XML(const.filterFile,'define_filter',"gramps")
|
||||
self.top = self.glade.get_widget('define_filter')
|
||||
self.window = self.glade.get_widget('define_filter')
|
||||
self.define_title = self.glade.get_widget('title')
|
||||
|
||||
Utils.set_titles(self.top,self.define_title,_('Define filter'))
|
||||
Utils.set_titles(self.window,self.define_title,_('Define filter'))
|
||||
|
||||
self.rule_list = self.glade.get_widget('rule_list')
|
||||
self.rlist = ListModel.ListModel(self.rule_list,
|
||||
@ -328,12 +382,12 @@ class FilterEditor:
|
||||
self.del_btn = self.glade.get_widget('delete')
|
||||
self.glade.signal_autoconnect({
|
||||
'on_ok_clicked' : self.on_ok_clicked,
|
||||
'on_cancel_clicked' : self.on_cancel_clicked,
|
||||
'on_cancel_clicked' : self.close,
|
||||
'on_filter_name_changed' : self.filter_name_changed,
|
||||
'on_delete_clicked' : self.on_delete_clicked,
|
||||
'on_add_clicked' : self.on_add_clicked,
|
||||
'on_edit_clicked' : self.on_edit_clicked,
|
||||
'on_cancel_clicked' : self.on_cancel_clicked,
|
||||
"on_edit_filter_delete_event" : self.on_delete_event,
|
||||
})
|
||||
if self.filter.get_invert():
|
||||
self.log_not.set_active(1)
|
||||
@ -348,6 +402,52 @@ class FilterEditor:
|
||||
self.comment.set_text(self.filter.get_comment())
|
||||
self.draw_rules()
|
||||
|
||||
self.window.set_transient_for(self.parent.window)
|
||||
self.add_itself_to_menu()
|
||||
self.window.show()
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.close_child_windows()
|
||||
self.remove_itself_from_menu()
|
||||
|
||||
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)
|
||||
@ -366,9 +466,6 @@ class FilterEditor:
|
||||
for r in self.filter.get_rules():
|
||||
self.rlist.add([r.trans_name(),r.display_values()],r)
|
||||
|
||||
def on_cancel_clicked(self,obj):
|
||||
self.top.destroy()
|
||||
|
||||
def on_ok_clicked(self,obj):
|
||||
n = unicode(self.fname.get_text()).strip()
|
||||
if n == '':
|
||||
@ -389,20 +486,40 @@ class FilterEditor:
|
||||
self.filter.set_logical_op(op)
|
||||
self.filterdb.add(self.filter)
|
||||
self.draw_filters()
|
||||
self.top.destroy()
|
||||
self.close(obj)
|
||||
|
||||
def on_add_clicked(self,obj):
|
||||
self.edit_rule(None,_('Add Rule'))
|
||||
EditRule(self,None,_('Add Rule'))
|
||||
|
||||
def on_edit_clicked(self,obj):
|
||||
store,iter = self.rlist.get_selected()
|
||||
if iter:
|
||||
d = self.rlist.get_object(iter)
|
||||
self.edit_rule(d,_('Edit Rule'))
|
||||
EditRule(self,d,_('Edit Rule'))
|
||||
|
||||
def edit_rule(self,val,label):
|
||||
def on_delete_clicked(self,obj):
|
||||
store,iter = self.rlist.get_selected()
|
||||
if iter:
|
||||
filter = self.rlist.get_object(iter)
|
||||
self.filter.delete_rule(filter)
|
||||
self.draw_rules()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class EditRule:
|
||||
def __init__(self,parent,val,label):
|
||||
|
||||
self.pmap = {}
|
||||
self.add_places = []
|
||||
self.win_key = self
|
||||
self.child_windows = {}
|
||||
|
||||
self.parent = parent
|
||||
self.db = parent.parent.db
|
||||
self.filterdb = parent.filterdb
|
||||
|
||||
for p_id in self.db.get_place_ids():
|
||||
p = self.db.find_place_from_id(p_id)
|
||||
@ -410,12 +527,12 @@ class FilterEditor:
|
||||
|
||||
self.active_rule = val
|
||||
self.rule = gtk.glade.XML(const.filterFile,'rule_editor',"gramps")
|
||||
self.rule_top = self.rule.get_widget('rule_editor')
|
||||
self.window = self.rule.get_widget('rule_editor')
|
||||
self.valuebox = self.rule.get_widget('valuebox')
|
||||
self.rname = self.rule.get_widget('ruletree')
|
||||
self.rule_name = self.rule.get_widget('rulename')
|
||||
|
||||
Utils.set_titles(self.rule_top, self.rule.get_widget('title'),label)
|
||||
Utils.set_titles(self.window, self.rule.get_widget('title'),label)
|
||||
|
||||
self.notebook = gtk.Notebook()
|
||||
self.notebook.set_show_tabs(0)
|
||||
@ -495,9 +612,9 @@ class FilterEditor:
|
||||
#
|
||||
sel_node = None
|
||||
if self.active_rule:
|
||||
sel_name = unicode(_(self.active_rule.name()))
|
||||
self.sel_name = unicode(_(self.active_rule.name()))
|
||||
else:
|
||||
sel_name = ""
|
||||
self.sel_name = ""
|
||||
|
||||
for v in map.keys():
|
||||
filter = GenericFilter.tasks[v]([None])
|
||||
@ -515,22 +632,54 @@ class FilterEditor:
|
||||
|
||||
#
|
||||
# if this is an edit rule, save the node
|
||||
if v == sel_name:
|
||||
if v == self.sel_name:
|
||||
sel_node = node
|
||||
|
||||
if sel_node:
|
||||
self.selection.select_iter(sel_node)
|
||||
page = self.name2page[sel_name]
|
||||
page = self.name2page[self.sel_name]
|
||||
self.notebook.set_current_page(page)
|
||||
self.display_values(sel_name)
|
||||
self.display_values(self.sel_name)
|
||||
(n,c,v,t) = self.page[page]
|
||||
r = self.active_rule.values()
|
||||
for i in range(0,len(t)):
|
||||
t[i].set_text(r[i])
|
||||
|
||||
self.selection.connect('changed', self.on_node_selected)
|
||||
self.rule.get_widget('ok').connect('clicked',self.rule_ok)
|
||||
self.rule.get_widget('cancel').connect('clicked',self.rule_cancel)
|
||||
self.rule.signal_autoconnect({
|
||||
'rule_ok_clicked' : self.rule_ok,
|
||||
"on_rule_edit_delete_event" : self.on_delete_event,
|
||||
'rule_cancel_clicked' : self.close,
|
||||
})
|
||||
|
||||
self.window.set_transient_for(self.parent.window)
|
||||
self.add_itself_to_menu()
|
||||
self.window.show()
|
||||
|
||||
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
|
||||
label = self.sel_name
|
||||
if not label.strip():
|
||||
label = _("New Rule")
|
||||
label = "%s: %s" % (_('Rule'),label)
|
||||
self.parent_menu_item = gtk.MenuItem(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_node_selected(self,obj):
|
||||
"""Updates the informational display on the right hand side of
|
||||
@ -553,13 +702,6 @@ class FilterEditor:
|
||||
filter = GenericFilter.tasks[key]([None])
|
||||
self.rule.get_widget('description').set_text(filter.description())
|
||||
|
||||
def on_delete_clicked(self,obj):
|
||||
store,iter = self.rlist.get_selected()
|
||||
if iter:
|
||||
filter = self.rlist.get_object(iter)
|
||||
self.filter.delete_rule(filter)
|
||||
self.draw_rules()
|
||||
|
||||
def rule_ok(self,obj):
|
||||
name = unicode(self.rule_name.get_text())
|
||||
class_def = GenericFilter.tasks[name]
|
||||
@ -577,16 +719,14 @@ class FilterEditor:
|
||||
self.filter.delete_rule(rule)
|
||||
self.filter.add_rule(new_rule)
|
||||
self.draw_rules()
|
||||
self.rule_top.destroy()
|
||||
self.window.destroy()
|
||||
except KeyError:
|
||||
pass
|
||||
except:
|
||||
import DisplayTrace
|
||||
self.rule_top.destroy()
|
||||
self.window.destroy()
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
||||
def rule_cancel(self,obj):
|
||||
self.rule_top.destroy()
|
||||
|
||||
class ShowResults:
|
||||
def __init__(self,db,id_list):
|
||||
@ -615,16 +755,16 @@ class ShowResults:
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def CustomFilterEditor(database,person,callback):
|
||||
FilterEditor(const.custom_filters,database)
|
||||
def CustomFilterEditor(database,person,callback,parent=None):
|
||||
FilterEditor(const.custom_filters,database,parent)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def SystemFilterEditor(database,person,callback):
|
||||
FilterEditor(const.system_filters,database)
|
||||
def SystemFilterEditor(database,person,callback,parent=None):
|
||||
FilterEditor(const.system_filters,database,parent)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -63,9 +63,9 @@ _nick_re = re.compile(r"(.+)[(\"](.*)[)\"]")
|
||||
# to "Name" and add "Nickname" into the nickname field.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,active_person,callback):
|
||||
def runTool(database,active_person,callback,parent=None):
|
||||
try:
|
||||
PatchNames(database,callback)
|
||||
PatchNames(database,callback,parent)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
@ -77,9 +77,12 @@ def runTool(database,active_person,callback):
|
||||
#-------------------------------------------------------------------------
|
||||
class PatchNames:
|
||||
|
||||
def __init__(self,db,callback):
|
||||
def __init__(self,db,callback,parent):
|
||||
self.cb = callback
|
||||
self.db = db
|
||||
self.parent = parent
|
||||
self.win_key = self
|
||||
self.child_windows = {}
|
||||
self.title_list = []
|
||||
self.nick_list = []
|
||||
|
||||
@ -98,7 +101,6 @@ class PatchNames:
|
||||
|
||||
msg = ""
|
||||
|
||||
|
||||
if self.nick_list or self.title_list:
|
||||
self.display()
|
||||
else:
|
||||
@ -113,18 +115,20 @@ class PatchNames:
|
||||
self.model.row_changed(path,row.iter)
|
||||
|
||||
def display(self):
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "patchnames.glade"
|
||||
|
||||
self.top = gtk.glade.XML(glade_file,"top","gramps")
|
||||
self.window = self.top.get_widget('top')
|
||||
self.top.signal_autoconnect({
|
||||
"destroy_passed_object" : Utils.destroy_passed_object,
|
||||
"on_ok_clicked" : self.on_ok_clicked
|
||||
"destroy_passed_object" : self.close,
|
||||
"on_ok_clicked" : self.on_ok_clicked,
|
||||
"on_delete_event" : self.on_delete_event
|
||||
})
|
||||
self.list = self.top.get_widget("list")
|
||||
Utils.set_titles(self.top.get_widget('top'),
|
||||
self.top.get_widget('title'),
|
||||
_('Name and title extraction tool'))
|
||||
self.label = _('Name and title extraction tool')
|
||||
Utils.set_titles(self.window,self.top.get_widget('title'),self.label)
|
||||
|
||||
self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
@ -171,6 +175,30 @@ class PatchNames:
|
||||
self.model.set_value(iter,3,nick)
|
||||
self.model.set_value(iter,4,p.get_primary_name().get_name())
|
||||
self.title_hash[id] = iter
|
||||
|
||||
self.add_itself_to_menu()
|
||||
self.window.show()
|
||||
|
||||
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.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:
|
||||
@ -195,7 +223,7 @@ class PatchNames:
|
||||
self.db.commit_person(p)
|
||||
Utils.modified()
|
||||
|
||||
Utils.destroy_passed_object(obj)
|
||||
self.close(obj)
|
||||
self.cb(1)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
@ -415,7 +415,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes"></property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="default_width">400</property>
|
||||
<property name="resizable">True</property>
|
||||
@ -423,9 +423,10 @@
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="has_separator">False</property>
|
||||
<signal name="delete_event" handler="on_filters_delete_event" last_modification_time="Mon, 10 May 2004 00:54:23 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox5">
|
||||
|
@ -18,6 +18,7 @@
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<signal name="delete_event" handler="on_delete_event" last_modification_time="Mon, 10 May 2004 00:32:54 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
|
@ -15,7 +15,13 @@
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="icon">gramps.png</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_CENTER</property>
|
||||
<property name="has_separator">False</property>
|
||||
<signal name="delete_event" handler="on_edit_filter_delete_event" last_modification_time="Mon, 10 May 2004 04:12:45 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox1">
|
||||
@ -36,6 +42,7 @@
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_cancel_clicked"/>
|
||||
</widget>
|
||||
@ -50,6 +57,7 @@
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_ok_clicked"/>
|
||||
</widget>
|
||||
@ -194,6 +202,7 @@
|
||||
<property name="label" translatable="yes">_Add...</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_add_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -212,6 +221,7 @@
|
||||
<property name="label" translatable="yes">_Edit...</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_edit_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -230,6 +240,7 @@
|
||||
<property name="label" translatable="yes">_Delete</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_delete_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -359,6 +370,7 @@
|
||||
<property name="label" translatable="yes">All _rules must apply</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
@ -380,6 +392,7 @@
|
||||
<property name="label" translatable="yes">At least _one rule must apply</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
@ -402,6 +415,7 @@
|
||||
<property name="label" translatable="yes">E_xactly one rule must apply</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
@ -448,6 +462,7 @@
|
||||
<property name="label" translatable="yes">_Return values that do not match the filter rules (invert)</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
@ -490,6 +505,11 @@
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="icon">gramps.png</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_CENTER</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
@ -511,6 +531,7 @@
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
@ -523,6 +544,7 @@
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
@ -748,7 +770,13 @@
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="icon">gramps.png</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_CENTER</property>
|
||||
<property name="has_separator">False</property>
|
||||
<signal name="delete_event" handler="on_filter_list_delete_event" last_modification_time="Mon, 10 May 2004 01:08:00 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox3">
|
||||
@ -769,6 +797,7 @@
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_close_clicked"/>
|
||||
</widget>
|
||||
@ -857,6 +886,7 @@
|
||||
<property name="label" translatable="yes">_Add...</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_add_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -876,6 +906,7 @@
|
||||
<property name="label" translatable="yes">_Edit...</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_edit_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -892,6 +923,7 @@
|
||||
<property name="label" translatable="yes">_Test...</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_test_clicked" last_modification_time="Thu, 06 Mar 2003 21:59:03 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -911,6 +943,7 @@
|
||||
<property name="label" translatable="yes">_Delete</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_delete_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -972,6 +1005,11 @@
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="icon">gramps.png</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_CENTER</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
@ -993,6 +1031,7 @@
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_close_clicked"/>
|
||||
</widget>
|
||||
@ -1040,6 +1079,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="overwrite">False</property>
|
||||
<property name="accepts_tab">True</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_WORD</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
@ -1073,7 +1114,13 @@
|
||||
<property name="default_height">500</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_CENTER</property>
|
||||
<property name="has_separator">False</property>
|
||||
<signal name="delete_event" handler="on_rule_edit_delete_event" last_modification_time="Mon, 10 May 2004 04:32:24 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox5">
|
||||
@ -1094,7 +1141,9 @@
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-6</property>
|
||||
<signal name="clicked" handler="rule_cancel_clicked" last_modification_time="Mon, 10 May 2004 04:30:50 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
@ -1106,7 +1155,9 @@
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-5</property>
|
||||
<signal name="clicked" handler="rule_ok_clicked" last_modification_time="Mon, 10 May 2004 04:30:20 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user