2007-05-19 Don Allingham <don@gramps-project.org>

* src/AutoComp.py: removal of unused functions
	* src/BaseDoc.py: clean up and add documentation



svn: r8497
This commit is contained in:
Don Allingham 2007-05-20 03:43:38 +00:00
parent 6ecc393988
commit 659814e22d
3 changed files with 73 additions and 24 deletions

View File

@ -1,3 +1,7 @@
2007-05-19 Don Allingham <don@gramps-project.org>
* src/AutoComp.py: removal of unused functions
* src/BaseDoc.py: clean up and add documentation
2007-05-18 Brian Matherly <brian@gramps-project.org>
* src/plugins/NarrativeWeb.py: fix gallery image links generated on Win32

View File

@ -20,6 +20,10 @@
# $Id$
"""
Provides autocompletion functionality.
"""
#-------------------------------------------------------------------------
#
# Standard python modules
@ -43,11 +47,13 @@ log = logging.getLogger(".AutoComp")
import gtk
def fill_combo(combo, data_list):
"""
Fill a combo box with completion data
"""
store = gtk.ListStore(str)
for data in data_list:
if data:
store.append(row=[data])
for data in [ item for item in data_list if item ]:
store.append(row=[data])
combo.set_model(store)
combo.set_text_column(0)
@ -58,11 +64,13 @@ def fill_combo(combo, data_list):
combo.child.set_completion(completion)
def fill_entry(entry, data_list):
"""
Fill a entry with completion data
"""
store = gtk.ListStore(str)
for data in data_list:
if data:
store.append(row=[data])
for data in [ item for item in data_list if item ]:
store.append(row=[data])
completion = gtk.EntryCompletion()
completion.set_model(store)
@ -70,18 +78,6 @@ def fill_entry(entry, data_list):
completion.set_text_column(0)
entry.set_completion(completion)
def fill_option_text(combobox, data):
store = gtk.ListStore(str)
for item in data:
if item:
store.append(row=[item])
combobox.set_model(store)
combobox.set_active(0)
def get_option(combobox):
store = combobox.get_model()
return store.get_value(combobox.get_active_iter(), 0)
#-------------------------------------------------------------------------
#
# StandardCustomSelector class
@ -163,6 +159,9 @@ class StandardCustomSelector:
self.selector.child.set_completion(completion)
def fill(self):
"""
Fill with data
"""
keys = self.mapping.keys()
keys.sort(self.by_value)
index = 0

View File

@ -38,8 +38,11 @@ __revision__ = "Revision:$Id$"
import os
from xml.sax.saxutils import escape
def escxml(d):
return escape(d, { '"' : '&quot;' } )
def escxml(string):
"""
Escapes XML special characters.
"""
return escape(string, { '"' : '&quot;' } )
#-------------------------------------------------------------------------
#
@ -65,7 +68,7 @@ log = logging.getLogger(".BaseDoc")
#-------------------------------------------------------------------------
try:
from xml.sax import make_parser, handler, SAXParseException
except:
except ImportError:
from _xmlplus.sax import make_parser, handler, SAXParseException
#-------------------------------------------------------------------------
@ -216,9 +219,21 @@ class PaperStyle:
self.__rmargin = 2.54
def get_size(self):
"""
returns the size of the paper.
@returns: object indicating the paper size
@rtype: PaperSize
"""
return self.__size
def get_orientation(self):
"""
returns the orientation of the page.
@returns: PAPER_PORTRIAT or PAPER_LANDSCAPE
@rtype: int
"""
return self.__orientation
def get_usable_width(self):
@ -236,15 +251,39 @@ class PaperStyle:
return self.__size.get_height() - (self.__tmargin + self.__bmargin)
def get_right_margin(self):
"""
Returns the right margin.
@returns: Right margin in centimeters
@rtype: float
"""
return self.__rmargin
def get_left_margin(self):
"""
Returns the left margin.
@returns: Left margin in centimeters
@rtype: float
"""
return self.__lmargin
def get_top_margin(self):
"""
Returns the top margin.
@returns: Top margin in centimeters
@rtype: float
"""
return self.__tmargin
def get_bottom_margin(self):
"""
Returns the bottom margin.
@returns: Bottom margin in centimeters
@rtype: float
"""
return self.__bmargin
#------------------------------------------------------------------------
@ -924,7 +963,8 @@ class StyleSheetList:
tmargin = float(para.get_top_margin())
bmargin = float(para.get_bottom_margin())
padding = float(para.get_padding())
xml_file.write('description="%s" ' % escxml(para.get_description()))
xml_file.write('description="%s" ' %
escxml(para.get_description()))
xml_file.write('rmargin="%s" ' % Utils.gformat(rmargin))
xml_file.write('lmargin="%s" ' % Utils.gformat(lmargin))
xml_file.write('first="%s" ' % Utils.gformat(findent))
@ -1471,14 +1511,20 @@ class DrawDoc:
Returns the width of the text area in centimeters. The value is
the page width less the margins.
"""
return self.paper.get_size().get_width() - (self.paper.get_right_margin() + self.paper.get_left_margin())
width = self.paper.get_size().get_width()
right = self.paper.get_right_margin()
left = self.paper.get_left_margin()
return width - (right + left)
def get_usable_height(self):
"""
Returns the height of the text area in centimeters. The value is
the page height less the margins.
"""
return self.paper.get_size().get_height() - (self.paper.get_top_margin() + self.paper.get_bottom_margin())
height = self.paper.get_size().get_height()
top = self.paper.get_top_margin()
bottom = self.paper.get_bottom_margin()
return height - (top + bottom)
def string_width(self, fontstyle, text):
"Determine the width need for text in given font"