Update
svn: r6123
This commit is contained in:
202
src/PluginUtils/_PaperMenu.py
Normal file
202
src/PluginUtils/_PaperMenu.py
Normal file
@@ -0,0 +1,202 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 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
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GNOME modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import BaseDoc
|
||||
import const
|
||||
import Utils
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# 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 = []
|
||||
|
||||
class GrampsPaperComboBox(gtk.ComboBox):
|
||||
|
||||
def __init__(self):
|
||||
gtk.ComboBox.__init__(self,model=None)
|
||||
|
||||
def set(self,mapping,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.mapping = {}
|
||||
|
||||
index = 0
|
||||
start_index = 0
|
||||
for key in mapping:
|
||||
self.mapping[key.get_name()] = key
|
||||
self.store.append(row=[key.get_name()])
|
||||
if key.get_name() == 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
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# make_orientation_menu
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def make_orientation_menu(main_menu,value=0):
|
||||
|
||||
myMenu = gtk.Menu()
|
||||
menuitem = gtk.MenuItem(_("Portrait"))
|
||||
menuitem.set_data("i",BaseDoc.PAPER_PORTRAIT)
|
||||
menuitem.show()
|
||||
myMenu.append(menuitem)
|
||||
|
||||
menuitem = gtk.MenuItem(_("Landscape"))
|
||||
menuitem.set_data("i",BaseDoc.PAPER_LANDSCAPE)
|
||||
menuitem.show()
|
||||
myMenu.append(menuitem)
|
||||
|
||||
if value == BaseDoc.PAPER_PORTRAIT:
|
||||
myMenu.set_active(0)
|
||||
elif value == BaseDoc.PAPER_LANDSCAPE:
|
||||
myMenu.set_active(1)
|
||||
|
||||
main_menu.set_menu(myMenu)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# PageSizeParser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
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 = Utils.gfloat(attrs['height'])
|
||||
width = Utils.gfloat(attrs['width'])
|
||||
self.paper_list.append(BaseDoc.PaperStyle(name,height,width))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Parse XML file. If failed, used default
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
try:
|
||||
parser = make_parser()
|
||||
parser.setContentHandler(PageSizeParser(paper_sizes))
|
||||
parser.parse(const.papersize)
|
||||
paper_sizes.append(BaseDoc.PaperStyle(_("Custom Size"),-1,-1))
|
||||
except (IOError,OSError,SAXParseException):
|
||||
paper_sizes = [
|
||||
BaseDoc.PaperStyle("Letter",27.94,21.59),
|
||||
BaseDoc.PaperStyle("Legal",35.56,21.59),
|
||||
BaseDoc.PaperStyle("A0",118.9,84.1),
|
||||
BaseDoc.PaperStyle("A1",84.1,59.4),
|
||||
BaseDoc.PaperStyle("A2",59.4,42.0),
|
||||
BaseDoc.PaperStyle("A3",42.0,29.7),
|
||||
BaseDoc.PaperStyle("A4",29.7,21.0),
|
||||
BaseDoc.PaperStyle("A5",21.0,14.8),
|
||||
BaseDoc.PaperStyle("B0",141.4,100.0),
|
||||
BaseDoc.PaperStyle("B1",100.0,70.7),
|
||||
BaseDoc.PaperStyle("B2",70.7,50.0),
|
||||
BaseDoc.PaperStyle("B3",50.0,35.3),
|
||||
BaseDoc.PaperStyle("B4",35.3,25.0),
|
||||
BaseDoc.PaperStyle("B5",25.0,17.6),
|
||||
BaseDoc.PaperStyle("B6",17.6,12.5),
|
||||
BaseDoc.PaperStyle("B",43.18,27.94),
|
||||
BaseDoc.PaperStyle("C",56.1,43.18),
|
||||
BaseDoc.PaperStyle("D",86.36, 56.1),
|
||||
BaseDoc.PaperStyle("E",111.76,86.36),
|
||||
BaseDoc.PaperStyle(_("Custom Size"),-1,-1)
|
||||
]
|
||||
@@ -54,9 +54,9 @@ import const
|
||||
import Utils
|
||||
import PluginMgr
|
||||
import BaseDoc
|
||||
import StyleEditor
|
||||
from _StyleEditor import StyleListDisplay
|
||||
import Config
|
||||
import PaperMenu
|
||||
import _PaperMenu
|
||||
import Errors
|
||||
import GenericFilter
|
||||
import NameDisplay
|
||||
@@ -961,8 +961,8 @@ class BareReportDialog:
|
||||
style sheet editor object and let them play. When they are
|
||||
done, the previous routine will be called to update the dialog
|
||||
menu for selecting a style."""
|
||||
StyleEditor.StyleListDisplay(self.style_sheet_list,self.build_style_menu,
|
||||
self.window)
|
||||
StyleListDisplay(self.style_sheet_list,self.build_style_menu,
|
||||
self.window)
|
||||
|
||||
def on_center_person_change_clicked(self,*obj):
|
||||
import SelectPerson
|
||||
@@ -1275,10 +1275,10 @@ class ReportDialog(BareReportDialog):
|
||||
self.paper_table.set_row_spacings(6)
|
||||
self.paper_table.set_border_width(6)
|
||||
|
||||
self.papersize_menu = PaperMenu.GrampsPaperComboBox()
|
||||
self.papersize_menu = _PaperMenu.GrampsPaperComboBox()
|
||||
self.papersize_menu.connect('changed',self.size_changed)
|
||||
|
||||
self.orientation_menu = PaperMenu.GrampsOrientationComboBox()
|
||||
self.orientation_menu = _PaperMenu.GrampsOrientationComboBox()
|
||||
l = gtk.Label("%s:" % _("Size"))
|
||||
l.set_alignment(0.0,0.5)
|
||||
|
||||
@@ -1314,7 +1314,7 @@ class ReportDialog(BareReportDialog):
|
||||
l.set_alignment(0.0,0.5)
|
||||
self.paper_table.attach(l,5,6,1,2,gtk.SHRINK|gtk.FILL)
|
||||
|
||||
self.papersize_menu.set(PaperMenu.paper_sizes,
|
||||
self.papersize_menu.set(_PaperMenu.paper_sizes,
|
||||
self.options.handler.get_paper_name())
|
||||
self.orientation_menu.set(self.options.handler.get_orientation())
|
||||
|
||||
@@ -1795,12 +1795,12 @@ class CommandLineReport:
|
||||
else:
|
||||
self.format = None
|
||||
|
||||
for paper in PaperMenu.paper_sizes:
|
||||
for paper in _PaperMenu.paper_sizes:
|
||||
if paper.get_name() == self.options_dict['papers']:
|
||||
self.paper = paper
|
||||
self.option_class.handler.set_paper(self.paper)
|
||||
self.options_help['papers'].append(
|
||||
[ paper.get_name() for paper in PaperMenu.paper_sizes
|
||||
[ paper.get_name() for paper in _PaperMenu.paper_sizes
|
||||
if paper.get_name() != 'Custom Size' ] )
|
||||
self.options_help['papers'].append(False)
|
||||
|
||||
|
||||
337
src/PluginUtils/_StyleEditor.py
Normal file
337
src/PluginUtils/_StyleEditor.py
Normal file
@@ -0,0 +1,337 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 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
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Paragraph/Font style editor
|
||||
"""
|
||||
|
||||
__author__ = "Donald N. Allingham"
|
||||
__version__ = "$Revision$"
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import logging
|
||||
log = logging.getLogger(".")
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GNOME/GTK modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import Utils
|
||||
import const
|
||||
import BaseDoc
|
||||
import ListModel
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# StyleList class
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class StyleListDisplay:
|
||||
"""
|
||||
Shows the available paragraph/font styles. Allows the user to select,
|
||||
add, edit, and delete styles from a StyleSheet.
|
||||
"""
|
||||
|
||||
def __init__(self,stylesheetlist,callback,parent_window):
|
||||
"""
|
||||
Creates a StyleListDisplay object that displays the styles in the
|
||||
StyleSheet.
|
||||
|
||||
stylesheetlist - styles that can be editied
|
||||
callback - task called with an object has been added.
|
||||
"""
|
||||
self.callback = callback
|
||||
|
||||
self.sheetlist = stylesheetlist
|
||||
self.top = gtk.glade.XML(const.gladeFile,"styles","gramps")
|
||||
self.window = self.top.get_widget('styles')
|
||||
|
||||
Utils.set_titles(self.window,
|
||||
self.top.get_widget('title'),
|
||||
_('Document Styles'))
|
||||
|
||||
self.top.signal_autoconnect({
|
||||
"destroy_passed_object" : Utils.destroy_passed_object,
|
||||
"on_ok_clicked" : self.on_ok_clicked,
|
||||
"on_add_clicked" : self.on_add_clicked,
|
||||
"on_delete_clicked" : self.on_delete_clicked,
|
||||
"on_button_press" : self.on_button_press,
|
||||
"on_edit_clicked" : self.on_edit_clicked
|
||||
})
|
||||
|
||||
title_label = self.top.get_widget('title')
|
||||
title_label.set_text(Utils.title(_('Style Editor')))
|
||||
title_label.set_use_markup(True)
|
||||
|
||||
self.list = ListModel.ListModel(self.top.get_widget("list"),
|
||||
[('Style',-1,10)],)
|
||||
self.redraw()
|
||||
if parent_window:
|
||||
self.window.set_transient_for(parent_window)
|
||||
self.window.run()
|
||||
self.window.destroy()
|
||||
|
||||
def redraw(self):
|
||||
"""Redraws the list of styles that are current available"""
|
||||
|
||||
self.list.model.clear()
|
||||
self.list.add(["default"])
|
||||
|
||||
index = 1
|
||||
for style in self.sheetlist.get_style_names():
|
||||
if style == "default":
|
||||
continue
|
||||
self.list.add([style])
|
||||
index = index + 1
|
||||
|
||||
def on_add_clicked(self,obj):
|
||||
"""Called with the ADD button is clicked. Invokes the StyleEditor to
|
||||
create a new style"""
|
||||
style = self.sheetlist.get_style_sheet("default")
|
||||
StyleEditor("New Style",style,self)
|
||||
|
||||
def on_ok_clicked(self,obj):
|
||||
"""Called with the OK button is clicked; Calls the callback task,
|
||||
then saves the stylesheet."""
|
||||
self.callback()
|
||||
try:
|
||||
self.sheetlist.save()
|
||||
except IOError,msg:
|
||||
from QuestionDialog import ErrorDialog
|
||||
ErrorDialog(_("Error saving stylesheet"),str(msg))
|
||||
except:
|
||||
log.error("Failed to save stylesheet",exc_info=True)
|
||||
|
||||
def on_button_press(self,obj,event):
|
||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||
self.on_edit_clicked(obj)
|
||||
|
||||
def on_edit_clicked(self,obj):
|
||||
"""
|
||||
Called with the EDIT button is clicked.
|
||||
Calls the StyleEditor to edit the selected style.
|
||||
"""
|
||||
store,node = self.list.selection.get_selected()
|
||||
if not node:
|
||||
return
|
||||
|
||||
name = self.list.model.get_value(node,0)
|
||||
style = self.sheetlist.get_style_sheet(name)
|
||||
StyleEditor(name,style,self)
|
||||
|
||||
def on_delete_clicked(self,obj):
|
||||
"""Deletes the selected style."""
|
||||
store,node = self.list.selection.get_selected()
|
||||
if not node:
|
||||
return
|
||||
name = self.list.model.get_value(node,0)
|
||||
self.sheetlist.delete_style_sheet(name)
|
||||
self.redraw()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# StyleEditor class
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class StyleEditor:
|
||||
"""
|
||||
Edits the current style definition. Presents a dialog allowing the values
|
||||
of the paragraphs in the style to be altered.
|
||||
"""
|
||||
|
||||
def __init__(self,name,style,parent):
|
||||
"""
|
||||
Creates the StyleEditor.
|
||||
|
||||
name - name of the style that is to be edited
|
||||
style - style object that is to be edited
|
||||
parent - StyleListDisplay object that called the editor
|
||||
"""
|
||||
|
||||
self.original_style = style
|
||||
self.style = BaseDoc.StyleSheet(style)
|
||||
self.parent = parent
|
||||
self.top = gtk.glade.XML(const.gladeFile,"editor","gramps")
|
||||
|
||||
self.top.signal_autoconnect({
|
||||
"on_save_style_clicked" : self.on_save_style_clicked,
|
||||
"destroy_passed_object" : Utils.destroy_passed_object
|
||||
})
|
||||
|
||||
self.window = self.top.get_widget("editor")
|
||||
self.pname = self.top.get_widget('pname')
|
||||
self.pdescription = self.top.get_widget('pdescription')
|
||||
|
||||
Utils.set_titles(self.window, self.top.get_widget('title'),_('Style editor'))
|
||||
|
||||
self.first = 1
|
||||
|
||||
titles = [(_('Paragraph'),0,130)]
|
||||
self.plist = ListModel.ListModel(self.top.get_widget("ptree"),titles,
|
||||
self.change_display)
|
||||
|
||||
self.top.get_widget('color').connect('color-set',self.fg_color_set)
|
||||
self.top.get_widget('bgcolor').connect('color-set',self.bg_color_set)
|
||||
self.top.get_widget("style_name").set_text(name)
|
||||
|
||||
names = self.style.get_names()
|
||||
names.reverse()
|
||||
for p_name in names:
|
||||
self.plist.add([p_name],self.style.get_style(p_name))
|
||||
self.plist.select_row(0)
|
||||
|
||||
def draw(self,name,p):
|
||||
"""Updates the display with the selected paragraph."""
|
||||
|
||||
self.current_p = p
|
||||
|
||||
self.pname.set_text('<span size="larger" weight="bold">%s</span>' % name)
|
||||
self.pname.set_use_markup(True)
|
||||
|
||||
descr = p.get_description()
|
||||
if descr:
|
||||
self.pdescription.set_text(descr)
|
||||
else:
|
||||
self.pdescription.set_text(_("No description available"))
|
||||
|
||||
font = p.get_font()
|
||||
self.top.get_widget("size").set_value(font.get_size())
|
||||
if font.get_type_face() == BaseDoc.FONT_SERIF:
|
||||
self.top.get_widget("roman").set_active(1)
|
||||
else:
|
||||
self.top.get_widget("swiss").set_active(1)
|
||||
self.top.get_widget("bold").set_active(font.get_bold())
|
||||
self.top.get_widget("italic").set_active(font.get_italic())
|
||||
self.top.get_widget("underline").set_active(font.get_underline())
|
||||
if p.get_alignment() == BaseDoc.PARA_ALIGN_LEFT:
|
||||
self.top.get_widget("lalign").set_active(1)
|
||||
elif p.get_alignment() == BaseDoc.PARA_ALIGN_RIGHT:
|
||||
self.top.get_widget("ralign").set_active(1)
|
||||
elif p.get_alignment() == BaseDoc.PARA_ALIGN_CENTER:
|
||||
self.top.get_widget("calign").set_active(1)
|
||||
else:
|
||||
self.top.get_widget("jalign").set_active(1)
|
||||
self.top.get_widget("rmargin").set_value(p.get_right_margin())
|
||||
self.top.get_widget("lmargin").set_value(p.get_left_margin())
|
||||
self.top.get_widget("pad").set_value(p.get_padding())
|
||||
self.top.get_widget("tmargin").set_value(p.get_top_margin())
|
||||
self.top.get_widget("bmargin").set_value(p.get_bottom_margin())
|
||||
self.top.get_widget("indent").set_value(p.get_first_indent())
|
||||
self.top.get_widget("tborder").set_active(p.get_top_border())
|
||||
self.top.get_widget("lborder").set_active(p.get_left_border())
|
||||
self.top.get_widget("rborder").set_active(p.get_right_border())
|
||||
self.top.get_widget("bborder").set_active(p.get_bottom_border())
|
||||
self.fg_color = font.get_color()
|
||||
self.top.get_widget("color").set_i8(self.fg_color[0],self.fg_color[1],self.fg_color[2],0)
|
||||
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
|
||||
|
||||
self.bg_color = p.get_background_color()
|
||||
self.top.get_widget("bgcolor").set_i8(self.bg_color[0],self.bg_color[1],self.bg_color[2],0)
|
||||
self.top.get_widget('bgcolor_code').set_text("#%02X%02X%02X" % self.bg_color)
|
||||
|
||||
def bg_color_set(self,x,r,g,b,a):
|
||||
self.bg_color = (r >> 8, g >> 8, b >> 8)
|
||||
self.top.get_widget('bgcolor_code').set_text("#%02X%02X%02X" % self.bg_color)
|
||||
|
||||
def fg_color_set(self,x,r,g,b,a):
|
||||
self.fg_color = (r >> 8, g >> 8, b >> 8)
|
||||
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
|
||||
|
||||
def save_paragraph(self,p):
|
||||
"""Saves the current paragraph displayed on the dialog"""
|
||||
|
||||
font = p.get_font()
|
||||
font.set_size(self.top.get_widget("size").get_value_as_int())
|
||||
|
||||
if self.top.get_widget("roman").get_active():
|
||||
font.set_type_face(BaseDoc.FONT_SERIF)
|
||||
else:
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
|
||||
font.set_bold(self.top.get_widget("bold").get_active())
|
||||
font.set_italic(self.top.get_widget("italic").get_active())
|
||||
font.set_underline(self.top.get_widget("underline").get_active())
|
||||
if self.top.get_widget("lalign").get_active():
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
|
||||
elif self.top.get_widget("ralign").get_active():
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_RIGHT)
|
||||
elif self.top.get_widget("calign").get_active():
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
else:
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_JUSTIFY)
|
||||
|
||||
p.set_right_margin(self.top.get_widget("rmargin").get_value())
|
||||
p.set_left_margin(self.top.get_widget("lmargin").get_value())
|
||||
p.set_top_margin(self.top.get_widget("tmargin").get_value())
|
||||
p.set_bottom_margin(self.top.get_widget("bmargin").get_value())
|
||||
p.set_padding(self.top.get_widget("pad").get_value())
|
||||
p.set_first_indent(self.top.get_widget("indent").get_value())
|
||||
p.set_top_border(self.top.get_widget("tborder").get_active())
|
||||
p.set_left_border(self.top.get_widget("lborder").get_active())
|
||||
p.set_right_border(self.top.get_widget("rborder").get_active())
|
||||
p.set_bottom_border(self.top.get_widget("bborder").get_active())
|
||||
|
||||
font.set_color(self.fg_color)
|
||||
p.set_background_color(self.bg_color)
|
||||
|
||||
def on_save_style_clicked(self,obj):
|
||||
"""
|
||||
Saves the current style sheet and causes the parent to be updated with
|
||||
the changes.
|
||||
"""
|
||||
p = self.current_p
|
||||
name = unicode(self.top.get_widget("style_name").get_text())
|
||||
|
||||
self.save_paragraph(p)
|
||||
self.style.set_name(name)
|
||||
self.parent.sheetlist.set_style_sheet(name,self.style)
|
||||
self.parent.redraw()
|
||||
Utils.destroy_passed_object(obj)
|
||||
|
||||
def change_display(self,obj):
|
||||
"""Called when the paragraph selection has been changed. Saves the
|
||||
old paragraph, then draws the newly selected paragraph"""
|
||||
|
||||
objs = self.plist.get_selected_objects()
|
||||
store,node = self.plist.get_selected()
|
||||
name = store.get_value(node,0)
|
||||
if self.first == 0:
|
||||
self.save_paragraph(self.current_p)
|
||||
else:
|
||||
self.first = 0
|
||||
self.current_p = objs[0]
|
||||
self.draw(name,self.current_p)
|
||||
Reference in New Issue
Block a user