* src/GenericFilter.py: Add a combobox that handles filter

selection
* src/PaperMenu.py: Add combobox classes to handle paper size
and paper orientation selection.
* src/Plugins.py: Add combobox classes to handle draw doc format
and text doc format selection
* src/Report.py: Use new comboboxes
* src/plugins/TimeLine.py: Use new comboboxes

* src/Filter.py: remove - no longer used


svn: r3839
This commit is contained in:
Don Allingham 2004-12-28 00:23:49 +00:00
parent 5f062fccc9
commit ce6192ea46
8 changed files with 363 additions and 348 deletions

View File

@ -1,4 +1,15 @@
2004-12-27 Don Allingham <dallingham@users.sourceforge.net>
* src/GenericFilter.py: Add a combobox that handles filter
selection
* src/PaperMenu.py: Add combobox classes to handle paper size
and paper orientation selection.
* src/Plugins.py: Add combobox classes to handle draw doc format
and text doc format selection
* src/Report.py: Use new comboboxes
* src/plugins/TimeLine.py: Use new comboboxes
2004-12-26 Don Allingham <dallingham@users.sourceforge.net> 2004-12-26 Don Allingham <dallingham@users.sourceforge.net>
* src/Filter.py: remove - no longer used
* src/Report.py: delay importing of GenericFilter * src/Report.py: delay importing of GenericFilter
* src/ReadGedcom.py: create GedcomDateParser class to handle * src/ReadGedcom.py: create GedcomDateParser class to handle
English requirements for GEDCOM English requirements for GEDCOM

View File

@ -147,6 +147,5 @@ def register_datehandler(locales,parse_class,display_class):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from Plugins import load_plugins from Plugins import load_plugins
from const import datesDir from const import datesDir
print "loading",datesDir
load_plugins(datesDir) load_plugins(datesDir)

View File

@ -1,142 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
import re
import os
import sys
import gtk
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# Base filter class
#
#-------------------------------------------------------------------------
class Filter:
def __init__(self,text):
self.text = text
self.invert = 0
def get_text(self):
return self.text
def get_invert(self):
return self.invert
def set_invert(self,invert):
self.invert = invert
def compare(self,person):
val = self.match(person)
if self.invert:
return not val
else:
return val
def get_name(self):
return str(self.__class__)
def match(self,person):
return 1
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
_filter_list = [(Filter, _("All people"), 0, _("Qualifier"))]
_filter2class = {}
_filter2descr = {}
def register_filter(class_name, description=None, qualifier=0, label=None):
name = str(class_name)
if label == None:
label = _("Qualifier")
if description == None:
description = _("No description")
_filter2class[name] = class_name
_filter2descr[name] = description
_filter_list.append((class_name,description,qualifier,label))
def get_filter_description(name):
if _filter2descr.has_key(name):
return _filter2descr[name]
else:
return ""
def make_filter_from_name(name,qualifier,invert):
a = _filter2class[name](qualifier)
a.set_invert(invert)
return a
#-------------------------------------------------------------------------
#
# load_filters - loads all filters in the specfied directory. Assumes
# that the filters will register themselves
#
#-------------------------------------------------------------------------
def load_filters(dir):
pymod = re.compile(r"^(.*)\.py$")
if not os.path.isdir(dir):
return
sys.path.append(dir)
for filename in os.listdir(dir):
name = os.path.split(filename)
match = pymod.match(name[1])
if match:
plugin = match.groups()[0]
try:
__import__(plugin)
except:
print _("Failed to load the module: %s") % plugin
import traceback
traceback.print_exc()
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def build_filter_menu(callback,fw):
myMenu = gtk.Menu()
for filter_obj in _filter_list:
menuitem = gtk.MenuItem(filter_obj[1])
myMenu.append(menuitem)
menuitem.set_data("filter",fw)
menuitem.set_data("name",filter[1])
menuitem.set_data("function",filter[0])
menuitem.set_data("qual",filter[2])
menuitem.set_data("label",filter[3])
menuitem.connect("activate",callback)
menuitem.show()
return myMenu

View File

@ -1598,11 +1598,6 @@ class GenericFilterList:
return l.replace('"','&quot;') return l.replace('"','&quot;')
def save(self): def save(self):
# try:
# f = open(self.file,'w')
# except:
# return
f = open(self.file.encode('utf-8'),'w') f = open(self.file.encode('utf-8'),'w')
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n") f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
@ -1720,6 +1715,60 @@ if not SystemFilters:
if not CustomFilters: if not CustomFilters:
reload_custom_filters() reload_custom_filters()
class GrampsFilterComboBox(gtk.ComboBox):
def set(self,local_filters,default=""):
self.store = gtk.ListStore(str)
self.set_model(self.store)
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
self.map = {}
active = 0
cnt = 0
for filt in local_filters:
self.store.append(row=[filt.get_name()])
self.map[filt.get_name()] = filt
if default != "" and default == filt.get_name():
active = cnt
cnt += 1
for filt in SystemFilters.get_filters():
self.store.append(row=[_(filt.get_name())])
self.map[filt.get_name()] = filt
if default != "" and default == filt.get_name():
active = cnt
cnt += 1
for filt in CustomFilters.get_filters():
self.store.append(row=[_(filt.get_name())])
self.map[filt.get_name()] = filt
if default != "" and default == filt.get_name():
active = cnt
cnt += 1
if active:
self.set_active(active)
elif len(local_filters):
self.set_active(2)
elif len(SystemFilters.get_filters()):
self.set_active(4 + len(local_filters))
elif len(CustomFilters.get_filters()):
self.set_active(6 + len(local_filters) + len(SystemFilters.get_filters()))
else:
self.set_active(0)
def get_value(self):
active = self.get_active()
if active < 0:
return None
key = self.store[active][0]
return self.map[key]
def build_filter_menu(local_filters = [], default=""): def build_filter_menu(local_filters = [], default=""):
menu = gtk.Menu() menu = gtk.Menu()

View File

@ -54,26 +54,65 @@ except:
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
paper_sizes = [] paper_sizes = []
#------------------------------------------------------------------------- class GrampsPaperComboBox(gtk.ComboBox):
#
# make_paper_menu
#
#-------------------------------------------------------------------------
def make_paper_menu(main_menu,default=""):
index = 0 def __init__(self):
myMenu = gtk.Menu() gtk.ComboBox.__init__(self,model=None)
for paper in paper_sizes:
name = paper.get_name() def set(self,mapping,default):
menuitem = gtk.MenuItem(name) self.store = gtk.ListStore(str)
menuitem.set_data("i",paper) self.set_model(self.store)
menuitem.set_data("label",name) cell = gtk.CellRendererText()
menuitem.show() self.pack_start(cell,True)
myMenu.append(menuitem) self.add_attribute(cell,'text',0)
if default == name: self.mapping = {}
myMenu.set_active(index)
index = index + 1 index = 0
main_menu.set_menu(myMenu) start_index = 0
for key in mapping:
self.mapping[key.get_name()] = key
self.store.append(row=[key.get_name()])
if key == default:
start_index = index
index += 1
self.set_active(start_index)
def get_value(self):
active = self.get_active()
if active < 0:
return None
key = self.store[active][0]
return (self.mapping[key],key)
class GrampsOrientationComboBox(gtk.ComboBox):
def __init__(self):
gtk.ComboBox.__init__(self,model=None)
def set(self,default=0):
self.store = gtk.ListStore(str)
self.set_model(self.store)
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
self.mapping = {}
self.store.append(row=[_('Portrait')])
self.store.append(row=[_('Landscape')])
if default == BaseDoc.PAPER_PORTRAIT:
self.set_active(0)
else:
self.set_active(1)
def get_value(self):
active = self.get_active()
if active < 0:
return None
if active == 0:
return BaseDoc.PAPER_PORTRAIT
else:
return BaseDoc.PAPER_LANDSCAPE
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -116,7 +116,8 @@ class PluginDialog:
"""Displays the dialog box that allows the user to select the """Displays the dialog box that allows the user to select the
report that is desired.""" report that is desired."""
def __init__(self,parent,db,active,item_list,msg,label=None,button_label=None,tool_tip=None): def __init__(self,parent,db,active,item_list,msg,label=None,
button_label=None,tool_tip=None):
"""Display the dialog box, and build up the list of available """Display the dialog box, and build up the list of available
reports. This is used to build the selection tree on the left reports. This is used to build the selection tree on the left
hand side of the dailog box.""" hand side of the dailog box."""
@ -844,44 +845,96 @@ def build_tools_menu(top_menu,callback):
# get_text_doc_menu # get_text_doc_menu
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def get_text_doc_menu(main_menu,tables,callback,obj=None,active=None):
index = 0
myMenu = gtk.Menu()
_textdoc.sort()
active_found = False
other_active = None
for item in _textdoc:
if tables and item[2] == 0:
continue
name = item[0]
menuitem = gtk.MenuItem(name)
menuitem.set_data("name",item[1])
menuitem.set_data("label",name)
menuitem.set_data("styles",item[4])
menuitem.set_data("paper",item[3])
menuitem.set_data("ext",item[5])
menuitem.set_data("obj",obj)
menuitem.set_data("printable",item[6])
if callback:
menuitem.connect("activate",callback)
menuitem.show()
myMenu.append(menuitem)
if name == active:
myMenu.set_active(index)
if callback:
callback(menuitem)
active_found = True
elif name == GrampsGconfKeys.get_output_preference():
other_active = index
other_item = menuitem
index = index + 1
if other_active and not active_found: class GrampsDocFormatComboBox(gtk.ComboBox):
myMenu.set_active(index)
if callback:
callback(other_item)
main_menu.set_menu(myMenu) def set(self,tables,callback,obj=None,active=None):
self.store = gtk.ListStore(str)
self.set_model(self.store)
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
out_pref = GrampsGconfKeys.get_output_preference()
index = 0
_textdoc.sort()
active_index = 0
for item in _textdoc:
if tables and item[2] == 0:
continue
name = item[0]
self.store.append(row=[name])
#if callback:
# menuitem.connect("activate",callback)
if name == active:
active_index = index
elif not active and name == out_pref:
active_index = index
index = index + 1
self.set_active(active_index)
def get_label(self):
return _textdoc[self.get_active()][0]
def get_reference(self):
return _textdoc[self.get_active()][1]
def get_paper(self):
return _textdoc[self.get_active()][3]
def get_styles(self):
return _textdoc[self.get_active()][4]
def get_ext(self):
return _textdoc[self.get_active()][5]
def get_printable(self):
return _textdoc[self.get_active()][6]
class GrampsDrawFormatComboBox(gtk.ComboBox):
def set(self,tables,callback,obj=None,active=None):
self.store = gtk.ListStore(str)
self.set_model(self.store)
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
out_pref = GrampsGconfKeys.get_output_preference()
index = 0
_drawdoc.sort()
active_index = 0
for item in _drawdoc:
if tables and item[2] == 0:
continue
name = item[0]
self.store.append(row=[name])
#if callback:
# menuitem.connect("activate",callback)
if name == active:
active_index = index
elif not active and name == out_pref:
active_index = index
index = index + 1
self.set_active(active_index)
def get_reference(self):
return _drawdoc[self.get_active()][1]
def get_label(self):
return _drawdoc[self.get_active()][0]
def get_paper(self):
return _drawdoc[self.get_active()][2]
def get_styles(self):
return _drawdoc[self.get_active()][3]
def get_ext(self):
return _drawdoc[self.get_active()][4]
def get_printable(self):
return _drawdoc[self.get_active()][5]
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -963,45 +1016,6 @@ def get_draw_doc_list():
l.append(item[0]) l.append(item[0])
return l return l
#-------------------------------------------------------------------------
#
# get_draw_doc_menu
#
#-------------------------------------------------------------------------
def get_draw_doc_menu(main_menu,callback=None,obj=None,active=None):
index = 0
myMenu = gtk.Menu()
active_found = False
other_active = None
for (name,classref,paper,styles,ext,printable,clname) in _drawdoc:
menuitem = gtk.MenuItem(name)
menuitem.set_data("name",classref)
menuitem.set_data("label",name)
menuitem.set_data("styles",styles)
menuitem.set_data("paper",paper)
menuitem.set_data("ext",ext)
menuitem.set_data("obj",obj)
menuitem.set_data("printable",printable)
if callback:
menuitem.connect("activate",callback)
menuitem.show()
myMenu.append(menuitem)
if name == active:
myMenu.set_active(index)
if callback:
callback(menuitem)
active_found = True
elif name == GrampsGconfKeys.get_goutput_preference():
other_active = index
other_item = menuitem
index = index + 1
if other_active and not active_found:
myMenu.set_active(index)
if callback:
callback(other_item)
main_menu.set_menu(myMenu)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -1,4 +1,4 @@
#
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2001 David R. Hampton # Copyright (C) 2001 David R. Hampton
@ -107,6 +107,69 @@ def run_print_dialog (filename):
os.environ["FILE"] = filename os.environ["FILE"] = filename
return os.system ('cat "$FILE" | %s &' % get_print_dialog_app ()) return os.system ('cat "$FILE" | %s &' % get_print_dialog_app ())
#-------------------------------------------------------------------------
#
# GrampsStyleComboBox
#
#-------------------------------------------------------------------------
class GrampsStyleComboBox(gtk.ComboBox):
"""
Derived from the ComboBox, this widget provides handling of Report
Styles.
"""
def __init__(self,model=None):
"""
Initializes the combobox, building the display column.
"""
gtk.ComboBox.__init__(self,model)
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
def set(self,style_map,default):
"""
Sets the options for the ComboBox, using the passed style
map as the data.
@param style_map: dictionary of style names and the corresponding
style sheet
@type style_map: dictionary
@param default: Default selection in the ComboBox
@type default: str
"""
self.store = gtk.ListStore(str)
self.set_model(self.store)
self.style_map = style_map
keys = style_map.keys()
keys.sort()
index = 0
start_index = 0
for key in keys:
if key == "default":
self.store.append(row=[_('default')])
else:
self.store.append(row=[key])
if key == default:
start_index = index
index += 1
self.set_active(start_index)
def get_value(self):
"""
Returns the selected key (style sheet name).
@returns: Returns the name of the selected style sheet
@rtype: str
"""
active = self.get_active()
if active < 0:
return None
key = self.store[active][0]
return (key,self.style_map[key])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Report # Report
@ -390,16 +453,6 @@ class BareReportDialog:
# Functions to create a default output style. # Functions to create a default output style.
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# def make_default_style(self):
# """Create the default style to be used by the associated report. This
# routine is a default implementation and should be overridden."""
# font = BaseDoc.FontStyle()
# font.set(face=BaseDoc.FONT_SANS_SERIF,size=16,bold=1)
# para = BaseDoc.ParagraphStyle()
# para.set_font(font)
# para.set_header_level(1)
# para.set(pad=0.5)
# self.default_style.add_style("Title",para)
def build_style_menu(self,default=None): def build_style_menu(self,default=None):
"""Build a menu of style sets that are available for use in """Build a menu of style sets that are available for use in
@ -414,8 +467,7 @@ class BareReportDialog:
default = self.style_name default = self.style_name
style_sheet_map = self.style_sheet_list.get_style_sheet_map() style_sheet_map = self.style_sheet_list.get_style_sheet_map()
myMenu = Utils.build_string_optmenu(style_sheet_map, default) self.style_menu.set(style_sheet_map,default)
self.style_menu.set_menu(myMenu)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -439,7 +491,8 @@ class BareReportDialog:
title = self.get_header(self.name) title = self.get_header(self.name)
label = gtk.Label('<span size="larger" weight="bold">%s</span>' % title) label = gtk.Label('<span size="larger" weight="bold">%s</span>' % title)
label.set_use_markup(gtk.TRUE) label.set_use_markup(gtk.TRUE)
self.window.vbox.pack_start(label,gtk.TRUE,gtk.TRUE,ReportDialog.border_pad) self.window.vbox.pack_start(label, gtk.TRUE, gtk.TRUE,
ReportDialog.border_pad)
def setup_target_frame(self): def setup_target_frame(self):
"""Bare report dialog only uses Doc Options header.""" """Bare report dialog only uses Doc Options header."""
@ -483,7 +536,7 @@ class BareReportDialog:
label = gtk.Label("%s:" % _("Style")) label = gtk.Label("%s:" % _("Style"))
label.set_alignment(0.0,0.5) label.set_alignment(0.0,0.5)
self.style_menu = gtk.OptionMenu() self.style_menu = GrampsStyleComboBox()
self.style_button = gtk.Button("%s..." % _("Style Editor")) self.style_button = gtk.Button("%s..." % _("Style Editor"))
self.style_button.connect('clicked',self.on_style_edit_clicked) self.style_button.connect('clicked',self.on_style_edit_clicked)
@ -559,16 +612,16 @@ class BareReportDialog:
row += 1 row += 1
if len(self.local_filters): if len(self.local_filters):
self.filter_combo = gtk.OptionMenu() self.filter_combo = GenericFilter.GrampsFilterComboBox()
l = gtk.Label("%s:" % _("Filter")) label = gtk.Label("%s:" % _("Filter"))
l.set_alignment(0.0,0.5) label.set_alignment(0.0,0.5)
table.attach(l,1,2,row,row+1,gtk.SHRINK|gtk.FILL,gtk.SHRINK|gtk.FILL) table.attach(label, 1, 2, row, row+1, gtk.SHRINK|gtk.FILL,
table.attach(self.filter_combo,2,3,row,row+1,gtk.SHRINK|gtk.FILL,gtk.SHRINK|gtk.FILL) gtk.SHRINK|gtk.FILL)
menu = GenericFilter.build_filter_menu(self.local_filters) table.attach(self.filter_combo, 2, 3, row, row+1,
gtk.SHRINK|gtk.FILL,gtk.SHRINK|gtk.FILL)
self.filter_combo.set_menu(menu) self.filter_combo.set(self.local_filters)
self.filter_combo.set_history(self.options.handler.get_filter_number()) self.filter_combo.set_active(self.options.handler.get_filter_number())
self.filter_menu = menu
row += 1 row += 1
# Set up the generations spin and page break checkbox # Set up the generations spin and page break checkbox
@ -578,10 +631,12 @@ class BareReportDialog:
adjustment = gtk.Adjustment(self.max_gen,1,31,1,0) adjustment = gtk.Adjustment(self.max_gen,1,31,1,0)
self.generations_spinbox.set_adjustment(adjustment) self.generations_spinbox.set_adjustment(adjustment)
adjustment.value_changed() adjustment.value_changed()
l = gtk.Label("%s:" % _("Generations")) label = gtk.Label("%s:" % _("Generations"))
l.set_alignment(0.0,0.5) label.set_alignment(0.0,0.5)
table.attach(l,1,2,row,row+1,gtk.SHRINK|gtk.FILL,gtk.SHRINK|gtk.FILL) table.attach(label, 1, 2, row, row+1,
table.attach(self.generations_spinbox,2,3,row,row+1,gtk.EXPAND|gtk.FILL,gtk.SHRINK|gtk.FILL) gtk.SHRINK|gtk.FILL, gtk.SHRINK|gtk.FILL)
table.attach(self.generations_spinbox, 2, 3, row, row+1,
gtk.EXPAND|gtk.FILL,gtk.SHRINK|gtk.FILL)
row += 1 row += 1
#if self.page_breaks: #if self.page_breaks:
@ -600,7 +655,8 @@ class BareReportDialog:
self.extra_menu.set_menu(myMenu) self.extra_menu.set_menu(myMenu)
self.extra_menu.set_sensitive(len(extra_map) > 1) self.extra_menu.set_sensitive(len(extra_map) > 1)
self.add_tooltip(self.extra_menu,em_tip) self.add_tooltip(self.extra_menu,em_tip)
table.attach(self.extra_menu_label,1,2,row,row+1,gtk.SHRINK|gtk.FILL) table.attach(self.extra_menu_label, 1, 2, row, row+1,
gtk.SHRINK|gtk.FILL)
table.attach(self.extra_menu,2,3,row,row+1) table.attach(self.extra_menu,2,3,row,row+1)
row += 1 row += 1
@ -621,7 +677,8 @@ class BareReportDialog:
self.extra_textbox.set_editable(1) self.extra_textbox.set_editable(1)
self.add_tooltip(self.extra_textbox,et_tip) self.add_tooltip(self.extra_textbox,et_tip)
table.attach(self.extra_textbox_label,1,2,row,row+1,gtk.SHRINK|gtk.FILL) table.attach(self.extra_textbox_label, 1, 2, row, row+1,
gtk.SHRINK|gtk.FILL)
table.attach(swin,2,3,row,row+1) table.attach(swin,2,3,row,row+1)
row += 1 row += 1
@ -690,9 +747,7 @@ class BareReportDialog:
retrieves a value whether or not the menu is displayed on the retrieves a value whether or not the menu is displayed on the
screen. The subclass will know whether this menu was enabled. screen. The subclass will know whether this menu was enabled.
This is for simplicity of programming.""" This is for simplicity of programming."""
item = self.style_menu.get_menu().get_active() (style_name,self.selected_style) = self.style_menu.get_value()
self.selected_style = item.get_data("d")
style_name = item.get_data('l')
self.options.handler.set_default_stylesheet_name(style_name) self.options.handler.set_default_stylesheet_name(style_name)
def parse_report_options_frame(self): def parse_report_options_frame(self):
@ -717,8 +772,9 @@ class BareReportDialog:
self.options.handler.set_report_generations(self.max_gen,self.pg_brk) self.options.handler.set_report_generations(self.max_gen,self.pg_brk)
if self.filter_combo: if self.filter_combo:
self.filter = self.filter_menu.get_active().get_data("filter") self.filter = self.filter_combo.get_value()
self.options.handler.set_filter_number(self.filter_combo.get_history()) active = self.filter_combo.get_active()
self.options.handler.set_filter_number(active)
else: else:
self.filter = None self.filter = None
@ -819,7 +875,8 @@ class ReportDialog(BareReportDialog):
for a basic *stand-alone* report.""" for a basic *stand-alone* report."""
self.style_name = "default" self.style_name = "default"
BareReportDialog.__init__(self,database,person,option_class,name,translated_name) BareReportDialog.__init__(self,database,person,option_class,
name,translated_name)
# Allow for post processing of the format frame, since the # Allow for post processing of the format frame, since the
# show_all task calls events that may reset values # show_all task calls events that may reset values
@ -827,12 +884,9 @@ class ReportDialog(BareReportDialog):
def init_interface(self): def init_interface(self):
BareReportDialog.init_interface(self) BareReportDialog.init_interface(self)
if self.format_menu: if self.format_menu:
self.doc_type_changed(self.format_menu.get_menu().get_active()) self.doc_type_changed(self.format_menu)
self.setup_post_process() self.setup_post_process()
# def on_cancel(self,*obj):
# self.window.destroy()
def setup_post_process(self): def setup_post_process(self):
pass pass
@ -912,7 +966,7 @@ class ReportDialog(BareReportDialog):
this report. This menu will be generated based upon the type this report. This menu will be generated based upon the type
of document (text, draw, graph, etc. - a subclass), whether or of document (text, draw, graph, etc. - a subclass), whether or
not the document requires table support, etc.""" not the document requires table support, etc."""
pass return None
def make_document(self): def make_document(self):
"""Create a document of the type requested by the user.""" """Create a document of the type requested by the user."""
@ -931,7 +985,7 @@ class ReportDialog(BareReportDialog):
paper size/orientation options, but it does need a template paper size/orientation options, but it does need a template
file. Those chances are made here.""" file. Those chances are made here."""
label = obj.get_data("printable") label = obj.get_printable()
if label: if label:
self.print_report.set_label (label) self.print_report.set_label (label)
self.print_report.set_sensitive (gtk.TRUE) self.print_report.set_sensitive (gtk.TRUE)
@ -942,7 +996,7 @@ class ReportDialog(BareReportDialog):
# Is this to be a printed report or an electronic report # Is this to be a printed report or an electronic report
# (i.e. a set of web pages) # (i.e. a set of web pages)
if obj.get_data("paper") == 1: if obj.get_paper() == 1:
self.notebook_page = 0 self.notebook_page = 0
else: else:
self.notebook_page = 1 self.notebook_page = 1
@ -956,15 +1010,15 @@ class ReportDialog(BareReportDialog):
fname = self.target_fileentry.get_full_path(0) fname = self.target_fileentry.get_full_path(0)
(spath,ext) = os.path.splitext(fname) (spath,ext) = os.path.splitext(fname)
ext_val = obj.get_data('ext') ext_val = obj.get_ext()
if ext_val: if ext_val:
fname = spath + ext_val fname = spath + ext_val
self.target_fileentry.set_filename(fname) self.target_fileentry.set_filename(fname)
# Does this report format use styles? # Does this report format use styles?
if self.style_button: if self.style_button:
self.style_button.set_sensitive(obj.get_data("styles")) self.style_button.set_sensitive(obj.get_styles())
self.style_menu.set_sensitive(obj.get_data("styles")) self.style_menu.set_sensitive(obj.get_styles())
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -1019,19 +1073,18 @@ class ReportDialog(BareReportDialog):
self.tbl.attach(self.print_report,2,4,self.col,self.col+1) self.tbl.attach(self.print_report,2,4,self.col,self.col+1)
self.col += 1 self.col += 1
self.format_menu = gtk.OptionMenu()
self.make_doc_menu(self.options.handler.get_format_name()) self.make_doc_menu(self.options.handler.get_format_name())
self.format_menu.connect('changed',self.doc_type_changed)
label = gtk.Label("%s:" % _("Output Format")) label = gtk.Label("%s:" % _("Output Format"))
label.set_alignment(0.0,0.5) label.set_alignment(0.0,0.5)
self.tbl.attach(label,1,2,self.col,self.col+1,gtk.SHRINK|gtk.FILL) self.tbl.attach(label,1,2,self.col,self.col+1,gtk.SHRINK|gtk.FILL)
self.tbl.attach(self.format_menu,2,4,self.col,self.col+1) self.tbl.attach(self.format_menu,2,4,self.col,self.col+1)
self.col += 1 self.col += 1
mtype = self.format_menu.get_menu().get_active() ext = self.format_menu.get_ext()
ext = mtype.get_data('ext')
if ext == None: if ext == None:
ext = "" ext = ""
if mtype: else:
spath = self.get_default_directory() spath = self.get_default_directory()
if self.get_target_is_directory(): if self.get_target_is_directory():
self.target_fileentry.set_filename(spath) self.target_fileentry.set_filename(spath)
@ -1040,7 +1093,6 @@ class ReportDialog(BareReportDialog):
spath = os.path.normpath("%s/%s%s" % (spath,base,ext)) spath = os.path.normpath("%s/%s%s" % (spath,base,ext))
self.target_fileentry.set_filename(spath) self.target_fileentry.set_filename(spath)
def setup_output_notebook(self): def setup_output_notebook(self):
"""Set up the output notebook of the dialog. This sole """Set up the output notebook of the dialog. This sole
purpose of this function is to grab a pointer for later use in purpose of this function is to grab a pointer for later use in
@ -1054,7 +1106,7 @@ class ReportDialog(BareReportDialog):
self.window.vbox.add(self.output_notebook) self.window.vbox.add(self.output_notebook)
def size_changed(self,obj): def size_changed(self,obj):
paper = self.papersize_menu.get_menu().get_active().get_data('i') (paper,name) = self.papersize_menu.get_value()
if paper.get_width() <= 0: if paper.get_width() <= 0:
self.pwidth.set_sensitive(1) self.pwidth.set_sensitive(1)
self.pheight.set_sensitive(1) self.pheight.set_sensitive(1)
@ -1064,7 +1116,6 @@ class ReportDialog(BareReportDialog):
self.pwidth.set_text("%.2f" % paper.get_width()) self.pwidth.set_text("%.2f" % paper.get_width())
self.pheight.set_text("%.2f" % paper.get_height()) self.pheight.set_text("%.2f" % paper.get_height())
def setup_paper_frame(self): def setup_paper_frame(self):
"""Set up the paper selection frame of the dialog. This """Set up the paper selection frame of the dialog. This
function relies on a paper_xxx() customization functions to function relies on a paper_xxx() customization functions to
@ -1087,10 +1138,10 @@ class ReportDialog(BareReportDialog):
paper_label.set_alignment(0.0,0.5) paper_label.set_alignment(0.0,0.5)
self.paper_table.attach(paper_label,0,6,0,1,gtk.SHRINK|gtk.FILL) self.paper_table.attach(paper_label,0,6,0,1,gtk.SHRINK|gtk.FILL)
self.papersize_menu = gtk.OptionMenu() self.papersize_menu = PaperMenu.GrampsPaperComboBox()
self.papersize_menu.connect('changed',self.size_changed) self.papersize_menu.connect('changed',self.size_changed)
self.orientation_menu = gtk.OptionMenu() self.orientation_menu = PaperMenu.GrampsOrientationComboBox()
l = gtk.Label("%s:" % _("Size")) l = gtk.Label("%s:" % _("Size"))
l.set_alignment(0.0,0.5) l.set_alignment(0.0,0.5)
@ -1124,12 +1175,9 @@ class ReportDialog(BareReportDialog):
l.set_alignment(0.0,0.5) l.set_alignment(0.0,0.5)
self.paper_table.attach(l,5,6,2,3,gtk.SHRINK|gtk.FILL) self.paper_table.attach(l,5,6,2,3,gtk.SHRINK|gtk.FILL)
PaperMenu.make_paper_menu(self.papersize_menu, self.papersize_menu.set(PaperMenu.paper_sizes,
self.options.handler.get_paper_name() self.options.handler.get_paper_name())
) self.orientation_menu.set(self.options.handler.get_orientation())
PaperMenu.make_orientation_menu(self.orientation_menu,
self.options.handler.get_orientation()
)
# The optional pagecount stuff. # The optional pagecount stuff.
if pagecount_map: if pagecount_map:
@ -1141,9 +1189,9 @@ class ReportDialog(BareReportDialog):
self.paper_table.attach(l,1,2,3,4,gtk.SHRINK|gtk.FILL) self.paper_table.attach(l,1,2,3,4,gtk.SHRINK|gtk.FILL)
self.paper_table.attach(self.pagecount_menu,2,3,3,4) self.paper_table.attach(self.pagecount_menu,2,3,3,4)
def html_file_enable(self,obj): def html_file_enable(self,obj):
text = unicode(obj.get_text()) active = obj.get_active()
text = unicode(obj.get_model()[active][0])
if _template_map.has_key(text): if _template_map.has_key(text):
if _template_map[text]: if _template_map[text]:
self.html_fileentry.set_sensitive(0) self.html_fileentry.set_sensitive(0)
@ -1167,35 +1215,32 @@ class ReportDialog(BareReportDialog):
html_label.set_use_markup(gtk.TRUE) html_label.set_use_markup(gtk.TRUE)
self.html_table.attach(html_label,0,3,0,1) self.html_table.attach(html_label,0,3,0,1)
self.output_notebook.append_page(self.html_table,gtk.Label(_("HTML Options"))) label = gtk.Label(_("HTML Options"))
self.output_notebook.append_page(self.html_table,label)
l = gtk.Label("%s:" % _("Template")) label = gtk.Label("%s:" % _("Template"))
l.set_alignment(0.0,0.5) label.set_alignment(0.0,0.5)
self.html_table.attach(l,1,2,1,2,gtk.SHRINK|gtk.FILL) self.html_table.attach(label, 1, 2, 1, 2, gtk.SHRINK|gtk.FILL)
self.template_combo = gtk.Combo() self.template_combo = gtk.combo_box_new_text()
template_list = [ _default_template ]
tlist = _template_map.keys() tlist = _template_map.keys()
tlist.sort() tlist.sort()
self.template_combo.append_text(_default_template)
for template in tlist: for template in tlist:
if template != _user_template: if template != _user_template:
template_list.append(template) self.template_combo.append_text(template)
template_list.append(_user_template) self.template_combo.append_text(_user_template)
self.template_combo.set_popdown_strings(template_list) self.template_combo.set_active(0)
self.template_combo.entry.set_editable(0) self.template_combo.connect('changed',self.html_file_enable)
def_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) self.html_table.attach(self.template_combo,2,3,1,2)
l = gtk.Label("%s:" % _("User Template")) label = gtk.Label("%s:" % _("User Template"))
l.set_alignment(0.0,0.5) label.set_alignment(0.0,0.5)
self.html_table.attach(l,1,2,2,3,gtk.SHRINK|gtk.FILL) self.html_table.attach(label, 1, 2, 2, 3, gtk.SHRINK|gtk.FILL)
self.html_fileentry = gnome.ui.FileEntry("HTML_Template",_("Choose File")) self.html_fileentry = gnome.ui.FileEntry("HTML_Template",
_("Choose File"))
self.html_fileentry.set_modal(True) self.html_fileentry.set_modal(True)
self.html_fileentry.set_sensitive(0) self.html_fileentry.set_sensitive(0)
user_template = '' user_template = ''
@ -1242,8 +1287,8 @@ class ReportDialog(BareReportDialog):
def parse_format_frame(self): def parse_format_frame(self):
"""Parse the format frame of the dialog. Save the user """Parse the format frame of the dialog. Save the user
selected output format for later use.""" selected output format for later use."""
self.format = self.format_menu.get_menu().get_active().get_data("name") self.format = self.format_menu.get_reference()
format_name = self.format_menu.get_menu().get_active().get_data("label") format_name = self.format_menu.get_label()
self.options.handler.set_format_name(format_name) self.options.handler.set_format_name(format_name)
def parse_paper_frame(self): def parse_paper_frame(self):
@ -1252,8 +1297,9 @@ class ReportDialog(BareReportDialog):
retrieves a value from the pagecount menu, whether or not it retrieves a value from the pagecount menu, whether or not it
is displayed on the screen. The subclass will know which ones is displayed on the screen. The subclass will know which ones
it has enabled. This is for simplicity of programming.""" it has enabled. This is for simplicity of programming."""
self.paper = self.papersize_menu.get_menu().get_active().get_data("i")
paper_name = self.papersize_menu.get_menu().get_active().get_data("label") (self.paper,paper_name) = self.papersize_menu.get_value()
self.options.handler.set_paper_name(paper_name) self.options.handler.set_paper_name(paper_name)
if self.paper.get_height() <= 0 or self.paper.get_width() <= 0: if self.paper.get_height() <= 0 or self.paper.get_width() <= 0:
@ -1271,7 +1317,7 @@ class ReportDialog(BareReportDialog):
self.paper.set_height(29.7) self.paper.set_height(29.7)
self.paper.set_width(21.0) self.paper.set_width(21.0)
self.orien = self.orientation_menu.get_menu().get_active().get_data("i") self.orien = self.orientation_menu.get_value()
self.options.handler.set_orientation(self.orien) self.options.handler.set_orientation(self.orien)
if self.pagecount_menu == None: if self.pagecount_menu == None:
@ -1286,7 +1332,10 @@ class ReportDialog(BareReportDialog):
displayed on the screen. The subclass will know whether this displayed on the screen. The subclass will know whether this
entry was enabled. This is for simplicity of programming.""" entry was enabled. This is for simplicity of programming."""
text = unicode(self.template_combo.entry.get_text()) model = self.template_combo.get_model()
text = unicode(model[self.template_combo.get_active()][0])
#text = unicode(self.template_combo.entry.get_text())
if _template_map.has_key(text): if _template_map.has_key(text):
if text == _user_template: if text == _user_template:
self.template_name = self.html_fileentry.get_full_path(0) self.template_name = self.html_fileentry.get_full_path(0)
@ -1361,8 +1410,9 @@ class TextReportDialog(ReportDialog):
"""Build a menu of document types that are appropriate for """Build a menu of document types that are appropriate for
this text report. This menu will be generated based upon this text report. This menu will be generated based upon
whether the document requires table support, etc.""" whether the document requires table support, etc."""
Plugins.get_text_doc_menu(self.format_menu, self.doc_uses_tables(), self.format_menu = Plugins.GrampsDocFormatComboBox()
self.doc_type_changed, None, active) self.format_menu.set(self.doc_uses_tables(),
self.doc_type_changed, None, active)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -1395,8 +1445,9 @@ class DrawReportDialog(ReportDialog):
def make_doc_menu(self,active=None): def make_doc_menu(self,active=None):
"""Build a menu of document types that are appropriate for """Build a menu of document types that are appropriate for
this drawing report.""" this drawing report."""
Plugins.get_draw_doc_menu(self.format_menu,self.doc_type_changed, self.format_menu = Plugins.GrampsDrawFormatComboBox()
None, active) self.format_menu.set(False,self.doc_type_changed, None, active)
class TemplateParser(handler.ContentHandler): class TemplateParser(handler.ContentHandler):
""" """

View File

@ -463,21 +463,15 @@ class TimeLineOptions(ReportOptions.ReportOptions):
the user to select the sort method. the user to select the sort method.
""" """
sort_style = gtk.OptionMenu() self.sort_menu = gtk.combo_box_new_text()
self.sort_menu = gtk.Menu()
sort_functions = self.get_sort_functions(Sort.Sort(dialog.db)) sort_functions = self.get_sort_functions(Sort.Sort(dialog.db))
for item_index in range(len(sort_functions)): for item in sort_functions:
item = sort_functions[item_index] self.sort_menu.append_text(item[0])
menuitem = gtk.MenuItem(item[0])
menuitem.set_data('index',item_index)
menuitem.show()
self.sort_menu.append(menuitem)
sort_style.set_menu(self.sort_menu) self.sort_menu.set_active(self.options_dict['sortby'])
sort_style.set_history(self.options_dict['sortby'])
dialog.add_option(_('Sort by'),sort_style) dialog.add_option(_('Sort by'),self.sort_menu)
self.title_box = gtk.Entry() self.title_box = gtk.Entry()
if self.options_dict['title']: if self.options_dict['title']:
@ -492,7 +486,7 @@ class TimeLineOptions(ReportOptions.ReportOptions):
Parses the custom options that we have added. Parses the custom options that we have added.
""" """
self.options_dict['title'] = unicode(self.title_box.get_text()) self.options_dict['title'] = unicode(self.title_box.get_text())
self.options_dict['sortby'] = self.sort_menu.get_active().get_data('index') self.options_dict['sortby'] = self.sort_menu.get_active()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #