New boolcolor option

Jose Marino jose.marino+gnucash at gmail.com
Fri Dec 1 10:51:39 EST 2017


Hi,
I would like some feedback about a new report configuration option that
allows the user to select a color and enable/disable the option at the same
time.
I've posted the current implementation in my repo (
https://github.com/jmarino/gnucash) in branch "new/boolcolor-option".
Link: https://github.com/jmarino/gnucash/commits/new/boolcolor-option
The new option is demonstrated in the cashflow-barchart report.

The motivation came from John Ralls in PR #215, where he suggested letting
the user choose colors in some of the standard reports. The easiest thing
would have been to add color options to the reports but that could create
some repetition in the options dialog. For example, in the
cashflow-barchart report, we would have these options:
  * Show Income
  * Show Expense
  * Show Net Flow
  * Income Color
  * Expense Color
  * Net Flow Color
I thought it would be much cleaner and nicer to combine the boolean and
color options into one.

The new option is called "boolcolor" and it's a combination of a
simple-boolean option and a color option, i.e., a check-button (and label),
and a color chooser button side by side. It is implemented as a new gtk
widget "GncBoolColor" that packs the check and color buttons together. The
gtk code for the new widget was copied and adapted from the GncDateEdit
widget.

>From guile, a new boolcolor option is created with:
(gnc:make-boolcolor-option
         section
         name
         sort-tag
         documentation-string
         default-value
         use-alpha)

Where "default-value" is a list containing the state of the check button
and a color string: (#t "#0000ff") -> enabled, blue.
And "use-alpha" is a boolean, indicating if the gtk color chooser should
use alpha transparency (like in the plain color option). Since the color is
specified as a string there's no need for the range option here. The last
commit in my branch uses this new widget in the cashflow-barchart report as
an example.

So for feedback:
- Is this a good idea? Creating a new widget for this purpose?
- Is the use of the plain color option preferred? Even if it leads to a
busier options dialog.
- Would it be better to extend the existing color option instead of
creating a completely new option and widget? The presence of the check
button would be made optional to recover the functionality of the plain
color option.
- I'm not in love with the name "boolcolor", couldn't think of anything
better.
- What about specifying the color as a string? This is different than in
the plain color option but I think it's more flexible. A color can be
specified as a CSS color with "#ffffff" or "rgb(0,0,255)" or "blue", and
can be directly passed to be interpreted by the html engine.

Jose

NOTE: I sent this email to the gnucash-devel list a few days ago before I
joined the list. It's been caught in limbo waiting for approval. Just
letting people know in case it shows up twice.


More information about the gnucash-devel mailing list