* src/plugins/WebPage.py: support for keeping track of options

* src/plugins/TimeLine.py: support for keeping track of options
* src/plugins/RelGraph.py: support for keeping track of options
* src/plugins/IndivSummary.py: support for keeping track of options
* src/plugins/IndivComplete.py: support for keeping track of options
* src/plugins/GraphViz.py: support for keeping track of options
* src/plugins/FtmStyleDescendants.py: support for keeping track of options
* src/plugins/FtmStyleAncestors.py: support for keeping track of options
* src/plugins/FanChart.py: support for keeping track of options
* src/plugins/FamilyGroup.py: support for keeping track of options
* src/plugins/DetAncestralReport.py: support for keeping track of options
* src/plugins/Ancestors.py: support for keeping track of options
* src/plugins/AncestorReport.py: support for keeping track of options
* src/plugins/AncestorChart.py: support for keeping track of options
* src/plugins/AncestorChart.py: support for keeping track of options
* src/Utils.py: save key on style mappings
* src/GenericFilter.py: allow setting of default value for filter menu
* src/PaperMenu.py: allow setting of perferred paper and orientation, GrampsCfg
no longer needed
* src/Report.py: keep track of options across reports


svn: r2297
This commit is contained in:
Don Allingham 2003-10-31 01:26:58 +00:00
parent 9a2de4c4ee
commit b317d9ddbd
3 changed files with 73 additions and 22 deletions

View File

@ -1573,28 +1573,41 @@ if not SystemFilters:
if not CustomFilters:
reload_custom_filters()
def build_filter_menu(local_filters = []):
def build_filter_menu(local_filters = [], default=""):
menu = gtk.Menu()
active = 0
cnt = 0
for filter in local_filters:
menuitem = gtk.MenuItem(filter.get_name())
menuitem.show()
menu.append(menuitem)
menuitem.set_data("filter", filter)
if default != "" and default == filter.get_name():
active = cnt
cnt += 1
for filter in SystemFilters.get_filters():
menuitem = gtk.MenuItem(_(filter.get_name()))
menuitem.show()
menu.append(menuitem)
menuitem.set_data("filter", filter)
if default != "" and default == filter.get_name():
active = cnt
cnt += 1
for filter in CustomFilters.get_filters():
menuitem = gtk.MenuItem(_(filter.get_name()))
menuitem.show()
menu.append(menuitem)
menuitem.set_data("filter", filter)
if default != "" and default == filter.get_name():
active = cnt
cnt += 1
if len(local_filters):
if active:
menu.set_active(active)
elif len(local_filters):
menu.set_active(2)
elif len(SystemFilters.get_filters()):
menu.set_active(4 + len(local_filters))

View File

@ -31,7 +31,6 @@ import gtk
#
#-------------------------------------------------------------------------
import BaseDoc
import GrampsCfg
import const
import Utils
from gettext import gettext as _
@ -58,7 +57,7 @@ paper_sizes = []
# make_paper_menu
#
#-------------------------------------------------------------------------
def make_paper_menu(main_menu):
def make_paper_menu(main_menu,default=""):
index = 0
myMenu = gtk.Menu()
@ -68,7 +67,7 @@ def make_paper_menu(main_menu):
menuitem.set_data("i",paper)
menuitem.show()
myMenu.append(menuitem)
if name == GrampsCfg.paper_preference:
if default == name:
myMenu.set_active(index)
index = index + 1
main_menu.set_menu(myMenu)
@ -78,17 +77,21 @@ def make_paper_menu(main_menu):
# make_orientation_menu
#
#-------------------------------------------------------------------------
def make_orientation_menu(main_menu):
def make_orientation_menu(main_menu,value=0):
myMenu = gtk.Menu()
menuitem = gtk.MenuItem(_("Portrait"))
menuitem.set_data("i",BaseDoc.PAPER_PORTRAIT)
menuitem.show()
if value == BaseDoc.PAPER_PORTRAIT:
menuitem.select()
myMenu.append(menuitem)
menuitem = gtk.MenuItem(_("Landscape"))
menuitem.set_data("i",BaseDoc.PAPER_LANDSCAPE)
menuitem.show()
if value == BaseDoc.PAPER_LANDSCAPE:
menuitem.select()
myMenu.append(menuitem)
main_menu.set_menu(myMenu)

View File

@ -79,7 +79,6 @@ _template_map = {
_user_template : None
}
#-------------------------------------------------------------------------
#
# Support for printing generated files
@ -190,11 +189,13 @@ class BareReportDialog:
frame_pad = 5
border_pad = 6
def __init__(self,database,person):
def __init__(self,database,person,options={}):
"""Initialize a dialog to request that the user select options
for a basic *bare* report."""
# Save info about who the report is about.
self.option_store = options
self.db = database
self.person = person
self.output_notebook = None
@ -367,7 +368,7 @@ class BareReportDialog:
para.set(pad=0.5)
self.default_style.add_style("Title",para)
def build_style_menu(self):
def build_style_menu(self,default=None):
"""Build a menu of style sets that are available for use in
this report. This menu will always have a default style
available, and will have any other style set name that the
@ -375,8 +376,12 @@ class BareReportDialog:
created here instead of inline with the rest of the style
frame, because it must be recreated to reflect any changes
whenever the user closes the style editor dialog."""
if default is None:
default = self.style_name
style_sheet_map = self.style_sheet_list.get_style_sheet_map()
myMenu = Utils.build_string_optmenu(style_sheet_map, self.style_name)
myMenu = Utils.build_string_optmenu(style_sheet_map, default)
self.style_menu.set_menu(myMenu)
#------------------------------------------------------------------------
@ -465,7 +470,8 @@ class BareReportDialog:
self.default_style)
# Now build the actual menu.
self.build_style_menu()
style = self.option_store.get('style',self.default_style.get_name())
self.build_style_menu(style)
def setup_report_options_frame(self):
"""Set up the report options frame of the dialog. This
@ -524,7 +530,7 @@ class BareReportDialog:
l.set_alignment(0.0,0.5)
table.attach(l,1,2,row,row+1,gtk.SHRINK|gtk.FILL,gtk.SHRINK|gtk.FILL)
table.attach(self.filter_combo,2,3,row,row+1,gtk.SHRINK|gtk.FILL,gtk.SHRINK|gtk.FILL)
menu = GenericFilter.build_filter_menu(local_filters)
menu = GenericFilter.build_filter_menu(local_filters,self.option_store.get('filter',''))
self.filter_combo.set_menu(menu)
self.filter_menu = menu
@ -652,7 +658,10 @@ class BareReportDialog:
retrieves a value whether or not the menu is displayed on the
screen. The subclass will know whether this menu was enabled.
This is for simplicity of programming."""
self.selected_style = self.style_menu.get_menu().get_active().get_data("d")
item = self.style_menu.get_menu().get_active()
self.selected_style = item.get_data("d")
style_name = item.get_data('l')
self.option_store['style'] = style_name
def parse_report_options_frame(self):
"""Parse the report options frame of the dialog. Save the
@ -674,6 +683,7 @@ class BareReportDialog:
if self.filter_combo:
self.filter = self.filter_menu.get_active().get_data("filter")
self.option_store['filter'] = self.filter.get_name()
else:
self.filter = None
@ -768,12 +778,12 @@ class ReportDialog(BareReportDialog):
dialog for a stand-alone report.
"""
def __init__(self,database,person):
def __init__(self,database,person,options={}):
"""Initialize a dialog to request that the user select options
for a basic *stand-alone* report."""
self.style_name = "default"
BareReportDialog.__init__(self,database,person)
BareReportDialog.__init__(self,database,person,options)
# Allow for post processing of the format frame, since the
# show_all task calls events that may reset values
@ -1058,8 +1068,10 @@ class ReportDialog(BareReportDialog):
l.set_alignment(0.0,0.5)
self.paper_table.attach(l,5,6,2,3,gtk.SHRINK|gtk.FILL)
PaperMenu.make_paper_menu(self.papersize_menu)
PaperMenu.make_orientation_menu(self.orientation_menu)
PaperMenu.make_paper_menu(self.papersize_menu,
self.option_store.get('paper',GrampsCfg.paper_preference))
PaperMenu.make_orientation_menu(self.orientation_menu,
self.option_store.get('orientation',BaseDoc.PAPER_PORTRAIT))
# The optional pagecount stuff.
if pagecount_map:
@ -1115,6 +1127,10 @@ class ReportDialog(BareReportDialog):
self.template_combo.set_popdown_strings(template_list)
self.template_combo.entry.set_editable(0)
def_template = self.option_store.get('default_template','')
if def_template in template_list:
self.template_combo.entry.set_text(def_template)
self.template_combo.entry.connect('changed',self.html_file_enable)
self.html_table.attach(self.template_combo,2,3,1,2)
@ -1123,6 +1139,9 @@ class ReportDialog(BareReportDialog):
self.html_table.attach(l,1,2,2,3,gtk.SHRINK|gtk.FILL)
self.html_fileentry = gnome.ui.FileEntry("HTML_Template",_("Choose File"))
self.html_fileentry.set_sensitive(0)
user_template = self.option_store.get('user_template','')
if os.path.isfile(user_template):
self.html_fileentry.set_filename(user_template)
self.html_table.attach(self.html_fileentry,2,3,2,3)
@ -1172,6 +1191,8 @@ class ReportDialog(BareReportDialog):
is displayed on the screen. The subclass will know which ones
it has enabled. This is for simplicity of programming."""
self.paper = self.papersize_menu.get_menu().get_active().get_data("i")
self.option_store['paper'] = self.paper.get_name()
if self.paper.get_height() <= 0 or self.paper.get_width() <= 0:
try:
h = float(self.pheight.get_text())
@ -1188,6 +1209,8 @@ class ReportDialog(BareReportDialog):
self.paper.set_width(21.0)
self.orien = self.orientation_menu.get_menu().get_active().get_data("i")
self.option_store['orientation'] = self.orien
if self.pagecount_menu == None:
self.pagecount = 0
else:
@ -1204,8 +1227,12 @@ class ReportDialog(BareReportDialog):
if _template_map.has_key(text):
if text == _user_template:
self.template_name = self.html_fileentry.get_full_path(0)
self.option_store['default_template'] = text
self.option_store['user_template'] = ''
else:
self.template_name = "%s/%s" % (const.template_dir,_template_map[text])
self.option_store['default_template'] = text
self.option_store['user_template'] = self.template_name
else:
self.template_name = None
@ -1243,11 +1270,11 @@ class ReportDialog(BareReportDialog):
class TextReportDialog(ReportDialog):
"""A class of ReportDialog customized for text based reports."""
def __init__(self,database,person):
def __init__(self,database,person,options={}):
"""Initialize a dialog to request that the user select options
for a basic text report. See the ReportDialog class for more
information."""
ReportDialog.__init__(self,database,person)
ReportDialog.__init__(self,database,person, options)
#------------------------------------------------------------------------
#
@ -1296,11 +1323,11 @@ class TextReportDialog(ReportDialog):
class DrawReportDialog(ReportDialog):
"""A class of ReportDialog customized for drawing based reports."""
def __init__(self,database,person):
def __init__(self,database,person,opt={}):
"""Initialize a dialog to request that the user select options
for a basic drawing report. See the ReportDialog class for
more information."""
ReportDialog.__init__(self,database,person)
ReportDialog.__init__(self,database,person,opt)
#------------------------------------------------------------------------
#
@ -1348,7 +1375,15 @@ class TemplateParser(handler.ContentHandler):
if tag == "template":
self.data[attrs['title']] = attrs['file']
#-----------------------------------------------------------------------
#
# Initialization
#
#-----------------------------------------------------------------------
try:
parser = make_parser()
spath = const.template_dir