removal of u2l, papersizes read from XML file

svn: r1194
This commit is contained in:
Don Allingham 2002-11-19 04:15:02 +00:00
parent a3708b62dc
commit af2fb7180c
10 changed files with 167 additions and 126 deletions

View File

@ -54,10 +54,11 @@ class DisplayTrace:
def __init__(self):
data = sys.exc_info()
msg = cStringIO.StringIO()
msg.write(_('GRAMPS has encountered an internal error.\n'
msg.write(_('GRAMPS %s has encountered an internal error.\n'
'Please copy the message below and post a bug report '
'at http://sourceforge.net/projects/gramps or send an '
'email message to gramps-users@lists.sourceforge.net\n\n'))
'email message to gramps-users@lists.sourceforge.net\n\n')
% const.version)
traceback.print_exception(data[0],data[1],data[2],None,msg)

View File

@ -19,8 +19,6 @@
#
import const
from latin_utf8 import utf8_to_latin
u2l = utf8_to_latin
ADOPT_NONE = 0
ADOPT_EVENT = 1
@ -175,15 +173,13 @@ class GedInfoParser:
p.ParseFile(file)
def startElement(self,tag,attrs):
tag = u2l(tag)
if tag == "target":
name = u2l(attrs['name'])
name = attrs['name']
self.current = GedcomDescription(name)
self.parent.add_description(name,self.current)
elif tag == "dest":
self.current.set_dest(u2l(attrs['val']))
self.current.set_dest(attrs['val'])
elif tag == "adopt":
val = u2l(attrs['val'])
if val == 'none':
self.current.set_adopt(ADOPT_NONE)
elif val == 'event':
@ -195,10 +191,9 @@ class GedInfoParser:
elif val == 'pedigree':
self.current.set_adopt(ADOPT_PEDI)
elif tag == "conc":
if u2l(attrs['val']) == 'broken':
if attrs['val'] == 'broken':
self.current.set_conc(CONC_BROKEN)
elif tag == "alternate_names":
val = u2l(attrs['val'])
if val == 'none':
self.current.set_alt_name(ALT_NAME_NONE)
elif val == 'event_aka':
@ -210,13 +205,13 @@ class GedInfoParser:
elif val == '_alias':
self.current.set_alt_name(ALT_NAME_UALIAS)
elif tag == "calendars":
if u2l(attrs['val']) == 'no':
if attrs['val'] == 'no':
self.current.set_alt_calendar(CALENDAR_NO)
elif tag == "event":
self.current.add_tag_value(u2l(attrs['tag']),u2l(attrs['value']))
self.current.add_tag_value(attrs['tag'],attrs['value'])
elif tag == "object_support":
if u2l(attrs['val']) == 'no':
if attrs['val'] == 'no':
self.current.set_obje(OBJE_NO)
elif tag == "residence":
if u2l(attrs['val']) == 'place':
if attrs['val'] == 'place':
self.current.set_resi(RESIDENCE_PLAC)

View File

@ -41,9 +41,6 @@ import os
from string import find,join,strip,replace
import gtk
from latin_utf8 import utf8_to_latin
u2l = utf8_to_latin
#-------------------------------------------------------------------------
#
# GRAMPS modules
@ -777,32 +774,30 @@ class FilterParser(handler.ContentHandler):
def startElement(self,tag,attrs):
if tag == "filter":
self.f = GenericFilter()
self.f.set_name(u2l(attrs['name']))
self.f.set_name(attrs['name'])
if attrs.has_key('function'):
try:
if int(u2l(attrs['function'])):
if int(attrs['function']):
op = 'or'
else:
op = 'and'
except ValueError:
op = u2l(attrs['function'])
op = attrs['function']
self.f.set_logical_op(op)
if attrs.has_key('comment'):
self.f.set_comment(u2l(attrs['comment']))
self.f.set_comment(attrs['comment'])
if attrs.has_key('invert'):
try:
self.f.set_invert(int(u2l(attrs['invert'])))
self.f.set_invert(int(attrs['invert']))
except ValueError:
pass
self.gfilter_list.add(self.f)
elif tag == "rule":
c = attrs['class']
name = _(u2l(c))
name = _(attrs['class'])
self.a = []
self.cname = tasks[name]
elif tag == "arg":
c = attrs['value']
self.a.append(u2l(c))
self.a.append(attrs['value'])
def endElement(self,tag):
if tag == "rule":

View File

@ -28,7 +28,6 @@ class ListModel:
self.mylist = [TYPE_STRING]*l + [TYPE_PYOBJECT]
self.new_model()
self.connect_model()
self.selection = self.tree.get_selection()
@ -45,17 +44,21 @@ class ListModel:
else:
column.set_resizable(gtk.TRUE)
cnum = cnum + 1
tree.append_column(column)
self.tree.append_column(column)
self.column = None
num = 0
for name in dlist:
column = tree.get_column(num)
column = self.tree.get_column(num)
if name[1] != -1:
column.set_sort_column_id(name[1])
if num == 0:
column.clicked()
num = num + 1
if not self.column:
self.column = column
num = num + 1
self.connect_model()
self.column.clicked()
if select_func:
self.selection.connect('changed',select_func)
if event_func:
@ -67,6 +70,7 @@ class ListModel:
def connect_model(self):
self.tree.set_model(self.model)
self.column.clicked()
def get_selected(self):
return self.selection.get_selected()

View File

@ -18,26 +18,45 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import TextDoc
#-------------------------------------------------------------------------
#
# GNOME modules
#
#-------------------------------------------------------------------------
import gtk
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import TextDoc
import GrampsCfg
import const
from intl import gettext as _
from intl import gettext
_ = gettext
#-------------------------------------------------------------------------
#
# Try to abstract SAX1 from SAX2
#
#-------------------------------------------------------------------------
try:
from xml.sax import make_parser,handler,SAXParseException
except:
from _xmlplus.sax import make_parser,handler,SAXParseException
paper_sizes = [
TextDoc.PaperStyle("Letter",27.94,21.59),
TextDoc.PaperStyle("Legal",35.56,21.59),
TextDoc.PaperStyle("A3",42.0,29.7),
TextDoc.PaperStyle("A4",29.7,21.0),
TextDoc.PaperStyle("A5",21.0,14.8),
TextDoc.PaperStyle("B4",35.3,25.0),
TextDoc.PaperStyle("B6",17.6,12.5),
TextDoc.PaperStyle("C4",32.4,22.9),
TextDoc.PaperStyle("C5",22.9,16.2),
TextDoc.PaperStyle("C6",16.2,11.4)
]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
paper_sizes = []
#-------------------------------------------------------------------------
#
# make_paper_menu
#
#-------------------------------------------------------------------------
def make_paper_menu(main_menu):
index = 0
@ -53,6 +72,11 @@ def make_paper_menu(main_menu):
index = index + 1
main_menu.set_menu(myMenu)
#-------------------------------------------------------------------------
#
# make_orientation_menu
#
#-------------------------------------------------------------------------
def make_orientation_menu(main_menu):
myMenu = gtk.Menu()
@ -68,3 +92,46 @@ def make_orientation_menu(main_menu):
main_menu.set_menu(myMenu)
#-------------------------------------------------------------------------
#
# FilterParser
#
#-------------------------------------------------------------------------
class PageSizeParser(handler.ContentHandler):
"""Parses the XML file and builds the list of page sizes"""
def __init__(self,paper_list):
handler.ContentHandler.__init__(self)
self.paper_list = paper_list
def setDocumentLocator(self,locator):
self.locator = locator
def startElement(self,tag,attrs):
if tag == "page":
name = attrs['name']
height = float(attrs['height'])
width = float(attrs['width'])
self.paper_list.append(TextDoc.PaperStyle(name,height,width))
#-------------------------------------------------------------------------
#
# Parse XML file. If failed, used default
#
#-------------------------------------------------------------------------
try:
parser = make_parser()
parser.setContentHandler(PageSizeParser(paper_sizes))
parser.parse(const.papersize)
except (IOError,OSError,SAXParseException):
paper_sizes = [
TextDoc.PaperStyle("Letter",27.94,21.59),
TextDoc.PaperStyle("Legal",35.56,21.59),
TextDoc.PaperStyle("A4",29.7,21.0),
TextDoc.PaperStyle("A5",21.0,14.8),
TextDoc.PaperStyle("B4",35.3,25.0),
TextDoc.PaperStyle("B6",17.6,12.5),
TextDoc.PaperStyle("C4",32.4,22.9),
TextDoc.PaperStyle("C5",22.9,16.2),
TextDoc.PaperStyle("C6",16.2,11.4)
]

View File

@ -52,11 +52,7 @@ import TextDoc
import StyleEditor
import GrampsCfg
import PaperMenu
import intl
import latin_utf8
u2l = latin_utf8.utf8_to_latin
_ = intl.gettext
from intl import gettext as _
from QuestionDialog import ErrorDialog
@ -1077,7 +1073,7 @@ class TemplateParser(handler.ContentHandler):
"""
if tag == "template":
self.data[u2l(attrs['title'])] = u2l(attrs['file'])
self.data[attrs['title']] = attrs['file']
try:
parser = make_parser()

View File

@ -30,8 +30,7 @@ import os
# internationalization
#
#-------------------------------------------------------------------------
from intl import gettext
_ = gettext
from intl import gettext as _
#-------------------------------------------------------------------------
#
@ -61,6 +60,7 @@ good_xpm = "%s/good.xpm" % rootDir
bad_xpm = "%s/bad.xpm" % rootDir
caution_xpm = "%s/caution.xpm" % rootDir
papersize = "%s/papersize.xml" % rootDir
system_filters = "%s/system_filters.xml" % rootDir
custom_filters = "~/.gramps/custom_filters.xml"
icon = "%s/gramps.xpm" % rootDir

14
gramps2/src/papersize.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<paper>
<page name="Letter" height="27.94" width="21.59"/>
<page name="Legal" height="35.56" width="21.59"/>
<page name="Banana" height="42.0" width="29.7"/>
<page name="A3" height="42.0" width="29.7"/>
<page name="A4" height="29.7" width="21.0"/>
<page name="A5" height="21.0" width="14.8"/>
<page name="B4" height="35.3" width="25.0"/>
<page name="B6" height="17.6" width="12.5"/>
<page name="C4" height="32.4" width="22.9"/>
<page name="C5" height="22.9" width="16.2"/>
<page name="C6" height="16.2" width="11.4"/>
</paper>

View File

@ -20,18 +20,33 @@
"Utilities/Relationship calculator"
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
import os
#-------------------------------------------------------------------------
#
# GNOME libraries
#
#-------------------------------------------------------------------------
from gtk import *
from gnome.ui import *
import gtk.glade
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import RelLib
import sort
import intl
import Utils
_ = intl.gettext
import ListModel
from intl import gettext as _
#-------------------------------------------------------------------------
#
@ -297,7 +312,7 @@ class RelCalc:
self.db = database
base = os.path.dirname(__file__)
glade_file = base + os.sep + "relcalc.glade"
glade_file = "%s/relcalc.glade" % base
self.glade = gtk.glade.XML(glade_file,"relcalc")
name = self.person.getPrimaryName().getRegularName()
@ -305,18 +320,16 @@ class RelCalc:
self.glade.get_widget("name").set_text(_("Relationship to %s") % name)
self.people = self.glade.get_widget("peopleList")
name_list = self.db.getPersonMap().values()
name_list.sort(sort.by_last_name)
index = 0
self.people.freeze()
for p in name_list:
name = p.getPrimaryName().getName()
birthday = p.getBirth().getDate()
id = p.getId()
self.people.append([name,id,birthday])
self.people.set_row_data(index,p)
index = index + 1
self.people.thaw()
self.clist = ListModel.ListModel(self.people, [(_('Name'),3,150),(_('ID'),1,50),
(_('Birthday'),4,150),
('',-1,0),('',-1,0)])
self.clist.new_model()
for key in self.db.getPersonKeys():
p = self.db.getPerson(key)
val = self.db.getPersonDisplay(key)
self.clist.add([val[0],val[1],val[3],val[5],val[6]],p.getId())
self.clist.connect_model()
self.glade.signal_autoconnect({
"on_close_clicked" : Utils.destroy_passed_object,
@ -331,10 +344,12 @@ class RelCalc:
common = []
rank = 9999999
if len(self.people.selection) == 0:
model,iter = self.clist.get_selected()
if not iter:
return
other_person = self.people.get_row_data(self.people.selection[0])
id = self.clist.get_object(iter)
other_person = self.db.getPerson(id)
filter(self.person,0,firstList,firstMap)
filter(other_person,0,secondList,secondMap)

View File

@ -108,59 +108,13 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkCList" id="peopleList">
<widget class="GtkTreeView" id="peopleList">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="n_columns">3</property>
<property name="column_widths">236,56,80</property>
<property name="selection_mode">GTK_SELECTION_SINGLE</property>
<property name="show_titles">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkLabel" id="label9">
<property name="label" translatable="yes">Name</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label10">
<property name="label" translatable="yes">ID</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="label" translatable="yes">Birthday</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
<property name="headers_visible">True</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>