From 7192a661224ccad426719ae580e79acdf9de275f Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 27 Apr 2006 00:10:07 +0000 Subject: [PATCH] * src/plugins/ChangeTypes.py: Fix wm; adapt to RelLib changes. * src/plugins/ChangeNames.py: Fix wm. svn: r6457 --- ChangeLog | 2 ++ src/plugins/ChangeNames.py | 22 +++++++-------- src/plugins/ChangeTypes.py | 55 +++++++++++++++++++------------------- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 948cf5464..3ceae13ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 2006-04-26 Alex Roitman + * src/plugins/ChangeTypes.py: Fix wm; adapt to RelLib changes. + * src/plugins/ChangeNames.py: Fix wm. * src/MergePeople.py: Adapt to RelLib changes. * src/plugins/Merge.py: Properly call MergePeople; properly call update; set dbstate and uistate as instance attributes. diff --git a/src/plugins/ChangeNames.py b/src/plugins/ChangeNames.py index a5370b27d..ee99e11b8 100644 --- a/src/plugins/ChangeNames.py +++ b/src/plugins/ChangeNames.py @@ -60,9 +60,10 @@ from PluginUtils import Tool, register_tool class ChangeNames(Tool.Tool, ManagedWindow.ManagedWindow): def __init__(self, dbstate, uistate, options_class, name, callback=None): + self.label = _('Capitalization changes') Tool.Tool.__init__(self, dbstate, options_class, name) - ManagedWindow.ManagedWindow.__init__(self, uistate, [], self) + ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__) self.cb = callback @@ -90,16 +91,14 @@ class ChangeNames(Tool.Tool, ManagedWindow.ManagedWindow): glade_file = base + os.sep + "patchnames.glade" self.top = gtk.glade.XML(glade_file,"top","gramps") - self.window = self.top.get_widget('top') + window = self.top.get_widget('top') self.top.signal_autoconnect({ "destroy_passed_object" : self.close, "on_ok_clicked" : self.on_ok_clicked, "on_help_clicked" : self.on_help_clicked, - "on_delete_event" : self.on_delete_event }) self.list = self.top.get_widget("list") - self.label = _('Capitalization changes') - Utils.set_titles(self.window,self.top.get_widget('title'),self.label) + self.set_window(window,self.top.get_widget('title'),self.label) self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING) @@ -131,16 +130,13 @@ class ChangeNames(Tool.Tool, ManagedWindow.ManagedWindow): self.show() + def build_menu_names(self,obj): + return (self.label,None) + def on_help_clicked(self,obj): """Display the relevant portion of GRAMPS manual""" GrampsDisplay.help('tools-db') - def on_delete_event(self,obj,b): - pass - - def close(self,obj): - self.window.destroy() - def on_ok_clicked(self,obj): self.trans = self.db.transaction_begin("",batch=True) self.db.disable_signals() @@ -165,7 +161,9 @@ class ChangeNames(Tool.Tool, ManagedWindow.ManagedWindow): self.db.transaction_commit(self.trans,_("Capitalization changes")) self.db.enable_signals() self.db.request_rebuild() - self.parent.bookmarks.redraw() + # FIXME: this probably needs to be removed, and bookmarks + # should always be rebuilt on a commit_person via signals + # self.parent.bookmarks.redraw() self.close() self.cb() diff --git a/src/plugins/ChangeTypes.py b/src/plugins/ChangeTypes.py index 0e1ce0d85..5678be970 100644 --- a/src/plugins/ChangeTypes.py +++ b/src/plugins/ChangeTypes.py @@ -47,7 +47,7 @@ import const import Utils import ManagedWindow import AutoComp - +from RelLib import EventType from QuestionDialog import OkDialog from PluginUtils import Tool, register_tool @@ -63,7 +63,9 @@ class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow): Tool.Tool.__init__(self, dbstate, options_class, name) if uistate: - ManagedWindow.ManagedWindow.__init__(self, uistate, [], self) + self.title = _('Change Event Types') + ManagedWindow.ManagedWindow.__init__(self,uistate,[], + self.__class__) self.init_gui() else: self.run_tool(cli=True) @@ -77,29 +79,29 @@ class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow): self.auto1 = self.glade.get_widget("original") self.auto2 = self.glade.get_widget("new") - - AutoComp.fill_combo(self.auto1,Utils.personal_events) - AutoComp.fill_combo(self.auto2,Utils.personal_events) + event_names = [item[1] for item in EventType._DATAMAP + if item[0] > 0 ] + AutoComp.fill_combo(self.auto1,event_names) + AutoComp.fill_combo(self.auto2,event_names) # Need to display localized event names - self.auto1.child.set_text(const.display_event( - self.options.handler.options_dict['fromtype'])) - self.auto2.child.set_text(const.display_event( - self.options.handler.options_dict['totype'])) + self.auto1.child.set_text( + _(self.options.handler.options_dict['fromtype'])) + self.auto2.child.set_text( + _(self.options.handler.options_dict['totype'])) - self.title = _('Change Event Types') - self.window = self.glade.get_widget('top') - Utils.set_titles(self.window, - self.glade.get_widget('title'), - self.title) + window = self.glade.get_widget('top') + self.set_window(window,self.glade.get_widget('title'),self.title) self.glade.signal_autoconnect({ "on_close_clicked" : self.close, - "on_delete_event" : self.on_delete_event, "on_apply_clicked" : self.on_apply_clicked, }) self.show() + def build_menu_names(self,obj): + return (self.title,None) + def run_tool(self,cli=False): # Run tool and return results # These are English names, no conversion needed @@ -115,12 +117,12 @@ class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow): for person_handle in self.db.get_person_handles(sort_handles=False): person = self.db.get_person_from_handle(person_handle) - for event_handle in person.get_event_list(): - if not event_handle: + for event_ref in person.get_event_ref_list(): + if not event_ref.ref: continue - event = self.db.get_event_from_handle(event_handle) - if event.get_name() == fromtype: - event.set_name(totype) + event = self.db.get_event_from_handle(event_ref.ref) + if str(event.get_type()) == fromtype: + event.set_type(totype) modified = modified + 1 self.db.commit_event(event,self.trans) if not cli: @@ -140,18 +142,15 @@ class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow): print "Done: ", msg return (bool(modified),msg) - def on_delete_event(self,obj,b): - pass - def on_apply_clicked(self,obj): # Need to store English names for later comparison - self.options.handler.options_dict['fromtype'] = const.save_event( - unicode(self.auto1.child.get_text())) - self.options.handler.options_dict['totype'] = const.save_event( - unicode(self.auto2.child.get_text())) + self.options.handler.options_dict['fromtype'] = EventType._I2EMAP[ + EventType._S2IMAP[unicode(self.auto1.child.get_text())]] + self.options.handler.options_dict['totype'] = EventType._I2EMAP[ + EventType._S2IMAP[unicode(self.auto2.child.get_text())]] modified,msg = self.run_tool(cli=False) - OkDialog(_('Change types'),msg,self.parent.topWindow) + OkDialog(_('Change types'),msg,self.window) # Save options self.options.handler.save_options()