[goffice] GOStyle: save and load font.auto_color.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOStyle: save and load font.auto_color.
- Date: Fri, 9 May 2014 01:54:19 +0000 (UTC)
commit 75594c8111c1635594aa7023589d19ceab7ad520
Author: Morten Welinder <terra gnome org>
Date: Thu May 8 21:53:44 2014 -0400
GOStyle: save and load font.auto_color.
ChangeLog | 4 +++
goffice/utils/go-style.c | 53 ++++++++++++++++++++++++++++++++++++---------
2 files changed, 46 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d11800d..2a6a4bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@
auto-width.
(go_style_line_sax_save): Save auto_width. Don't save width when
auto_width.
+ (go_style_apply_theme): Apply font color.
+ (go_style_font_sax_save): Save auto_color and auto_font (but see
+ comments).
+ (go_style_sax_load_font): Read auto-color.
* goffice/graph/gog-axis.c (map_linear_calc_ticks): Keep values as
integers as long as possible.
diff --git a/goffice/utils/go-style.c b/goffice/utils/go-style.c
index 3bdd02e..9a5fcea 100644
--- a/goffice/utils/go-style.c
+++ b/goffice/utils/go-style.c
@@ -1265,15 +1265,22 @@ go_style_apply_theme (GOStyle *dst, GOStyle const *src, GOStyleFlag fields)
if ((fields & GO_STYLE_TEXT_LAYOUT) && dst->text_layout.auto_angle)
dst->text_layout.angle = src->text_layout.angle;
+ if (fields & GO_STYLE_FONT) {
+ if (dst->font.auto_color)
+ dst->font.color = src->font.color;
+
#if 0
- /* Fonts are not themed until we have some sort of auto mechanism
- * stronger than 'auto_size' */
- if (src->font.font != NULL)
- go_font_ref (src->font.font);
- if (dst->font.font != NULL)
- go_font_unref (dst->font.font);
- dst->font = src->font;
+ /*
+ * Fonts are not themed until we have some sort of auto
+ * mechanism stronger than 'auto_size'
+ */
+ if (src->font.font != NULL)
+ go_font_ref (src->font.font);
+ if (dst->font.font != NULL)
+ go_font_unref (dst->font.font);
+ dst->font = src->font;
#endif
+ }
}
static void
@@ -1516,12 +1523,21 @@ static void
go_style_font_sax_save (GsfXMLOut *output, GOStyle const *style)
{
char *str;
+
gsf_xml_out_start_element (output, "font");
- go_xml_out_add_color (output, "color", style->font.color);
+
+ gsf_xml_out_add_bool (output, "auto-color", style->font.auto_color);
+ if (!style->font.auto_color)
+ go_xml_out_add_color (output, "color", style->font.color);
+
+ gsf_xml_out_add_bool (output, "auto-font", style->font.auto_font);
+ /* Unconditionally save font; theme support for fonts is incomplete */
str = go_font_as_str (style->font.font);
gsf_xml_out_add_cstr (output, "font", str);
g_free (str);
+
gsf_xml_out_add_bool (output, "auto-scale", style->font.auto_scale);
+
gsf_xml_out_end_element (output);
}
@@ -1676,10 +1692,15 @@ static void
go_style_sax_load_font (GsfXMLIn *xin, xmlChar const **attrs)
{
GOStyle *style = GO_STYLE (xin->user_state);
- for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
- if (0 == strcmp (attrs[0], "color"))
+ gboolean seen_auto_color = FALSE, seen_color = FALSE;
+
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
+ if (0 == strcmp (attrs[0], "color")) {
+ seen_color = TRUE;
go_color_from_str (attrs[1], &style->font.color);
- else if (0 == strcmp (attrs[0], "font")) {
+ } else if (bool_sax_prop ("auto-color", attrs[0], attrs[1], &style->font.auto_color)) {
+ seen_auto_color = TRUE;
+ } else if (0 == strcmp (attrs[0], "font")) {
PangoFontDescription *desc = pango_font_description_from_string (attrs[1]);
if (desc != NULL) {
if (pango_font_description_get_family (desc) == NULL)
@@ -1688,7 +1709,17 @@ go_style_sax_load_font (GsfXMLIn *xin, xmlChar const **attrs)
}
} else if (bool_sax_prop ("auto-scale", attrs[0], attrs[1], &style->font.auto_scale))
;
+ }
+
+ if (seen_color && !seen_auto_color) {
+ /*
+ * Pre-0.10.16 lacked the auto-color attribute. Let's just
+ * assume it was explicitly set iff it is black.
+ */
+ style->font.auto_color = (style->font.color == GO_COLOR_BLACK);
+ }
}
+
static void
go_style_sax_load_text_layout (GsfXMLIn *xin, xmlChar const **attrs)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]