[gnumeric] css: allow theming of grid colour.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] css: allow theming of grid colour.
- Date: Sat, 20 Feb 2021 17:34:31 +0000 (UTC)
commit 0660fe3c92605b13b66671791b43b8c4f415bfb1
Author: Morten Welinder <terra gnome org>
Date: Sat Feb 20 12:34:10 2021 -0500
css: allow theming of grid colour.
NEWS | 1 +
src/gnumeric.css | 12 +++++++++---
src/item-bar.c | 16 +++++++++-------
src/item-grid.c | 2 +-
src/preview-grid.c | 2 +-
src/print-cell.c | 2 +-
src/sheet-style.c | 4 ++--
src/sheet-style.h | 2 +-
src/style-border.c | 2 +-
src/style-color.c | 21 +++++++++++++--------
src/style-color.h | 2 +-
11 files changed, 40 insertions(+), 26 deletions(-)
---
diff --git a/NEWS b/NEWS
index bbf34939b..d3c27e4c8 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,7 @@ Morten:
* Implement #ifdef for built-in css.
* Dead kitten in css.
* Improve the drawing of filter combos.
+ * Allow theming of grid color.
--------------------------------------------------------------------------
Gnumeric 1.12.48
diff --git a/src/gnumeric.css b/src/gnumeric.css
index 0dccb84fb..c1b115893 100644
--- a/src/gnumeric.css
+++ b/src/gnumeric.css
@@ -3,9 +3,10 @@
/* GnmPane is the canvas we use for sheets. We store custom properties
here because there is no un-deprecated way to store them for the
canvas items which aren't widgets. */
-GnmPane {
+GnmPane,
+pane {
-GnmPane-function-indicator-size: 10px;
- -GnmPane-cell-comment-indicator-size: 6px;
+ -GnmPane-comment-indicator-size: 6px;
-GnmPane-resize-guide-width: 1px;
-GnmPane-pane-resize-guide-width: 7px;
-GnmPane-control-circle-size: 5px;
@@ -32,11 +33,16 @@ GnmItemGrid:selected {
background-color: lavender;
}
+GnmItemGrid.grid,
+GnmPreviewGrid.grid {
+ color: #c7c7c7;
+}
+
/* Function markers are enabled from View->View Properties->Cell Markers */
GnmItemGrid.function-marker {
color: #80ff80;
border-color: #555555;
- /* See also GnmPane */
+ /* Size defined for GnmPane */
}
/* This is the divider between panes when an area is frozen. */
diff --git a/src/item-bar.c b/src/item-bar.c
index 239ed3504..a2519f88d 100644
--- a/src/item-bar.c
+++ b/src/item-bar.c
@@ -105,17 +105,12 @@ static const GtkStateFlags selection_type_flags[3] = {
};
static const char * const selection_styles[3] = {
+ // Caution! assuming a fixed prefix
"button.itembar",
"button.itembar:hover",
"button.itembar:active"
};
-static const char * const selection_style_names[3] = {
- "itembar.color",
- "itembar.color.hover",
- "itembar.color.selected"
-};
-
static void
ib_reload_color_style (GnmItemBar *ib)
{
@@ -131,7 +126,14 @@ ib_reload_color_style (GnmItemBar *ib)
GtkStateFlags state = selection_type_flags[ui];
gnm_style_context_get_color
(context, state, &ib->selection_colors[ui]);
- gnm_css_debug_color (selection_style_names[ui], &ib->selection_colors[ui]);
+ if (gnm_debug_flag ("css")) {
+ char *name = g_strdup_printf
+ ("itembar.%s%s.color",
+ ib->is_col_header ? "col" : "row",
+ selection_styles[ui] + strlen (selection_styles[0]));
+ gnm_css_debug_color (name, &ib->selection_colors[ui]);
+ g_free (name);
+ }
}
}
diff --git a/src/item-grid.c b/src/item-grid.c
index a9c8d764e..e5b406ce2 100644
--- a/src/item-grid.c
+++ b/src/item-grid.c
@@ -519,7 +519,7 @@ item_grid_draw_region (GocItem const *item, cairo_t *cr,
row_calc_spans ((ColRowInfo *)ri, row, sheet);
}
- sheet_style_update_grid_color (sheet);
+ sheet_style_update_grid_color (sheet, ctxt);
/* Fill entire region with default background (even past far edge) */
cairo_save (cr);
diff --git a/src/preview-grid.c b/src/preview-grid.c
index cc2e268c9..c42eb36a2 100644
--- a/src/preview-grid.c
+++ b/src/preview-grid.c
@@ -225,7 +225,7 @@ preview_grid_draw_region (GocItem const *item, cairo_t *cr,
int *colwidths = NULL;
- gnm_style_border_none_set_color (style_color_grid ());
+ gnm_style_border_none_set_color (style_color_grid (goc_item_get_style_context (item)));
/*
* allocate a single blob of memory for all 8 arrays of pointers.
diff --git a/src/print-cell.c b/src/print-cell.c
index f9072ce89..f6cba2817 100644
--- a/src/print-cell.c
+++ b/src/print-cell.c
@@ -337,7 +337,7 @@ gnm_gtk_print_cell_range (cairo_t *context,
break;
}
- sheet_style_update_grid_color (sheet);
+ sheet_style_update_grid_color (sheet, NULL);
/* Get ordered list of merged regions */
merged_active = merged_active_seen = merged_used = NULL;
diff --git a/src/sheet-style.c b/src/sheet-style.c
index cfda28e1b..ecf406ee5 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -856,11 +856,11 @@ sheet_style_get_auto_pattern_color (Sheet const *sheet)
* is used for the grid.
*/
void
-sheet_style_update_grid_color (Sheet const *sheet)
+sheet_style_update_grid_color (Sheet const *sheet, GtkStyleContext *context)
{
GnmColor *default_auto = style_color_auto_pattern ();
GnmColor *sheet_auto = sheet_style_get_auto_pattern_color (sheet);
- GnmColor *grid_color = style_color_grid ();
+ GnmColor *grid_color = style_color_grid (context);
GnmColor *new_color;
new_color = (style_color_equal (default_auto, sheet_auto)
diff --git a/src/sheet-style.h b/src/sheet-style.h
index a96f2bedd..1191a2efe 100644
--- a/src/sheet-style.h
+++ b/src/sheet-style.h
@@ -76,7 +76,7 @@ void sheet_style_shutdown (Sheet *sheet);
void sheet_style_set_auto_pattern_color (Sheet *sheet,
GnmColor *grid_color);
GnmColor *sheet_style_get_auto_pattern_color (Sheet const *sheet);
-void sheet_style_update_grid_color (Sheet const *sheet);
+void sheet_style_update_grid_color (Sheet const *sheet, GtkStyleContext *context);
GnmStyle const *style_list_get_style (GnmStyleList const *l, int col, int row);
void style_list_free (GnmStyleList *l);
diff --git a/src/style-border.c b/src/style-border.c
index b12fba678..d2008d439 100644
--- a/src/style-border.c
+++ b/src/style-border.c
@@ -145,7 +145,7 @@ gnm_style_border_none (void)
if (border_none == NULL) {
border_none = g_new0 (GnmBorder, 1);
border_none->line_type = GNM_STYLE_BORDER_NONE;
- border_none->color = style_color_grid ();
+ border_none->color = style_color_grid (NULL);
border_none->begin_margin = border_none->end_margin = border_none->width = 0;
border_none->ref_count = 1;
/* Note: not in the hash. */
diff --git a/src/style-color.c b/src/style-color.c
index 09004c262..c66229070 100644
--- a/src/style-color.c
+++ b/src/style-color.c
@@ -9,11 +9,11 @@
#include <gnumeric.h>
#include <style-color.h>
#include <style-border.h>
+#include <gui-util.h>
static GHashTable *style_color_hash;
static GnmColor *sc_black;
static GnmColor *sc_white;
-static GnmColor *sc_grid;
static GnmColor *sc_auto_back;
static GnmColor *sc_auto_font;
static GnmColor *sc_auto_pattern;
@@ -113,11 +113,19 @@ style_color_white (void)
}
GnmColor *
-style_color_grid (void)
+style_color_grid (GtkStyleContext *context)
{
- if (!sc_grid)
- sc_grid = gnm_color_new_rgb8 (0xc7, 0xc7, 0xc7);
- return style_color_ref (sc_grid);
+ if (context) {
+ GdkRGBA color;
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, "grid");
+ gnm_style_context_get_color (context, GTK_STATE_FLAG_NORMAL,
+ &color);
+ gnm_css_debug_color ("grid.color", &color);
+ gtk_style_context_restore (context);
+ return gnm_color_new_gdk (&color);
+ } else
+ return gnm_color_new_rgb8 (0xc7, 0xc7, 0xc7);
}
/*
@@ -246,9 +254,6 @@ gnm_color_shutdown (void)
style_color_unref (sc_white);
sc_white = NULL;
- style_color_unref (sc_grid);
- sc_grid = NULL;
-
style_color_unref (sc_auto_back);
sc_auto_back = NULL;
diff --git a/src/style-color.h b/src/style-color.h
index 2b77596eb..7e1dc84d7 100644
--- a/src/style-color.h
+++ b/src/style-color.h
@@ -31,7 +31,7 @@ void style_color_unref (GnmColor *sc);
gint style_color_equal (GnmColor const *a, GnmColor const *b);
GnmColor *style_color_black (void);
GnmColor *style_color_white (void);
-GnmColor *style_color_grid (void);
+GnmColor *style_color_grid (GtkStyleContext *context);
/****************************************************************/
/* Internal */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]