2003-05-13 08:56:33 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-03-25 05:54:37 +05:30
|
|
|
# Copyright (C) 2003-2005 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
|
2005-03-25 05:54:37 +05:30
|
|
|
from gettext import gettext as _
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# 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
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2005-03-25 05:54:37 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Actual tool
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-05-11 07:51:09 +05:30
|
|
|
class Leak:
|
|
|
|
|
|
|
|
def __init__(self,parent):
|
|
|
|
self.parent = parent
|
2005-03-25 05:54:37 +05:30
|
|
|
if self.parent.child_windows.has_key(self.__class__):
|
|
|
|
self.parent.child_windows[self.__class__].present(None)
|
|
|
|
return
|
|
|
|
self.win_key = self.__class__
|
2003-05-13 08:56:33 +05:30
|
|
|
|
|
|
|
glade_file = "%s/%s" % (os.path.dirname(__file__),"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
|
|
|
|
|
|
|
self.top = self.glade.get_widget("top")
|
2005-03-25 05:54:37 +05:30
|
|
|
self.top.set_icon(self.parent.topWindow.get_icon())
|
2003-05-13 08:56:33 +05:30
|
|
|
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)
|
|
|
|
|
2005-03-25 05:54:37 +05:30
|
|
|
self.title = _('Uncollected Objects Tool')
|
|
|
|
Utils.set_titles(self.top,
|
|
|
|
self.glade.get_widget('title'),
|
|
|
|
self.title)
|
|
|
|
|
2003-05-13 08:56:33 +05:30
|
|
|
self.glade.signal_autoconnect({
|
|
|
|
"on_apply_clicked" : self.apply_clicked,
|
2004-05-11 07:51:09 +05:30
|
|
|
"on_delete_event" : self.on_delete_event,
|
2003-05-13 08:56:33 +05:30
|
|
|
"on_close_clicked" : self.close_clicked,
|
|
|
|
})
|
|
|
|
self.display()
|
|
|
|
|
2004-05-11 07:51:09 +05:30
|
|
|
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
|
2005-03-25 05:54:37 +05:30
|
|
|
self.parent_menu_item = gtk.MenuItem(self.title)
|
2004-05-11 07:51:09 +05:30
|
|
|
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()
|
|
|
|
|
2003-05-13 08:56:33 +05:30
|
|
|
def display(self):
|
|
|
|
gc.collect()
|
|
|
|
mylist = []
|
|
|
|
if len(gc.garbage):
|
|
|
|
for each in gc.garbage:
|
|
|
|
mylist.append(str(each))
|
2005-03-25 05:54:37 +05:30
|
|
|
self.ebuf.set_text(_("Uncollected objects:\n\n") + '\n\n'.join(mylist))
|
2003-05-13 08:56:33 +05:30
|
|
|
else:
|
2004-05-11 07:51:09 +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-01-05 10:32:19 +05:30
|
|
|
from PluginMgr import register_tool
|
2003-05-13 08:56:33 +05:30
|
|
|
|
2004-05-11 07:51:09 +05:30
|
|
|
def runtool(database,person,callback,parent=None):
|
|
|
|
Leak(parent)
|
2003-05-13 08:56:33 +05:30
|
|
|
|
|
|
|
register_tool(
|
|
|
|
runtool,
|
|
|
|
_("Show uncollected objects"),
|
|
|
|
category=_("Debug"),
|
2003-05-23 21:50:59 +05:30
|
|
|
description=_("Provide a window listing all uncollected objects"),
|
2003-05-13 08:56:33 +05:30
|
|
|
)
|