* src/plugins/AncestorChart2.py:

* src/plugins/DescendChart.py:
	Make AncestorChart and DescendChart consistent in options
* src/ReportBase/_BareReportDialog.py: remove get_report_extra_textbox_info
* src/ReportBase/_CommandLineReport.py:
* src/ReportBase/_ReportOptions.py:
	remove dispf

svn: r8263
This commit is contained in:
Brian Matherly 2007-03-03 03:12:04 +00:00
parent 34bb7bdad1
commit cd570de9e3
6 changed files with 66 additions and 95 deletions

View File

@ -1,3 +1,13 @@
2007-03-02 Brian Matherly <brian@gramps-project.org>
* src/plugins/AncestorChart2.py:
* src/plugins/DescendChart.py:
Make AncestorChart and DescendChart consistent in options
* src/ReportBase/_BareReportDialog.py:
remove get_report_extra_textbox_info
* src/ReportBase/_CommandLineReport.py:
* src/ReportBase/_ReportOptions.py:
remove dispf
2007-02-28 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/GrampsDbUtils/_GedcomParse.py: Fix level of handle_source calls
* src/GrampsDbUtils/_GedcomLex.py: fix typo

View File

@ -224,16 +224,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
a string to use as the tooltip for the textbox."""
return (None, None, None, None)
def get_report_extra_textbox_info(self):
"""Return the data used to fill out the 'extra' textbox in the
report options dialog. The first value is the string to be
used as the label to the left of the textbox. The second
value is the string to use as the default contents of the
textbox. If None, then the text box will be hidden. The
final value is a string to use as the tooltip for the
textbox."""
return (None, None, None)
#------------------------------------------------------------------------
#
# Functions related to extending the options
@ -412,7 +402,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
(but not all) dialog boxes."""
(em_label, extra_map, preset, em_tip) = self.get_report_extra_menu_info()
(et_label, string, et_tip) = self.get_report_extra_textbox_info()
row = 0
max_rows = 0
@ -424,8 +413,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
max_rows = max_rows + 1
if extra_map:
max_rows = max_rows + 1
if string:
max_rows = max_rows + 1
max_rows = max_rows + len(self.widgets)
@ -494,25 +481,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
table.attach(self.extra_menu, 2, 3, row, row+1,
yoptions=gtk.SHRINK)
row += 1
# Now the "extra" text box
if string:
self.extra_textbox_label = gtk.Label("%s:" % et_label)
self.extra_textbox_label.set_alignment(0.0,0)
swin = gtk.ScrolledWindow()
swin.set_shadow_type(gtk.SHADOW_IN)
swin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
self.extra_textbox = gtk.TextView()
swin.add(self.extra_textbox)
self.extra_textbox.get_buffer().set_text('\n'.join(string))
self.extra_textbox.set_editable(1)
self.add_tooltip(self.extra_textbox,et_tip)
table.attach(self.extra_textbox_label, 1, 2, row, row+1,
gtk.SHRINK|gtk.FILL,gtk.SHRINK)
table.attach(swin, 2, 3, row, row+1,
yoptions=gtk.SHRINK)
row += 1
# Setup requested widgets
for (text,widget) in self.widgets:
@ -624,14 +592,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
self.report_menu = self.extra_menu.get_menu().get_active().get_data("d")
else:
self.report_menu = None
if self.extra_textbox:
b = self.extra_textbox.get_buffer()
text_val = unicode(b.get_text(b.get_start_iter(),b.get_end_iter(),False))
self.report_text = text_val.split('\n')
self.options.handler.set_display_format(self.report_text)
else:
self.report_text = []
def parse_other_frames(self):
"""Do nothing. This sole purpose of this function is to give

View File

@ -78,7 +78,6 @@ class CommandLineReport:
'filter' : ["=num","Filter number."],
'gen' : ["=num","Number of generations to follow."],
'pagebbg' : ["=0/1","Page break between generations."],
'dispf' : ["=str","Display format for the outputbox."],
}
if noopt:
@ -139,13 +138,6 @@ class CommandLineReport:
"No page break","Page break"])
self.options_help['pagebbg'].append(True)
if self.options_dict.has_key('dispf'):
dispf = ''.join(self.options_dict['dispf']).replace('\\n','\n')
self.option_class.handler.set_display_format(dispf)
self.options_help['dispf'].append(
"Any string -- may use keyword substitutions")
self.option_class.handler.output = self.options_dict['of']
self.options_help['of'].append(os.path.join(const.user_home,
"whatever_name"))

View File

@ -432,18 +432,6 @@ class OptionHandler(_Options.OptionHandler):
def set_default_stylesheet_name(self,style_name):
self.style_name = style_name
def get_display_format(self):
if self.default_options_dict.has_key('dispf'):
return self.options_dict.get('dispf',
self.default_options_dict['dispf'])
else:
return []
def set_display_format(self,val):
if type(val) != list:
val = val.split('\n')
self.options_dict['dispf'] = val
def get_format_name(self):
return self.format_name

View File

@ -185,9 +185,8 @@ class AncestorChart(Report):
"""
Report.__init__(self,database,person,options_class)
(self.max_generations,self.pgbrk) \
= options_class.get_report_generations()
self.display = options_class.handler.options_dict['dispf']
self.max_generations = options_class.handler.options_dict['maxgen']
self.force_fit = options_class.handler.options_dict['singlep']
self.incblank = options_class.handler.options_dict['incblank']
self.compress = options_class.handler.options_dict['compress']
@ -230,7 +229,7 @@ class AncestorChart(Report):
em = self.doc.string_width(self.font,"m")
subst = SubstKeywords(self.database,person_handle)
self.text[index] = subst.replace_and_clean(self.display)
self.text[index] = subst.replace_and_clean(self.display.split('\n'))
for line in self.text[index]:
this_box_width = self.doc.string_width(self.font,line) + 2*em
@ -443,11 +442,19 @@ class AncestorChartOptions(ReportOptions):
def set_new_options(self):
# Options specific for this report
self.options_dict = {
'dispf' : "$n\n%s $b\n%s $d" % (_BORN,_DIED),
'maxgen' : 10,
'singlep' : 1,
'incblank' : 1,
'compress' : 1,
}
self.options_help = {
'dispf' : ("=str","Display format for the outputbox.",
"Allows you to customize the data in the boxes in the report",
True),
'maxgen' : ("=int","Generations",
"The number of generations to include in the report",
True),
'singlep' : ("=0/1","Whether to scale to fit on a single page.",
["Do not scale to fit","Scale to fit"],
True),
@ -461,23 +468,25 @@ class AncestorChartOptions(ReportOptions):
def enable_options(self):
# Semi-common options that should be enabled for this report
self.enable_dict = {
'gen' : 10,
'pagebbg' : 0,
'dispf' : [ "$n", "%s $b" % _BORN, "%s $d" % _DIED ],
}
def get_textbox_info(self):
"""Label the textbox and provide the default contents."""
return (_("Display Format"), self.options_dict['dispf'],
_("Allows you to customize the data in the boxes in the report"))
self.enable_dict = {}
def add_user_options(self,dialog):
"""
Override the base class add_user_options task to add a menu that allows
the user to select the sort method.
"""
dialog.get_report_extra_textbox_info = self.get_textbox_info
self.max_gen = gtk.SpinButton(gtk.Adjustment(1,1,100,1))
self.max_gen.set_value(self.options_dict['maxgen'])
dialog.add_option(_('Generations'),self.max_gen)
self.extra_textbox = gtk.TextView()
self.extra_textbox.get_buffer().set_text(self.options_dict['dispf'])
self.extra_textbox.set_editable(1)
swin = gtk.ScrolledWindow()
swin.set_shadow_type(gtk.SHADOW_IN)
swin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
swin.add(self.extra_textbox)
dialog.add_option(_("Display Format"),swin)
self.scale = gtk.CheckButton(_('Sc_ale to fit on a single page'))
self.scale.set_active(self.options_dict['singlep'])
@ -495,6 +504,10 @@ class AncestorChartOptions(ReportOptions):
"""
Parses the custom options that we have added.
"""
b = self.extra_textbox.get_buffer()
text_val = unicode(b.get_text(b.get_start_iter(),b.get_end_iter(),False))
self.options_dict['dispf'] = text_val
self.options_dict['maxgen'] = int(self.max_gen.get_value_as_int())
self.options_dict['singlep'] = int(self.scale.get_active ())
self.options_dict['incblank'] = int(self.blank.get_active())
self.options_dict['compress'] = int(self.compress.get_active ())

View File

@ -126,12 +126,10 @@ class DescendChart(Report):
"""
Report.__init__(self,database,person,options_class)
(self.max_generations,self.pgbrk) \
= options_class.get_report_generations()
self.display = options_class.handler.options_dict['dispf']
self.max_generations = options_class.handler.options_dict['maxgen']
self.force_fit = options_class.handler.options_dict['singlep']
self.incblank = options_class.handler.options_dict['incblank']
self.max_gen = options_class.handler.options_dict['maxgen']
name = NameDisplay.displayer.display_formal(person)
self.title = _("Descendant Chart for %s") % name
@ -158,7 +156,7 @@ class DescendChart(Report):
of a line is found, or until we reach the maximum number of
generations that we want to deal with"""
if x/2 >= self.max_gen:
if x/2 >= self.max_generations:
return 0
self.genchart.set_xy(x,y,person_handle)
@ -170,7 +168,7 @@ class DescendChart(Report):
em = self.doc.string_width(self.font,"m")
subst = SubstKeywords(self.database,person_handle)
self.text[(x,y)] = subst.replace_and_clean(self.display)
self.text[(x,y)] = subst.replace_and_clean(self.display.split('\n'))
self.font = self.doc.style_list["DC2-Normal"].get_font()
for line in self.text[(x,y)]:
this_box_width = self.doc.string_width(self.font,line) + 2*em
@ -399,11 +397,19 @@ class DescendChartOptions(ReportOptions):
def set_new_options(self):
# Options specific for this report
self.options_dict = {
'singlep' : 1,
'dispf' : "$n\n%s $b\n%s $d" % (_BORN,_DIED),
'maxgen' : 32,
'singlep' : 1,
'incblank' : 1,
'incblank' : 1,
}
self.options_help = {
'dispf' : ("=str","Display format for the outputbox.",
"Allows you to customize the data in the boxes in the report",
True),
'maxgen' : ("=int","Generations",
"The number of generations to include in the report",
True),
'singlep' : ("=0/1","Whether to scale to fit on a single page.",
["Do not scale to fit","Scale to fit"],
True),
@ -414,21 +420,25 @@ class DescendChartOptions(ReportOptions):
def enable_options(self):
# Semi-common options that should be enabled for this report
self.enable_dict = {
'dispf' : [ "$n", "%s %%b" % _BORN, "%s %%d" % _DIED ],
}
def get_textbox_info(self):
"""Label the textbox and provide the default contents."""
return (_("Display Format"), self.options_dict['dispf'],
_("Allows you to customize the data in the boxes in the report"))
self.enable_dict = {}
def add_user_options(self,dialog):
"""
Override the base class add_user_options task to add a menu that allows
the user to select the sort method.
"""
dialog.get_report_extra_textbox_info = self.get_textbox_info
self.max_gen = gtk.SpinButton(gtk.Adjustment(1,1,100,1))
self.max_gen.set_value(self.options_dict['maxgen'])
dialog.add_option(_('Generations'),self.max_gen)
self.extra_textbox = gtk.TextView()
self.extra_textbox.get_buffer().set_text(self.options_dict['dispf'])
self.extra_textbox.set_editable(1)
swin = gtk.ScrolledWindow()
swin.set_shadow_type(gtk.SHADOW_IN)
swin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
swin.add(self.extra_textbox)
dialog.add_option(_("Display Format"),swin)
self.scale = gtk.CheckButton(_('Sc_ale to fit on a single page'))
self.scale.set_active(self.options_dict['singlep'])
@ -438,18 +448,16 @@ class DescendChartOptions(ReportOptions):
self.blank.set_active(self.options_dict['incblank'])
dialog.add_option('',self.blank)
self.max_gen = gtk.SpinButton(gtk.Adjustment(1,1,100,1))
self.max_gen.set_value(self.options_dict['maxgen'])
dialog.add_option(_('Generations'),self.max_gen)
def parse_user_options(self,dialog):
"""
Parses the custom options that we have added.
"""
b = self.extra_textbox.get_buffer()
text_val = unicode(b.get_text(b.get_start_iter(),b.get_end_iter(),False))
self.options_dict['dispf'] = text_val
self.options_dict['maxgen'] = int(self.max_gen.get_value_as_int())
self.options_dict['singlep'] = int(self.scale.get_active ())
self.options_dict['incblank'] = int(self.blank.get_active())
self.options_dict['maxgen'] = int(self.max_gen.get_value_as_int())
def make_default_style(self,default_style):
"""Make the default output style for the Ancestor Chart report."""