From 527d01a583ac5d06f4fbbef94b2d2030c367cecd Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 22 Apr 2006 04:48:40 +0000 Subject: [PATCH] * src/StartupDialog.py: fix close * src/plugins/Desbrowser.py: Use ActivPersonTool * src/PluginUtils/_Tool.py: active person tool added svn: r6412 --- gramps2/ChangeLog | 3 +++ gramps2/src/PluginUtils/_PluginStatus.py | 1 - gramps2/src/PluginUtils/_Plugins.py | 10 +++------- gramps2/src/PluginUtils/_Tool.py | 22 ++++++++++++++++++++++ gramps2/src/StartupDialog.py | 2 +- gramps2/src/plugins/Desbrowser.py | 23 ++++++++++++----------- 6 files changed, 41 insertions(+), 20 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 885d292a4..b95723eb4 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,7 @@ 2006-04-21 Don Allingham + * src/StartupDialog.py: fix close + * src/plugins/Desbrowser.py: Use ActivPersonTool + * src/PluginUtils/_Tool.py: active person tool added * src/plugins/FilterEditor.py: fix close arguments * src/plugins/ChangeNames.py: fix close arguments * src/plugins/Merge.py: fix close arguments diff --git a/gramps2/src/PluginUtils/_PluginStatus.py b/gramps2/src/PluginUtils/_PluginStatus.py index 897dd95e6..11734bc20 100644 --- a/gramps2/src/PluginUtils/_PluginStatus.py +++ b/gramps2/src/PluginUtils/_PluginStatus.py @@ -88,7 +88,6 @@ class PluginStatus(ManagedWindow.ManagedWindow): scrolled_window.add(self.list) self.window.vbox.add(scrolled_window) - self.window.connect self.window.show_all() for i in PluginMgr.failmsg_list: diff --git a/gramps2/src/PluginUtils/_Plugins.py b/gramps2/src/PluginUtils/_Plugins.py index 9c5070503..5a69a646a 100644 --- a/gramps2/src/PluginUtils/_Plugins.py +++ b/gramps2/src/PluginUtils/_Plugins.py @@ -101,8 +101,7 @@ class PluginDialog(ManagedWindow.ManagedWindow): self.dialog = gtk.glade.XML(const.plugins_glade,"report","gramps") self.dialog.signal_autoconnect({ "on_report_apply_clicked" : self.on_apply_clicked, - "destroy_passed_object" : self.close, - "on_delete_event" : self.on_delete_event, + "destroy_passed_object" : self.close_window, }) self.tree = self.dialog.get_widget("tree") @@ -146,11 +145,8 @@ class PluginDialog(ManagedWindow.ManagedWindow): self.build_plugin_tree(item_list,categories) self.window.show() - def on_delete_event(self,obj,b): - pass - - def close(self,ok=0): - self.window.destroy() + def close_window(self, obj): + self.close() def on_apply_clicked(self,obj): """Execute the selected report""" diff --git a/gramps2/src/PluginUtils/_Tool.py b/gramps2/src/PluginUtils/_Tool.py index 4c39945d7..7fd1b4058 100644 --- a/gramps2/src/PluginUtils/_Tool.py +++ b/gramps2/src/PluginUtils/_Tool.py @@ -96,6 +96,28 @@ class Tool: pass +class ActivePersonTool(Tool): + """ + The Tool base class. This is a base class for generating + customized tools. It cannot be used as is, but it can be easily + sub-classed to create a functional tool. + """ + + def __init__(self, dbstate, options_class, name): + + if not dbstate.get_active_person(): + from QuestionDialog import ErrorDialog + + ErrorDialog(_('Active person has not been set'), + _('You must select an active person for this ' + 'tool to work properly.')) + self.fail = True + return + + Tool.__init__(self, dbstate, options_class, name) + self.fail = False + + #------------------------------------------------------------------------ # # Command-line tool diff --git a/gramps2/src/StartupDialog.py b/gramps2/src/StartupDialog.py index 739ada963..a3b1a179f 100644 --- a/gramps2/src/StartupDialog.py +++ b/gramps2/src/StartupDialog.py @@ -114,7 +114,7 @@ class StartupDialog: if not const.no_gconf and upgrade_prefs(): Config.save_startup(const.startup) - self.close(None) + self.close() return self.w = Assistant.Assistant(self.complete) self.w.add_text_page( diff --git a/gramps2/src/plugins/Desbrowser.py b/gramps2/src/plugins/Desbrowser.py index c2075cb2a..1fd3ff354 100644 --- a/gramps2/src/plugins/Desbrowser.py +++ b/gramps2/src/plugins/Desbrowser.py @@ -44,7 +44,6 @@ from PluginUtils import Tool, register_tool # GTK/GNOME modules # #------------------------------------------------------------------------ -import gobject import gtk import gtk.glade import GrampsDisplay @@ -55,28 +54,26 @@ import ManagedWindow # # #------------------------------------------------------------------------ -class DesBrowse(Tool.Tool, ManagedWindow.ManagedWindow): +class DesBrowse(Tool.ActivePersonTool, ManagedWindow.ManagedWindow): def __init__(self, dbstate, uistate, options_class, name, callback=None): - Tool.Tool.__init__(self, dbstate, options_class, name) + Tool.ActivePersonTool.__init__(self, dbstate, options_class, name) + if self.fail: + return + ManagedWindow.ManagedWindow.__init__(self, uistate, [], self) + self.dbstate = dbstate self.active = dbstate.get_active_person() self.callback = callback - if not self.active: - ErrorDialog(_('Active person has not been set'), - _('You must select an active person for this ' - 'tool to work properly.')) - return - base = os.path.dirname(__file__) glade_file = base + os.sep + "desbrowse.glade" self.glade = gtk.glade.XML(glade_file,"top","gramps") self.glade.signal_autoconnect({ - "destroy_passed_object" : self.close, + "destroy_passed_object" : self.close_window, "on_help_clicked" : self.on_help_clicked, }) self.window = self.glade.get_widget("top") @@ -96,6 +93,9 @@ class DesBrowse(Tool.Tool, ManagedWindow.ManagedWindow): self.window.show() + def close_window(self,obj): + self.close() + def make_new_model(self): self.model = gtk.TreeStore(str, object) self.tree.set_model(self.model) @@ -129,7 +129,8 @@ class DesBrowse(Tool.Tool, ManagedWindow.ManagedWindow): if iter: person_handle = store.get_value(node, 1) person = self.db.get_person_from_handle(person_handle) - EditPerson(self.parent, person, self.db, self.this_callback) + EditPerson(self.dbstate, self.uistate, self.track, person, + self.this_callback) def this_callback(self, epo, val): self.callback(epo, val)