Update the register for the change in RegisterColor enums

Change the map of RegisterColors to CSS style classes to reflect the
changes and reduce the get colour type to one call per class
This commit is contained in:
Robert Fewell 2017-11-01 12:30:03 +00:00
parent 6228881d6a
commit ed3de42c96
4 changed files with 21 additions and 33 deletions

View File

@ -88,8 +88,8 @@ gnc_header_draw_offscreen (GncHeader *header)
gtk_style_context_save (stylectxt);
// Get the background color type and apply the css class
color_type = gnc_table_get_bg_color (table, virt_loc, NULL);
// Get the color type and apply the css class
color_type = gnc_table_get_color (table, virt_loc, NULL);
gnucash_get_style_classes (header->sheet, stylectxt, color_type);
if (header->surface)

View File

@ -487,11 +487,8 @@ draw_background_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
gtk_style_context_save (stylectxt);
// Get the background and foreground color types and apply the css class
color_type = gnc_table_get_bg_color (item_edit->sheet->table, item_edit->virt_loc, NULL);
gnucash_get_style_classes (item_edit->sheet, stylectxt, color_type);
color_type = gnc_table_get_fg_color (item_edit->sheet->table, item_edit->virt_loc);
// Get the color type and apply the css class
color_type = gnc_table_get_color (item_edit->sheet->table, item_edit->virt_loc, NULL);
gnucash_get_style_classes (item_edit->sheet, stylectxt, color_type);
gtk_render_background (stylectxt, cr, 0, 1, width, height - 2);

View File

@ -399,11 +399,8 @@ draw_cell (GnucashSheet *sheet,
gtk_style_context_save (stylectxt);
// Get the background and foreground color types and apply the css class
color_type = gnc_table_get_bg_color (table, virt_loc, &hatching);
gnucash_get_style_classes (sheet, stylectxt, color_type);
color_type = gnc_table_get_fg_color (table, virt_loc);
// Get the color type and apply the css class
color_type = gnc_table_get_color (table, virt_loc, &hatching);
gnucash_get_style_classes (sheet, stylectxt, color_type);
// Are we in a read-only row? Then make the background color somewhat more grey.

View File

@ -2428,52 +2428,46 @@ gnucash_sheet_table_load (GnucashSheet *sheet, gboolean do_scroll)
/*************************************************************/
/** Map a cell type to a css style class. */
/** Map a cell color type to a css style class. */
void
gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
RegisterColor field_type)
{
gchar *full_class, *style_class = NULL;
if (field_type >= COLOR_NEGATIVE) // Require a Negative fg color
{
gtk_style_context_add_class (stylectxt, "negative-numbers");
field_type -= COLOR_NEGATIVE;
}
switch (field_type)
{
default:
case COLOR_UNKNOWN_BG:
case COLOR_UNKNOWN_FG:
case COLOR_UNDEFINED:
gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND);
return;
case COLOR_NEGATIVE:
gtk_style_context_add_class (stylectxt, "negative-numbers");
return;
case COLOR_HEADER_BG:
case COLOR_HEADER_FG:
case COLOR_HEADER:
style_class = "header";
break;
case COLOR_PRIMARY_BG:
case COLOR_PRIMARY_FG:
case COLOR_PRIMARY:
style_class = "primary";
break;
case COLOR_PRIMARY_BG_ACTIVE:
case COLOR_PRIMARY_FG_ACTIVE:
case COLOR_SECONDARY_BG_ACTIVE:
case COLOR_SECONDARY_FG_ACTIVE:
case COLOR_SPLIT_BG_ACTIVE:
case COLOR_SPLIT_FG_ACTIVE:
case COLOR_PRIMARY_ACTIVE:
case COLOR_SECONDARY_ACTIVE:
case COLOR_SPLIT_ACTIVE:
gtk_style_context_set_state (stylectxt, GTK_STATE_FLAG_SELECTED);
style_class = "cursor";
break;
case COLOR_SECONDARY_BG:
case COLOR_SECONDARY_FG:
case COLOR_SECONDARY:
style_class = "secondary";
break;
case COLOR_SPLIT_BG:
case COLOR_SPLIT_FG:
case COLOR_SPLIT:
style_class = "split";
break;
}