mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-16 18:25:11 -06:00
Configure the coloring of negative quantities with a user preference
instead of a compile-time option. Implement the 'thin blue line' separating past transactions from future transactions. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2975 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
908da3fcf5
commit
52a55ce64b
@ -47,10 +47,6 @@
|
||||
/* check for stpcpy for Solaris */
|
||||
#undef HAVE_STPCPY
|
||||
|
||||
/* Don't color the balance depending on whether positive
|
||||
* or negative */
|
||||
#define USE_NO_COLOR
|
||||
|
||||
/* If configure found libXpm, then use it */
|
||||
#undef HAVE_XPM
|
||||
|
||||
|
@ -69,12 +69,6 @@ AM_GNU_GETTEXT
|
||||
### Variables
|
||||
### Set up all the initial variable values...
|
||||
|
||||
# Should we uses color (red/black) balances?
|
||||
AC_ARG_ENABLE(color,
|
||||
[ --disable-color don't use color (red/black) balances],
|
||||
AC_DEFINE(USE_NO_COLOR,1),
|
||||
AC_DEFINE(USE_NO_COLOR,0) )
|
||||
|
||||
AC_ARG_ENABLE(opt-style-install,
|
||||
[ --enable-opt-style-install install everything in subdirs of --prefix],
|
||||
[case "${enableval}" in
|
||||
|
@ -156,6 +156,10 @@ struct _SRInfo
|
||||
/* true if the current blank split has been edited and commited */
|
||||
gboolean blank_split_edited;
|
||||
|
||||
/* true if the demarcation between 'past' and 'future' transactions
|
||||
* should be visible */
|
||||
gboolean show_present_divider;
|
||||
|
||||
/* User data for users of SplitRegisters */
|
||||
void *user_data;
|
||||
|
||||
@ -3046,11 +3050,13 @@ xaccSRCountRows (SplitRegister *reg,
|
||||
Transaction *trans;
|
||||
Split *split;
|
||||
Table *table;
|
||||
time_t present;
|
||||
|
||||
gboolean found_split = FALSE;
|
||||
gboolean found_trans = FALSE;
|
||||
gboolean found_trans_split = FALSE;
|
||||
gboolean on_blank_split = FALSE;
|
||||
gboolean found_divider = FALSE;
|
||||
gboolean did_expand = FALSE;
|
||||
gboolean on_trans_split;
|
||||
gboolean multi_line;
|
||||
@ -3120,6 +3126,8 @@ xaccSRCountRows (SplitRegister *reg,
|
||||
if ((split != NULL) && (split == find_trans_split))
|
||||
found_trans_split = TRUE;
|
||||
|
||||
present = time(NULL);
|
||||
|
||||
/* now count the rows */
|
||||
i=0;
|
||||
if (slist)
|
||||
@ -3134,6 +3142,14 @@ xaccSRCountRows (SplitRegister *reg,
|
||||
|
||||
trans = xaccSplitGetParent(split);
|
||||
|
||||
if (info->show_present_divider &&
|
||||
!found_divider &&
|
||||
(present < xaccTransGetDate (trans)))
|
||||
{
|
||||
table->dividing_row = num_phys_rows;
|
||||
found_divider = TRUE;
|
||||
}
|
||||
|
||||
/* lets determine where to locate the cursor ... */
|
||||
on_trans_split = (find_trans_split == split);
|
||||
|
||||
@ -3811,4 +3827,17 @@ xaccSRCheckReconciled (SplitRegister *reg)
|
||||
return gnc_verify_dialog_parented(xaccSRGetParent(reg), message, FALSE);
|
||||
}
|
||||
|
||||
/* ======================================================== */
|
||||
|
||||
void
|
||||
xaccSRShowPresentDivider (SplitRegister *reg, gboolean show_present)
|
||||
{
|
||||
SRInfo *info = xaccSRGetInfo(reg);
|
||||
|
||||
if (reg == NULL)
|
||||
return;
|
||||
|
||||
info->show_present_divider = show_present;
|
||||
}
|
||||
|
||||
/* ======================= end of file =================== */
|
||||
|
@ -171,4 +171,9 @@ gboolean xaccSRHasPendingChanges (SplitRegister *reg);
|
||||
* Otherwise, it returns FALSE. */
|
||||
gboolean xaccSRCheckReconciled (SplitRegister *reg);
|
||||
|
||||
/* If TRUE, visually indicate the demarcation between splits with post
|
||||
* dates prior to the present, and after. This will only make sense if
|
||||
* the splits are ordered primarily by post date. */
|
||||
void xaccSRShowPresentDivider (SplitRegister *reg, gboolean show_present);
|
||||
|
||||
#endif /* __XACC_SPLIT_LEDGER_H__ */
|
||||
|
@ -199,7 +199,7 @@ gnc_account_tree_init(GNCAccountTree *tree)
|
||||
|
||||
tree->deficit_style = NULL;
|
||||
|
||||
#if !USE_NO_COLOR
|
||||
if (gnc_color_deficits())
|
||||
{
|
||||
GdkColormap *cm = gtk_widget_get_colormap(GTK_WIDGET(tree));
|
||||
GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(tree));
|
||||
@ -211,7 +211,6 @@ gnc_account_tree_init(GNCAccountTree *tree)
|
||||
|
||||
gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_NORMAL], FALSE, TRUE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@ -986,7 +985,7 @@ gnc_account_tree_insert_row(GNCAccountTree *tree,
|
||||
for (i = 0; i < tree->num_columns; i++)
|
||||
g_free(text[i]);
|
||||
|
||||
#if !USE_NO_COLOR
|
||||
if (gnc_color_deficits())
|
||||
{
|
||||
GtkStyle *style;
|
||||
double balance;
|
||||
@ -1020,7 +1019,6 @@ gnc_account_tree_insert_row(GNCAccountTree *tree,
|
||||
tree->total_column + 1, style);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set the user_data for the tree item to the account it */
|
||||
/* represents. */
|
||||
|
@ -417,6 +417,24 @@ gnc_get_toolbar_style(void)
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_color_deficits *
|
||||
* return a boolean value indicating whether deficit quantities *
|
||||
* should be displayed using the gnc_get_deficit_color(). *
|
||||
* *
|
||||
* Args: none *
|
||||
* Returns: boolean deficit color indicator *
|
||||
\*******************************************************************/
|
||||
gboolean
|
||||
gnc_color_deficits (void)
|
||||
{
|
||||
return gnc_lookup_boolean_option ("General",
|
||||
"Display negative amounts in red",
|
||||
TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_get_deficit_color *
|
||||
* fill in the 3 color values for the color of deficit values *
|
||||
@ -444,10 +462,15 @@ gnc_get_deficit_color(GdkColor *color)
|
||||
void
|
||||
gnc_set_label_color(GtkWidget *label, double value)
|
||||
{
|
||||
#if !USE_NO_COLOR
|
||||
gboolean deficit;
|
||||
GdkColormap *cm = gtk_widget_get_colormap(GTK_WIDGET(label));
|
||||
GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(label));
|
||||
GdkColormap *cm;
|
||||
GtkStyle *style;
|
||||
|
||||
if (!gnc_color_deficits())
|
||||
return;
|
||||
|
||||
cm = gtk_widget_get_colormap(GTK_WIDGET(label));
|
||||
style = gtk_widget_get_style(GTK_WIDGET(label));
|
||||
|
||||
style = gtk_style_copy(style);
|
||||
|
||||
@ -464,7 +487,6 @@ gnc_set_label_color(GtkWidget *label, double value)
|
||||
gtk_widget_set_style(label, style);
|
||||
|
||||
gtk_style_unref(style);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,6 +95,8 @@ GtkWidget * gnc_build_option_menu(GNCOptionInfo *option_info,
|
||||
|
||||
GtkToolbarStyle gnc_get_toolbar_style(void);
|
||||
|
||||
gboolean gnc_color_deficits (void);
|
||||
|
||||
void gnc_get_deficit_color(GdkColor *color);
|
||||
void gnc_set_label_color(GtkWidget *label, double value);
|
||||
|
||||
|
@ -181,23 +181,24 @@ gnc_reconcile_list_init(GNCReconcileList *list)
|
||||
|
||||
list->reconciled_style = gtk_style_copy(style);
|
||||
|
||||
#if !USE_NO_COLOR
|
||||
style = list->reconciled_style;
|
||||
if (gnc_color_deficits())
|
||||
{
|
||||
style = list->reconciled_style;
|
||||
|
||||
/* A dark green */
|
||||
style->fg[GTK_STATE_NORMAL].red = 0;
|
||||
style->fg[GTK_STATE_NORMAL].green = 40000;
|
||||
style->fg[GTK_STATE_NORMAL].blue = 0;
|
||||
/* A dark green */
|
||||
style->fg[GTK_STATE_NORMAL].red = 0;
|
||||
style->fg[GTK_STATE_NORMAL].green = 40000;
|
||||
style->fg[GTK_STATE_NORMAL].blue = 0;
|
||||
|
||||
gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_NORMAL], FALSE, TRUE);
|
||||
gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_NORMAL], FALSE, TRUE);
|
||||
|
||||
/* A nice yellow */
|
||||
style->fg[GTK_STATE_SELECTED].red = 65280;
|
||||
style->fg[GTK_STATE_SELECTED].green = 62976;
|
||||
style->fg[GTK_STATE_SELECTED].blue = 36608;
|
||||
/* A nice yellow */
|
||||
style->fg[GTK_STATE_SELECTED].red = 65280;
|
||||
style->fg[GTK_STATE_SELECTED].green = 62976;
|
||||
style->fg[GTK_STATE_SELECTED].blue = 36608;
|
||||
|
||||
gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_SELECTED], FALSE, TRUE);
|
||||
#endif
|
||||
gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_SELECTED], FALSE, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,6 +346,7 @@ static void
|
||||
gnc_register_sort(RegWindow *regData, sort_type_t sort_code)
|
||||
{
|
||||
Query *query = regData->ledger->query;
|
||||
gboolean show_present_divider = FALSE;
|
||||
|
||||
if (regData->sort_type == sort_code)
|
||||
return;
|
||||
@ -354,9 +355,11 @@ gnc_register_sort(RegWindow *regData, sort_type_t sort_code)
|
||||
{
|
||||
case BY_STANDARD:
|
||||
xaccQuerySetSortOrder(query, BY_STANDARD, BY_NONE, BY_NONE);
|
||||
show_present_divider = TRUE;
|
||||
break;
|
||||
case BY_DATE:
|
||||
xaccQuerySetSortOrder(query, BY_DATE, BY_STANDARD, BY_NONE);
|
||||
show_present_divider = TRUE;
|
||||
break;
|
||||
case BY_DATE_ENTERED:
|
||||
xaccQuerySetSortOrder(query, BY_DATE_ENTERED, BY_STANDARD, BY_NONE);
|
||||
@ -381,6 +384,8 @@ gnc_register_sort(RegWindow *regData, sort_type_t sort_code)
|
||||
assert(0); /* we should never be here */
|
||||
}
|
||||
|
||||
xaccSRShowPresentDivider (regData->ledger->ledger, show_present_divider);
|
||||
|
||||
regData->sort_type = sort_code;
|
||||
|
||||
regData->ledger->dirty = 1;
|
||||
@ -703,7 +708,7 @@ gnc_register_date_window(RegWindow *regData)
|
||||
radio = gtk_radio_button_new_with_label(NULL, SHOW_EARLIEST_STR);
|
||||
gtk_box_pack_start(GTK_BOX(vbox2), radio, FALSE, FALSE, 0);
|
||||
regDateData->show_earliest = radio;
|
||||
|
||||
|
||||
if (show_all)
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
|
||||
|
||||
@ -1720,6 +1725,8 @@ regWindowLedger(xaccLedgerDisplay *ledger)
|
||||
|
||||
gtk_widget_show_all(register_window);
|
||||
|
||||
xaccSRShowPresentDivider (ledger->ledger, TRUE);
|
||||
|
||||
ledger->dirty = 1;
|
||||
xaccLedgerDisplayRefresh(ledger);
|
||||
gnc_reg_refresh_toolbar(regData);
|
||||
|
@ -40,7 +40,7 @@ static int color_inited;
|
||||
static GdkColorContext *gnucash_color_context;
|
||||
|
||||
/* Public Colors */
|
||||
GdkColor gn_white, gn_black, gn_light_gray, gn_dark_gray, gn_red;
|
||||
GdkColor gn_white, gn_black, gn_light_gray, gn_dark_gray, gn_blue;
|
||||
|
||||
static GHashTable *color_hash_table = NULL;
|
||||
|
||||
@ -130,7 +130,6 @@ gnucash_color_argb_to_gdk (guint32 argb)
|
||||
color->blue);
|
||||
|
||||
g_hash_table_insert (color_hash_table, newkey, color);
|
||||
/* Fixme: do we need to refcount the colors */
|
||||
}
|
||||
|
||||
return color;
|
||||
@ -152,7 +151,7 @@ gnucash_color_init (void)
|
||||
|
||||
gnucash_color_alloc_name ("gray60", &gn_light_gray);
|
||||
gnucash_color_alloc_name ("gray40", &gn_dark_gray);
|
||||
gnucash_color_alloc_name ("red", &gn_red);
|
||||
gnucash_color_alloc_name ("sky blue", &gn_blue);
|
||||
|
||||
if (!color_hash_table)
|
||||
color_hash_table = g_hash_table_new(color_hash, color_equal);
|
||||
|
@ -31,7 +31,6 @@ void gnucash_color_alloc_name (const char *name, GdkColor *color);
|
||||
void gnucash_color_alloc_gdk (GdkColor *color);
|
||||
GdkColor *gnucash_color_argb_to_gdk (guint32 argb);
|
||||
|
||||
|
||||
extern GdkColor gn_white, gn_light_gray, gn_dark_gray, gn_black, gn_red;
|
||||
extern GdkColor gn_white, gn_light_gray, gn_dark_gray, gn_black, gn_blue;
|
||||
|
||||
#endif /* GNUCASH_COLOR_H */
|
||||
|
@ -263,6 +263,7 @@ draw_cell (GnucashGrid *grid, int block,
|
||||
SheetBlock *sheet_block;
|
||||
SheetBlockCell *sb_cell;
|
||||
VirtualCellLocation vcell_loc = { block, 0 };
|
||||
VirtualCell *vcell;
|
||||
|
||||
gdk_gc_set_background (grid->gc, &gn_white);
|
||||
|
||||
@ -271,7 +272,7 @@ draw_cell (GnucashGrid *grid, int block,
|
||||
sb_cell = gnucash_sheet_block_get_cell (sheet_block, i, j);
|
||||
|
||||
gdk_gc_set_foreground (grid->gc, sb_cell->bg_color);
|
||||
gdk_draw_rectangle (drawable, grid->gc, TRUE, x, y, width, height);
|
||||
gdk_draw_rectangle (drawable, grid->gc, TRUE, x, y, width, height);
|
||||
|
||||
gdk_gc_set_foreground (grid->gc, &gn_black);
|
||||
|
||||
@ -295,6 +296,28 @@ draw_cell (GnucashGrid *grid, int block,
|
||||
if (cs->border & STYLE_BORDER_LEFT)
|
||||
gdk_draw_line (drawable, grid->gc, x, y+height, x, y);
|
||||
|
||||
/* dividing line */
|
||||
if ((i == 0) && (table->dividing_row >= 0))
|
||||
{
|
||||
vcell = gnc_table_get_virtual_cell (table, vcell_loc);
|
||||
if (vcell->phys_loc.phys_row == table->dividing_row)
|
||||
{
|
||||
gdk_gc_set_foreground (grid->gc, &gn_blue);
|
||||
gdk_draw_line (drawable, grid->gc, x, y, x + width, y);
|
||||
}
|
||||
}
|
||||
|
||||
if ((i == (style->nrows - 1)) && (table->dividing_row >= 0))
|
||||
{
|
||||
vcell = gnc_table_get_virtual_cell (table, vcell_loc);
|
||||
if (vcell->phys_loc.phys_row == (table->dividing_row - 1))
|
||||
{
|
||||
gdk_gc_set_foreground (grid->gc, &gn_blue);
|
||||
gdk_draw_line (drawable, grid->gc, x, y + height,
|
||||
x + width, y + height);
|
||||
}
|
||||
}
|
||||
|
||||
#undef ROUNDED_CORNERS
|
||||
#ifdef ROUNDED_CORNERS
|
||||
gdk_gc_set_foreground (grid->gc, sheet_block->bg_colors[i][j]);
|
||||
|
@ -107,6 +107,7 @@ gnc_table_init (Table * table)
|
||||
table->num_virt_cols = -1;
|
||||
|
||||
table->current_cursor = NULL;
|
||||
|
||||
table->current_cursor_virt_loc.virt_row = -1;
|
||||
table->current_cursor_virt_loc.virt_col = -1;
|
||||
table->current_cursor_phys_loc.phys_row = -1;
|
||||
@ -119,6 +120,8 @@ gnc_table_init (Table * table)
|
||||
|
||||
table->alternate_bg_colors = FALSE;
|
||||
|
||||
table->dividing_row = -1;
|
||||
|
||||
/* initialize private data */
|
||||
|
||||
table->virt_cells = NULL;
|
||||
|
@ -210,6 +210,9 @@ struct _Table
|
||||
* physical rows within cellblocks. */
|
||||
gboolean alternate_bg_colors;
|
||||
|
||||
/* If positive, denotes a row that marks a boundary that should
|
||||
* be visually distinguished. */
|
||||
short dividing_row;
|
||||
|
||||
/* private data */
|
||||
|
||||
@ -285,7 +288,7 @@ void gnc_table_set_size (Table * table,
|
||||
/* The gnc_table_create_cursor() method can be called whenever a
|
||||
* reconfig of the cursor may require new gui elements to be
|
||||
* initialized. */
|
||||
void gnc_table_create_cursor (Table *, CellBlock *);
|
||||
void gnc_table_create_cursor (Table *table, CellBlock *cursor);
|
||||
|
||||
/* indicate what handler should be used for a given virtual block */
|
||||
void gnc_table_set_cursor (Table *table, CellBlock *curs,
|
||||
|
@ -422,12 +422,17 @@ transaction." #t))
|
||||
"General" "Display \"Tip of the Day\""
|
||||
"f" "Display hints for using GnuCash at startup" #t))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-simple-boolean-option
|
||||
"General" "Display negative amounts in red"
|
||||
"g" "Display negative amounts in red" #t))
|
||||
|
||||
; this option also changes the next option so that its
|
||||
; selectability matches the state of this option.
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-complex-boolean-option
|
||||
"General" "Automatic Decimal Point"
|
||||
"g"
|
||||
"h"
|
||||
"Automatically insert a decimal point into values that are entered without one."
|
||||
#f #f
|
||||
(lambda (x) (gnc:set-option-selectable-by-name "General"
|
||||
@ -437,7 +442,7 @@ transaction." #t))
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-number-range-option
|
||||
"General" "Auto Decimal Places"
|
||||
"h" "How many automatic decimal places will be filled in."
|
||||
"i" "How many automatic decimal places will be filled in."
|
||||
;; current range is 1-8 with default from the locale
|
||||
( gnc:locale-decimal-places ) ;; default
|
||||
1.0 ;; lower bound
|
||||
|
Loading…
Reference in New Issue
Block a user