Add draw styles to style sheet editor
This commit is contained in:
parent
f66a810b46
commit
6ce73e128e
@ -166,6 +166,9 @@ class StyleSheetList(object):
|
|||||||
for c_name in sheet.get_cell_style_names():
|
for c_name in sheet.get_cell_style_names():
|
||||||
self.write_cell_style(xml_file, sheet, c_name)
|
self.write_cell_style(xml_file, sheet, c_name)
|
||||||
|
|
||||||
|
for g_name in sheet.get_draw_style_names():
|
||||||
|
self.write_graphics_style(xml_file, sheet, g_name)
|
||||||
|
|
||||||
xml_file.write('</sheet>\n')
|
xml_file.write('</sheet>\n')
|
||||||
xml_file.write('</stylelist>\n')
|
xml_file.write('</stylelist>\n')
|
||||||
xml_file.close()
|
xml_file.close()
|
||||||
@ -247,6 +250,24 @@ class StyleSheetList(object):
|
|||||||
'</style>\n'
|
'</style>\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def write_graphics_style(self, xml_file, sheet, g_name):
|
||||||
|
|
||||||
|
draw = sheet.get_draw_style(g_name)
|
||||||
|
|
||||||
|
# Write out style definition
|
||||||
|
xml_file.write(
|
||||||
|
'<style name="%s">\n' % escxml(g_name) +
|
||||||
|
'<draw para="%s" ' % draw.get_paragraph_style() +
|
||||||
|
'width="%.3f" ' % draw.get_line_width() +
|
||||||
|
'style="%d" ' % draw.get_line_style() +
|
||||||
|
'color="#%02x%02x%02x" ' % draw.get_color() +
|
||||||
|
'fillcolor="#%02x%02x%02x" ' % draw.get_fill_color() +
|
||||||
|
'shadow="%d" ' % draw.get_shadow() +
|
||||||
|
'space="%.3f" ' % draw.get_shadow_space() +
|
||||||
|
'/>\n' +
|
||||||
|
'</style>\n'
|
||||||
|
)
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
"""
|
"""
|
||||||
Loads the StyleSheets from the associated file, if it exists.
|
Loads the StyleSheets from the associated file, if it exists.
|
||||||
@ -490,6 +511,15 @@ class SheetParser(handler.ContentHandler):
|
|||||||
self.c.set_top_border(int(attrs['tborder']))
|
self.c.set_top_border(int(attrs['tborder']))
|
||||||
self.c.set_bottom_border(int(attrs['bborder']))
|
self.c.set_bottom_border(int(attrs['bborder']))
|
||||||
self.c.set_padding(glocale.float(attrs['pad']))
|
self.c.set_padding(glocale.float(attrs['pad']))
|
||||||
|
elif tag == "draw":
|
||||||
|
self.g = GraphicsStyle()
|
||||||
|
self.g.set_paragraph_style(attrs['para'])
|
||||||
|
self.g.set_line_width(glocale.float(attrs['width']))
|
||||||
|
self.g.set_line_style(int(attrs['style']))
|
||||||
|
self.g.set_color(cnv2color(attrs['color']))
|
||||||
|
self.g.set_fill_color(cnv2color(attrs['fillcolor']))
|
||||||
|
self.g.set_shadow(int(attrs['shadow']),
|
||||||
|
glocale.float(attrs['space']))
|
||||||
|
|
||||||
def endElement(self, tag):
|
def endElement(self, tag):
|
||||||
"Overridden class that handles the end of a XML element"
|
"Overridden class that handles the end of a XML element"
|
||||||
@ -502,3 +532,5 @@ class SheetParser(handler.ContentHandler):
|
|||||||
self.s.add_table_style(self.style_name, self.t)
|
self.s.add_table_style(self.style_name, self.t)
|
||||||
elif tag == "cell":
|
elif tag == "cell":
|
||||||
self.s.add_cell_style(self.style_name, self.c)
|
self.s.add_cell_style(self.style_name, self.c)
|
||||||
|
elif tag == "draw":
|
||||||
|
self.s.add_draw_style(self.style_name, self.g)
|
||||||
|
@ -9,6 +9,18 @@
|
|||||||
<property name="step_increment">0.10000000000000001</property>
|
<property name="step_increment">0.10000000000000001</property>
|
||||||
<property name="page_increment">1</property>
|
<property name="page_increment">1</property>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkAdjustment" id="adjustment10">
|
||||||
|
<property name="upper">20</property>
|
||||||
|
<property name="value">1</property>
|
||||||
|
<property name="step_increment">0.10000000000000001</property>
|
||||||
|
<property name="page_increment">1</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkAdjustment" id="adjustment11">
|
||||||
|
<property name="upper">5</property>
|
||||||
|
<property name="value">0.20000000000000001</property>
|
||||||
|
<property name="step_increment">0.10000000000000001</property>
|
||||||
|
<property name="page_increment">1</property>
|
||||||
|
</object>
|
||||||
<object class="GtkAdjustment" id="adjustment2">
|
<object class="GtkAdjustment" id="adjustment2">
|
||||||
<property name="lower">-100</property>
|
<property name="lower">-100</property>
|
||||||
<property name="upper">100</property>
|
<property name="upper">100</property>
|
||||||
@ -1546,6 +1558,329 @@
|
|||||||
<property name="tab_fill">False</property>
|
<property name="tab_fill">False</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid" id="grid2">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="border_width">12</property>
|
||||||
|
<property name="row_spacing">6</property>
|
||||||
|
<property name="column_spacing">12</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label32">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0</property>
|
||||||
|
<property name="ypad">3</property>
|
||||||
|
<property name="label" translatable="yes">Line</property>
|
||||||
|
<property name="justify">center</property>
|
||||||
|
<property name="ellipsize">end</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
<property name="width">4</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label33">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0</property>
|
||||||
|
<property name="ypad">3</property>
|
||||||
|
<property name="label" translatable="yes">Color</property>
|
||||||
|
<property name="justify">center</property>
|
||||||
|
<property name="ellipsize">end</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
<property name="width">4</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label34">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Style:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label35">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Width:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label36">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Line:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">4</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label37">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Fill:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">5</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label38">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0</property>
|
||||||
|
<property name="ypad">3</property>
|
||||||
|
<property name="label" translatable="yes">Shadow</property>
|
||||||
|
<property name="justify">center</property>
|
||||||
|
<property name="ellipsize">end</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="weight" value="bold"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">6</property>
|
||||||
|
<property name="width">4</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColorButton" id="line_color">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="top_attach">4</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColorButton" id="fill_color">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="top_attach">5</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="line_color_code">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">3</property>
|
||||||
|
<property name="top_attach">4</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="fill_color_code">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">3</property>
|
||||||
|
<property name="top_attach">5</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="line_width">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="adjustment">adjustment10</property>
|
||||||
|
<property name="digits">1</property>
|
||||||
|
<property name="numeric">True</property>
|
||||||
|
<property name="value">1</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label39">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">pt</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">3</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBox" id="line_style">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label40">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Spacing:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">8</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="shadow_space">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="adjustment">adjustment11</property>
|
||||||
|
<property name="digits">2</property>
|
||||||
|
<property name="numeric">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="top_attach">8</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="shadow">
|
||||||
|
<property name="label" translatable="yes">Draw shadow</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="top_attach">7</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label41">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">cm</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">3</property>
|
||||||
|
<property name="top_attach">8</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">5</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child type="tab">
|
||||||
|
<object class="GtkLabel" id="label31">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes"><b>Draw options</b></property>
|
||||||
|
<property name="use_markup">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">5</property>
|
||||||
|
<property name="tab_fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">True</property>
|
<property name="resize">True</property>
|
||||||
|
@ -52,7 +52,8 @@ from gi.repository import Gtk, Gdk
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from gramps.gen.plug.docgen import (StyleSheet, FONT_SERIF, FONT_SANS_SERIF,
|
from gramps.gen.plug.docgen import (StyleSheet, FONT_SERIF, FONT_SANS_SERIF,
|
||||||
PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT,
|
PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT,
|
||||||
PARA_ALIGN_JUSTIFY, ParagraphStyle, TableStyle, TableCellStyle)
|
PARA_ALIGN_JUSTIFY, ParagraphStyle, TableStyle, TableCellStyle,
|
||||||
|
GraphicsStyle)
|
||||||
from gramps.gen.constfunc import cuni
|
from gramps.gen.constfunc import cuni
|
||||||
from ...listmodel import ListModel
|
from ...listmodel import ListModel
|
||||||
from ...managedwindow import set_titles
|
from ...managedwindow import set_titles
|
||||||
@ -213,6 +214,16 @@ class StyleEditor(object):
|
|||||||
self.notebook = self.top.get_object('notebook1')
|
self.notebook = self.top.get_object('notebook1')
|
||||||
self.vbox = self.top.get_object('column_widths')
|
self.vbox = self.top.get_object('column_widths')
|
||||||
|
|
||||||
|
self.line_style = self.top.get_object('line_style')
|
||||||
|
line_styles = Gtk.ListStore(int, str)
|
||||||
|
line_styles.append([0, "Solid"])
|
||||||
|
line_styles.append([1, "Dashed"])
|
||||||
|
line_styles.append([2, "Dotted"])
|
||||||
|
self.line_style.set_model(line_styles)
|
||||||
|
renderer_text = Gtk.CellRendererText()
|
||||||
|
self.line_style.pack_start(renderer_text, True)
|
||||||
|
self.line_style.add_attribute(renderer_text, "text", 1)
|
||||||
|
|
||||||
set_titles(self.window, self.top.get_object('title'),
|
set_titles(self.window, self.top.get_object('title'),
|
||||||
_('Style editor'))
|
_('Style editor'))
|
||||||
self.top.get_object("label6").set_text(_("point size|pt"))
|
self.top.get_object("label6").set_text(_("point size|pt"))
|
||||||
@ -221,8 +232,11 @@ class StyleEditor(object):
|
|||||||
self.plist = ListModel(self.top.get_object("ptree"), titles,
|
self.plist = ListModel(self.top.get_object("ptree"), titles,
|
||||||
self.change_display)
|
self.change_display)
|
||||||
|
|
||||||
self.top.get_object('color').connect('color-set', self.fg_color_set)
|
for name in ('color', 'bgcolor', 'line_color', 'fill_color'):
|
||||||
self.top.get_object('bgcolor').connect('color-set', self.bg_color_set)
|
color = self.top.get_object(name)
|
||||||
|
label = self.top.get_object(name + '_code')
|
||||||
|
color.connect('notify::color', self.color_changed, label)
|
||||||
|
|
||||||
self.top.get_object("style_name").set_text(name)
|
self.top.get_object("style_name").set_text(name)
|
||||||
|
|
||||||
def _alphanumeric_sort(iterable):
|
def _alphanumeric_sort(iterable):
|
||||||
@ -240,6 +254,9 @@ class StyleEditor(object):
|
|||||||
names = _alphanumeric_sort(self.style.get_cell_style_names())
|
names = _alphanumeric_sort(self.style.get_cell_style_names())
|
||||||
for c_name in names:
|
for c_name in names:
|
||||||
self.plist.add([c_name], self.style.get_cell_style(c_name))
|
self.plist.add([c_name], self.style.get_cell_style(c_name))
|
||||||
|
names = _alphanumeric_sort(self.style.get_draw_style_names())
|
||||||
|
for d_name in names:
|
||||||
|
self.plist.add([d_name], self.style.get_draw_style(d_name))
|
||||||
self.plist.select_row(0)
|
self.plist.select_row(0)
|
||||||
|
|
||||||
if self.parent:
|
if self.parent:
|
||||||
@ -274,6 +291,30 @@ class StyleEditor(object):
|
|||||||
elif isinstance(self.current_style, TableCellStyle):
|
elif isinstance(self.current_style, TableCellStyle):
|
||||||
self.show_pages([0, 4])
|
self.show_pages([0, 4])
|
||||||
self.draw_cell()
|
self.draw_cell()
|
||||||
|
elif isinstance(self.current_style, GraphicsStyle):
|
||||||
|
self.show_pages([0, 5])
|
||||||
|
self.draw_graphics()
|
||||||
|
|
||||||
|
def draw_graphics(self):
|
||||||
|
"""
|
||||||
|
Updates the display with the selected graphics style.
|
||||||
|
"""
|
||||||
|
g = self.current_style
|
||||||
|
self.pname.set_text( '<span size="larger" weight="bold">%s</span>' %
|
||||||
|
self.current_name)
|
||||||
|
self.pname.set_use_markup(True)
|
||||||
|
self.pdescription.set_text(_("No description available") )
|
||||||
|
|
||||||
|
self.top.get_object("line_style").set_active(g.get_line_style())
|
||||||
|
self.top.get_object("line_width").set_value(g.get_line_width())
|
||||||
|
|
||||||
|
self.line_color = rgb2color(g.get_color())
|
||||||
|
self.top.get_object("line_color").set_color(self.line_color)
|
||||||
|
self.fill_color = rgb2color(g.get_fill_color())
|
||||||
|
self.top.get_object("fill_color").set_color(self.fill_color)
|
||||||
|
|
||||||
|
self.top.get_object("shadow").set_active(g.get_shadow())
|
||||||
|
self.top.get_object("shadow_space").set_value(g.get_shadow_space())
|
||||||
|
|
||||||
def draw_cell(self):
|
def draw_cell(self):
|
||||||
"""
|
"""
|
||||||
@ -362,34 +403,18 @@ class StyleEditor(object):
|
|||||||
self.top.get_object("rborder").set_active(p.get_right_border())
|
self.top.get_object("rborder").set_active(p.get_right_border())
|
||||||
self.top.get_object("bborder").set_active(p.get_bottom_border())
|
self.top.get_object("bborder").set_active(p.get_bottom_border())
|
||||||
|
|
||||||
self.fg_color = font.get_color()
|
color = rgb2color(font.get_color())
|
||||||
c = Gdk.Color(self.fg_color[0] << 8,
|
self.top.get_object("color").set_color(color)
|
||||||
self.fg_color[1] << 8,
|
bg_color = rgb2color(p.get_background_color())
|
||||||
self.fg_color[2] << 8)
|
self.top.get_object("bgcolor").set_color(bg_color)
|
||||||
self.top.get_object("color").set_color(c)
|
|
||||||
self.top.get_object('color_code').set_text(
|
|
||||||
"#%02X%02X%02X" % self.fg_color)
|
|
||||||
|
|
||||||
self.bg_color = p.get_background_color()
|
def color_changed(self, color, name, label):
|
||||||
c = Gdk.Color(self.bg_color[0] << 8,
|
"""
|
||||||
self.bg_color[1] << 8,
|
Called to set the color code when a color is changed.
|
||||||
self.bg_color[2] << 8)
|
"""
|
||||||
self.top.get_object("bgcolor").set_color(c)
|
rgb = color2rgb(color.get_color())
|
||||||
self.top.get_object('bgcolor_code').set_text(
|
label.set_text("#%02X%02X%02X" % color2rgb(color.get_color()))
|
||||||
"#%02X%02X%02X" % self.bg_color)
|
|
||||||
|
|
||||||
def bg_color_set(self, x):
|
|
||||||
c = x.get_color()
|
|
||||||
self.bg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
|
||||||
self.top.get_object('bgcolor_code').set_text(
|
|
||||||
"#%02X%02X%02X" % self.bg_color)
|
|
||||||
|
|
||||||
def fg_color_set(self, x):
|
|
||||||
c = x.get_color()
|
|
||||||
self.fg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
|
||||||
self.top.get_object('color_code').set_text(
|
|
||||||
"#%02X%02X%02X" % self.fg_color)
|
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
"""
|
"""
|
||||||
Saves the current style displayed on the dialog.
|
Saves the current style displayed on the dialog.
|
||||||
@ -400,6 +425,25 @@ class StyleEditor(object):
|
|||||||
self.save_table()
|
self.save_table()
|
||||||
elif isinstance(self.current_style, TableCellStyle):
|
elif isinstance(self.current_style, TableCellStyle):
|
||||||
self.save_cell()
|
self.save_cell()
|
||||||
|
elif isinstance(self.current_style, GraphicsStyle):
|
||||||
|
self.save_graphics()
|
||||||
|
|
||||||
|
def save_graphics(self):
|
||||||
|
"""
|
||||||
|
Saves the current graphics style displayed on the dialog.
|
||||||
|
"""
|
||||||
|
g = self.current_style
|
||||||
|
g.set_line_style(self.top.get_object("line_style").get_active())
|
||||||
|
g.set_line_width(self.top.get_object("line_width").get_value())
|
||||||
|
line_color = self.top.get_object("line_color").get_color()
|
||||||
|
g.set_color(color2rgb(line_color))
|
||||||
|
fill_color = self.top.get_object("fill_color").get_color()
|
||||||
|
g.set_fill_color(color2rgb(fill_color))
|
||||||
|
shadow = self.top.get_object("shadow").get_active()
|
||||||
|
shadow_space = self.top.get_object("shadow_space").get_value()
|
||||||
|
g.set_shadow(shadow, shadow_space)
|
||||||
|
|
||||||
|
self.style.add_draw_style(self.current_name, self.current_style)
|
||||||
|
|
||||||
def save_cell(self):
|
def save_cell(self):
|
||||||
"""
|
"""
|
||||||
@ -461,8 +505,10 @@ class StyleEditor(object):
|
|||||||
p.set_right_border(self.top.get_object("rborder").get_active())
|
p.set_right_border(self.top.get_object("rborder").get_active())
|
||||||
p.set_bottom_border(self.top.get_object("bborder").get_active())
|
p.set_bottom_border(self.top.get_object("bborder").get_active())
|
||||||
|
|
||||||
font.set_color(self.fg_color)
|
color = self.top.get_object("color").get_color()
|
||||||
p.set_background_color(self.bg_color)
|
font.set_color(color2rgb(color))
|
||||||
|
bg_color = self.top.get_object("bgcolor").get_color()
|
||||||
|
p.set_background_color(color2rgb(bg_color))
|
||||||
|
|
||||||
self.style.add_paragraph_style(self.current_name, self.current_style)
|
self.style.add_paragraph_style(self.current_name, self.current_style)
|
||||||
|
|
||||||
@ -495,6 +541,19 @@ class StyleEditor(object):
|
|||||||
self.current_style = objs[0]
|
self.current_style = objs[0]
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
|
|
||||||
|
def rgb2color(rgb):
|
||||||
|
"""
|
||||||
|
Convert a tuple containing RGB values into a Gdk Color.
|
||||||
|
"""
|
||||||
|
return Gdk.Color(rgb[0] << 8, rgb[1] << 8, rgb[2] << 8)
|
||||||
|
|
||||||
|
def color2rgb(color):
|
||||||
|
"""
|
||||||
|
Convert a Gdk Color into a tuple containing RGB values.
|
||||||
|
"""
|
||||||
|
return (color.red >> 8, color.green >> 8, color.blue >> 8)
|
||||||
|
|
||||||
def dummy_callback(obj):
|
def dummy_callback(obj):
|
||||||
"""Dummy callback to satisfy gtkbuilder on connect of signals.
|
"""Dummy callback to satisfy gtkbuilder on connect of signals.
|
||||||
There are two widgets in the glade file, although only one is needed,
|
There are two widgets in the glade file, although only one is needed,
|
||||||
|
Loading…
Reference in New Issue
Block a user