diff --git a/ChangeLog b/ChangeLog index 52aabbfe6..705f82388 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,13 @@ * src/plugins/Verify.py: Window management. * src/plugins/verify.glade: Define event handler. + * src/plugins/Eval.py: Window management. Replaces eval.py. + * src/plugins/eval.py: Remove from CVS. + * src/plugins/eval.glade: Define event handler. + * src/plugins/Leak.py: Window management. Replaces leak.py. + * src/plugins/leak.py: Remove from CVS. + * src/plugins/leak.glade: Define event handler. + 2004-05-09 Don Allingham * src/DbPrompter.py: added a .grdb if not specified. diff --git a/src/plugins/eval.py b/src/plugins/Eval.py similarity index 74% rename from src/plugins/eval.py rename to src/plugins/Eval.py index 187a6ad43..d900439cb 100644 --- a/src/plugins/eval.py +++ b/src/plugins/Eval.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003 Donald N. Allingham +# Copyright (C) 2003-2004 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 @@ -36,7 +36,10 @@ from gettext import gettext as _ class EvalWindow: - def __init__(self): + def __init__(self,parent): + self.parent = parent + self.win_key = self + glade_file = "%s/%s" % (os.path.dirname(__file__),"eval.glade") self.glade = gtk.glade.XML(glade_file,"top","gramps") @@ -48,12 +51,37 @@ class EvalWindow: self.glade.signal_autoconnect({ "on_apply_clicked" : self.apply_clicked, "on_close_clicked" : self.close_clicked, + "on_delete_event" : self.on_delete_event, "on_clear_clicked" : self.clear_clicked, }) Utils.set_titles(self.top,self.glade.get_widget('title'), _("Python Evaluation Window")) + 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(_('Python Evaluation Window')) + 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 apply_clicked(self,obj): text = unicode(self.ebuf.get_text(self.ebuf.get_start_iter(), self.ebuf.get_end_iter(),gtk.FALSE)) @@ -73,10 +101,6 @@ class EvalWindow: self.ebuf.set_text("") self.error.set_text("") - def close_clicked(self,obj): - self.top.destroy() - - #------------------------------------------------------------------------ # # @@ -84,8 +108,8 @@ class EvalWindow: #------------------------------------------------------------------------ from Plugins import register_tool -def runtool(database,person,callback): - EvalWindow() +def runtool(database,person,callback,parent): + EvalWindow(parent) register_tool( runtool, @@ -93,4 +117,3 @@ register_tool( category=_("Debug"), description=_("Provides a window that can evaluate python code") ) - diff --git a/src/plugins/leak.py b/src/plugins/Leak.py similarity index 63% rename from src/plugins/leak.py rename to src/plugins/Leak.py index 395bfbbd8..70f772030 100644 --- a/src/plugins/leak.py +++ b/src/plugins/Leak.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003 Donald N. Allingham +# Copyright (C) 2003-2004 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 @@ -18,9 +18,12 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + """ -Provides a python evaluation window +Show uncollected objects in a window. """ + import os import gtk import gtk.glade @@ -29,9 +32,12 @@ import string from gettext import gettext as _ -class EvalWindow: +class Leak: + + def __init__(self,parent): + self.parent = parent + self.win_key = self - def __init__(self): glade_file = "%s/%s" % (os.path.dirname(__file__),"leak.glade") self.glade = gtk.glade.XML(glade_file,"top","gramps") @@ -42,27 +48,48 @@ class EvalWindow: self.glade.signal_autoconnect({ "on_apply_clicked" : self.apply_clicked, + "on_delete_event" : self.on_delete_event, "on_close_clicked" : self.close_clicked, }) self.display() + 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(_('Uncollected objects')) + 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 display(self): gc.collect() mylist = [] if len(gc.garbage): for each in gc.garbage: mylist.append(str(each)) - self.ebuf.set_text("Uncollected objects:\n\n" + string.join(mylist,'\n\n')) + self.ebuf.set_text(_("Uncollected objects:\n\n") + string.join(mylist,'\n\n')) else: - self.ebuf.set_text("No uncollected objects\n" + str(gc.get_debug())) + self.ebuf.set_text(_("No uncollected objects\n") + str(gc.get_debug())) def apply_clicked(self,obj): self.display() - def close_clicked(self,obj): - self.top.destroy() - - #------------------------------------------------------------------------ # # @@ -70,8 +97,8 @@ class EvalWindow: #------------------------------------------------------------------------ from Plugins import register_tool -def runtool(database,person,callback): - EvalWindow() +def runtool(database,person,callback,parent=None): + Leak(parent) register_tool( runtool, @@ -79,4 +106,3 @@ register_tool( category=_("Debug"), description=_("Provide a window listing all uncollected objects"), ) - diff --git a/src/plugins/eval.glade b/src/plugins/eval.glade index e03d0e3ad..a629550fe 100644 --- a/src/plugins/eval.glade +++ b/src/plugins/eval.glade @@ -14,6 +14,12 @@ 500 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + @@ -67,6 +73,8 @@ True True True + False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE True @@ -102,6 +110,8 @@ True True False + False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE True @@ -186,6 +196,8 @@ True True False + False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE True @@ -254,6 +266,7 @@ gtk-clear True GTK_RELIEF_NORMAL + True @@ -266,6 +279,7 @@ gtk-execute True GTK_RELIEF_NORMAL + True @@ -278,6 +292,7 @@ gtk-close True GTK_RELIEF_NORMAL + True diff --git a/src/plugins/leak.glade b/src/plugins/leak.glade index 057d7035e..bb26678b6 100644 --- a/src/plugins/leak.glade +++ b/src/plugins/leak.glade @@ -14,6 +14,12 @@ 500 True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + @@ -67,6 +73,8 @@ True True True + False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE True @@ -134,6 +142,7 @@ gtk-refresh True GTK_RELIEF_NORMAL + True @@ -146,6 +155,7 @@ gtk-close True GTK_RELIEF_NORMAL + True