Fix the register sheet insensitive when in reverse order

pull/1546/head
Robert Fewell 3 years ago
parent 672cfddd69
commit 8c613ff7ab

@ -644,6 +644,9 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
save_loc.phys_col_offset = 0;
}
// used in the setting the rows insensitive
table->model->blank_trans_row = vcell_loc.virt_row;
gnc_split_register_add_transaction (reg,
blank_trans, blank_split,
lead_cursor, split_cursor,
@ -726,6 +729,9 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
save_loc.phys_col_offset = 0;
}
// used in the setting the rows insensitive
table->model->blank_trans_row = vcell_loc.virt_row;
gnc_split_register_add_transaction (reg, blank_trans, blank_split,
lead_cursor, split_cursor,
multi_line, start_primary_color,

@ -145,6 +145,8 @@ gnc_table_model_new (void)
model->dividing_row = -1;
model->dividing_row_lower = -1;
model->blank_trans_row = -1;
return model;
}

@ -136,6 +136,9 @@ typedef struct
* be visually distinguished. */
int dividing_row_lower;
/* If positive, denotes the row position of the blank trans */
int blank_trans_row;
VirtCellDataAllocator cell_data_allocator;
VirtCellDataDeallocator cell_data_deallocator;
VirtCellDataCopy cell_data_copy;

@ -374,6 +374,13 @@ draw_divider_line (cairo_t *cr, VirtualLocation virt_loc,
cairo_stroke (cr);
}
static void
set_cell_insensitive (GtkStyleContext *stylectxt)
{
if (!gtk_style_context_has_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND))
gtk_style_context_set_state (stylectxt, GTK_STATE_FLAG_INSENSITIVE);
}
static void
draw_cell (GnucashSheet *sheet, SheetBlock *block,
VirtualLocation virt_loc, cairo_t *cr,
@ -409,10 +416,7 @@ draw_cell (GnucashSheet *sheet, SheetBlock *block,
gnucash_get_style_classes (sheet, stylectxt, color_type, use_neg_class);
if (sheet->read_only)
{
if (!gtk_style_context_has_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND))
gtk_style_context_set_state (stylectxt, GTK_STATE_FLAG_INSENSITIVE);
}
set_cell_insensitive (stylectxt);
else
{
if (gtk_style_context_has_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND))
@ -421,11 +425,27 @@ draw_cell (GnucashSheet *sheet, SheetBlock *block,
// Are we in a read-only row? Then make the background color somewhat more grey.
if ((virt_loc.phys_row_offset < block->style->nrows)
&& (table->model->dividing_row_upper >= 0)
&& (virt_loc.vcell_loc.virt_row < table->model->dividing_row_upper))
&& (table->model->dividing_row_upper >= 0))
{
if (!gtk_style_context_has_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND))
gtk_style_context_set_state (stylectxt, GTK_STATE_FLAG_INSENSITIVE);
if (table->model->reverse_sort)
{
if ((table->model->blank_trans_row < table->model->dividing_row_upper)
&& (virt_loc.vcell_loc.virt_row >= table->model->dividing_row_upper))
{
set_cell_insensitive (stylectxt); // future trans after blank
}
if ((virt_loc.vcell_loc.virt_row >= table->model->dividing_row_upper)
&& (virt_loc.vcell_loc.virt_row < table->model->blank_trans_row))
{
set_cell_insensitive (stylectxt);
}
}
else // normal order
{
if (virt_loc.vcell_loc.virt_row < table->model->dividing_row_upper)
set_cell_insensitive (stylectxt);
}
}
gtk_render_background (stylectxt, cr, x, y, width, height);

Loading…
Cancel
Save