diff --git a/gramps/gen/plug/docgen/stylesheet.py b/gramps/gen/plug/docgen/stylesheet.py index 7e15b4e4a..5a0d64aec 100644 --- a/gramps/gen/plug/docgen/stylesheet.py +++ b/gramps/gen/plug/docgen/stylesheet.py @@ -163,6 +163,9 @@ class StyleSheetList(object): for t_name in sheet.get_table_style_names(): self.write_table_style(xml_file, sheet, t_name) + for c_name in sheet.get_cell_style_names(): + self.write_cell_style(xml_file, sheet, c_name) + xml_file.write('\n') xml_file.write('\n') xml_file.close() @@ -228,6 +231,22 @@ class StyleSheetList(object): xml_file.write('\n') xml_file.write('\n') + def write_cell_style(self, xml_file, sheet, c_name): + + cell = sheet.get_cell_style(c_name) + + # Write out style definition + xml_file.write( + '\n' + ) + def parse(self): """ Loads the StyleSheets from the associated file, if it exists. @@ -464,6 +483,13 @@ class SheetParser(handler.ContentHandler): self.column_widths = [] elif tag == "column": self.column_widths.append(int(attrs['width'])) + elif tag == "cell": + self.c = TableCellStyle() + self.c.set_left_border(int(attrs['lborder'])) + self.c.set_right_border(int(attrs['rborder'])) + self.c.set_top_border(int(attrs['tborder'])) + self.c.set_bottom_border(int(attrs['bborder'])) + self.c.set_padding(glocale.float(attrs['pad'])) def endElement(self, tag): "Overridden class that handles the end of a XML element" @@ -474,3 +500,5 @@ class SheetParser(handler.ContentHandler): elif tag == "table": self.t.set_column_widths(self.column_widths) self.s.add_table_style(self.style_name, self.t) + elif tag == "cell": + self.s.add_cell_style(self.style_name, self.c) diff --git a/gramps/gui/glade/styleeditor.glade b/gramps/gui/glade/styleeditor.glade index 8b774b3da..98254fff8 100644 --- a/gramps/gui/glade/styleeditor.glade +++ b/gramps/gui/glade/styleeditor.glade @@ -50,6 +50,12 @@ 1 10 + + 100 + 0.20000000000000001 + 0.10000000000000001 + 1 + False dialog @@ -1372,6 +1378,174 @@ False + + + True + False + 12 + 6 + 12 + + + True + False + 0 + 0 + 3 + Borders + center + + + + + + 0 + 0 + 5 + 1 + + + + + True + True + adjustment9 + 1 + 2 + True + + + 2 + 2 + 1 + 1 + + + + + True + False + Padding: + + + 1 + 2 + 1 + 1 + + + + + True + False + cm + + + 3 + 2 + 1 + 1 + + + + + True + False + 12 + + + Left + True + True + False + 0 + True + + + False + True + 0 + + + + + Right + True + True + False + 0 + True + + + False + True + 1 + + + + + Top + True + True + False + 0 + True + + + False + True + 2 + + + + + Bottom + True + True + False + 0 + True + + + False + True + 3 + + + + + 1 + 1 + 4 + 1 + + + + + + + + + + + + + + 4 + + + + + True + False + <b>Cell options</b> + True + + + 4 + False + + True diff --git a/gramps/gui/plug/report/_styleeditor.py b/gramps/gui/plug/report/_styleeditor.py index 60f42a5a3..8c91aa81b 100644 --- a/gramps/gui/plug/report/_styleeditor.py +++ b/gramps/gui/plug/report/_styleeditor.py @@ -52,7 +52,7 @@ from gi.repository import Gtk, Gdk #------------------------------------------------------------------------ from gramps.gen.plug.docgen import (StyleSheet, FONT_SERIF, FONT_SANS_SERIF, PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT, - PARA_ALIGN_JUSTIFY, ParagraphStyle, TableStyle) + PARA_ALIGN_JUSTIFY, ParagraphStyle, TableStyle, TableCellStyle) from gramps.gen.constfunc import cuni from ...listmodel import ListModel from ...managedwindow import set_titles @@ -237,6 +237,9 @@ class StyleEditor(object): names = _alphanumeric_sort(self.style.get_table_style_names()) for t_name in names: self.plist.add([t_name], self.style.get_table_style(t_name)) + names = _alphanumeric_sort(self.style.get_cell_style_names()) + for c_name in names: + self.plist.add([c_name], self.style.get_cell_style(c_name)) self.plist.select_row(0) if self.parent: @@ -268,6 +271,25 @@ class StyleEditor(object): elif isinstance(self.current_style, TableStyle): self.show_pages([0, 3]) self.draw_table() + elif isinstance(self.current_style, TableCellStyle): + self.show_pages([0, 4]) + self.draw_cell() + + def draw_cell(self): + """ + Updates the display with the selected cell style. + """ + c = self.current_style + self.pname.set_text( '%s' % + self.current_name) + self.pname.set_use_markup(True) + self.pdescription.set_text(_("No description available") ) + + self.top.get_object("cell_lborder").set_active(c.get_left_border()) + self.top.get_object("cell_rborder").set_active(c.get_right_border()) + self.top.get_object("cell_tborder").set_active(c.get_top_border()) + self.top.get_object("cell_bborder").set_active(c.get_bottom_border()) + self.top.get_object("cell_padding").set_value(c.get_padding()) def draw_table(self): """ @@ -376,6 +398,21 @@ class StyleEditor(object): self.save_paragraph() elif isinstance(self.current_style, TableStyle): self.save_table() + elif isinstance(self.current_style, TableCellStyle): + self.save_cell() + + def save_cell(self): + """ + Saves the current cell style displayed on the dialog. + """ + c = self.current_style + c.set_left_border(self.top.get_object("cell_lborder").get_active()) + c.set_right_border(self.top.get_object("cell_rborder").get_active()) + c.set_top_border(self.top.get_object("cell_tborder").get_active()) + c.set_bottom_border(self.top.get_object("cell_bborder").get_active()) + c.set_padding(self.top.get_object("cell_padding").get_value()) + + self.style.add_cell_style(self.current_name, self.current_style) def save_table(self): """