2003-05-13 08:56:33 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-01 01:24:35 +05:30
|
|
|
# Copyright (C) 2003-2006 Donald N. Allingham
|
2003-05-13 08:56:33 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2004-05-11 07:51:09 +05:30
|
|
|
# $Id$
|
|
|
|
|
2003-05-13 08:56:33 +05:30
|
|
|
"""
|
2004-05-11 07:51:09 +05:30
|
|
|
Show uncollected objects in a window.
|
2003-05-13 08:56:33 +05:30
|
|
|
"""
|
2004-05-11 07:51:09 +05:30
|
|
|
|
2005-03-25 05:54:37 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# standard python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-05-13 08:56:33 +05:30
|
|
|
import os
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2006-03-01 01:24:35 +05:30
|
|
|
from bsddb.db import DBError
|
2005-03-25 05:54:37 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-05-13 08:56:33 +05:30
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
import gc
|
|
|
|
|
2005-03-25 05:54:37 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import Utils
|
2006-03-11 06:42:06 +05:30
|
|
|
from PluginUtils import Tool, register_tool
|
2006-04-28 00:49:10 +05:30
|
|
|
import ManagedWindow
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2005-03-25 05:54:37 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Actual tool
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-28 00:49:10 +05:30
|
|
|
class Leak(Tool.Tool,ManagedWindow.ManagedWindow):
|
|
|
|
def __init__(self,dbstate, uistate, options_class, name, callback=None):
|
|
|
|
self.title = _('Uncollected Objects Tool')
|
2004-05-11 07:51:09 +05:30
|
|
|
|
2006-04-28 00:49:10 +05:30
|
|
|
Tool.Tool.__init__(self,dbstate, options_class, name)
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2007-11-22 04:45:10 +05:30
|
|
|
glade_file = os.path.dirname(__file__) + os.sep + "leak.glade"
|
2003-08-17 07:44:33 +05:30
|
|
|
self.glade = gtk.glade.XML(glade_file,"top","gramps")
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2006-04-28 00:49:10 +05:30
|
|
|
window = self.glade.get_widget("top")
|
2003-05-13 08:56:33 +05:30
|
|
|
self.eval = self.glade.get_widget("eval")
|
|
|
|
self.ebuf = self.eval.get_buffer()
|
2006-04-28 00:49:10 +05:30
|
|
|
gc.set_debug(gc.DEBUG_UNCOLLECTABLE|gc.DEBUG_OBJECTS|gc.DEBUG_SAVEALL)
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2006-04-28 00:49:10 +05:30
|
|
|
self.set_window(window,self.glade.get_widget('title'),self.title)
|
2005-03-25 05:54:37 +05:30
|
|
|
|
2003-05-13 08:56:33 +05:30
|
|
|
self.glade.signal_autoconnect({
|
|
|
|
"on_apply_clicked" : self.apply_clicked,
|
2006-04-28 00:49:10 +05:30
|
|
|
"on_close_clicked" : self.close,
|
2003-05-13 08:56:33 +05:30
|
|
|
})
|
|
|
|
self.display()
|
2006-04-28 00:49:10 +05:30
|
|
|
self.show()
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2006-04-28 00:49:10 +05:30
|
|
|
def build_menu_names(self,obj):
|
|
|
|
return (self.title,None)
|
2004-05-11 07:51:09 +05:30
|
|
|
|
2003-05-13 08:56:33 +05:30
|
|
|
def display(self):
|
|
|
|
gc.collect()
|
|
|
|
mylist = []
|
|
|
|
if len(gc.garbage):
|
|
|
|
for each in gc.garbage:
|
2006-03-01 01:24:35 +05:30
|
|
|
try:
|
|
|
|
mylist.append(str(each))
|
|
|
|
except DBError:
|
|
|
|
mylist.append('db.DB instance at %s' % id(each))
|
|
|
|
self.ebuf.set_text(_("Uncollected objects:\n\n")
|
|
|
|
+ '\n\n'.join(mylist))
|
2003-05-13 08:56:33 +05:30
|
|
|
else:
|
2006-03-01 01:24:35 +05:30
|
|
|
self.ebuf.set_text(_("No uncollected objects\n")
|
|
|
|
+ str(gc.get_debug()))
|
2003-05-13 08:56:33 +05:30
|
|
|
|
|
|
|
def apply_clicked(self,obj):
|
|
|
|
self.display()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-12-06 12:08:09 +05:30
|
|
|
class LeakOptions(Tool.ToolOptions):
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
def __init__(self,name,person_id=None):
|
|
|
|
Tool.ToolOptions.__init__(self,name,person_id)
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if __debug__:
|
|
|
|
register_tool(
|
2006-05-08 23:51:11 +05:30
|
|
|
name = 'leak',
|
2005-12-06 12:08:09 +05:30
|
|
|
category = Tool.TOOL_DEBUG,
|
|
|
|
tool_class = Leak,
|
|
|
|
options_class = LeakOptions,
|
|
|
|
modes = Tool.MODE_GUI,
|
|
|
|
translated_name = _("Show uncollected objects"),
|
|
|
|
status = _("Stable"),
|
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "don@gramps-project.org",
|
|
|
|
description=_("Provide a window listing all uncollected objects"),
|
|
|
|
)
|