diff --git a/ChangeLog b/ChangeLog index e15d8810b..5ca20d935 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-04-27 Alex Roitman + * src/PluginUtils/_PluginStatus.py: Fix wm. + * src/PluginUtils/_Plugins.py: Fix Reload tool. The re-building of + the menus still needs to be fixed. + * src/plugins/Leak.py: Fix wm. + * src/docgen/LPRDoc.py: Import Errors module before it is called. + * src/plugins/DumpGenderStats.py: Fix wm. + 2006-04-27 Don Allingham * src/DisplayModels.py: flush cache on row update * src/DisplayTabs.py: check of event==None when determining default type diff --git a/src/PluginUtils/_PluginStatus.py b/src/PluginUtils/_PluginStatus.py index 5808576d6..0e687383e 100644 --- a/src/PluginUtils/_PluginStatus.py +++ b/src/PluginUtils/_PluginStatus.py @@ -55,15 +55,14 @@ class PluginStatus(ManagedWindow.ManagedWindow): def __init__(self, state, uistate, track=[]): self.title = _("Plugin Status") - ManagedWindow.ManagedWindow.__init__(self, uistate, track, self) + ManagedWindow.ManagedWindow.__init__(self,uistate,track,self.__class__) self.set_window(gtk.Dialog("",uistate.window, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)), None, self.title) self.window.set_size_request(600,400) - self.window.connect('delete-event',self.close_window) - self.window.connect('response', self.close_window) + self.window.connect('response', self.close) scrolled_window = gtk.ScrolledWindow() self.list = gtk.TreeView() @@ -106,9 +105,6 @@ class PluginStatus(ManagedWindow.ManagedWindow): '%s' % _("OK"), i[0], descr, None]) - def close_window(self, *obj): - self.close() - def button_press(self, obj, event): if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: model, node = self.selection.get_selected() @@ -138,8 +134,7 @@ class PluginTrace(ManagedWindow.ManagedWindow): (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)), None, title) self.window.set_size_request(600,400) - self.window.connect('delete-event',self.close_window) - self.window.connect('response', self.close_window) + self.window.connect('response', self.close) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) @@ -153,6 +148,3 @@ class PluginTrace(ManagedWindow.ManagedWindow): def build_menu_names(self,obj): return (self.name, None) - - def close_window(self, *obj): - self.close() diff --git a/src/PluginUtils/_Plugins.py b/src/PluginUtils/_Plugins.py index 0e249a262..9df6d8314 100644 --- a/src/PluginUtils/_Plugins.py +++ b/src/PluginUtils/_Plugins.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2000-2006 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ import Errors import _Report import _Tool import _PluginMgr +import _PluginStatus import GrampsDisplay import ManagedWindow @@ -379,8 +380,8 @@ def by_menu_name(a,b): # #------------------------------------------------------------------------- class Reload(_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) """ Treated as a callback, causes all plugins to get reloaded. @@ -393,12 +394,12 @@ class Reload(_Tool.Tool): _PluginMgr.failmsg_list = [] # attempt to reload all plugins that have succeeded in the past - for plugin in _PluginMgr._success_list: - filename = os.path.basename(plugin.__file__) + for plugin in _PluginMgr.success_list: + filename = plugin[0] filename = filename.replace('pyc','py') filename = filename.replace('pyo','py') try: - reload(plugin) + reload(plugin[1]) except: _PluginMgr.failmsg_list.append((filename,sys.exc_info())) @@ -440,7 +441,7 @@ class Reload(_Tool.Tool): # Looks like a bug in Python. a = __import__(plugin) reload(a) - _PluginMgr._success_list.append(a) + _PluginMgr.success_list.append((filename,a)) except: _PluginMgr.failmsg_list.append((filename,sys.exc_info())) @@ -457,21 +458,25 @@ class Reload(_Tool.Tool): plugin = match.groups()[0] try: a = __import__(plugin) - if a not in _PluginMgr._success_list: - _PluginMgr._success_list.append(a) + if a not in [plugin[1] + for plugin in _PluginMgr.success_list]: + _PluginMgr.success_list.append((filename,a)) except: _PluginMgr.failmsg_list.append((filename,sys.exc_info())) - if Config.get(Config.POP_PLUGIN_STATUS) and len(_PluginMgr.failmsg_list): - PluginStatus() - else: - global status_up - if status_up: - status_up.close(None) - status_up = None + if Config.get(Config.POP_PLUGIN_STATUS) \ + and len(_PluginMgr.failmsg_list): + try: + _PluginStatus.PluginStatus(dbstate,uistate) + except Errors.WindowActiveError: + old_win = uistate.gwm.get_item_from_id( + _PluginStatus.PluginStatus) + old_win.close() + _PluginStatus.PluginStatus(dbstate,uistate) # Re-generate tool and report menus - parent.build_plugin_menus(rebuild=True) + # FIXME: This needs to be fixed! + # build_plugin_menus(rebuild=True) class ReloadOptions(_Tool.ToolOptions): """ diff --git a/src/docgen/LPRDoc.py b/src/docgen/LPRDoc.py index 9396fc03e..e428c55af 100644 --- a/src/docgen/LPRDoc.py +++ b/src/docgen/LPRDoc.py @@ -42,7 +42,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import gtk.gdk - +import Errors try: import gnomeprint, gnomeprint.ui @@ -60,8 +60,6 @@ else: print " or wait for the next gnome-python release." ### end FIXME ### -import Errors - #------------------------------------------------------------------------ # # gramps modules diff --git a/src/plugins/DumpGenderStats.py b/src/plugins/DumpGenderStats.py index 39bce2ba2..d4682fe30 100644 --- a/src/plugins/DumpGenderStats.py +++ b/src/plugins/DumpGenderStats.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Martin Hawlisch, Donald N. Allingham +# Copyright (C) 2000-2006 Martin Hawlisch, Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,10 +37,9 @@ _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] class DumpGenderStats(Tool.Tool, ManagedWindow.ManagedWindow): def __init__(self, dbstate, uistate, options_class, name, callback=None): - + self.label = _("Gender Statistics tool") Tool.Tool.__init__(self, dbstate, options_class, name) - - ManagedWindow.ManagedWindow.__init__(self, uistate, [], self) + ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__) stats_list = [] @@ -63,18 +62,23 @@ class DumpGenderStats(Tool.Tool, ManagedWindow.ManagedWindow): for entry in stats_list: model.add(entry,entry[0]) - self.window = gtk.Window() - self.window.set_default_size(400,300) + window = gtk.Window() + window.set_default_size(400,300) s = gtk.ScrolledWindow() s.add(treeview) - self.window.add(s) - self.window.show_all() + window.add(s) + window.show_all() + self.set_window(window,None,self.label) + self.show() else: print "\t%s\t%s\t%s\t%s\t%s\n" % ( 'Name','Male','Female','Unknown','Guess') for entry in stats_list: print "\t%s\t%s\t%s\t%s\t%s" % entry + + def build_menu_names(self,obj): + return (self.label,None) #------------------------------------------------------------------------ # diff --git a/src/plugins/Leak.py b/src/plugins/Leak.py index 29f946561..9d95a7fbd 100644 --- a/src/plugins/Leak.py +++ b/src/plugins/Leak.py @@ -49,66 +49,39 @@ import gc #------------------------------------------------------------------------ import Utils from PluginUtils import Tool, register_tool +import ManagedWindow #------------------------------------------------------------------------- # # Actual tool # #------------------------------------------------------------------------- -class Leak(Tool.Tool): - def __init__(self,db,person,options_class,name,callback=None,parent=None): - Tool.Tool.__init__(self,db,person,options_class,name) +class Leak(Tool.Tool,ManagedWindow.ManagedWindow): + def __init__(self,dbstate, uistate, options_class, name, callback=None): + self.title = _('Uncollected Objects Tool') - 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__ + Tool.Tool.__init__(self,dbstate, options_class, name) + ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__) glade_file = "%s/%s" % (os.path.dirname(__file__),"leak.glade") self.glade = gtk.glade.XML(glade_file,"top","gramps") - self.top = self.glade.get_widget("top") - self.top.set_icon(self.parent.topWindow.get_icon()) + window = self.glade.get_widget("top") self.eval = self.glade.get_widget("eval") self.ebuf = self.eval.get_buffer() - gc.set_debug(gc.DEBUG_UNCOLLECTABLE | gc.DEBUG_OBJECTS | gc.DEBUG_SAVEALL) + gc.set_debug(gc.DEBUG_UNCOLLECTABLE|gc.DEBUG_OBJECTS|gc.DEBUG_SAVEALL) - self.title = _('Uncollected Objects Tool') - Utils.set_titles(self.top, - self.glade.get_widget('title'), - self.title) + self.set_window(window,self.glade.get_widget('title'),self.title) self.glade.signal_autoconnect({ "on_apply_clicked" : self.apply_clicked, - "on_delete_event" : self.on_delete_event, - "on_close_clicked" : self.close_clicked, + "on_close_clicked" : self.close, }) self.display() + self.show() - self.add_itself_to_menu() - self.top.show() - - def on_delete_event(self,obj,b): - self.remove_itself_from_menu() - - def close_clicked(self,obj): - self.remove_itself_from_menu() - self.top.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.top.present() + def build_menu_names(self,obj): + return (self.title,None) def display(self): gc.collect()