Added inheritance to plugin dialogs

svn: r824
This commit is contained in:
Don Allingham 2002-03-09 00:14:45 +00:00
parent ca3dfd2198
commit 01ece9715a
4 changed files with 150 additions and 397 deletions

View File

@ -86,20 +86,21 @@ STATUS = "s"
#-------------------------------------------------------------------------
#
# ReportPlugins interface class
# PluginDialog interface class
#
#-------------------------------------------------------------------------
class ReportPlugins:
class PluginDialog:
"""Displays the dialog box that allows the user to select the
report that is desired."""
def __init__(self,db,active):
def __init__(self,db,active,list,msg):
"""Display the dialog box, and build up the list of available
reports. This is used to build the selection tree on the left
hand side of the dailog box."""
self.db = db
self.active = active
self.update = None
self.dialog = libglade.GladeXML(const.pluginsFile,"report")
self.dialog.signal_autoconnect({
@ -109,122 +110,45 @@ class ReportPlugins:
})
tree = self.dialog.get_widget("tree")
self.top = self.dialog.get_widget("report")
self.img = self.dialog.get_widget("image")
self.description = self.dialog.get_widget("description")
self.status = self.dialog.get_widget("report_status")
self.label = self.dialog.get_widget("report_label")
self.title = self.dialog.get_widget("title")
self.run_tool = None
build_tree(tree,_reports,self.on_node_selected)
self.build_tree(tree,list)
self.title.set_text(msg)
self.top.set_title("%s - GRAMPS" % msg)
def on_apply_clicked(self,obj):
"""Execute the selected report"""
Utils.destroy_passed_object(obj)
if self.run_tool:
if self.update:
self.run_tool(self.db,self.active,self.update)
else:
self.run_tool(self.db,self.active)
def on_node_selected(self,obj):
"""Updates the informational display on the right hand side of
the dialog box with the description of the selected report"""
doc = obj.get_data(DOCSTRING)
xpm = obj.get_data(IMAGE)
status = ": %s" % obj.get_data(STATUS)
title = obj.get_data(TITLE)
img = self.dialog.get_widget("image")
self.dialog.get_widget("description").set_text(doc)
self.dialog.get_widget("report_status").set_text(status)
self.dialog.get_widget("report_label").show()
(task,cat,title,doc,xpm,status) = obj.get_data(TASK)
i,m = gtk.create_pixmap_from_xpm_d(gtk.GtkWindow(),None,xpm)
img.set(i,m)
self.description.set_text(doc)
self.status.set_text(": %s" % status)
self.label.show()
self.img.set(i,m)
self.title.set_text(title)
self.dialog.get_widget("title").set_text(title)
self.run_tool = obj.get_data(TASK)
self.run_tool = task
#-------------------------------------------------------------------------
#
# ToolPlugins interface class
#
#-------------------------------------------------------------------------
class ToolPlugins:
"""Displays the dialog box that allows the user to select the tool
that is desired."""
def __init__(self,db,active,update):
"""Display the dialog box, and build up the list of available
reports. This is used to build the selection tree on the left
hand side of the dailog box."""
self.db = db
self.active = active
self.update = update
self.dialog = libglade.GladeXML(const.pluginsFile,"pluginsel")
self.dialog.signal_autoconnect({
"on_apply_clicked" : self.on_apply_clicked,
"on_ok_clicked" : self.on_apply_clicked,
"destroy_passed_object" : Utils.destroy_passed_object
})
tree = self.dialog.get_widget("tree")
self.run_tool = None
build_tree(tree,_tools,self.on_node_selected)
def on_apply_clicked(self,obj):
"""Execute the selected tool."""
Utils.destroy_passed_object(obj)
if self.run_tool:
self.run_tool(self.db,self.active,self.update)
def on_node_selected(self,obj):
"""Updates the informational display on the right hand side of
the dialog box with the description of the selected tool."""
doc = obj.get_data(DOCSTRING)
title = obj.get_data(TITLE)
self.dialog.get_widget("description").set_text(doc)
self.dialog.get_widget("title").set_text(title)
self.run_tool = obj.get_data(TASK)
#-------------------------------------------------------------------------
#
# PluginStatus
#
#-------------------------------------------------------------------------
class PluginStatus:
"""Displays a dialog showing the status of loaded plugins"""
def __init__(self):
import cStringIO
self.glade = libglade.GladeXML(const.plugfile,"plugstat")
self.top = self.glade.get_widget("plugstat")
window = self.glade.get_widget("text")
info = cStringIO.StringIO()
info.write(_("The following modules could not be loaded:"))
info.write("\n\n")
for (file,msgs) in _failmsg:
error = str(msgs[0])
if error[0:11] == "exceptions.":
error = error[11:]
msg = msgs[1]
trc = msgs[2]
info.write("%s\n\t%s: %s\n\n" % (file,error,msg) )
info.seek(0)
window.show_string(info.read())
self.top.run_and_close()
#-------------------------------------------------------------------------
#
# build_tree
#
#-------------------------------------------------------------------------
def build_tree(tree,list,task):
def build_tree(self,tree,list):
"""Populates a GtkTree with each menu item assocated with a entry
in the lists. The list must consist of a tuples with the following
format:
@ -238,12 +162,8 @@ def build_tree(tree,list,task):
item_hash = {}
for report in list:
item = gtk.GtkTreeItem(report[2])
item.connect("select",task)
item.set_data(TASK,report[0])
item.set_data(TITLE,report[2])
item.set_data(DOCSTRING,report[3])
item.set_data(IMAGE,report[4])
item.set_data(STATUS,report[5])
item.connect("select",self.on_node_selected)
item.set_data(TASK,report)
if item_hash.has_key(report[1]):
item_hash[report[1]].append(item)
@ -266,6 +186,71 @@ def build_tree(tree,list,task):
item.show()
subtree.append(item)
#-------------------------------------------------------------------------
#
# ReportPlugins interface class
#
#-------------------------------------------------------------------------
class ReportPlugins(PluginDialog):
"""Displays the dialog box that allows the user to select the
report that is desired."""
def __init__(self,db,active):
"""Display the dialog box, and build up the list of available
reports. This is used to build the selection tree on the left
hand side of the dailog box."""
PluginDialog.__init__(self,db,active,_reports,_("Report Selection"))
#-------------------------------------------------------------------------
#
# ToolPlugins interface class
#
#-------------------------------------------------------------------------
class ToolPlugins(PluginDialog):
"""Displays the dialog box that allows the user to select the tool
that is desired."""
def __init__(self,db,active,update):
"""Display the dialog box, and build up the list of available
reports. This is used to build the selection tree on the left
hand side of the dailog box."""
PluginDialog.__init__(self,db,active,_tools,_("Tool Selection"))
self.update = update
#-------------------------------------------------------------------------
#
# PluginStatus
#
#-------------------------------------------------------------------------
class PluginStatus:
"""Displays a dialog showing the status of loaded plugins"""
def __init__(self):
import cStringIO
self.glade = libglade.GladeXML(const.pluginsFile,"plugstat")
self.top = self.glade.get_widget("plugstat")
window = self.glade.get_widget("text")
info = cStringIO.StringIO()
info.write(_("The following modules could not be loaded:"))
info.write("\n\n")
for (file,msgs) in _failmsg:
error = str(msgs[0])
if error[0:11] == "exceptions.":
error = error[11:]
msg = msgs[1]
trc = msgs[2]
info.write("%s\n\t%s: %s\n\n" % (file,error,msg) )
info.seek(0)
window.show_string(info.read())
self.top.run_and_close()
#-------------------------------------------------------------------------
#
# load_plugins

View File

@ -73,7 +73,6 @@ srcselFile = "%s/srcsel.glade" % rootDir
findFile = "%s/find.glade" % rootDir
mergeFile = "%s/mergedata.glade" % rootDir
traceFile = "%s/trace.glade" % rootDir
plugfile = "%s/plugstat.glade" % rootDir
pluginsDir = "%s/plugins" % rootDir
docgenDir = "%s/docgen" % rootDir
filtersDir = "%s/filters" % rootDir

View File

@ -12,222 +12,6 @@
<gettext_support>True</gettext_support>
</project>
<widget>
<class>GnomeDialog</class>
<name>pluginsel</name>
<title>Tool Selection - GRAMPS</title>
<type>GTK_WINDOW_DIALOG</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>vbox33</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>hbuttonbox20</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button101</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_ok_clicked</handler>
<object>pluginsel</object>
<last_modification_time>Sun, 11 Mar 2001 22:54:53 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button102</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_apply_clicked</handler>
<object>pluginsel</object>
<last_modification_time>Sun, 11 Mar 2001 22:54:34 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button103</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>destroy_passed_object</handler>
<object>pluginsel</object>
<last_modification_time>Sun, 11 Mar 2001 22:54:19 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
<widget>
<class>GtkHPaned</class>
<name>hpaned1</name>
<handle_size>10</handle_size>
<gutter_size>6</gutter_size>
<position>0</position>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkTree</class>
<name>tree</name>
<border_width>5</border_width>
<width>250</width>
<height>300</height>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<view_mode>GTK_TREE_VIEW_ITEM</view_mode>
<view_line>True</view_line>
<child>
<shrink>False</shrink>
<resize>True</resize>
</child>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox34</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<shrink>True</shrink>
<resize>True</resize>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>20</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkPixmap</class>
<name>image</name>
<filename>gramps.xpm</filename>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<build_insensitive>True</build_insensitive>
<child>
<padding>10</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>title</name>
<label>Tool Selection</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>10</xpad>
<ypad>10</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator18</name>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>pluginTitle</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>10</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>description</name>
<width>300</width>
<label>Select a tool from those available on the left.</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>True</wrap>
<xalign>0</xalign>
<yalign>0</yalign>
<xpad>10</xpad>
<ypad>20</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GnomeDialog</class>
<name>report</name>
@ -491,4 +275,71 @@
</widget>
</widget>
<widget>
<class>GnomeDialog</class>
<name>plugstat</name>
<title>Plugin Status - GRAMPS</title>
<type>GTK_WINDOW_DIALOG</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>vbox37</name>
<width>450</width>
<height>350</height>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>hbuttonbox22</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button107</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
</widget>
</widget>
<widget>
<class>GnomeLess</class>
<name>text</name>
<width>450</width>
<height>350</height>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@ -1,82 +0,0 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Project1</name>
<program_name>project1</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
</project>
<widget>
<class>GnomeDialog</class>
<name>plugstat</name>
<title>Plugin Status - GRAMPS</title>
<type>GTK_WINDOW_DIALOG</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<width>450</width>
<height>350</height>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
</widget>
</widget>
<widget>
<class>GnomeLess</class>
<name>text</name>
<width>450</width>
<height>350</height>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
</GTK-Interface>