* 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.


svn: r3155
This commit is contained in:
Alex Roitman 2004-05-11 02:21:09 +00:00
parent 33e69e8d45
commit ac562c81fa
5 changed files with 103 additions and 22 deletions

View File

@ -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 <donaldallingham@users.sourceforge.net>
* src/DbPrompter.py: added a .grdb if not specified.

View File

@ -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")
)

View File

@ -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"),
)

View File

@ -14,6 +14,12 @@
<property name="default_height">500</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="delete_event" handler="on_delete_event" last_modification_time="Tue, 11 May 2004 01:57:33 GMT"/>
<child>
<widget class="GtkVBox" id="vbox1">
@ -67,6 +73,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
@ -102,6 +110,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
@ -186,6 +196,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
@ -254,6 +266,7 @@
<property name="label">gtk-clear</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_clear_clicked" last_modification_time="Sun, 11 May 2003 21:01:15 GMT"/>
</widget>
</child>
@ -266,6 +279,7 @@
<property name="label">gtk-execute</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_apply_clicked" last_modification_time="Sun, 11 May 2003 21:01:26 GMT"/>
</widget>
</child>
@ -278,6 +292,7 @@
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_close_clicked" last_modification_time="Sun, 11 May 2003 21:01:38 GMT"/>
</widget>
</child>

View File

@ -14,6 +14,12 @@
<property name="default_height">500</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="delete_event" handler="on_delete_event" last_modification_time="Tue, 11 May 2004 02:16:52 GMT"/>
<child>
<widget class="GtkVBox" id="vbox1">
@ -67,6 +73,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
@ -134,6 +142,7 @@
<property name="label">gtk-refresh</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_apply_clicked" last_modification_time="Sun, 11 May 2003 21:01:26 GMT"/>
</widget>
</child>
@ -146,6 +155,7 @@
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_close_clicked" last_modification_time="Sun, 11 May 2003 21:01:38 GMT"/>
</widget>
</child>