2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-01-25 00:59:51 +05:30
|
|
|
# Copyright (C) 2000-2005 Donald N. Allingham
|
2008-03-12 07:51:03 +05:30
|
|
|
# Copyright (C) 2007-2008 Brian G. Matherly
|
|
|
|
# Copyright (C) 2008 Peter Landgren
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2007-07-19 09:18:38 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2002-10-20 19:55:16 +05:30
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
Paragraph/Font style editor
|
|
|
|
"""
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import sgettext as _
|
2006-01-09 16:58:44 +05:30
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".")
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import gtk
|
2006-04-29 21:14:44 +05:30
|
|
|
from gtk.gdk import Color
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import Utils
|
|
|
|
import const
|
2009-05-31 20:29:56 +05:30
|
|
|
from gen.plug.docgen import (StyleSheet, FONT_SERIF, FONT_SANS_SERIF,
|
2009-05-30 03:55:44 +05:30
|
|
|
PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT,
|
|
|
|
PARA_ALIGN_JUSTIFY)
|
2002-10-28 19:06:39 +05:30
|
|
|
import ListModel
|
2006-06-05 04:53:10 +05:30
|
|
|
import ManagedWindow
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
#------------------------------------------------------------------------
|
2005-12-06 12:08:09 +05:30
|
|
|
#
|
|
|
|
# StyleList class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-05-21 22:49:50 +05:30
|
|
|
class StyleListDisplay(object):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2007-07-19 09:18:38 +05:30
|
|
|
Shows the available paragraph/font styles. Allows the user to select,
|
2002-10-20 19:55:16 +05:30
|
|
|
add, edit, and delete styles from a StyleSheet.
|
|
|
|
"""
|
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def __init__(self, stylesheetlist, callback, parent_window):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create a StyleListDisplay object that displays the styles in the
|
2002-10-20 19:55:16 +05:30
|
|
|
StyleSheet.
|
|
|
|
|
|
|
|
stylesheetlist - styles that can be editied
|
|
|
|
callback - task called with an object has been added.
|
|
|
|
"""
|
|
|
|
self.callback = callback
|
|
|
|
|
|
|
|
self.sheetlist = stylesheetlist
|
2009-05-06 20:14:22 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.top = Glade(toplevel='styles')
|
|
|
|
self.window = self.top.toplevel
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
ManagedWindow.set_titles( self.window,
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object('title'),
|
2006-06-05 04:53:10 +05:30
|
|
|
_('Document Styles') )
|
2003-03-07 07:51:18 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.connect_signals({
|
2007-07-19 09:18:38 +05:30
|
|
|
"destroy_passed_object" : self.__close,
|
|
|
|
"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,
|
2002-10-20 19:55:16 +05:30
|
|
|
"on_edit_clicked" : self.on_edit_clicked
|
|
|
|
})
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
title_label = self.top.get_object('title')
|
2003-03-05 11:31:31 +05:30
|
|
|
title_label.set_text(Utils.title(_('Style Editor')))
|
2005-02-24 05:55:34 +05:30
|
|
|
title_label.set_use_markup(True)
|
2002-10-28 19:06:39 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
self.list = ListModel.ListModel(self.top.get_object("list"),
|
2007-07-19 09:18:38 +05:30
|
|
|
[(_('Style'), -1, 10)], )
|
2002-10-20 19:55:16 +05:30
|
|
|
self.redraw()
|
2004-12-22 07:26:37 +05:30
|
|
|
if parent_window:
|
|
|
|
self.window.set_transient_for(parent_window)
|
2005-01-09 07:48:49 +05:30
|
|
|
self.window.run()
|
2004-12-22 07:26:37 +05:30
|
|
|
self.window.destroy()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def __close(self, obj):
|
|
|
|
self.top.destroy()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def redraw(self):
|
|
|
|
"""Redraws the list of styles that are current available"""
|
|
|
|
|
2002-10-28 19:06:39 +05:30
|
|
|
self.list.model.clear()
|
|
|
|
self.list.add(["default"])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
index = 1
|
|
|
|
for style in self.sheetlist.get_style_names():
|
|
|
|
if style == "default":
|
|
|
|
continue
|
2002-10-28 19:06:39 +05:30
|
|
|
self.list.add([style])
|
2009-09-11 00:19:48 +05:30
|
|
|
index += 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def on_add_clicked(self, obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Called with the ADD button is clicked. Invokes the StyleEditor to
|
|
|
|
create a new style"""
|
|
|
|
style = self.sheetlist.get_style_sheet("default")
|
2007-07-19 09:18:38 +05:30
|
|
|
StyleEditor("New Style", style, self)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def on_ok_clicked(self, obj):
|
|
|
|
"""Called with the OK button is clicked; Calls the callback task,
|
2004-12-22 07:26:37 +05:30
|
|
|
then saves the stylesheet."""
|
2008-04-29 10:17:50 +05:30
|
|
|
if self.callback is not None:
|
|
|
|
self.callback()
|
2003-01-29 10:13:12 +05:30
|
|
|
try:
|
|
|
|
self.sheetlist.save()
|
2007-07-19 09:18:38 +05:30
|
|
|
except IOError, msg:
|
2003-01-29 10:13:12 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2007-07-19 09:18:38 +05:30
|
|
|
ErrorDialog(_("Error saving stylesheet"), str(msg))
|
2003-01-29 10:13:12 +05:30
|
|
|
except:
|
2007-07-19 09:18:38 +05:30
|
|
|
log.error("Failed to save stylesheet", exc_info=True)
|
2002-10-28 19:06:39 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def on_button_press(self, obj, event):
|
2002-10-28 19:06:39 +05:30
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
|
|
self.on_edit_clicked(obj)
|
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def on_edit_clicked(self, obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2005-12-06 12:08:09 +05:30
|
|
|
Called with the EDIT button is clicked.
|
|
|
|
Calls the StyleEditor to edit the selected style.
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2007-07-19 09:18:38 +05:30
|
|
|
store, node = self.list.selection.get_selected()
|
2004-08-23 04:46:57 +05:30
|
|
|
if not node:
|
2002-10-28 19:06:39 +05:30
|
|
|
return
|
|
|
|
|
2008-01-23 18:44:05 +05:30
|
|
|
name = unicode(self.list.model.get_value(node, 0))
|
2002-10-28 19:06:39 +05:30
|
|
|
style = self.sheetlist.get_style_sheet(name)
|
2007-07-19 09:18:38 +05:30
|
|
|
StyleEditor(name, style, self)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def on_delete_clicked(self, obj):
|
2003-03-04 11:18:36 +05:30
|
|
|
"""Deletes the selected style."""
|
2007-07-19 09:18:38 +05:30
|
|
|
store, node = self.list.selection.get_selected()
|
2004-08-23 04:46:57 +05:30
|
|
|
if not node:
|
2002-10-28 19:06:39 +05:30
|
|
|
return
|
2008-01-23 18:44:05 +05:30
|
|
|
name = unicode(self.list.model.get_value(node, 0))
|
2002-10-28 19:06:39 +05:30
|
|
|
self.sheetlist.delete_style_sheet(name)
|
|
|
|
self.redraw()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# StyleEditor class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-05-21 22:49:50 +05:30
|
|
|
class StyleEditor(object):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2005-12-06 12:08:09 +05:30
|
|
|
Edits the current style definition. Presents a dialog allowing the values
|
|
|
|
of the paragraphs in the style to be altered.
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def __init__(self, name, style, parent):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the StyleEditor.
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
2007-04-23 17:16:26 +05:30
|
|
|
self.current_p = None
|
|
|
|
self.current_name = None
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-30 03:55:44 +05:30
|
|
|
self.style = StyleSheet(style)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent = parent
|
2009-05-15 01:45:59 +05:30
|
|
|
self.top = Glade(toplevel='editor')
|
|
|
|
self.window = self.top.toplevel
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.connect_signals({
|
2007-07-19 09:18:38 +05:30
|
|
|
"on_save_style_clicked" : self.on_save_style_clicked,
|
|
|
|
"destroy_passed_object" : self.__close,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
self.pname = self.top.get_object('pname')
|
|
|
|
self.pdescription = self.top.get_object('pdescription')
|
2009-05-15 01:45:59 +05:30
|
|
|
|
2006-06-05 04:53:10 +05:30
|
|
|
ManagedWindow.set_titles( self.window,
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object('title'),
|
2006-06-05 04:53:10 +05:30
|
|
|
_('Style editor'))
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("label6").set_text(_("point size|pt"))
|
2003-03-04 11:18:36 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
titles = [(_('Paragraph'), 0, 130)]
|
2009-05-06 20:14:22 +05:30
|
|
|
self.plist = ListModel.ListModel(self.top.get_object("ptree"), titles,
|
2003-03-04 11:18:36 +05:30
|
|
|
self.change_display)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object('color').connect('color-set', self.fg_color_set)
|
|
|
|
self.top.get_object('bgcolor').connect('color-set', self.bg_color_set)
|
|
|
|
self.top.get_object("style_name").set_text(name)
|
2003-03-04 11:18:36 +05:30
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
names = self.style.get_paragraph_style_names()
|
2003-03-08 10:33:18 +05:30
|
|
|
names.reverse()
|
|
|
|
for p_name in names:
|
2007-07-19 09:18:38 +05:30
|
|
|
self.plist.add([p_name], self.style.get_paragraph_style(p_name))
|
2003-03-04 11:18:36 +05:30
|
|
|
self.plist.select_row(0)
|
2006-09-28 08:59:23 +05:30
|
|
|
|
|
|
|
if self.parent:
|
|
|
|
self.window.set_transient_for(parent.window)
|
|
|
|
self.window.run()
|
|
|
|
self.window.destroy()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def __close(self, obj):
|
|
|
|
self.window.destroy()
|
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
def draw(self):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Updates the display with the selected paragraph."""
|
2003-03-08 10:33:18 +05:30
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
p = self.current_p
|
|
|
|
self.pname.set_text( '<span size="larger" weight="bold">%s</span>' %
|
|
|
|
self.current_name )
|
2005-02-24 05:55:34 +05:30
|
|
|
self.pname.set_use_markup(True)
|
2003-03-08 10:33:18 +05:30
|
|
|
|
|
|
|
descr = p.get_description()
|
2009-05-06 20:14:22 +05:30
|
|
|
self.pdescription.set_text(descr or _("No description available") )
|
2003-03-08 10:33:18 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
font = p.get_font()
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("size").set_value(font.get_size())
|
2009-05-30 03:55:44 +05:30
|
|
|
if font.get_type_face() == FONT_SERIF:
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("roman").set_active(1)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("swiss").set_active(1)
|
|
|
|
self.top.get_object("bold").set_active(font.get_bold())
|
|
|
|
self.top.get_object("italic").set_active(font.get_italic())
|
|
|
|
self.top.get_object("underline").set_active(font.get_underline())
|
2009-05-30 03:55:44 +05:30
|
|
|
if p.get_alignment() == PARA_ALIGN_LEFT:
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("lalign").set_active(1)
|
2009-05-30 03:55:44 +05:30
|
|
|
elif p.get_alignment() == PARA_ALIGN_RIGHT:
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("ralign").set_active(1)
|
2009-05-30 03:55:44 +05:30
|
|
|
elif p.get_alignment() == PARA_ALIGN_CENTER:
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("calign").set_active(1)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("jalign").set_active(1)
|
|
|
|
self.top.get_object("rmargin").set_value(p.get_right_margin())
|
|
|
|
self.top.get_object("lmargin").set_value(p.get_left_margin())
|
|
|
|
self.top.get_object("pad").set_value(p.get_padding())
|
|
|
|
self.top.get_object("tmargin").set_value(p.get_top_margin())
|
|
|
|
self.top.get_object("bmargin").set_value(p.get_bottom_margin())
|
|
|
|
self.top.get_object("indent").set_value(p.get_first_indent())
|
|
|
|
self.top.get_object("tborder").set_active(p.get_top_border())
|
|
|
|
self.top.get_object("lborder").set_active(p.get_left_border())
|
|
|
|
self.top.get_object("rborder").set_active(p.get_right_border())
|
|
|
|
self.top.get_object("bborder").set_active(p.get_bottom_border())
|
2006-04-29 21:14:44 +05:30
|
|
|
|
2003-01-10 10:51:32 +05:30
|
|
|
self.fg_color = font.get_color()
|
2008-03-12 07:51:03 +05:30
|
|
|
c = Color(self.fg_color[0] << 8,
|
|
|
|
self.fg_color[1] << 8,
|
|
|
|
self.fg_color[2] << 8)
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("color").set_color(c)
|
|
|
|
self.top.get_object('color_code').set_text(
|
2008-03-12 07:51:03 +05:30
|
|
|
"#%02X%02X%02X" % self.fg_color)
|
2006-04-29 21:14:44 +05:30
|
|
|
|
2003-01-10 10:51:32 +05:30
|
|
|
self.bg_color = p.get_background_color()
|
2008-03-12 07:51:03 +05:30
|
|
|
c = Color(self.bg_color[0] << 8,
|
|
|
|
self.bg_color[1] << 8,
|
|
|
|
self.bg_color[2] << 8)
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object("bgcolor").set_color(c)
|
|
|
|
self.top.get_object('bgcolor_code').set_text(
|
2008-03-12 07:51:03 +05:30
|
|
|
"#%02X%02X%02X" % self.bg_color)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def bg_color_set(self, x):
|
2006-04-29 21:14:44 +05:30
|
|
|
c = x.get_color()
|
|
|
|
self.bg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object('bgcolor_code').set_text(
|
2008-03-12 07:51:03 +05:30
|
|
|
"#%02X%02X%02X" % self.bg_color)
|
2002-10-28 19:06:39 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def fg_color_set(self, x):
|
2006-04-29 21:14:44 +05:30
|
|
|
c = x.get_color()
|
|
|
|
self.fg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
2009-05-06 20:14:22 +05:30
|
|
|
self.top.get_object('color_code').set_text(
|
2008-03-12 07:51:03 +05:30
|
|
|
"#%02X%02X%02X" % self.fg_color)
|
2002-10-28 19:06:39 +05:30
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
def save_paragraph(self):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Saves the current paragraph displayed on the dialog"""
|
2007-04-23 17:16:26 +05:30
|
|
|
p = self.current_p
|
2002-10-20 19:55:16 +05:30
|
|
|
font = p.get_font()
|
2009-05-06 20:14:22 +05:30
|
|
|
font.set_size(self.top.get_object("size").get_value_as_int())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
if self.top.get_object("roman").get_active():
|
2009-05-30 03:55:44 +05:30
|
|
|
font.set_type_face(FONT_SERIF)
|
2005-01-25 00:59:51 +05:30
|
|
|
else:
|
2009-05-30 03:55:44 +05:30
|
|
|
font.set_type_face(FONT_SANS_SERIF)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
font.set_bold(self.top.get_object("bold").get_active())
|
|
|
|
font.set_italic(self.top.get_object("italic").get_active())
|
|
|
|
font.set_underline(self.top.get_object("underline").get_active())
|
|
|
|
if self.top.get_object("lalign").get_active():
|
2009-05-30 03:55:44 +05:30
|
|
|
p.set_alignment(PARA_ALIGN_LEFT)
|
2009-05-06 20:14:22 +05:30
|
|
|
elif self.top.get_object("ralign").get_active():
|
2009-05-30 03:55:44 +05:30
|
|
|
p.set_alignment(PARA_ALIGN_RIGHT)
|
2009-05-06 20:14:22 +05:30
|
|
|
elif self.top.get_object("calign").get_active():
|
2009-05-30 03:55:44 +05:30
|
|
|
p.set_alignment(PARA_ALIGN_CENTER)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2009-05-30 03:55:44 +05:30
|
|
|
p.set_alignment(PARA_ALIGN_JUSTIFY)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
p.set_right_margin(self.top.get_object("rmargin").get_value())
|
|
|
|
p.set_left_margin(self.top.get_object("lmargin").get_value())
|
|
|
|
p.set_top_margin(self.top.get_object("tmargin").get_value())
|
|
|
|
p.set_bottom_margin(self.top.get_object("bmargin").get_value())
|
|
|
|
p.set_padding(self.top.get_object("pad").get_value())
|
|
|
|
p.set_first_indent(self.top.get_object("indent").get_value())
|
|
|
|
p.set_top_border(self.top.get_object("tborder").get_active())
|
|
|
|
p.set_left_border(self.top.get_object("lborder").get_active())
|
|
|
|
p.set_right_border(self.top.get_object("rborder").get_active())
|
|
|
|
p.set_bottom_border(self.top.get_object("bborder").get_active())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-01-10 10:51:32 +05:30
|
|
|
font.set_color(self.fg_color)
|
|
|
|
p.set_background_color(self.bg_color)
|
2007-04-23 17:16:26 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
self.style.add_paragraph_style(self.current_name, self.current_p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def on_save_style_clicked(self, obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
Saves the current style sheet and causes the parent to be updated with
|
|
|
|
the changes.
|
|
|
|
"""
|
2009-05-06 20:14:22 +05:30
|
|
|
name = unicode(self.top.get_object("style_name").get_text())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
self.save_paragraph()
|
2003-06-09 23:34:04 +05:30
|
|
|
self.style.set_name(name)
|
2007-07-19 09:18:38 +05:30
|
|
|
self.parent.sheetlist.set_style_sheet(name, self.style)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.redraw()
|
2007-07-19 09:18:38 +05:30
|
|
|
self.window.destroy()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2007-07-19 09:18:38 +05:30
|
|
|
def change_display(self, obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Called when the paragraph selection has been changed. Saves the
|
|
|
|
old paragraph, then draws the newly selected paragraph"""
|
2008-03-12 07:51:03 +05:30
|
|
|
# Don't save until current_name is defined
|
|
|
|
# If it's defined, save under the current paragraph name
|
|
|
|
if self.current_name:
|
|
|
|
self.save_paragraph()
|
|
|
|
# Then change to new paragraph
|
2003-03-04 11:18:36 +05:30
|
|
|
objs = self.plist.get_selected_objects()
|
2007-07-19 09:18:38 +05:30
|
|
|
store, node = self.plist.get_selected()
|
|
|
|
self.current_name = store.get_value(node, 0)
|
2003-03-04 11:18:36 +05:30
|
|
|
self.current_p = objs[0]
|
2007-04-23 17:16:26 +05:30
|
|
|
self.draw()
|