diff --git a/gnucash/register/ledger-core/gncEntryLedgerModel.c b/gnucash/register/ledger-core/gncEntryLedgerModel.c index 3b08fdd4eb..d257c4ae83 100644 --- a/gnucash/register/ledger-core/gncEntryLedgerModel.c +++ b/gnucash/register/ledger-core/gncEntryLedgerModel.c @@ -920,7 +920,6 @@ static CellIOFlags get_qty_io_flags (VirtualLocation virt_loc, gpointer user_dat static guint32 gnc_entry_ledger_get_color_internal (VirtualLocation virt_loc, GncEntryLedger *ledger, - const guint32 *color_table, gboolean foreground) { VirtualCell *vcell; @@ -931,29 +930,29 @@ gnc_entry_ledger_get_color_internal (VirtualLocation virt_loc, colorbase = COLOR_UNKNOWN_FG; /* a bit of enum arithmetic */ if (!ledger) - return color_table[colorbase + COLOR_UNKNOWN_BG]; + return (colorbase + COLOR_UNKNOWN_BG); if (gnc_table_virtual_location_in_header (ledger->table, virt_loc)) - return color_table[colorbase + COLOR_HEADER_BG]; + return (colorbase + COLOR_HEADER_BG); vcell = gnc_table_get_virtual_cell (ledger->table, virt_loc.vcell_loc); if (!vcell || !vcell->cellblock) - return color_table[colorbase + COLOR_UNKNOWN_BG]; + return (colorbase + COLOR_UNKNOWN_BG); if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) || (virt_loc.phys_col_offset > vcell->cellblock->stop_col)) - return color_table[colorbase + COLOR_UNKNOWN_BG]; + return (colorbase + COLOR_UNKNOWN_BG); is_current = virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc); if (is_current) return vcell->start_primary_color ? - color_table[colorbase + COLOR_PRIMARY_BG_ACTIVE] : - color_table[colorbase + COLOR_SECONDARY_BG_ACTIVE]; + (colorbase + COLOR_PRIMARY_BG_ACTIVE) : + (colorbase + COLOR_SECONDARY_BG_ACTIVE); return vcell->start_primary_color ? - color_table[colorbase + COLOR_PRIMARY_BG] : color_table[colorbase + COLOR_SECONDARY_BG]; + (colorbase + COLOR_PRIMARY_BG) : (colorbase + COLOR_SECONDARY_BG); } @@ -962,15 +961,7 @@ gnc_entry_ledger_get_fg_color (VirtualLocation virt_loc, gpointer user_data) { GncEntryLedger *ledger = user_data; - return gnc_entry_ledger_get_color_internal (virt_loc, ledger, reg_colors_default, TRUE); -} - -static guint32 -gnc_entry_ledger_get_gtkrc_fg_color (VirtualLocation virt_loc, - gpointer user_data) -{ - GncEntryLedger *ledger = user_data; - return gnc_entry_ledger_get_color_internal (virt_loc, ledger, reg_colors_gtkrc, TRUE); + return gnc_entry_ledger_get_color_internal (virt_loc, ledger, TRUE); } static guint32 @@ -982,19 +973,7 @@ gnc_entry_ledger_get_bg_color (VirtualLocation virt_loc, if (hatching) *hatching = FALSE; - return gnc_entry_ledger_get_color_internal (virt_loc, ledger, reg_colors_default, FALSE); -} - -static guint32 -gnc_entry_ledger_get_gtkrc_bg_color (VirtualLocation virt_loc, - gboolean *hatching, gpointer user_data) -{ - GncEntryLedger *ledger = user_data; - - if (hatching) - *hatching = FALSE; - - return gnc_entry_ledger_get_color_internal (virt_loc, ledger, reg_colors_gtkrc, FALSE); + return gnc_entry_ledger_get_color_internal (virt_loc, ledger, FALSE); } /* SAVE CELLS */ @@ -1249,16 +1228,9 @@ static void gnc_entry_ledger_model_new_handlers (TableModel *model, gnc_table_model_set_default_fg_color_handler (model, gnc_entry_ledger_get_fg_color); - gnc_table_model_set_fg_color_handler - (model, gnc_entry_ledger_get_gtkrc_fg_color, "gtkrc"); - gnc_table_model_set_default_bg_color_handler (model, gnc_entry_ledger_get_bg_color); - gnc_table_model_set_bg_color_handler - (model, gnc_entry_ledger_get_gtkrc_bg_color, "gtkrc"); - - for (i = 0; i < (sizeof(models) / sizeof(*models)); i++) { if (models[i].entry_handler) diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c index ee31252cd6..255a9e9aed 100644 --- a/gnucash/register/ledger-core/split-register-model.c +++ b/gnucash/register/ledger-core/split-register-model.c @@ -517,7 +517,6 @@ get_trans_total_balance (SplitRegister *reg, Transaction *trans) static guint32 gnc_split_register_get_color_internal (VirtualLocation virt_loc, SplitRegister *reg, - const guint32 *color_table, gboolean foreground) { const char *cursor_name; @@ -530,18 +529,18 @@ gnc_split_register_get_color_internal (VirtualLocation virt_loc, colorbase = COLOR_UNKNOWN_FG; /* a bit of enum arithmetic */ if (!reg) - return color_table[colorbase + COLOR_UNKNOWN_BG]; + return (colorbase + COLOR_UNKNOWN_BG); if (gnc_table_virtual_location_in_header (reg->table, virt_loc)) - return color_table[colorbase + COLOR_HEADER_BG]; + return (colorbase + COLOR_HEADER_BG); vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc); if (!vcell || !vcell->cellblock) - return color_table[colorbase + COLOR_UNKNOWN_BG]; + return (colorbase + COLOR_UNKNOWN_BG); if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) || (virt_loc.phys_col_offset > vcell->cellblock->stop_col)) - return color_table[colorbase + COLOR_UNKNOWN_BG]; + return (colorbase + COLOR_UNKNOWN_BG); is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc); @@ -553,11 +552,11 @@ gnc_split_register_get_color_internal (VirtualLocation virt_loc, { if (is_current) return vcell->start_primary_color ? - color_table[colorbase + COLOR_PRIMARY_BG_ACTIVE] : - color_table[colorbase + COLOR_SECONDARY_BG_ACTIVE]; + (colorbase + COLOR_PRIMARY_BG_ACTIVE) : + (colorbase + COLOR_SECONDARY_BG_ACTIVE); return vcell->start_primary_color ? - color_table[colorbase + COLOR_PRIMARY_BG] : color_table[colorbase + COLOR_SECONDARY_BG]; + (colorbase + COLOR_PRIMARY_BG) : (colorbase + COLOR_SECONDARY_BG); } if (g_strcmp0 (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 || @@ -571,49 +570,47 @@ gnc_split_register_get_color_internal (VirtualLocation virt_loc, { if (double_alternate_virt) return vcell->start_primary_color ? - color_table[colorbase + COLOR_PRIMARY_BG_ACTIVE] : - color_table[colorbase + COLOR_SECONDARY_BG_ACTIVE]; + (colorbase + COLOR_PRIMARY_BG_ACTIVE) : + (colorbase + COLOR_SECONDARY_BG_ACTIVE); return (virt_loc.phys_row_offset % 2 == 0) ? - color_table[colorbase + COLOR_PRIMARY_BG_ACTIVE] : - color_table[colorbase + COLOR_SECONDARY_BG_ACTIVE]; + (colorbase + COLOR_PRIMARY_BG_ACTIVE) : + (colorbase + COLOR_SECONDARY_BG_ACTIVE); } if (double_alternate_virt) return vcell->start_primary_color ? - color_table[colorbase + COLOR_PRIMARY_BG] : - color_table[colorbase + COLOR_SECONDARY_BG]; + (colorbase + COLOR_PRIMARY_BG) : + (colorbase + COLOR_SECONDARY_BG); return (virt_loc.phys_row_offset % 2 == 0) ? - color_table[colorbase + COLOR_PRIMARY_BG] : - color_table[colorbase + COLOR_SECONDARY_BG]; + (colorbase + COLOR_PRIMARY_BG) : + (colorbase + COLOR_SECONDARY_BG); } if (g_strcmp0 (cursor_name, CURSOR_SPLIT) == 0) { if (is_current) - return color_table[colorbase + COLOR_SPLIT_BG_ACTIVE]; + return (colorbase + COLOR_SPLIT_BG_ACTIVE); - return color_table[colorbase + COLOR_SPLIT_BG]; + return (colorbase + COLOR_SPLIT_BG); } PWARN ("Unexpected cursor: %s\n", cursor_name); - return color_table[colorbase + COLOR_UNKNOWN_BG]; + return (colorbase + COLOR_UNKNOWN_BG); } static guint32 gnc_split_register_get_fg_color_internal (VirtualLocation virt_loc, - SplitRegister *reg, - const guint32 *color_table) + SplitRegister *reg) { - const guint32 red_color = color_table[COLOR_NEGATIVE]; guint32 fg_color; const char * cell_name; gnc_numeric value; Split *split; - fg_color = gnc_split_register_get_color_internal (virt_loc, reg, color_table, TRUE); + fg_color = gnc_split_register_get_color_internal (virt_loc, reg, TRUE); if (!use_red_for_negative) return fg_color; @@ -653,7 +650,7 @@ gnc_split_register_get_fg_color_internal (VirtualLocation virt_loc, } if (gnc_numeric_negative_p (value)) - return red_color; + return COLOR_NEGATIVE; return fg_color; } @@ -663,15 +660,7 @@ gnc_split_register_get_fg_color (VirtualLocation virt_loc, gpointer user_data) { SplitRegister *reg = user_data; - return gnc_split_register_get_fg_color_internal (virt_loc, reg, reg_colors_default); -} - -static guint32 -gnc_split_register_get_gtkrc_fg_color (VirtualLocation virt_loc, - gpointer user_data) -{ - SplitRegister *reg = user_data; - return gnc_split_register_get_fg_color_internal (virt_loc, reg, reg_colors_gtkrc); + return gnc_split_register_get_fg_color_internal (virt_loc, reg); } static guint32 @@ -684,21 +673,7 @@ gnc_split_register_get_bg_color (VirtualLocation virt_loc, if (hatching) *hatching = FALSE; - return gnc_split_register_get_color_internal (virt_loc, reg, reg_colors_default, FALSE); -} - - -static RegisterColor -gnc_split_register_get_gtkrc_bg_color (VirtualLocation virt_loc, - gboolean *hatching, - gpointer user_data) -{ - SplitRegister *reg = user_data; - - if (hatching) - *hatching = FALSE; - - return gnc_split_register_get_color_internal (virt_loc, reg, reg_colors_gtkrc, FALSE); + return gnc_split_register_get_color_internal (virt_loc, reg, FALSE); } static guint32 @@ -2656,16 +2631,10 @@ gnc_split_register_model_new (void) gnc_table_model_set_fg_color_handler( model, gnc_split_register_get_fg_color, RBALN_CELL); - gnc_table_model_set_fg_color_handler( - model, gnc_split_register_get_gtkrc_fg_color, "gtkrc"); - gnc_table_model_set_default_bg_color_handler( model, gnc_split_register_get_bg_color); - gnc_table_model_set_bg_color_handler( - model, gnc_split_register_get_gtkrc_bg_color, "gtkrc"); - gnc_table_model_set_bg_color_handler( model, gnc_split_register_get_debcred_bg_color, DEBT_CELL); diff --git a/gnucash/register/register-core/table-allgui.c b/gnucash/register/register-core/table-allgui.c index f289595754..8c0826df91 100644 --- a/gnucash/register/register-core/table-allgui.c +++ b/gnucash/register/register-core/table-allgui.c @@ -346,22 +346,27 @@ gnc_table_get_label (Table *table, VirtualLocation virt_loc) } static guint32 -gnc_table_get_fg_color_internal (Table *table, VirtualLocation virt_loc, - gboolean want_gtkrc) +gnc_table_get_fg_color_internal (Table *table, VirtualLocation virt_loc) { TableGetFGColorHandler fg_color_handler; - const char *handler_name = "gtkrc"; + const char *handler_name; if (!table || !table->model) - return 0x0; /* black */ + return COLOR_UNKNOWN_FG; - if (!want_gtkrc) - handler_name = gnc_table_get_cell_name (table, virt_loc); + handler_name = gnc_table_get_cell_name (table, virt_loc); fg_color_handler = gnc_table_model_get_fg_color_handler (table->model, handler_name); if (!fg_color_handler) - return 0x0; + { + TableGetBGColorHandler bg_color_handler = + gnc_table_model_get_bg_color_handler (table->model, handler_name); + + guint32 bg_color = + bg_color_handler (virt_loc, NULL, table->model->handler_user_data); + return bg_color + COLOR_UNKNOWN_FG; + } return fg_color_handler (virt_loc, table->model->handler_user_data); } @@ -369,36 +374,29 @@ gnc_table_get_fg_color_internal (Table *table, VirtualLocation virt_loc, guint32 gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc) { - return gnc_table_get_fg_color_internal (table, virt_loc, FALSE); -} - -guint32 -gnc_table_get_gtkrc_fg_color (Table *table, VirtualLocation virt_loc) -{ - return gnc_table_get_fg_color_internal (table, virt_loc, TRUE); + return gnc_table_get_fg_color_internal (table, virt_loc); } static guint32 gnc_table_get_bg_color_internal (Table *table, VirtualLocation virt_loc, - gboolean *hatching, - gboolean want_gtkrc) + gboolean *hatching) { TableGetBGColorHandler bg_color_handler; - const char *handler_name = "gtkrc"; + const char *handler_name; if (hatching) *hatching = FALSE; if (!table || !table->model) - return 0xffffff; /* white */ + return COLOR_UNKNOWN_BG; - if (!want_gtkrc) - handler_name = gnc_table_get_cell_name (table, virt_loc); + handler_name = gnc_table_get_cell_name (table, virt_loc); bg_color_handler = gnc_table_model_get_bg_color_handler (table->model, handler_name); + if (!bg_color_handler) - return 0xffffff; + return COLOR_UNKNOWN_BG; return bg_color_handler (virt_loc, hatching, table->model->handler_user_data); @@ -408,14 +406,7 @@ guint32 gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc, gboolean *hatching) { - return gnc_table_get_bg_color_internal (table, virt_loc, hatching, FALSE); -} - -guint32 -gnc_table_get_gtkrc_bg_color (Table *table, VirtualLocation virt_loc, - gboolean *hatching) -{ - return gnc_table_get_bg_color_internal (table, virt_loc, hatching, TRUE); + return gnc_table_get_bg_color_internal (table, virt_loc, hatching); } void diff --git a/gnucash/register/register-core/table-allgui.h b/gnucash/register/register-core/table-allgui.h index 3b54d5a1f5..d827fd5fce 100644 --- a/gnucash/register/register-core/table-allgui.h +++ b/gnucash/register/register-core/table-allgui.h @@ -182,89 +182,32 @@ struct table typedef enum { /* Colors used for background drawing */ - COLOR_UNKNOWN_BG, - COLOR_HEADER_BG, - COLOR_PRIMARY_BG, - COLOR_PRIMARY_BG_ACTIVE, - COLOR_SECONDARY_BG, - COLOR_SECONDARY_BG_ACTIVE, - COLOR_SPLIT_BG, - COLOR_SPLIT_BG_ACTIVE, + COLOR_UNKNOWN_BG, // 0 + COLOR_HEADER_BG, // 1 + COLOR_PRIMARY_BG, // 2 + COLOR_PRIMARY_BG_ACTIVE, // 3 + COLOR_SECONDARY_BG, // 4 + COLOR_SECONDARY_BG_ACTIVE, // 5 + COLOR_SPLIT_BG, // 6 + COLOR_SPLIT_BG_ACTIVE, // 7 /* Colors used for foreground drawing (text etc) * ATTENTION: the background and foreground lists should have * the same types (the same amount of entries) ! * The code relies on this ! */ - COLOR_UNKNOWN_FG, - COLOR_HEADER_FG, - COLOR_PRIMARY_FG, - COLOR_PRIMARY_FG_ACTIVE, - COLOR_SECONDARY_FG, - COLOR_SECONDARY_FG_ACTIVE, - COLOR_SPLIT_FG, - COLOR_SPLIT_FG_ACTIVE, + COLOR_UNKNOWN_FG, // 8 + COLOR_HEADER_FG, // 9 + COLOR_PRIMARY_FG, // 10 + COLOR_PRIMARY_FG_ACTIVE, // 11 + COLOR_SECONDARY_FG, // 12 + COLOR_SECONDARY_FG_ACTIVE, // 13 + COLOR_SPLIT_FG, // 14 + COLOR_SPLIT_FG_ACTIVE, // 15 /* Other colors */ - COLOR_NEGATIVE, /* Color to use for negative numbers */ + COLOR_NEGATIVE, // 16 Color to use for negative numbers } RegisterColor; - - - -/** Alternative color tables to use for the register. - * The colors in this array are ordered according to the RegisterColor Enum - * Be careful to respect this order ! - */ -static const guint32 reg_colors_default [] = -{ - 0xFFFFFF, // COLOR_UNKNOWN_BG - 0x96B183, // COLOR_HEADER_BG - 0xBFDEB9, // COLOR_PRIMARY_BG - 0xFFEF98, // COLOR_PRIMARY_BG_ACTIVE - 0xF6FFDA, // COLOR_SECONDARY_BG - 0xFFEF98, // COLOR_SECONDARY_BG_ACTIVE - 0xEDE7D3, // COLOR_SPLIT_BG - 0xFFEF98, // COLOR_SPLIT_BG_ACTIVE - - 0x000000, // COLOR_UNKNOWN_FG - 0x000000, // COLOR_HEADER_FG - 0x000000, // COLOR_PRIMARY_FG - 0x000000, // COLOR_PRIMARY_FG_ACTIVE - 0x000000, // COLOR_SECONDARY_FG - 0x000000, // COLOR_SECONDARY_FG_ACTIVE - 0x000000, // COLOR_SPLIT_FG - 0x000000, // COLOR_SPLIT_FG_ACTIVE - - 0xFF0000, // COLOR_NEGATIVE -}; - -/* The colors in this array are ordered according to the RegisterColor Enum - * Be careful to respect this order ! - */ -static const guint32 reg_colors_gtkrc [] = -{ - COLOR_UNKNOWN_BG, // COLOR_UNKNOWN_BG - COLOR_HEADER_BG, // COLOR_HEADER_BG - COLOR_PRIMARY_BG, // COLOR_PRIMARY_BG - COLOR_PRIMARY_BG_ACTIVE, // COLOR_PRIMARY_BG_ACTIVE - COLOR_SECONDARY_BG, // COLOR_SECONDARY_BG - COLOR_SECONDARY_BG_ACTIVE, // COLOR_SECONDARY_BG_ACTIVE - COLOR_SPLIT_BG, // COLOR_SPLIT_BG - COLOR_SPLIT_BG_ACTIVE, // COLOR_SPLIT_BG_ACTIVE - - COLOR_UNKNOWN_FG, // COLOR_UNKNOWN_FG - COLOR_HEADER_FG, // COLOR_HEADER_FG - COLOR_PRIMARY_FG, // COLOR_PRIMARY_FG - COLOR_PRIMARY_FG_ACTIVE, // COLOR_PRIMARY_FG_ACTIVE - COLOR_SECONDARY_FG, // COLOR_SECONDARY_FG - COLOR_SECONDARY_FG_ACTIVE, // COLOR_SECONDARY_FG_ACTIVE - COLOR_SPLIT_FG, // COLOR_SPLIT_FG - COLOR_SPLIT_FG_ACTIVE, // COLOR_SPLIT_FG_ACTIVE - - COLOR_NEGATIVE, // COLOR_NEGATIVE -}; - - /** Set the default gui handlers used by new tables. */ void gnc_table_set_default_gui_handlers (TableGUIHandlers *gui_handlers); @@ -317,12 +260,8 @@ CellIOFlags gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc); guint32 gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc); -guint32 gnc_table_get_gtkrc_fg_color (Table *table, VirtualLocation virt_loc); - guint32 gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc, gboolean *hatching); -guint32 gnc_table_get_gtkrc_bg_color (Table *table, VirtualLocation virt_loc, - gboolean *hatching); void gnc_table_get_borders (Table *table, VirtualLocation virt_loc, PhysicalCellBorders *borders); diff --git a/gnucash/register/register-gnome/gnucash-header.c b/gnucash/register/register-gnome/gnucash-header.c index feb75f6cff..be6a462f91 100644 --- a/gnucash/register/register-gnome/gnucash-header.c +++ b/gnucash/register/register-gnome/gnucash-header.c @@ -88,7 +88,7 @@ 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_gtkrc_bg_color (table, virt_loc, NULL); + color_type = gnc_table_get_bg_color (table, virt_loc, NULL); gnucash_get_style_classes (header->sheet, stylectxt, color_type); if (header->surface) diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c index 5278748a62..2042df5838 100644 --- a/gnucash/register/register-gnome/gnucash-item-edit.c +++ b/gnucash/register/register-gnome/gnucash-item-edit.c @@ -345,10 +345,10 @@ 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_gtkrc_bg_color (item_edit->sheet->table, item_edit->virt_loc, NULL); + 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_gtkrc_fg_color (item_edit->sheet->table, item_edit->virt_loc); + color_type = gnc_table_get_fg_color (item_edit->sheet->table, item_edit->virt_loc); gnucash_get_style_classes (item_edit->sheet, stylectxt, color_type); gtk_render_background (stylectxt, cr, 0, 0, width, height); diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c index 1b942ea48a..60bd3c7837 100644 --- a/gnucash/register/register-gnome/gnucash-sheet-private.c +++ b/gnucash/register/register-gnome/gnucash-sheet-private.c @@ -399,10 +399,10 @@ 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_gtkrc_bg_color (table, virt_loc, &hatching); + color_type = gnc_table_get_bg_color (table, virt_loc, &hatching); gnucash_get_style_classes (sheet, stylectxt, color_type); - color_type = gnc_table_get_gtkrc_fg_color (table, virt_loc); + color_type = gnc_table_get_fg_color (table, virt_loc); gnucash_get_style_classes (sheet, stylectxt, color_type); // Are we in a read-only row? Then make the background color somewhat more grey.