5900: reports should remember their last-used GUI output filename

Requested on 6720: Reports: Translated filename by default on output
(5900 is already in gramps40 and trunk, see revision 19988)


svn: r22355
This commit is contained in:
Paul Franklin 2013-05-17 15:50:42 +00:00
parent 8b11e650f7
commit e19d519d25
3 changed files with 36 additions and 3 deletions

View File

@ -4,7 +4,7 @@
# Copyright (C) 2004-2007 Donald N. Allingham
# Copyright (C) 2008,2011 Gary Burton
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2011 Paul Franklin
# Copyright (C) 2011-2013 Paul Franklin
#
# 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
@ -83,6 +83,7 @@ class OptionList(_options.OptionList):
self.margins = [2.54, 2.54, 2.54, 2.54]
self.format_name = None
self.css_filename = None
self.output = None
def set_style_name(self, style_name):
"""
@ -234,6 +235,22 @@ class OptionList(_options.OptionList):
"""
return self.format_name
def set_output(self, output):
"""
Set the output for the OptionList.
@param output: name of the output to set.
@type output: str
"""
self.output = output
def get_output(self):
"""
Return the output of the OptionList.
@returns: returns the output name
@rtype: str
"""
return self.output
#-------------------------------------------------------------------------
#
# Collection of option lists
@ -445,6 +462,9 @@ class OptionListCollection(_options.OptionListCollection):
if option_list.get_style_name():
f.write(' <style name="%s"/>\n' %
escxml(option_list.get_style_name()) )
if option_list.get_output():
f.write(' <output name="%s"/>\n' %
escxml(os.path.basename(option_list.get_output())) )
def parse(self):
"""
@ -529,6 +549,9 @@ class OptionParser(_options.OptionParser):
self.collection.set_last_margin(pos, value)
else:
self.option_list.set_margin(pos, value)
elif tag == 'output':
if not self.common:
self.option_list.set_output(attrs['name'])
else:
# Tag is not report-specific, so we let the base class handle it.
_options.OptionParser.startElement(self, tag, attrs)
@ -615,6 +638,8 @@ class OptionHandler(_options.OptionHandler):
self.paper_name = self.saved_option_list.get_paper_name()
if self.saved_option_list.get_format_name():
self.format_name = self.saved_option_list.get_format_name()
if self.saved_option_list.get_output():
self.output = self.saved_option_list.get_output()
def save_options(self):
"""
@ -636,6 +661,7 @@ class OptionHandler(_options.OptionHandler):
def save_common_options(self):
# First we save common options
self.saved_option_list.set_style_name(self.style_name)
self.saved_option_list.set_output(self.output)
self.saved_option_list.set_orientation(self.orientation)
self.saved_option_list.set_custom_paper_size(self.custom_paper_size)
self.saved_option_list.set_margins(self.margins)

View File

@ -3,6 +3,7 @@
#
# Copyright (C) 2007 Brian G. Matherly
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2013 Paul Franklin
#
# 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
@ -176,6 +177,9 @@ class DocReportDialog(ReportDialog):
else:
spath = self.get_default_directory()
default_name = self.dbname + "_" + self.raw_name
if self.options.get_output():
base = os.path.basename(self.options.get_output())
else:
base = "%s.%s" % (default_name, ext)
spath = os.path.normpath(os.path.join(spath, base))
self.target_fileentry.set_filename(spath)

View File

@ -169,7 +169,10 @@ class GraphvizReportDialog(ReportDialog):
else:
spath = self.get_default_directory()
default_name = self.dbname + "_" + self.raw_name
base = "%s%s" % (default_name, ext) # "ext" already has a dot
if self.options.get_output():
base = os.path.basename(self.options.get_output())
else:
base = "%s%s" % (default_name, ext)
spath = os.path.normpath(os.path.join(spath, base))
self.target_fileentry.set_filename(spath)