From 8fe2ef9602bb90cf7cb53e3df2c57ae387d0b009 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 13 May 2003 03:26:33 +0000 Subject: [PATCH] Debug tools svn: r1518 --- src/plugins/eval.glade | 235 +++++++++++++++++++++++++++++++++++++++++ src/plugins/eval.py | 75 +++++++++++++ src/plugins/leak.glade | 163 ++++++++++++++++++++++++++++ src/plugins/leak.py | 82 ++++++++++++++ 4 files changed, 555 insertions(+) create mode 100644 src/plugins/eval.glade create mode 100644 src/plugins/eval.py create mode 100644 src/plugins/leak.glade create mode 100644 src/plugins/leak.py diff --git a/src/plugins/eval.glade b/src/plugins/eval.glade new file mode 100644 index 000000000..34b3dd890 --- /dev/null +++ b/src/plugins/eval.glade @@ -0,0 +1,235 @@ + + + + + + + + True + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 450 + 500 + True + False + + + + 6 + True + False + 6 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 6 + True + 4 + 2 + False + 6 + 6 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 1 + 2 + 1 + 2 + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 1 + 2 + 3 + 4 + fill + + + + + + True + <b>Evaluation Window</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 2 + 0 + 1 + fill + + + + + + + True + <b>Output Window</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 2 + 2 + 3 + fill + + + + + + 0 + True + True + + + + + + 6 + True + GTK_BUTTONBOX_END + 6 + + + + True + True + True + gtk-clear + True + GTK_RELIEF_NORMAL + + + + + + + True + True + True + gtk-apply + True + GTK_RELIEF_NORMAL + + + + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + + + + + + 0 + False + True + + + + + + + diff --git a/src/plugins/eval.py b/src/plugins/eval.py new file mode 100644 index 000000000..116b6c95b --- /dev/null +++ b/src/plugins/eval.py @@ -0,0 +1,75 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2003 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Provides a python evaluation window +""" +import os +import gtk +import gtk.glade + +from intl import gettext as _ + +class EvalWindow: + + def __init__(self): + glade_file = "%s/%s" % (os.path.dirname(__file__),"eval.glade") + self.glade = gtk.glade.XML(glade_file,"top") + + self.top = self.glade.get_widget("top") + self.display = self.glade.get_widget("display") + self.eval = self.glade.get_widget("eval") + self.ebuf = self.eval.get_buffer() + + self.glade.signal_autoconnect({ + "on_apply_clicked" : self.apply_clicked, + "on_close_clicked" : self.close_clicked, + "on_clear_clicked" : self.clear_clicked, + }) + + def apply_clicked(self,obj): + text = self.ebuf.get_text(self.ebuf.get_start_iter(), + self.ebuf.get_end_iter(),gtk.FALSE) + exec(text) + + def clear_clicked(self,obj): + pass + + def close_clicked(self,obj): + self.top.destroy() + + +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +from Plugins import register_tool + +def runtool(database,person,callback): + EvalWindow() + +register_tool( + runtool, + _("Python evaluation window"), + category=_("Debug"), + description=_("Provides a window that can evaluate python code") + ) + diff --git a/src/plugins/leak.glade b/src/plugins/leak.glade new file mode 100644 index 000000000..057d7035e --- /dev/null +++ b/src/plugins/leak.glade @@ -0,0 +1,163 @@ + + + + + + + + True + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 450 + 500 + True + False + + + + 6 + True + False + 6 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 6 + True + 2 + 2 + False + 6 + 6 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 1 + 2 + 1 + 2 + + + + + + True + <b>Uncollected Objects</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 2 + 0 + 1 + fill + + + + + + 0 + True + True + + + + + + 6 + True + GTK_BUTTONBOX_END + 6 + + + + True + True + True + gtk-refresh + True + GTK_RELIEF_NORMAL + + + + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + + + + + + 0 + False + True + + + + + + + diff --git a/src/plugins/leak.py b/src/plugins/leak.py new file mode 100644 index 000000000..ec2a58b52 --- /dev/null +++ b/src/plugins/leak.py @@ -0,0 +1,82 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2003 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Provides a python evaluation window +""" +import os +import gtk +import gtk.glade +import gc +import string + +from intl import gettext as _ + +class EvalWindow: + + def __init__(self): + glade_file = "%s/%s" % (os.path.dirname(__file__),"leak.glade") + self.glade = gtk.glade.XML(glade_file,"top") + + self.top = 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) + + self.glade.signal_autoconnect({ + "on_apply_clicked" : self.apply_clicked, + "on_close_clicked" : self.close_clicked, + }) + self.display() + + 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')) + else: + 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() + + +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +from Plugins import register_tool + +def runtool(database,person,callback): + EvalWindow() + +register_tool( + runtool, + _("Show uncollected objects"), + category=_("Debug"), + description=_(""), + ) +