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:
parent
6ecc393988
commit
659814e22d
@ -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>
|
2007-05-18 Brian Matherly <brian@gramps-project.org>
|
||||||
* src/plugins/NarrativeWeb.py: fix gallery image links generated on Win32
|
* src/plugins/NarrativeWeb.py: fix gallery image links generated on Win32
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
"""
|
||||||
|
Provides autocompletion functionality.
|
||||||
|
"""
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Standard python modules
|
# Standard python modules
|
||||||
@ -43,11 +47,13 @@ log = logging.getLogger(".AutoComp")
|
|||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
def fill_combo(combo, data_list):
|
def fill_combo(combo, data_list):
|
||||||
|
"""
|
||||||
|
Fill a combo box with completion data
|
||||||
|
"""
|
||||||
store = gtk.ListStore(str)
|
store = gtk.ListStore(str)
|
||||||
|
|
||||||
for data in data_list:
|
for data in [ item for item in data_list if item ]:
|
||||||
if data:
|
store.append(row=[data])
|
||||||
store.append(row=[data])
|
|
||||||
|
|
||||||
combo.set_model(store)
|
combo.set_model(store)
|
||||||
combo.set_text_column(0)
|
combo.set_text_column(0)
|
||||||
@ -58,11 +64,13 @@ def fill_combo(combo, data_list):
|
|||||||
combo.child.set_completion(completion)
|
combo.child.set_completion(completion)
|
||||||
|
|
||||||
def fill_entry(entry, data_list):
|
def fill_entry(entry, data_list):
|
||||||
|
"""
|
||||||
|
Fill a entry with completion data
|
||||||
|
"""
|
||||||
store = gtk.ListStore(str)
|
store = gtk.ListStore(str)
|
||||||
|
|
||||||
for data in data_list:
|
for data in [ item for item in data_list if item ]:
|
||||||
if data:
|
store.append(row=[data])
|
||||||
store.append(row=[data])
|
|
||||||
|
|
||||||
completion = gtk.EntryCompletion()
|
completion = gtk.EntryCompletion()
|
||||||
completion.set_model(store)
|
completion.set_model(store)
|
||||||
@ -70,18 +78,6 @@ def fill_entry(entry, data_list):
|
|||||||
completion.set_text_column(0)
|
completion.set_text_column(0)
|
||||||
entry.set_completion(completion)
|
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
|
# StandardCustomSelector class
|
||||||
@ -163,6 +159,9 @@ class StandardCustomSelector:
|
|||||||
self.selector.child.set_completion(completion)
|
self.selector.child.set_completion(completion)
|
||||||
|
|
||||||
def fill(self):
|
def fill(self):
|
||||||
|
"""
|
||||||
|
Fill with data
|
||||||
|
"""
|
||||||
keys = self.mapping.keys()
|
keys = self.mapping.keys()
|
||||||
keys.sort(self.by_value)
|
keys.sort(self.by_value)
|
||||||
index = 0
|
index = 0
|
||||||
|
@ -38,8 +38,11 @@ __revision__ = "Revision:$Id$"
|
|||||||
import os
|
import os
|
||||||
from xml.sax.saxutils import escape
|
from xml.sax.saxutils import escape
|
||||||
|
|
||||||
def escxml(d):
|
def escxml(string):
|
||||||
return escape(d, { '"' : '"' } )
|
"""
|
||||||
|
Escapes XML special characters.
|
||||||
|
"""
|
||||||
|
return escape(string, { '"' : '"' } )
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -65,7 +68,7 @@ log = logging.getLogger(".BaseDoc")
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
try:
|
try:
|
||||||
from xml.sax import make_parser, handler, SAXParseException
|
from xml.sax import make_parser, handler, SAXParseException
|
||||||
except:
|
except ImportError:
|
||||||
from _xmlplus.sax import make_parser, handler, SAXParseException
|
from _xmlplus.sax import make_parser, handler, SAXParseException
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -216,9 +219,21 @@ class PaperStyle:
|
|||||||
self.__rmargin = 2.54
|
self.__rmargin = 2.54
|
||||||
|
|
||||||
def get_size(self):
|
def get_size(self):
|
||||||
|
"""
|
||||||
|
returns the size of the paper.
|
||||||
|
|
||||||
|
@returns: object indicating the paper size
|
||||||
|
@rtype: PaperSize
|
||||||
|
"""
|
||||||
return self.__size
|
return self.__size
|
||||||
|
|
||||||
def get_orientation(self):
|
def get_orientation(self):
|
||||||
|
"""
|
||||||
|
returns the orientation of the page.
|
||||||
|
|
||||||
|
@returns: PAPER_PORTRIAT or PAPER_LANDSCAPE
|
||||||
|
@rtype: int
|
||||||
|
"""
|
||||||
return self.__orientation
|
return self.__orientation
|
||||||
|
|
||||||
def get_usable_width(self):
|
def get_usable_width(self):
|
||||||
@ -236,15 +251,39 @@ class PaperStyle:
|
|||||||
return self.__size.get_height() - (self.__tmargin + self.__bmargin)
|
return self.__size.get_height() - (self.__tmargin + self.__bmargin)
|
||||||
|
|
||||||
def get_right_margin(self):
|
def get_right_margin(self):
|
||||||
|
"""
|
||||||
|
Returns the right margin.
|
||||||
|
|
||||||
|
@returns: Right margin in centimeters
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
return self.__rmargin
|
return self.__rmargin
|
||||||
|
|
||||||
def get_left_margin(self):
|
def get_left_margin(self):
|
||||||
|
"""
|
||||||
|
Returns the left margin.
|
||||||
|
|
||||||
|
@returns: Left margin in centimeters
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
return self.__lmargin
|
return self.__lmargin
|
||||||
|
|
||||||
def get_top_margin(self):
|
def get_top_margin(self):
|
||||||
|
"""
|
||||||
|
Returns the top margin.
|
||||||
|
|
||||||
|
@returns: Top margin in centimeters
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
return self.__tmargin
|
return self.__tmargin
|
||||||
|
|
||||||
def get_bottom_margin(self):
|
def get_bottom_margin(self):
|
||||||
|
"""
|
||||||
|
Returns the bottom margin.
|
||||||
|
|
||||||
|
@returns: Bottom margin in centimeters
|
||||||
|
@rtype: float
|
||||||
|
"""
|
||||||
return self.__bmargin
|
return self.__bmargin
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -924,7 +963,8 @@ class StyleSheetList:
|
|||||||
tmargin = float(para.get_top_margin())
|
tmargin = float(para.get_top_margin())
|
||||||
bmargin = float(para.get_bottom_margin())
|
bmargin = float(para.get_bottom_margin())
|
||||||
padding = float(para.get_padding())
|
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('rmargin="%s" ' % Utils.gformat(rmargin))
|
||||||
xml_file.write('lmargin="%s" ' % Utils.gformat(lmargin))
|
xml_file.write('lmargin="%s" ' % Utils.gformat(lmargin))
|
||||||
xml_file.write('first="%s" ' % Utils.gformat(findent))
|
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
|
Returns the width of the text area in centimeters. The value is
|
||||||
the page width less the margins.
|
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):
|
def get_usable_height(self):
|
||||||
"""
|
"""
|
||||||
Returns the height of the text area in centimeters. The value is
|
Returns the height of the text area in centimeters. The value is
|
||||||
the page height less the margins.
|
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):
|
def string_width(self, fontstyle, text):
|
||||||
"Determine the width need for text in given font"
|
"Determine the width need for text in given font"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user