fix typo
svn: r6291
This commit is contained in:
parent
790de99bf9
commit
a96333aa24
211
src/BaseDoc.py
211
src/BaseDoc.py
@ -58,7 +58,7 @@ interfaces should be derived from the core classes.
|
||||
"""
|
||||
|
||||
__author__ = "Donald N. Allingham"
|
||||
__version__ = "Revision:$Id$"
|
||||
__revision__ = "Revision:$Id$"
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -101,33 +101,41 @@ except:
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
FONT_SANS_SERIF = 0
|
||||
FONT_SERIF = 1
|
||||
FONT_MONOSPACE = 2
|
||||
FONT_SERIF = 1
|
||||
FONT_MONOSPACE = 2
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Page orientation
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
PAPER_PORTRAIT = 0
|
||||
PAPER_LANDSCAPE = 1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Paragraph alignment
|
||||
#
|
||||
PARA_ALIGN_CENTER = 0
|
||||
PARA_ALIGN_LEFT = 1
|
||||
PARA_ALIGN_RIGHT = 2
|
||||
PARA_ALIGN_JUSTIFY= 3
|
||||
#-------------------------------------------------------------------------
|
||||
PARA_ALIGN_CENTER = 0
|
||||
PARA_ALIGN_LEFT = 1
|
||||
PARA_ALIGN_RIGHT = 2
|
||||
PARA_ALIGN_JUSTIFY = 3
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Text vs. Graphics mode
|
||||
#
|
||||
TEXT_MODE = 0
|
||||
#-------------------------------------------------------------------------
|
||||
TEXT_MODE = 0
|
||||
GRAPHICS_MODE = 1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Line style
|
||||
#
|
||||
SOLID = 0
|
||||
#-------------------------------------------------------------------------
|
||||
SOLID = 0
|
||||
DASHED = 1
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -140,10 +148,7 @@ def cnv2color(text):
|
||||
converts a hex value in the form of #XXXXXX into a tuple of integers
|
||||
representing the RGB values
|
||||
"""
|
||||
c0 = int(text[1:3], 16)
|
||||
c1 = int(text[3:5], 16)
|
||||
c2 = int(text[5:7], 16)
|
||||
return (c0, c1, c2)
|
||||
return (int(text[1:3], 16), int(text[3:5], 16), int(text[5:7], 16))
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -548,13 +553,19 @@ class ParagraphStyle:
|
||||
self.right_border = 0
|
||||
self.left_border = 0
|
||||
self.pad = 0
|
||||
self.bgcolor = (255,255,255)
|
||||
self.bgcolor = (255, 255, 255)
|
||||
self.description = ""
|
||||
|
||||
def set_description(self, text):
|
||||
"""
|
||||
Sets the desciption of the paragraph
|
||||
"""
|
||||
self.description = text
|
||||
|
||||
def get_description(self):
|
||||
"""
|
||||
Returns the desciption of the paragraph
|
||||
"""
|
||||
return self.description
|
||||
|
||||
def set(self, rmargin=None, lmargin=None, first_indent=None,
|
||||
@ -681,7 +692,7 @@ class ParagraphStyle:
|
||||
"Returns 1 if a left border is specified"
|
||||
return self.left_border
|
||||
|
||||
def set_right_border(self ,val):
|
||||
def set_right_border(self, val):
|
||||
"""
|
||||
Sets the presence or absence of rigth border.
|
||||
|
||||
@ -800,7 +811,7 @@ class StyleSheetList:
|
||||
"""
|
||||
defstyle.set_name('default')
|
||||
self.map = { "default" : defstyle }
|
||||
self.file = os.path.join(const.home_dir,filename)
|
||||
self.file = os.path.join(const.home_dir, filename)
|
||||
self.parse()
|
||||
|
||||
def delete_style_sheet(self, name):
|
||||
@ -846,48 +857,49 @@ class StyleSheetList:
|
||||
"""
|
||||
Saves the current StyleSheet definitions to the associated file.
|
||||
"""
|
||||
f = open(self.file,"w")
|
||||
f.write("<?xml version=\"1.0\"?>\n")
|
||||
f.write('<stylelist>\n')
|
||||
xml_file = open(self.file,"w")
|
||||
xml_file.write("<?xml version=\"1.0\"?>\n")
|
||||
xml_file.write('<stylelist>\n')
|
||||
for name in self.map.keys():
|
||||
if name == "default":
|
||||
continue
|
||||
sheet = self.map[name]
|
||||
f.write('<sheet name="%s">\n' % name)
|
||||
xml_file.write('<sheet name="%s">\n' % name)
|
||||
for p_name in sheet.get_names():
|
||||
p = sheet.get_style(p_name)
|
||||
f.write('<style name="%s">\n' % p_name)
|
||||
font = p.get_font()
|
||||
f.write('<font face="%d" ' % font.get_type_face())
|
||||
f.write('size="%d" ' % font.get_size())
|
||||
f.write('italic="%d" ' % font.get_italic())
|
||||
f.write('bold="%d" ' % font.get_bold())
|
||||
f.write('underline="%d" ' % font.get_underline())
|
||||
f.write('color="#%02x%02x%02x"/>\n' % font.get_color())
|
||||
f.write('<para ')
|
||||
rm = float(p.get_right_margin())
|
||||
lm = float(p.get_left_margin())
|
||||
fi = float(p.get_first_indent())
|
||||
tm = float(p.get_top_margin())
|
||||
bm = float(p.get_bottom_margin())
|
||||
pa = float(p.get_padding())
|
||||
f.write('rmargin="%s" ' % Utils.gformat(rm))
|
||||
f.write('lmargin="%s" ' % Utils.gformat(lm))
|
||||
f.write('first="%s" ' % Utils.gformat(fi))
|
||||
f.write('tmargin="%s" ' % Utils.gformat(tm))
|
||||
f.write('bmargin="%s" ' % Utils.gformat(bm))
|
||||
f.write('pad="%s" ' % Utils.gformat(pa))
|
||||
f.write('bgcolor="#%02x%02x%02x" ' % p.get_background_color())
|
||||
f.write('level="%d" ' % p.get_header_level())
|
||||
f.write('align="%d" ' % p.get_alignment())
|
||||
f.write('tborder="%d" ' % p.get_top_border())
|
||||
f.write('lborder="%d" ' % p.get_left_border())
|
||||
f.write('rborder="%d" ' % p.get_right_border())
|
||||
f.write('bborder="%d"/>\n' % p.get_bottom_border())
|
||||
f.write('</style>\n')
|
||||
f.write('</sheet>\n')
|
||||
f.write('</stylelist>\n')
|
||||
f.close()
|
||||
para = sheet.get_style(p_name)
|
||||
xml_file.write('<style name="%s">\n' % p_name)
|
||||
font = para.get_font()
|
||||
xml_file.write('<font face="%d" ' % font.get_type_face())
|
||||
xml_file.write('size="%d" ' % font.get_size())
|
||||
xml_file.write('italic="%d" ' % font.get_italic())
|
||||
xml_file.write('bold="%d" ' % font.get_bold())
|
||||
xml_file.write('underline="%d" ' % font.get_underline())
|
||||
xml_file.write('color="#%02x%02x%02x"/>\n' % font.get_color())
|
||||
xml_file.write('<para ')
|
||||
rmargin = float(para.get_right_margin())
|
||||
lmargin = float(para.get_left_margin())
|
||||
findent = float(para.get_first_indent())
|
||||
tmargin = float(para.get_top_margin())
|
||||
bmargin = float(para.get_bottom_margin())
|
||||
padding = float(para.get_padding())
|
||||
xml_file.write('rmargin="%s" ' % Utils.gformat(rmargin))
|
||||
xml_file.write('lmargin="%s" ' % Utils.gformat(lmargin))
|
||||
xml_file.write('first="%s" ' % Utils.gformat(findent))
|
||||
xml_file.write('tmargin="%s" ' % Utils.gformat(tmargin))
|
||||
xml_file.write('bmargin="%s" ' % Utils.gformat(bmargin))
|
||||
xml_file.write('pad="%s" ' % Utils.gformat(padding))
|
||||
bg_color = para.get_background_color()
|
||||
xml_file.write('bgcolor="#%02x%02x%02x" ' % bg_color)
|
||||
xml_file.write('level="%d" ' % para.get_header_level())
|
||||
xml_file.write('align="%d" ' % para.get_alignment())
|
||||
xml_file.write('tborder="%d" ' % para.get_top_border())
|
||||
xml_file.write('lborder="%d" ' % para.get_left_border())
|
||||
xml_file.write('rborder="%d" ' % para.get_right_border())
|
||||
xml_file.write('bborder="%d"/>\n' % para.get_bottom_border())
|
||||
xml_file.write('</style>\n')
|
||||
xml_file.write('</sheet>\n')
|
||||
xml_file.write('</stylelist>\n')
|
||||
xml_file.close()
|
||||
|
||||
def parse(self):
|
||||
"""
|
||||
@ -895,9 +907,9 @@ class StyleSheetList:
|
||||
"""
|
||||
try:
|
||||
if os.path.isfile(self.file):
|
||||
p = make_parser()
|
||||
p.setContentHandler(SheetParser(self))
|
||||
p.parse(self.file)
|
||||
parser = make_parser()
|
||||
parser.setContentHandler(SheetParser(self))
|
||||
parser.parse(self.file)
|
||||
except (IOError,OSError,SAXParseException):
|
||||
pass
|
||||
|
||||
@ -911,7 +923,7 @@ class StyleSheet:
|
||||
A collection of named paragraph styles.
|
||||
"""
|
||||
|
||||
def __init__(self,obj=None):
|
||||
def __init__(self, obj=None):
|
||||
"""
|
||||
Creates a new empty StyleSheet.
|
||||
|
||||
@ -926,9 +938,15 @@ class StyleSheet:
|
||||
self.style_list[style_name] = ParagraphStyle(style)
|
||||
|
||||
def set_name(self, name):
|
||||
"""
|
||||
Sets the name of the StyleSheet
|
||||
"""
|
||||
self.name = name
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Returns the name of the StyleSheet
|
||||
"""
|
||||
return self.name
|
||||
|
||||
def clear(self):
|
||||
@ -1027,9 +1045,9 @@ class SheetParser(handler.ContentHandler):
|
||||
"Overridden class that handles the start of a XML element"
|
||||
if tag == "style":
|
||||
self.p.set_font(self.f)
|
||||
self.s.add_style(self.pname,self.p)
|
||||
self.s.add_style(self.pname, self.p)
|
||||
elif tag == "sheet":
|
||||
self.sheetlist.set_style_sheet(self.sname,self.s)
|
||||
self.sheetlist.set_style_sheet(self.sname, self.s)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -1037,7 +1055,16 @@ class SheetParser(handler.ContentHandler):
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class GraphicsStyle:
|
||||
"""
|
||||
Defines the properties of graphics objects, such as line width,
|
||||
color, fill, ect.
|
||||
"""
|
||||
def __init__(self, obj=None):
|
||||
"""
|
||||
Initialize the object with default values, unless a source
|
||||
object is specified. In that case, make a copy of the source
|
||||
object.
|
||||
"""
|
||||
if obj:
|
||||
self.height = obj.height
|
||||
self.width = obj.width
|
||||
@ -1055,14 +1082,20 @@ class GraphicsStyle:
|
||||
self.shadow = 0
|
||||
self.shadow_space = 0.2
|
||||
self.lwidth = 0.5
|
||||
self.color = (0,0,0)
|
||||
self.fill_color = (255,255,255)
|
||||
self.color = (0, 0, 0)
|
||||
self.fill_color = (255, 255, 255)
|
||||
self.lstyle = SOLID
|
||||
|
||||
def set_line_width(self, val):
|
||||
"""
|
||||
sets the line width
|
||||
"""
|
||||
self.lwidth = val
|
||||
|
||||
def get_line_width(self):
|
||||
"""
|
||||
Returns the name of the StyleSheet
|
||||
"""
|
||||
return self.lwidth
|
||||
|
||||
def get_line_style(self):
|
||||
@ -1122,7 +1155,7 @@ class BaseDoc:
|
||||
such as OpenOffice, AbiWord, and LaTeX are derived from this base
|
||||
class, providing a common interface to all document generators.
|
||||
"""
|
||||
def __init__(self, styles, paper_type ,template,
|
||||
def __init__(self, styles, paper_type, template,
|
||||
orientation=PAPER_PORTRAIT):
|
||||
"""
|
||||
Creates a BaseDoc instance, which provides a document generation
|
||||
@ -1180,7 +1213,7 @@ class BaseDoc:
|
||||
def print_requested(self):
|
||||
self.print_req = 1
|
||||
|
||||
def set_owner(self,owner):
|
||||
def set_owner(self, owner):
|
||||
"""
|
||||
Sets the name of the owner of the document.
|
||||
|
||||
@ -1226,7 +1259,7 @@ class BaseDoc:
|
||||
def get_bottom_margin(self):
|
||||
return self.bmargin
|
||||
|
||||
def creator(self,name):
|
||||
def creator(self, name):
|
||||
"Returns the owner name"
|
||||
self.name = name
|
||||
|
||||
@ -1279,7 +1312,7 @@ class BaseDoc:
|
||||
|
||||
def string_width(self, fontstyle, text):
|
||||
"Determine the width need for text in given font"
|
||||
return FontScale.string_width(fontstyle,text)
|
||||
return FontScale.string_width(fontstyle, text)
|
||||
|
||||
def line_break(self):
|
||||
"Forces a line break within a paragraph"
|
||||
@ -1430,48 +1463,48 @@ class BaseDoc:
|
||||
|
||||
p = []
|
||||
|
||||
degreestoradians = pi/180.0
|
||||
radiansdelta = degreestoradians/2
|
||||
sangle = start_angle*degreestoradians
|
||||
eangle = end_angle*degreestoradians
|
||||
while eangle<sangle:
|
||||
eangle = eangle+2*pi
|
||||
degreestoradians = pi / 180.0
|
||||
radiansdelta = degreestoradians / 2
|
||||
sangle = start_angle * degreestoradians
|
||||
eangle = end_angle * degreestoradians
|
||||
while eangle < sangle:
|
||||
eangle = eangle + 2 * pi
|
||||
angle = sangle
|
||||
|
||||
if short_radius == 0:
|
||||
p.append((centerx, centery))
|
||||
else:
|
||||
origx = (centerx + cos(angle)*short_radius)
|
||||
origy = (centery + sin(angle)*short_radius)
|
||||
origx = (centerx + cos(angle) * short_radius)
|
||||
origy = (centery + sin(angle) * short_radius)
|
||||
p.append((origx, origy))
|
||||
|
||||
while angle<eangle:
|
||||
x = centerx + cos(angle)*radius
|
||||
y = centery + sin(angle)*radius
|
||||
while angle < eangle:
|
||||
x = centerx + cos(angle) * radius
|
||||
y = centery + sin(angle) * radius
|
||||
p.append((x, y))
|
||||
angle = angle+radiansdelta
|
||||
x = centerx + cos(eangle)*radius
|
||||
y = centery + sin(eangle)*radius
|
||||
angle = angle + radiansdelta
|
||||
x = centerx + cos(eangle) * radius
|
||||
y = centery + sin(eangle) * radius
|
||||
p.append((x, y))
|
||||
|
||||
if short_radius:
|
||||
x = centerx + cos(eangle)*short_radius
|
||||
y = centery + sin(eangle)*short_radius
|
||||
x = centerx + cos(eangle) * short_radius
|
||||
y = centery + sin(eangle) * short_radius
|
||||
p.append((x, y))
|
||||
|
||||
angle = eangle
|
||||
while angle>=sangle:
|
||||
x = centerx + cos(angle)*short_radius
|
||||
y = centery + sin(angle)*short_radius
|
||||
while angle >= sangle:
|
||||
x = centerx + cos(angle) * short_radius
|
||||
y = centery + sin(angle) * short_radius
|
||||
p.append((x, y))
|
||||
angle = angle-radiansdelta
|
||||
angle = angle - radiansdelta
|
||||
self.draw_path(style, p)
|
||||
|
||||
delta = (eangle - sangle)/2.0
|
||||
rad = short_radius + (radius-short_radius)/2.0
|
||||
delta = (eangle - sangle) / 2.0
|
||||
rad = short_radius + (radius - short_radius) / 2.0
|
||||
|
||||
return ( (centerx + cos(sangle+delta) * rad),
|
||||
(centery + sin(sangle+delta) * rad))
|
||||
return ( (centerx + cos(sangle + delta) * rad),
|
||||
(centery + sin(sangle + delta) * rad))
|
||||
|
||||
def start_path(self, style, x, y):
|
||||
pass
|
||||
|
@ -63,7 +63,7 @@ import GrampsWidgets
|
||||
|
||||
from _EditPrimary import EditPrimary
|
||||
from QuestionDialog import WarningDialog, ErrorDialog, QuestionDialog2
|
||||
from DisplayTabs import NoteTab, GalleryTab, WebEmbedList, LdsEmbedList
|
||||
from DisplayTabs import *
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -5,17 +5,17 @@
|
||||
#
|
||||
# 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
|
||||
# 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,
|
||||
# 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
|
||||
# along with this program; if not,write to the Free Software
|
||||
# Foundation,Inc.,59 Temple Place,Suite 330,Boston,MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
@ -91,16 +91,16 @@ _MARKER_COL= 20
|
||||
#
|
||||
# python 2.3 has a bug in the unicode sorting using locale.strcoll. Seems
|
||||
# to have a buffer overrun. We can convince it to do the right thing by
|
||||
# forcing the string to be nul terminated, sorting, then stripping off the
|
||||
# forcing the string to be nul terminated,sorting,then stripping off the
|
||||
# nul.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
if sys.version_info[0:2] == (2,3):
|
||||
if sys.version_info[0:2] == (2, 3):
|
||||
def locale_sort(mylist):
|
||||
mylist = map(lambda x: x + "\x00", mylist)
|
||||
mylist = map(lambda x: x + "\x00",mylist)
|
||||
mylist.sort(locale.strcoll)
|
||||
return map(lambda x: x[:-1], mylist)
|
||||
return map(lambda x: x[:-1],mylist)
|
||||
else:
|
||||
def locale_sort(mylist):
|
||||
mylist.sort(locale.strcoll)
|
||||
@ -113,7 +113,7 @@ else:
|
||||
#-------------------------------------------------------------------------
|
||||
class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def __init__(self,db,data_filter=None,invert_result=False,skip=[]):
|
||||
def __init__(self, db, data_filter=None, invert_result=False, skip=[]):
|
||||
gtk.GenericTreeModel.__init__(self)
|
||||
|
||||
self.db = db
|
||||
@ -125,13 +125,13 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
self.prev_handle = None
|
||||
self.prev_data = None
|
||||
self.temp_top_path2iter = []
|
||||
self.rebuild_data(data_filter,skip)
|
||||
self.rebuild_data(data_filter, skip)
|
||||
|
||||
def rebuild_data(self,data_filter=None,skip=[]):
|
||||
self.calculate_data(data_filter,skip)
|
||||
def rebuild_data(self, data_filter=None, skip=[]):
|
||||
self.calculate_data(data_filter, skip)
|
||||
self.assign_data()
|
||||
|
||||
def calculate_data(self,dfilter=None,skip=[]):
|
||||
def calculate_data(self, dfilter=None, skip=[]):
|
||||
if dfilter:
|
||||
self.dfilter = dfilter
|
||||
self.temp_iter2path = {}
|
||||
@ -150,7 +150,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
node = cursor.first()
|
||||
|
||||
while node:
|
||||
handle,d = node
|
||||
handle, d = node
|
||||
if not (handle in skip or (dfilter and not dfilter.match(handle))):
|
||||
name_data = d[_NAME_COL]
|
||||
self.sortnames[handle] = nsn(name_data)
|
||||
@ -168,15 +168,15 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
def clear_cache(self):
|
||||
self.prev_handle = None
|
||||
|
||||
def build_sub_entry(self,name):
|
||||
def build_sub_entry(self, name):
|
||||
self.prev_handle = None
|
||||
slist = [ (locale.strxfrm(self.sortnames[x]),x) \
|
||||
slist = [ (locale.strxfrm(self.sortnames[x]), x) \
|
||||
for x in self.temp_sname_sub[name] ]
|
||||
slist.sort()
|
||||
|
||||
val = 0
|
||||
for (junk,person_handle) in slist:
|
||||
tpl = (name,val)
|
||||
for (junk, person_handle) in slist:
|
||||
tpl = (name, val)
|
||||
self.temp_iter2path[person_handle] = tpl
|
||||
self.temp_path2iter[tpl] = person_handle
|
||||
val += 1
|
||||
@ -194,33 +194,32 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
def on_get_n_columns(self):
|
||||
return len(COLUMN_DEFS)
|
||||
|
||||
def on_get_path(self, node):
|
||||
def on_get_path(self,node):
|
||||
'''returns the tree path (a tuple of indices at the various
|
||||
levels) for a particular node.'''
|
||||
try:
|
||||
return (self.top_path2iter.index(node),)
|
||||
return (self.top_path2iter.index(node), )
|
||||
except:
|
||||
(surname,index) = self.iter2path[node]
|
||||
return (self.top_path2iter.index(surname),index)
|
||||
(surname, index) = self.iter2path[node]
|
||||
return (self.top_path2iter.index(surname), index)
|
||||
|
||||
def is_visable(self,handle):
|
||||
def is_visable(self, handle):
|
||||
return self.iter2path.has_key(handle)
|
||||
|
||||
def on_get_column_type(self,index):
|
||||
# return column data-type, from table
|
||||
return COLUMN_DEFS[index][COLUMN_DEF_TYPE]
|
||||
def on_get_column_type(self, index):
|
||||
return COLUMN_DEFS[index][COLUMN_DEF_TYPE]
|
||||
|
||||
def on_get_iter(self, path):
|
||||
def on_get_iter(self,path):
|
||||
try:
|
||||
if len(path)==1: # Top Level
|
||||
return self.top_path2iter[path[0]]
|
||||
else: # Sublevel
|
||||
surname = self.top_path2iter[path[0]]
|
||||
return self.path2iter[(surname,path[1])]
|
||||
return self.path2iter[(surname, path[1])]
|
||||
except:
|
||||
return None
|
||||
|
||||
def on_get_value(self,node,col):
|
||||
def on_get_value(self, node, col):
|
||||
# test for header or data row-type
|
||||
if self.sname_sub.has_key(node):
|
||||
# Header rows dont get the background color set
|
||||
@ -229,25 +228,26 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
# test for 'header' column being empty (most are)
|
||||
if not COLUMN_DEFS[col][COLUMN_DEF_HEADER]:
|
||||
return u''
|
||||
# return values for 'header' row, calling a function
|
||||
# return values for 'header' row,calling a function
|
||||
# according to column_defs table
|
||||
val = COLUMN_DEFS[col][COLUMN_DEF_HEADER](self,node)
|
||||
val = COLUMN_DEFS[col][COLUMN_DEF_HEADER](self, node)
|
||||
return val
|
||||
else:
|
||||
# return values for 'data' row, calling a function
|
||||
# return values for 'data' row,calling a function
|
||||
# according to column_defs table
|
||||
try:
|
||||
if node != self.prev_handle:
|
||||
self.prev_data = self.db.get_raw_person_data(str(node))
|
||||
self.prev_handle = node
|
||||
return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.prev_data,node)
|
||||
return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,
|
||||
self.prev_data, node)
|
||||
except:
|
||||
if col == _MARKER_COL:
|
||||
return None
|
||||
else:
|
||||
return u'error'
|
||||
|
||||
def on_iter_next(self, node):
|
||||
def on_iter_next(self,node):
|
||||
'''returns the next node at this level of the tree'''
|
||||
try:
|
||||
path = self.top_path2iter.index(node)
|
||||
@ -255,17 +255,17 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return None
|
||||
return self.top_path2iter[path+1]
|
||||
except:
|
||||
(surname,val) = self.iter2path[node]
|
||||
return self.path2iter.get((surname,val+1))
|
||||
(surname, val) = self.iter2path[node]
|
||||
return self.path2iter.get((surname, val+1))
|
||||
|
||||
def on_iter_children(self,node):
|
||||
def on_iter_children(self, node):
|
||||
"""Return the first child of the node"""
|
||||
if node == None:
|
||||
return self.top_path2iter[0]
|
||||
else:
|
||||
return self.path2iter.get((node,0))
|
||||
return self.path2iter.get((node, 0))
|
||||
|
||||
def on_iter_has_child(self, node):
|
||||
def on_iter_has_child(self,node):
|
||||
'''returns true if this node has children'''
|
||||
if node == None:
|
||||
return len(self.sname_sub)
|
||||
@ -273,7 +273,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return True
|
||||
return False
|
||||
|
||||
def on_iter_n_children(self,node):
|
||||
def on_iter_n_children(self, node):
|
||||
if node == None:
|
||||
return len(self.sname_sub)
|
||||
try:
|
||||
@ -281,61 +281,62 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
except:
|
||||
return 0
|
||||
|
||||
def on_iter_nth_child(self,node,n):
|
||||
def on_iter_nth_child(self, node, n):
|
||||
try:
|
||||
if node == None:
|
||||
return self.top_path2iter[n]
|
||||
try:
|
||||
return self.path2iter[(node,n)]
|
||||
return self.path2iter[(node, n)]
|
||||
except:
|
||||
return None
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
def on_iter_parent(self, node):
|
||||
def on_iter_parent(self,node):
|
||||
'''returns the parent of this node'''
|
||||
path = self.iter2path.get(node)
|
||||
if path:
|
||||
return path[0]
|
||||
return None
|
||||
|
||||
def column_sort_name(self,data,node):
|
||||
def column_sort_name(self, data, node):
|
||||
n = Name()
|
||||
n.unserialize(data[_NAME_COL])
|
||||
return NameDisplay.displayer.sort_string(n)
|
||||
|
||||
def column_spouse(self,data,node):
|
||||
def column_spouse(self, data, node):
|
||||
spouses_names = u""
|
||||
handle = data[0]
|
||||
for family_handle in data[_FAMILY_COL]:
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
for spouse_id in [family.get_father_handle(), family.get_mother_handle()]:
|
||||
for spouse_id in [family.get_father_handle(),
|
||||
family.get_mother_handle()]:
|
||||
if not spouse_id:
|
||||
continue
|
||||
if spouse_id == handle:
|
||||
continue
|
||||
spouse = self.db.get_person_from_handle(spouse_id)
|
||||
if len(spouses_names) > 0:
|
||||
spouses_names += ", "
|
||||
spouses_names += ","
|
||||
spouses_names += NameDisplay.displayer.display(spouse)
|
||||
return spouses_names
|
||||
|
||||
def column_name(self,data,node):
|
||||
def column_name(self, data, node):
|
||||
n = Name()
|
||||
n.unserialize(data[_NAME_COL])
|
||||
return NameDisplay.displayer.sorted_name(n)
|
||||
|
||||
def column_id(self,data,node):
|
||||
def column_id(self, data, node):
|
||||
return data[_ID_COL]
|
||||
|
||||
def column_change(self,data,node):
|
||||
return unicode(time.strftime('%x %X',time.localtime(data[_CHANGE_COL])),
|
||||
def column_change(self, data, node):
|
||||
return unicode(time.strftime('%x %X', time.localtime(data[_CHANGE_COL])),
|
||||
_codeset)
|
||||
|
||||
def column_gender(self,data,node):
|
||||
def column_gender(self, data, node):
|
||||
return _GENDER[data[_GENDER_COL]]
|
||||
|
||||
def column_birth_day(self,data,node):
|
||||
def column_birth_day(self, data, node):
|
||||
if data[_BIRTH_COL]:
|
||||
b=EventRef()
|
||||
b.unserialize(data[_BIRTH_COL])
|
||||
@ -350,13 +351,13 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
event = self.db.get_event_from_handle(er.ref)
|
||||
etype = event.get_type()[0]
|
||||
date_str = DateHandler.get_date(event)
|
||||
if (etype in [Event.BAPTISM, Event.CHRISTEN]
|
||||
if (etype in [Event.BAPTISM,Event.CHRISTEN]
|
||||
and date_str != ""):
|
||||
return "<i>" + cgi.escape(date_str) + "</i>"
|
||||
|
||||
return u""
|
||||
|
||||
def column_death_day(self,data,node):
|
||||
def column_death_day(self, data, node):
|
||||
if data[_DEATH_COL]:
|
||||
dr = EventRef()
|
||||
dr.unserialize(data[_DEATH_COL])
|
||||
@ -371,13 +372,13 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
event = self.db.get_event_from_handle(er.ref)
|
||||
etype = event.get_type()[0]
|
||||
date_str = DateHandler.get_date(event)
|
||||
if (etype in [Event.BURIAL, Event.CREMATION]
|
||||
if (etype in [Event.BURIAL,Event.CREMATION]
|
||||
and date_str != ""):
|
||||
return "<i>" + cgi.escape(date_str) + "</i>"
|
||||
|
||||
return u""
|
||||
|
||||
def column_cause_of_death(self,data,node):
|
||||
def column_cause_of_death(self, data, node):
|
||||
if data[_DEATH_COL]:
|
||||
dr = EventRef()
|
||||
dr.unserialize(data[_DEATH_COL])
|
||||
@ -385,15 +386,16 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
else:
|
||||
return u""
|
||||
|
||||
def column_birth_place(self,data,node):
|
||||
def column_birth_place(self, data, node):
|
||||
if data[_BIRTH_COL]:
|
||||
br = EventRef()
|
||||
br.unserialize(data[_BIRTH_COL])
|
||||
event = self.db.get_event_from_handle(br.ref)
|
||||
if event:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place_title = self.db.get_place_from_handle(place_handle).get_title()
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.db.get_place_from_handle(place_handle)
|
||||
place_title = place.get_title()
|
||||
if place_title != "":
|
||||
return cgi.escape(place_title)
|
||||
|
||||
@ -402,23 +404,24 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
er.unserialize(event_ref)
|
||||
event = self.db.get_event_from_handle(er.ref)
|
||||
etype = event.get_type()[0]
|
||||
if etype in [Event.BAPTISM, Event.CHRISTEN]:
|
||||
if etype in [Event.BAPTISM,Event.CHRISTEN]:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place_title = self.db.get_place_from_handle(place_handle).get_title()
|
||||
place = self.db.get_place_from_handle(place_handle)
|
||||
place_title = place.get_title()
|
||||
if place_title != "":
|
||||
return "<i>" + cgi.escape(place_title) + "</i>"
|
||||
|
||||
return u""
|
||||
|
||||
def column_death_place(self,data,node):
|
||||
def column_death_place(self, data, node):
|
||||
if data[_DEATH_COL]:
|
||||
dr = EventRef()
|
||||
dr.unserialize(data[_DEATH_COL])
|
||||
event = self.db.get_event_from_handle(dr.ref)
|
||||
if event:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place_title = self.db.get_place_from_handle(place_handle).get_title()
|
||||
if place_title != "":
|
||||
return cgi.escape(place_title)
|
||||
@ -428,7 +431,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
er.unserialize(event_ref)
|
||||
event = self.db.get_event_from_handle(er.ref)
|
||||
etype = event.get_type()[0]
|
||||
if etype in [Event.BURIAL, Event.CREMATION]:
|
||||
if etype in [Event.BURIAL,Event.CREMATION]:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place_title = self.db.get_place_from_handle(place_handle).get_title()
|
||||
@ -437,7 +440,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
return u""
|
||||
|
||||
def column_marker_text(self,data,node):
|
||||
def column_marker_text(self, data, node):
|
||||
try:
|
||||
if data[_MARKER_COL]:
|
||||
if data[_MARKER_COL][0] == PrimaryObject.MARKER_CUSTOM:
|
||||
@ -448,7 +451,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return ""
|
||||
return ""
|
||||
|
||||
def column_marker_color(self,data,node):
|
||||
def column_marker_color(self, data, node):
|
||||
try:
|
||||
if data[_MARKER_COL]:
|
||||
if data[_MARKER_COL][0] == PrimaryObject.MARKER_COMPLETE:
|
||||
@ -461,49 +464,48 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
pass
|
||||
return None
|
||||
|
||||
def column_tooltip(self,data,node):
|
||||
def column_tooltip(self, data, node):
|
||||
if const.use_tips:
|
||||
return ToolTips.TipFromFunction(self.db, lambda: self.db.get_person_from_handle(data[0]))
|
||||
return ToolTips.TipFromFunction(self.db,lambda: self.db.get_person_from_handle(data[0]))
|
||||
else:
|
||||
return u''
|
||||
|
||||
|
||||
def column_int_id(self,data,node):
|
||||
def column_int_id(self, data, node):
|
||||
return node
|
||||
|
||||
def column_header(self,node):
|
||||
def column_header(self, node):
|
||||
return node
|
||||
|
||||
def column_header_view(self,node):
|
||||
def column_header_view(self, node):
|
||||
return True
|
||||
|
||||
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
|
||||
_GENDER = [ _(u'female'),_(u'male'),_(u'unknown') ]
|
||||
|
||||
# table of column definitions
|
||||
# (unless this is declared after the PeopleModel class, an error is thrown)
|
||||
# (unless this is declared after the PeopleModel class,an error is thrown)
|
||||
COLUMN_DEFS = [
|
||||
# data column (method) header column (method) column data type
|
||||
(PeopleModel.column_name, PeopleModel.column_header, str),
|
||||
(PeopleModel.column_id, None, str),
|
||||
(PeopleModel.column_gender, None, str),
|
||||
(PeopleModel.column_birth_day, None, str),
|
||||
(PeopleModel.column_birth_place,None, str),
|
||||
(PeopleModel.column_death_day, None, str),
|
||||
(PeopleModel.column_death_place,None, str),
|
||||
(PeopleModel.column_spouse, None, str),
|
||||
(PeopleModel.column_change, None, str),
|
||||
(PeopleModel.column_cause_of_death, None, str),
|
||||
(PeopleModel.column_marker_text, None, str),
|
||||
(PeopleModel.column_marker_color, None, str),
|
||||
(PeopleModel.column_name, PeopleModel.column_header, str),
|
||||
(PeopleModel.column_id, None, str),
|
||||
(PeopleModel.column_gender, None, str),
|
||||
(PeopleModel.column_birth_day, None, str),
|
||||
(PeopleModel.column_birth_place, None, str),
|
||||
(PeopleModel.column_death_day, None, str),
|
||||
(PeopleModel.column_death_place, None, str),
|
||||
(PeopleModel.column_spouse, None, str),
|
||||
(PeopleModel.column_change, None, str),
|
||||
(PeopleModel.column_cause_of_death, None, str),
|
||||
(PeopleModel.column_marker_text, None, str),
|
||||
(PeopleModel.column_marker_color, None, str),
|
||||
# the order of the above columns must match PeopleView.column_names
|
||||
|
||||
# these columns are hidden, and must always be last in the list
|
||||
(PeopleModel.column_tooltip, None, object),
|
||||
# (PeopleModel.column_sort_name, None, str),
|
||||
(PeopleModel.column_int_id, None, str),
|
||||
# these columns are hidden,and must always be last in the list
|
||||
(PeopleModel.column_tooltip, None, object),
|
||||
(PeopleModel.column_int_id, None, str),
|
||||
]
|
||||
|
||||
# dynamic calculation of column indices, for use by various Views
|
||||
# dynamic calculation of column indices,for use by various Views
|
||||
COLUMN_INT_ID = 13
|
||||
|
||||
# indices into main column definition table
|
||||
|
Loading…
Reference in New Issue
Block a user