Commit 0660fe3c authored by Morten Welinder's avatar Morten Welinder
Browse files

css: allow theming of grid colour.

parent bee0ca4f
......@@ -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
......
......@@ -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. */
......
......@@ -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);
}
}
}
......
......@@ -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);
......
......@@ -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.
......
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
......@@ -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. */
......
......@@ -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;
......
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment