Difference between revisions of "GTK3"

From GnuCash
Jump to: navigation, search
(current row)
(Maint -> stable; use {{URL:Bugs}} and partial {{URL:GTK-docs}})
 
(111 intermediate revisions by 11 users not shown)
Line 1: Line 1:
With version 3.0, GnuCash has upgraded to the GTK3 library from [[GTK2]].
+
Since '''GnuCash 3.0''' the [{{URL:wp}}GTK GTK]3 library is used for the Graphical User Interface (GUI). Older versions were using [[GTK2]].
  
This page contains instructions on how to customize GTK3 appearance and behaviour.
+
Many parts of GnuCash's appearance—and in rare cases behaviour—depend on the [[#Themes|theme]] selected in your desktop environment.
  
== Keyboard Shortcuts ==
+
This page contains instructions on how to customize GTK3 appearance and behavior.
  
Keyboard shortcuts can be assigned to actions in GnuCash application. To assign a custom shortcut, do the following:
+
For more information about the location of the configuration files, see [[Configuration Locations]].
  
With GnuCash *not running* open $GNC_DOC_PATH/Gnucash/accelerator_map in any text editor and find the line with the desired command, i.e. for double-line in the register view use
+
== Cascading Style Sheets (CSS) ==
 +
GnuCash since version 3 uses a new version of the GTK framework with a completely new styling mechanism based on [{{URL:W3C}}Style/CSS/ Cascading Style Sheets (CSS)]. For Windows users, this has unfortunately rendered the theming tool that we used to distribute useless and sadly there isn't a replacement available that works with GTK3.
 +
 
 +
Fortunately, [{{URL:GTK-docs}}gtk3/css-overview.html GTK's CSS] is fairly simple. This page will explain the basics and provide some examples for commonly-requested changes.
 +
 
 +
For reference, there is a sample GTK css file available at: [{{URL:GH}}Gnucash/gnucash/blob/stable/doc/gtk-3.0.css GTK css example]
 +
;See also: [[CSS]]
 +
 
 +
==Tools for Managing GTK Settings==
 +
=== Query GSettings ===
 +
Some theme information is kept in gsettings and can be queried with [https://developer.gnome.org/gtk3/unstable/gtk-query-settings.html gtk-query-settings]. For example
 +
<Syntaxhighlight lang="sh">
 +
gtk-query-settings theme
 +
</Syntaxhighlight>
 +
will return all of the settings whose name includes the word "theme".
 +
It is usually in a package [https://developer.gnome.org/gtk3/stable/pt06.html gtk3-tools].
 +
 
 +
=== Using the GTK Inspector ===
 +
GTK has a built in [https://wiki.gnome.org/Projects/GTK%2B/Inspector Inspector] that you can enable by setting environment varialbe GTK_DEBUG to interactive. There are several ways to do this. The most straight-forward on linux is launching GnuCash from the command line with
 +
<Syntaxhighlight lang="sh">
 +
GTK_DEBUG=interactive path/to/gnucash
 +
</Syntaxhighlight>
 +
 
 +
For flatpak the command is slightly different. See [[Flatpak#GTK_Inspector|GTK Inspector on Flatpak]].
 +
 
 +
What will work on all platforms is to create file named ''environment.local'' in directory gnucash of the [[Configuration_Locations#System-wide|system-wide configuration directory]] with this contents:
 +
<Syntaxhighlight lang="ini">
 +
[Variables]
 +
GTK_DEBUG=interactive
 +
</Syntaxhighlight>
 +
You will likely need administrator privileges on your system to do this though.
 +
 
 +
It's quite useful for poking and prodding various bits of GnuCash to see what styles apply to which controls and to allow you to change things and to see the results immediately.
 +
 
 +
Note: You must have GTK+3 installed to use the Inspector.
 +
:*On macOS, you can use [https://brew.sh Homebrew]  to install GTK+3. Install Homebrew and then issue the command <Syntaxhighlight lang="sh">brew install gtk+3</Syntaxhighlight>
 +
 
 +
=== Linux Desktop Environments ===
 +
They have often a tool in their ''System Settings'' to adjust the appearance of ''all GTK apps'' per user:
 +
:;Gnome: [https://wiki.gnome.org/Apps/Tweaks Tweaks] is a graphical interface for advanced GNOME 3 settings. It was previously known as ''Gnome Tweak Tool''.
 +
:;KDE: [{{URL:GH}}KDE/kde-gtk-config kde-gtk-config] is a GTK2 and GTK3 Configurator for KDE.
 +
 
 +
== Behavior ==
 +
Certain aspects of widget behavior can also be customized.
 +
 
 +
=== Restoring Visible Mnenomics ===
 +
GTK Mnemonics are underlined characters in a label, used for keyboard navigation. Examples of labels which may include a mnemonic are the text on a button, the label of a field, and the text in a menu line. The mnemonic is activated by pressing the mnenomic activator key (<code>Alt</code> for Linux and Windows, <code>Command</code> for macOS) at the same time as the underlined character.
 +
 
 +
Since GTK 3.10, the underlines of the mnenomics are only visible after pressing the mnenomic activator key.
 +
 
 +
=== Scrollbars ===
 +
The behavior of the scrollbars can be customized. Compared to GTK2, if you now click above (or below) the current position bar in the scrollbar, it takes you to the place in the window which is proportional to where in the scroll bar you click, rather than up (or down) 1 screen full.
 +
This can be adjusted by using below instruction in the GTK settings file <tt>[[Configuration Locations#GTK_CONFIG_HOME|GTK_CONFIG_HOME]]/settings.ini</tt>:
 +
 
 +
<Syntaxhighlight lang="ini">
 +
[Settings]
 +
 
 +
# Use Windows style PgUp/PgDn scrollbars
 +
gtk-primary-button-warps-slider=false
 +
</Syntaxhighlight>
 +
 
 +
=== Menu Keyboard Shortcuts ===
 +
Keyboard shortcuts can be assigned to actions in GnuCash application. A more detailed information is available on [[Keyboard Shortcuts]].
 +
 
 +
To assign a custom shortcut, do the following:
 +
 
 +
With GnuCash *not running* open <tt>[[Configuration Locations#GNC_DATA_HOME|GNC_DATA_HOME]]/accelerator-map</tt> in any text editor and find the line with the desired command, i.e. for double-line in the register view use
 
   ;(gtk_accel_path "<Actions>/GncPluginPageRegisterActions/ViewStyleDoubleLineAction" "")
 
   ;(gtk_accel_path "<Actions>/GncPluginPageRegisterActions/ViewStyleDoubleLineAction" "")
 
If, for some reason, the line is missing in the accelerator-map file, simply copy the line above into the file.
 
If, for some reason, the line is missing in the accelerator-map file, simply copy the line above into the file.
Line 13: Line 79:
 
Save the file.  
 
Save the file.  
  
GNC_DOC_PATH defaults to:
+
The Ctrl key is referenced as <Primary>. For example, if you want to use Ctrl+2 for a shortcut, set the value to "<Primary>2".
;Linux: FIXME
+
 
;MacOS: FIXME
+
The next time you open GnuCash, you will be able to use the shortcut key to trigger the desired functionality. The relevant menu item will reflect this fact by displaying the shortcut key next to the assigned action's name.
;Windows: CSIDL_APPDATA, which is referenced via %APPDATA% variable and normally points to C:\Users\<userid>\AppData\Roaming.
+
 
 +
For full list of possible actions see [{{URL:GH}}Gnucash/gnucash/blob/stable/gnucash/ui/osx_accel_map source code on GitHub].
 +
 
 +
=== Key Bindings ===
 +
Customizing key bindings is done by editing (or creating if needed) the file <tt>[[Configuration Locations#GNC_CONFIG_HOME|GNC_CONFIG_HOME]]/gtk-3.0.css</tt> in the GnuCash configuration directory.
  
The Ctrl key is referenced as <Primary>. For example, if you want to use Ctrl+2 for a shortcut, set the value to "<Primary>2".
+
For example, to add a new binding so that the F11 key is bound to the ''copy-clipboard'' action and the F12 key is bound to the ''paste-clipboard'' action and existing keybindings for these actions remain unchanged, add something like this to gtk-3.0.css:
 +
<Syntaxhighlight lang="CSS">
 +
/* Bind F11 to Copy, F12 to Paste */
 +
@binding-set F11CopyF12Paste
 +
{
 +
  bind "F11" { "copy-clipboard" () };
 +
  bind "F12" { "paste-clipboard" () };
 +
}
 +
 
 +
entry
 +
{
 +
  -gtk-key-bindings: F11CopyF12Paste;
 +
}</Syntaxhighlight>
 +
 
 +
If you like Emacs-style keybindings you can add,
 +
<Syntaxhighlight lang="ini">
 +
gtk-key-theme-name = Emacs
 +
</Syntaxhighlight>
 +
to your settings.ini.
 +
;macOS only: Unfortunately for macOS users that setting is hard-coded to the Mac keybindings theme for Quartz (macOS Native) screens. Fortunately, there's a fairly painless workaround  (and this way you get both the emacs and the Mac bindings which is how most native apps actually work):
 +
:Copy <tt>GnuCash.app/Contents/share/themes/Emacs/gtk-3.0/gtk-keys.css</tt> to
 +
:<tt>~/Library/Application Support/Gnucash config gtk-3.0</tt>. If you have no other customizations, just name it <tt>gtk.css</tt>. If you already have a <tt>gtk.css</tt> there, add to it <Syntaxhighlight lang="CSS">
 +
@import url("gtk-keys.css");
 +
</Syntaxhighlight>
 +
 
 +
== Typefaces ==
 +
There are two ways of setting a default font and size for GnuCash.
 +
:The first sets an option in GTK's <tt>settings.ini</tt> for ''all GTK applications'' (GIMP etc.),
 +
:the other uses css to accomplish the same for ''GnuCash only''.
 +
*If neither you nor a program changed the default values before, the files mentioned in this section will ''not exist''. In this case just create them as ''pure text files'' and with normal file access rights.
 +
The examples below with both set the '''default font''' to Arial and '''font size''' to 14.
 +
 
 +
=== Via settings.ini ===
 +
Create if necessary and add the following line to <tt>[[Configuration Locations#GTK_CONFIG_HOME|GTK_CONFIG_HOME]]/settings.ini</tt>:
 +
<Syntaxhighlight lang="ini">
 +
[Settings]
 +
gtk-font-name=Arial 14
 +
</Syntaxhighlight>
 +
;General notes:
 +
* In <tt>settings.ini</tt>, lines beginning with a <code>#</code> and blank lines are considered comments.
 +
* If the file exists and has a <tt>[Settings]</tt> line just add the font line beneath it.
 +
* Setting font family via settings.ini doesn't work on macOS and Microsoft Windows. Use CSS to set font family on those operating systems.
 +
 
 +
=== Via css ===
 +
Create if necessary and add the following to <tt>[[Configuration Locations#GNC_CONFIG_HOME|GNC_CONFIG_HOME]]/gtk-3.0.css</tt>:
 +
<Syntaxhighlight lang="css">
 +
* {
 +
  font: 14pt arial, sans-serif;
 +
}
 +
</Syntaxhighlight>
 +
 
 +
If you see some or all '''non-ASCII characters''' displayed as a missing-glyph character, often some variation of a white square, it means that those characters aren't supported by the font you've selected. You'll need to find a font family for your platform that better supports your language.
 +
 
 +
'''Note:''' Gtk on Microsoft Windows will not set the font family globally with the '*' css selector. Use <tt>#gnc-id-main-window</tt> instead.
  
The next time you open GnuCash, you will be able to the shortcut to trigger the desired functionality. The relevant menu item will reflect this fact by displaying the shortcut key next to the assigned action's name.
+
For Simplified Chinese one user found
 +
<Syntaxhighlight lang="css">
 +
#gnc-id-main-window {
 +
  font-family: Microsoft YaHei;
 +
  font-size: 14pt;
 +
}
 +
</Syntaxhighlight>
 +
worked well.
  
 
== Visual Styling ==
 
== Visual Styling ==
 +
As GTK3 uses Cascading Style Sheets (CSS) for themes this is fairly easy to resolve by styling the GTK applications manually or using one of myriad available graphical themes.
 +
This is easily done by placing a custom CSS file at the correct location, depending on your system, or downloading and using a custom-made theme.
 +
'''N.B.''' css files must be '''plain ascii text'''. Be sure to use a suitable editor; if you use a word processor be sure to save the file as plain text. Most Windows users can use Notepad, while macOS users can use TextEdit but must select File>Make Plain Text when first creating the file.
  
As noted in [https://bugzilla.gnome.org/show_bug.cgi?id=791823 bug 791823], the GTK theming tool is not being distributed with GTK3 any more, compared to GTK2. This, due to the fact that GTK3 uses Cascading Style Sheets (CSS) for themes, is fairly easy to resolve by styling the GTK applications manually or using one of myriad available graphical themes.
+
===Register Appearance===
This is easily done by placing a custom CSS file at the correct location, depending on your system, or downloading and using a custom-made theme.
+
The GnuCash registers use a yellow/green theme by default for register windows. Users must disable this default theme in order to change register appearance.  
 +
 
 +
To override this, one first has to disable this custom theme by ''disabling'' "'''Use GnuCash built-in color theme'''" in the GnuCash Preferences.
 +
 
 +
Next, create or change the GTK css file for further styling tweaks. The location and name of the resource file is explained in [[Configuration Locations]].
 +
 
 +
For adjusting register colors, you can override the relevant css style definitions in your own GTK3 resource file. See [{{URL:GH}}Gnucash/gnucash/blob/stable/doc/gtk-3.0.css GTK css example] for example settings.
  
 
=== Manual Styling using CSS file ===
 
=== Manual Styling using CSS file ===
 
 
The comprehensive [https://developer.gnome.org/gtk3/stable/chap-css-overview.html GTK+ CSS Overview], as it relates to GTK, is available at Gnome Developer web site.
 
The comprehensive [https://developer.gnome.org/gtk3/stable/chap-css-overview.html GTK+ CSS Overview], as it relates to GTK, is available at Gnome Developer web site.
  
Line 35: Line 173:
 
A sample GnuCash CSS file can be found below:
 
A sample GnuCash CSS file can be found below:
  
* [https://github.com/Gnucash/gnucash/blob/master/doc/gtk-3.0.css GTK 3 CSS]
+
* [{{URL:GH}}Gnucash/gnucash/blob/stable/doc/gtk-3.0.css GTK 3 CSS]
  
 
For extra info, you can also check these low-level customizations:  
 
For extra info, you can also check these low-level customizations:  
  
* [https://github.com/Gnucash/gnucash/blob/master/gnucash/gnucash-310.css gnucash-310]
+
;gnucash 4 or more recent: [{{URL:GH}}Gnucash/gnucash/blob/stable/gnucash/gnucash.css gnucash.css]
* [https://github.com/Gnucash/gnucash/blob/master/gnucash/gnucash-320.css gnucash-320]
+
;gnucash 3 with gtk 3.20 or more recent: [{{URL:GH}}Gnucash/gnucash/blob/3.10/gnucash/gnucash-320.css gnucash-320]
 +
;gnucash 3 with gtk older than 3.20: [{{URL:GH}}Gnucash/gnucash/blob/3.10/gnucash/gnucash-310.css gnucash-310]
  
 
Note that these contain the @ variables, as explained in the CSS customization overview, Colors section.
 
Note that these contain the @ variables, as explained in the CSS customization overview, Colors section.
Line 46: Line 185:
 
To precisely locate the UI elements for customization, you can use the [https://wiki.gnome.org/Projects/GTK%2B/Inspector GTK Inspector] tool.
 
To precisely locate the UI elements for customization, you can use the [https://wiki.gnome.org/Projects/GTK%2B/Inspector GTK Inspector] tool.
  
To customize the way GnuCash looks, create or modify an existing Cascading Style Sheets (CSS) file at the appropriate location. The correct location on different operating systems is explained in the following FAQ answer: [https://wiki.gnucash.org/wiki/FAQ#Q:_Where_can_I_find_the_gtk_resource_file.3F Where can I find the GTK resource file?]
+
CSS rules to customize the GnuCash appearance should be stored in <tt>[[Configuration Locations#GNC_CONFIG_HOME|GNC_CONFIG_HOME]]/gtk-3.0.css</tt>.
Note that, by default, no gtk-3.0.css file will be created by GnuCash application. Once you add the file, add the desired CSS rules or copy values from an existing theme.
+
 
There are plenty of GTK3 theme resources caused by the fact that CSS is a widely-adopted standard for UI styling and many people are familiar with it.
+
Note that GnuCash will never create this file for you but you can to create it yourself as a plain text file. If you are on Linux(various), macOS(TextEdit.app) or Windows10(Notepad), your default text editor will work fine to create plain text files. If you are on an older version of Windows, you'll need to use something other than Notepad that can save files with Unix/Linux line endings. Do not use Rich Text Editors or formats, or any word processor that can't save as plain text.
 +
 
 +
You can write your own css rules or copy them from existing themes. The [[#Themes]] section below has a few links to websites where you can find sample themes.
  
 
Related wiki entries:
 
Related wiki entries:
  
* [https://wiki.gnucash.org/wiki/FAQ#Q:_How_do_I_change_the_register_colors.3F How do I change the register colors?]
+
* [[FAQ#Q: How do I change the register colors?]]
* [https://wiki.gnucash.org/wiki/FAQ#Q:_Where_can_I_find_the_gtk_resource_file.3F Where can I find the gtk resource file?]
+
* [[FAQ#Q: Where can I find the gtk resource file?]]
  
 
==== Custom GnuCash Styles ====
 
==== Custom GnuCash Styles ====
 
+
To style the register you can use css rules like below:
For register, you can use the the style as follows:
+
<syntaxhighlight lang="css">
 
+
*.register-primary {
  *.register-primary {
+
  color: red;
    color: red;
+
}
  }
+
</syntaxhighlight>
 
 
 
where
 
where
 +
: *.register-header => header bar at top of sheet
 
: *.register-primary => primary (dark-background) lines
 
: *.register-primary => primary (dark-background) lines
 
: *.register-secondary => secondary (light-background) lines
 
: *.register-secondary => secondary (light-background) lines
 +
: *.register-split => split lines
 
:cursor entry => the cell containing the cursor
 
:cursor entry => the cell containing the cursor
 
: *.register-foreground => setting the colour for this selector will paint all the register text in that colour.
 
: *.register-foreground => setting the colour for this selector will paint all the register text in that colour.
 
: *.register-cursor => the currently selected row in the register
 
: *.register-cursor => the currently selected row in the register
  
=== Themes ===
+
If you want to apply a change to the entire register sheet:
 +
<syntaxhighlight lang="css">
 +
sheet {
 +
  font: 12px;
 +
}
 +
</syntaxhighlight>
 +
 
 +
==== Sample GnuCash Selectors (CSS Nodes) ====
 +
Chart of Accounts Tab:
 +
 
 +
This sheet has an ID of #account_tree which affects the entire sheet below the column headers.
 +
 
 +
Thus:
 +
<syntaxhighlight lang="css">
 +
#account_tree {
 +
  font-size: 1.2em;
 +
}
 +
</syntaxhighlight>
 +
 
 +
will increase the font size by 20% for all of the account names and their related right-hand columns.
 +
 
 +
If you want to color the area behind and around the Totals Bar:
 +
<syntaxhighlight lang="css">
 +
.GncAccountPage {
 +
  background-color: lightgrey;
 +
}
 +
</syntaxhighlight>
 +
 
 +
If you want to style the column headers, use the following selector for the full header bar:
 +
 
 +
<syntaxhighlight lang="css">
 +
#account_tree header button{
 +
}
 +
</syntaxhighlight>
 +
 
 +
If you just want to apply font/text rules to the header labels themselves, use:
 +
 
 +
<syntaxhighlight lang="css">
 +
#account_tree header label {
 +
}
 +
</syntaxhighlight>
 +
 
 +
==== Labels of Toolbar Buttons ====
 +
Starting with ''GnuCash 3.3'' the toolbar buttons will have their labels ''enabled''. This will widen the buttons, so on some screens that means not all buttons will be visible any more. If you prefer to have no labels under the buttons, you can use the following css snippet to hide them:
 +
 
 +
<syntaxhighlight lang="css">
 +
toolbar toolbutton label
 +
{
 +
  font-size: 0;
 +
}
 +
</syntaxhighlight> which is bad style. Better use <syntaxhighlight lang="ini">
 +
gtk-toolbar-style=0
 +
</syntaxhighlight> in your <tt>settings.ini</tt>. <ref>https://developer.gnome.org/gtk3/stable/GtkToolbar.html#gtk-toolbar-set-style</ref>
 +
 
 +
==== Toolbar Button spacing ====
 +
 
 +
The toolbar buttons are visually very wide apart. This appears to be a conscious design choice in the Gtk default Adwaita theme. If you prefer to have them closer together to fit more buttons on the toolbar, you can use the following snippet to reduce the spacing. There are two css nodes that together make up for the total spacing. Both are set to 8px by default. The snippet below will reduce both of them to 4px. You can reduce them even further to your taste:
 +
 
 +
<syntaxhighlight lang="css">
 +
toolbar toolbutton button
 +
{
 +
    padding-left: 4px;
 +
    padding-right: 4px;
 +
}
 +
 
 +
toolbar toolbutton label
 +
{
 +
    padding-left: 4px;
 +
    padding-right: 4px;
 +
}
 +
</syntaxhighlight>
 +
 
 +
==== Scrollbar adjustments ====
 +
Some sample settings to adjust the scrollbar: <syntaxhighlight lang="css">
 +
scrollbar {
 +
    /* Just in case another file disabled them */
 +
    -GtkScrollbar-has-backward-stepper: 1;
 +
    -GtkScrollbar-has-forward-stepper: 1;
 +
}
 +
 
 +
scrollbar slider {
 +
    /* Size of the slider */
 +
    min-width: 12px;
 +
    min-height: 12px;
 +
    border-radius: 22px;
 +
 
 +
    /* Padding around the slider */
 +
    border: 5px solid transparent;
 +
}
 +
</syntaxhighlight>
 +
 
 +
 
 +
===== Disable the overlay scrolling =====
 +
 
 +
GTK 3.0 has scrollbar overlap setting (default set to Boolean true) which may cause last entry in a list to show behind the scrollbars (specifically on horizontal ones) making it difficult to click on it when not disabled. It can be disabled by editing <tt>[[Configuration Locations#GTK_CONFIG_HOME|GTK_CONFIG_HOME]]/settings.ini</tt> file. Create it with a text editor if it does not exist.
 +
 
 +
<syntaxhighlight lang="css">
 +
[Settings]
 +
gtk-overlay-scrolling = false
 +
 
 +
</syntaxhighlight>
 +
 
 +
==== Dropdown List of Accounts Transparency Problem ====
 +
There is a problem with some Linux themes, such as the Ubuntu '''yaru''' theme, where the account list dropdown in the register '''Transfer''' field has a transparent background in the line under the mouse pointer. This makes it hard to read. See [{{URL:Bugs}}show_bug.cgi?id=797493 Bug 797493].
 +
 
 +
The following should fix this:<syntaxhighlight lang="css">
 +
/* GnuCash 4.x Fix transparent background in register Transfer dropdown Bug 797493 */
 +
gnc-id-sheet-list {
 +
  background-color: @theme_bg_color;
 +
}</syntaxhighlight>
 +
Or<syntaxhighlight lang="css">
 +
/* GnuCash 3.x Fix transparent background in register Transfer dropdown Bug 797493 */
 +
register sheet widget {
 +
  background-color: @theme_bg_color;
 +
}
 +
</syntaxhighlight>
 +
 
 +
==== KDE Register Input Field Black on Dark Background Problem ====
 +
There is a problem with some Linux themes, such as the Ubuntu '''breeze-dark''' theme on the KDE Plasma desktop, where the current register field is black on a dark background. This makes it hard to read. See [{{URL:Bugs}}show_bug.cgi?id=798202 Bug 798202]. This problem is fixed in GnuCash 4.6.
 +
 
 +
The following should fix this:<syntaxhighlight lang="css">
 +
/* GnuCash 4.x Fix register black on dark background Bug 798202 */
 +
.gnc-class-register-foreground.flat {                                                                                                                                                   
 +
    background-color: white;                                                                       
 +
}</syntaxhighlight>
 +
Or<syntaxhighlight lang="css">
 +
/* GnuCash 3.x Fix register black on dark background Bug 798202 */
 +
.header-color {
 +
  background-color: #363636;
 +
  color: #c8c8c8;
 +
}
 +
 
 +
.primary-color {
 +
  background-color: #383838;
 +
}
 +
 
 +
.primary-color:disabled {
 +
  background-color: #383838;
 +
}
 +
 
 +
.secondary-color {
 +
  background-color: #323232;
 +
}
 +
 
 +
.secondary-color:disabled {
 +
  background-color: #323232;
 +
}
 +
 
 +
.split-color {
 +
  background-color: #474747;
 +
}
 +
 
 +
.split-color:disabled {
 +
  background-color: #53728e;
 +
}
 +
 
 +
.cursor-color {
 +
  background-color: #383838;
 +
  color: #c8c8c8;
 +
}
 +
 
 +
cursor entry {
 +
  background-color: #383838;
 +
  color: #c8c8c8;
 +
}</syntaxhighlight>
 +
 
 +
==== Sample Style Properties ====
 +
This is a list of the most likely desired properties you can change in GnuCash with Gtk+3 as of version 3.22. Note, not all properties apply to all selectors (nodes). Properties may also not apply as expected compared to web CSS and may or may not cascade to child nodes.
 +
 
 +
*background-blend-mode
 +
*background-clip
 +
*background-color
 +
*background-image
 +
*background-position
 +
*background-repeat
 +
*background-size
 +
 
 +
*border-bottom-color
 +
*border-bottom-left-radius
 +
*border-bottom-right-radius
 +
*border-bottom-style
 +
*border-bottom-width
 +
 
 +
*border-image-repeat
 +
*border-image-slice
 +
*border-image-source
 +
*border-image-width
 +
 
 +
*border-left-color
 +
*border-left-style
 +
*border-left-width
 +
 
 +
*border-right-color
 +
*border-right-style
 +
*border-right-width
 +
 
 +
*border-top-color
 +
*border-top-left-radius
 +
*border-top-right-radius
 +
*border-top-style
 +
*border-top-width
 +
 
 +
*box-shadow
 +
 
 +
*color
 +
 
 +
*font-family
 +
*font-size
 +
*font-stretch
 +
*font-style
 +
*font-variant (does not seem to work)
 +
*font-weight
 +
 
 +
*letter-spacing
 +
 
 +
*margin-bottom
 +
*margin-left
 +
*margin-right
 +
*margin-top
 +
 
 +
*min-height
 +
*min-width
 +
 
 +
*opacity
 +
 
 +
*outline-color
 +
*outline-offset
 +
*outline-style
 +
*outline-width
 +
 
 +
*padding-bottom
 +
*padding-left
 +
*padding-right
 +
*padding-top
 +
 
 +
*text-decoration-color
 +
*text-decoration-line
 +
*text-decoration-style
 +
 
 +
*text-shadow
 +
 
 +
== Themes ==
 +
At first a warning about theming: [https://blogs.gnome.org/tbernard/2018/10/15/restyling-apps-at-scale/ restyling apps at scale].
  
 
You can use a predefined GTK3 theme. Note that applying a custom theme will affect all the gtk3-based applications on your system!
 
You can use a predefined GTK3 theme. Note that applying a custom theme will affect all the gtk3-based applications on your system!
  
 
Short summary:
 
Short summary:
# download an appropriate gtk3 theme from www.gnome-look.org or other sites
+
# download an appropriate GTK3 theme from www.gnome-look.org or other sites
# copy the theme into a directory where gtk3 looks for themes (see below)
+
# copy the theme into a directory where GTK3 looks for themes (see below)
# create or adjust a settings.ini file to instruct gtk3 to use this theme
+
# create or adjust a settings.ini file to instruct GTK3 to use this theme
  
 
Some sites which host custom GTK3 themes:
 
Some sites which host custom GTK3 themes:
Line 86: Line 470:
 
Below is a slightly longer explanation with platform dependent remarks:
 
Below is a slightly longer explanation with platform dependent remarks:
  
1. Go to the gnome-look.org website
+
# Go to the gnome-look.org website.
 +
# Click the '''GTK3 Themes''' link, ''not the GTK2'' one.
 +
# Select a theme you like. Alternatively you can search for keywords (like "dark") in the top right corner and then filter on "GTK3 Theme category".
 +
# If you have found a theme you like, download the proper file (in the files section of the theme page). Note depending on your operating system you may not be able to open all theme files. There are, for example, .deb archives which are specifically targeted at the Debian linux distribution and derivates such as Ubuntu. While Ubuntu and Debian users can install those themes via their package manager these themes are not useful for other platforms.<br />Theme files ending with .zip, .tar.gz or tar.xz are likely installable on all platforms, although you may have to find a proper application to extract them. <br />On Windows 7-Zip is a good candidate,  linux users can probably extract the files directly from their file manager. <br />Let's take the theme "Eye-friendly Dark RBC" as an example (it's not the best theme but it can serve as an example). The file to download is <code>Eye-friendly-Dark-RBC.tar.gz</code>.
 +
# Extract this file using an appropriate tool. This  should give you a directory named <tt>Eye-friendly-Dark-RBC</tt>.
 +
# Move this directory to [[Configuration Locations#USER_CONFIG_HOME|USER_CONFIG_HOME]]/themes. Note on Windows you'll need to use the %LOCALAPPDATA% variant as we're adjusting 
 +
GTK3's configuration.
 +
# Next tell GTK to load this theme.
 +
Linux users can probably most easily do this by install the "Gnome Tweak Tool" on their platform and select the new theme there.
 +
The manual method is this:
 +
Create a file named <tt>[[Configuration Locations#GTK_CONFIG_HOME|GTK_CONFIG_HOME]]/settings.ini</tt>.
  
2. Click the "Gtk3 Themes" link (*not* the Gtk2 one)
+
The contents of this file should be
 +
<Syntaxhighlight lang="ini">
 +
[Settings]
 +
gtk-theme-name=Eye-friendly-Dark-RBC
 +
</Syntaxhighlight>
 +
And that's it. Note the name is the name of the directory as you put in the themes directory.
 +
The next time you start GnuCash it should pick up this theme.
  
3. Select a theme you like. Alternatively you can search for keywords (like "dark") in the top right
+
A few extra notes:
corner and then filter on "Gtk3 Theme category".
+
* The default GTK3 theme is called "Adwaita".
 +
* On linux there's a second default theme called "Adwaita-dark" which should also give you a dark themed GnuCash. Unfortunately, this doesn't work on Windows out-of-the-box but there is a workaround. See under [[#Dark Themes]] below.
 +
* If you're adventurous you can probably also play with customized icon themes which you find on the gnome-look.org website. These themes should be installed in the icons directory next to the themes directory. And to activate them you can add <code>gtk-icon-theme-name=<directory name></code> in settings.ini.
 +
* A list of GTK settings that can be adjusted via settings.ini can be found at [https://developer.gnome.org/gtk3/stable/GtkSettings.html GTK Settings page].
  
4. If you have found a theme you like, download the proper file (in the files section of the theme page).
+
==== Dark Themes ====
Note depending on your operating system you may not be able to open all theme files. There are, for example, .deb archives which are specifically targeted at the Debian linux distribution and derivates such as Ubuntu. While Ubuntu and Debian users can install those themes via their package manager these themes are not useful for other platforms.
+
It may be possible to get the default dark theme on Windows using the following technique:
Theme files ending with .zip, .tar.gz or tar.xz are likely installable on all platforms, although you may have to find a proper application to extract them.
+
* Create/modify <tt>[[Configuration Locations#GTK_CONFIG_HOME|GTK_CONFIG_HOME]]/settings.ini</tt>.
On Windows 7-Zip is a good candiate,  linux users can probably extract the files directly from their file manager.
+
* Add this contents:
Let's take the theme "Eye-friendly Dark RBC" as an example (it's not the best theme but it can serve as an example). The file to download is "Eye-friendly-Dark-RBC.tar.gz"
 
  
5. Extract this file using an appropriate tool. This  should give you a directory named "Eye-friendly-Dark-RBC"
+
<Syntaxhighlight lang="ini">
 +
[Settings]
 +
gtk-application-prefer-dark-theme=true
 +
</Syntaxhighlight>
 +
If you then want to adjust highlighted text and negative numbers, insert <syntaxhighlight lang="css">
 +
/* Negative number color */
 +
.gnc-class-negative-numbers {
 +
  color: shade(@negative-numbers, 1.9);
 +
}
 +
gnc-id-sheet .gnc-class-negative-numbers {
 +
  color: @negative-numbers;
 +
}
 +
/* Highlight Text */
 +
.gnc-class-highlight {
 +
  color: shade(blue, 1.6);
 +
}
 +
</syntaxhighlight> into your gtk-3.0.css.<ref>[{{URL:Bugs}}show_bug.cgi?id=798936#c3 Bug 798936 - When using dark them, some texts are hard to read]</ref>
  
6. Move this directory to a location on your system that's parsed by gtk. This is platform dependent:
+
If this doesn't work an alternative option is to install a suitable theme as described above. A couple of suggestions for decent dark themes that may apply well to GnuCash:
;Linux: $HOME/.local/share/themes/
 
;OS X: $HOME/.local/share/themes/
 
;Windows: %LOCALAPPDATA%\themes\
 
  
7. Next tell gtk to load this theme.
+
* [https://www.opendesktop.org/p/1223551/ Leather-Dark]{{dead link}} theme,
Linux users can probably most easily do this by install the "Gnome Tweak Tool"
+
* [https://www.gnome-look.org/p/1225712/ Eye-friendly Dark RBC Theme]{{dead link}} - fully-working pleasant dark theme.
on their platform and select the new theme there.
 
The manual method is this:
 
Create a file named "settings.ini" in the appropriate location. Again this
 
depends on your platform:
 
;Linux: $HOME/.config/gtk-3.0/
 
;OS X: Either $HOME/.config/gtk-3.0/ (like on linux) or  $HOME/Library/Application Support/Gnucash/config/gtk-3.0
 
I suspect the latter in this case because gnucash overrides the XDG_CONFIG_HOME environment variable on OS X
 
;Windows: %LOCALAPPDATA%\gtk-3.0\
 
  
The contents of this file should be
+
The adventurous could of course also try and create such a theme from scratch. Below are a few pointers to get started:
  
[Settings]
+
* [https://gist.github.com/MisterY/e0e588eca2ee05c8afd858c7800cfc4a gtk-3.0.css] Black Theme,
gtk-theme-name=Eye-friendly-Dark-RBC
+
* [https://gist.github.com/MisterY/15ea50fee571865ca9efd8c5437a1713 gtk-3.0.css] settings that go well with a dark theme (i.e. Leather Dark).
  
And that's it. Note the name is the name of the directory as you put in the themes directory.
+
Ongoing work on a Dark [https://ethanschoonover.com/solarized/ Solarized] theme for use with GnuCash 4.0+ can be found here:
The next time you start gnucash it should pick up this theme.
 
  
A few extra notes:
+
* [https://raw.githubusercontent.com/davidschmitt/gnucash_gtk3/master/dark_solarized/gtk-3.0.css gtk-3.0.css] Dark Solarized theme CSS
* The default gtk3 theme is called "Adwaita"
+
* [https://raw.githubusercontent.com/davidschmitt/gnucash_gtk3/master/dark_solarized/gnucashShot.png screenshot] Dark Solarized theme screenshot
* On linux there's a second default theme called "Adwaita-dark" which should also give you a dark themed gnucash. Unfortunately this doesn't work on Windows.  
 
* If you're adventurous you can probably also play with customized icon themes which you find on the gnome-look.org website. These themes should be installed in the icons directory next ot the themese directory. And to activate them you can add gtk-icon-theme-name=<directory name> in settings.ini.
 
* Another setting some of you will be interested in is gtk-font-name=<a font description>
 
for example
 
gtk-font-name=Abyssinica SIL Regular 10
 
* More gtk settings one can override can be found here: //developer.gnome.org/gtk3/stable/GtkSettings.html
 
  
 +
==== Transparent Dropdown Backgrounds ====
 +
Some themes attempt to make elements translucent and screw it up. We've had a [{{URL:Bugs}}show_bug.cgi?id=797493 number] [{{URL:Bugs}}show_bug.cgi?id=797875 of] [{{URL:Bugs}}show_bug.cgi?id=798030 reports] of these efforts failing spectacularly, especially on Ubuntu. The symptom is that a drop-down list will have a transparent background either for the selected item or for the whole list box. As one might imagine this make finding the item one wants rather difficult.
  
==== Dark Themes ====
+
The solution is to override the theme's background. The following snippets should be added to the <tt>[[Configuration Locations#GNC_CONFIG_HOME|GNC_CONFIG_HOME]]/gtk-3.0.css</tt>. The Gtk one in <tt>[[Configuration Locations#GTK_CONFIG_HOME|GTK_CONFIG_HOME]]/gtk.css</tt> is loaded before the theme and will be overridden by loading the theme.
  
Due to the lack of a dark theme on Windows, a guide could be a ready-made custom theme to which GnuCash-specific style rules would be added.
+
For Ubunutu's
 +
;Yaru theme on GnuCash 3.x: <Syntaxhighlight lang="CSS">
 +
register sheet widget {
 +
  background-color: @theme_bg_color;
 +
  }
 +
</Syntaxhighlight>
  
Here is an example of a dark theme for GnuCash 3. Note that this is still a work in progress, though.
+
;Yaru on GnuCash 4.x: <Syntaxhighlight lang="CSS">
 +
gnc-id-sheet-list {
 +
  background-color: @theme_bg_color;
 +
  }
 +
</Syntaxhighlight>
  
* [https://gist.github.com/MisterY/e0e588eca2ee05c8afd858c7800cfc4a GnuCash 3 Black Theme] gtk-3.0.css
+
;KDE Breeze theme on 4.x: <Syntaxhighlight lang="CSS">
 +
treeview.view:hover {
 +
  background-color: @theme_selected_bg_color_breeze;
 +
  }
 +
</Syntaxhighlight>
 +
On GnuCash 3.x you'd change the selector to <tt>register sheet widget</tt> like the Yaru example-
 +
Other themes may not have <tt>@theme_bg_color</tt> or <tt>@theme_selected_bg_color</tt>. You'll have to explore your themes css files to find its equivalent. If you can't find the right one you can pick a standard css color like <tt>white</tt>.
  
===== Ready-made Themes =====
+
== Additional Links ==
 +
* [[Windows#Gnucash_3.0_and_up|Windows]] page contains some instructions on customization of visual appearance.
  
Here are some ready-made themes that may apply well to GnuCash.
 
 
* [https://www.opendesktop.org/p/1223551/ Leather-Dark] theme
 
* [https://www.gnome-look.org/p/1225712/ Eye-friendly Dark RBC Theme] - fully-working pleasant dark theme
 
* [https://www.gnome-look.org/p/1014995/ Adwaita Dark] GTK2 - not 100% correct (on Windows)
 
 
== Font Size in Documents ==
 
Creating
 
;Linux: FIXME
 
;MacOs: ~/Library/Application Support/Gnucash/gtk-3.0.css
 
;Windows: FIXME
 
with this content:
 
<Syntaxhighlight lang="css">
 
* {
 
  font: 14px arial, sans-serif;
 
}
 
</Syntaxhighlight>
 
Will adjust the fontsize, also of the register to 14 pixel.
 
 
----
 
----
 
[[Category:GTK]] [[Category:Customization]]
 
[[Category:GTK]] [[Category:Customization]]

Latest revision as of 23:17, 24 October 2023

Since GnuCash 3.0 the GTK3 library is used for the Graphical User Interface (GUI). Older versions were using GTK2.

Many parts of GnuCash's appearance—and in rare cases behaviour—depend on the theme selected in your desktop environment.

This page contains instructions on how to customize GTK3 appearance and behavior.

For more information about the location of the configuration files, see Configuration Locations.

Cascading Style Sheets (CSS)

GnuCash since version 3 uses a new version of the GTK framework with a completely new styling mechanism based on Cascading Style Sheets (CSS). For Windows users, this has unfortunately rendered the theming tool that we used to distribute useless and sadly there isn't a replacement available that works with GTK3.

Fortunately, GTK's CSS is fairly simple. This page will explain the basics and provide some examples for commonly-requested changes.

For reference, there is a sample GTK css file available at: GTK css example

See also
CSS

Tools for Managing GTK Settings

Query GSettings

Some theme information is kept in gsettings and can be queried with gtk-query-settings. For example

gtk-query-settings theme

will return all of the settings whose name includes the word "theme". It is usually in a package gtk3-tools.

Using the GTK Inspector

GTK has a built in Inspector that you can enable by setting environment varialbe GTK_DEBUG to interactive. There are several ways to do this. The most straight-forward on linux is launching GnuCash from the command line with

GTK_DEBUG=interactive path/to/gnucash

For flatpak the command is slightly different. See GTK Inspector on Flatpak.

What will work on all platforms is to create file named environment.local in directory gnucash of the system-wide configuration directory with this contents:

[Variables]
GTK_DEBUG=interactive

You will likely need administrator privileges on your system to do this though.

It's quite useful for poking and prodding various bits of GnuCash to see what styles apply to which controls and to allow you to change things and to see the results immediately.

Note: You must have GTK+3 installed to use the Inspector.

  • On macOS, you can use Homebrew to install GTK+3. Install Homebrew and then issue the command
    brew install gtk+3
    

Linux Desktop Environments

They have often a tool in their System Settings to adjust the appearance of all GTK apps per user:

Gnome
Tweaks is a graphical interface for advanced GNOME 3 settings. It was previously known as Gnome Tweak Tool.
KDE
kde-gtk-config is a GTK2 and GTK3 Configurator for KDE.

Behavior

Certain aspects of widget behavior can also be customized.

Restoring Visible Mnenomics

GTK Mnemonics are underlined characters in a label, used for keyboard navigation. Examples of labels which may include a mnemonic are the text on a button, the label of a field, and the text in a menu line. The mnemonic is activated by pressing the mnenomic activator key (Alt for Linux and Windows, Command for macOS) at the same time as the underlined character.

Since GTK 3.10, the underlines of the mnenomics are only visible after pressing the mnenomic activator key.

Scrollbars

The behavior of the scrollbars can be customized. Compared to GTK2, if you now click above (or below) the current position bar in the scrollbar, it takes you to the place in the window which is proportional to where in the scroll bar you click, rather than up (or down) 1 screen full. This can be adjusted by using below instruction in the GTK settings file GTK_CONFIG_HOME/settings.ini:

[Settings]

# Use Windows style PgUp/PgDn scrollbars
gtk-primary-button-warps-slider=false

Menu Keyboard Shortcuts

Keyboard shortcuts can be assigned to actions in GnuCash application. A more detailed information is available on Keyboard Shortcuts.

To assign a custom shortcut, do the following:

With GnuCash *not running* open GNC_DATA_HOME/accelerator-map in any text editor and find the line with the desired command, i.e. for double-line in the register view use

 ;(gtk_accel_path "<Actions>/GncPluginPageRegisterActions/ViewStyleDoubleLineAction" "")

If, for some reason, the line is missing in the accelerator-map file, simply copy the line above into the file. Remove the ';' at the beginning and insert whatever shortcut you like between the last set of double quotes. Save the file.

The Ctrl key is referenced as <Primary>. For example, if you want to use Ctrl+2 for a shortcut, set the value to "<Primary>2".

The next time you open GnuCash, you will be able to use the shortcut key to trigger the desired functionality. The relevant menu item will reflect this fact by displaying the shortcut key next to the assigned action's name.

For full list of possible actions see source code on GitHub.

Key Bindings

Customizing key bindings is done by editing (or creating if needed) the file GNC_CONFIG_HOME/gtk-3.0.css in the GnuCash configuration directory.

For example, to add a new binding so that the F11 key is bound to the copy-clipboard action and the F12 key is bound to the paste-clipboard action and existing keybindings for these actions remain unchanged, add something like this to gtk-3.0.css:

/* Bind F11 to Copy, F12 to Paste */
@binding-set F11CopyF12Paste
{
  bind "F11" { "copy-clipboard" () };
  bind "F12" { "paste-clipboard" () };
}

entry
{
  -gtk-key-bindings: F11CopyF12Paste;
}

If you like Emacs-style keybindings you can add,

gtk-key-theme-name = Emacs

to your settings.ini.

macOS only
Unfortunately for macOS users that setting is hard-coded to the Mac keybindings theme for Quartz (macOS Native) screens. Fortunately, there's a fairly painless workaround (and this way you get both the emacs and the Mac bindings which is how most native apps actually work):
Copy GnuCash.app/Contents/share/themes/Emacs/gtk-3.0/gtk-keys.css to
~/Library/Application Support/Gnucash config gtk-3.0. If you have no other customizations, just name it gtk.css. If you already have a gtk.css there, add to it
@import url("gtk-keys.css");

Typefaces

There are two ways of setting a default font and size for GnuCash.

The first sets an option in GTK's settings.ini for all GTK applications (GIMP etc.),
the other uses css to accomplish the same for GnuCash only.
  • If neither you nor a program changed the default values before, the files mentioned in this section will not exist. In this case just create them as pure text files and with normal file access rights.

The examples below with both set the default font to Arial and font size to 14.

Via settings.ini

Create if necessary and add the following line to GTK_CONFIG_HOME/settings.ini:

[Settings]
gtk-font-name=Arial 14
General notes
  • In settings.ini, lines beginning with a # and blank lines are considered comments.
  • If the file exists and has a [Settings] line just add the font line beneath it.
  • Setting font family via settings.ini doesn't work on macOS and Microsoft Windows. Use CSS to set font family on those operating systems.

Via css

Create if necessary and add the following to GNC_CONFIG_HOME/gtk-3.0.css:

* {
  font: 14pt arial, sans-serif;
}

If you see some or all non-ASCII characters displayed as a missing-glyph character, often some variation of a white square, it means that those characters aren't supported by the font you've selected. You'll need to find a font family for your platform that better supports your language.

Note: Gtk on Microsoft Windows will not set the font family globally with the '*' css selector. Use #gnc-id-main-window instead.

For Simplified Chinese one user found

#gnc-id-main-window {
  font-family: Microsoft YaHei;
  font-size: 14pt;
}

worked well.

Visual Styling

As GTK3 uses Cascading Style Sheets (CSS) for themes this is fairly easy to resolve by styling the GTK applications manually or using one of myriad available graphical themes. This is easily done by placing a custom CSS file at the correct location, depending on your system, or downloading and using a custom-made theme. N.B. css files must be plain ascii text. Be sure to use a suitable editor; if you use a word processor be sure to save the file as plain text. Most Windows users can use Notepad, while macOS users can use TextEdit but must select File>Make Plain Text when first creating the file.

Register Appearance

The GnuCash registers use a yellow/green theme by default for register windows. Users must disable this default theme in order to change register appearance.

To override this, one first has to disable this custom theme by disabling "Use GnuCash built-in color theme" in the GnuCash Preferences.

Next, create or change the GTK css file for further styling tweaks. The location and name of the resource file is explained in Configuration Locations.

For adjusting register colors, you can override the relevant css style definitions in your own GTK3 resource file. See GTK css example for example settings.

Manual Styling using CSS file

The comprehensive GTK+ CSS Overview, as it relates to GTK, is available at Gnome Developer web site.

Configuration tools
Various Linux distributions provide custom tools for managing themes. There is a nice overview of graphical tools available, depending on the desktop environment at archlinux.

A sample GnuCash CSS file can be found below:

For extra info, you can also check these low-level customizations:

gnucash 4 or more recent
gnucash.css
gnucash 3 with gtk 3.20 or more recent
gnucash-320
gnucash 3 with gtk older than 3.20
gnucash-310

Note that these contain the @ variables, as explained in the CSS customization overview, Colors section.

To precisely locate the UI elements for customization, you can use the GTK Inspector tool.

CSS rules to customize the GnuCash appearance should be stored in GNC_CONFIG_HOME/gtk-3.0.css.

Note that GnuCash will never create this file for you but you can to create it yourself as a plain text file. If you are on Linux(various), macOS(TextEdit.app) or Windows10(Notepad), your default text editor will work fine to create plain text files. If you are on an older version of Windows, you'll need to use something other than Notepad that can save files with Unix/Linux line endings. Do not use Rich Text Editors or formats, or any word processor that can't save as plain text.

You can write your own css rules or copy them from existing themes. The #Themes section below has a few links to websites where you can find sample themes.

Related wiki entries:

Custom GnuCash Styles

To style the register you can use css rules like below:

*.register-primary {
  color: red;
}

where

*.register-header => header bar at top of sheet
*.register-primary => primary (dark-background) lines
*.register-secondary => secondary (light-background) lines
*.register-split => split lines
cursor entry => the cell containing the cursor
*.register-foreground => setting the colour for this selector will paint all the register text in that colour.
*.register-cursor => the currently selected row in the register

If you want to apply a change to the entire register sheet:

sheet {
  font: 12px;
}

Sample GnuCash Selectors (CSS Nodes)

Chart of Accounts Tab:

This sheet has an ID of #account_tree which affects the entire sheet below the column headers.

Thus:

#account_tree {
  font-size: 1.2em;
}

will increase the font size by 20% for all of the account names and their related right-hand columns.

If you want to color the area behind and around the Totals Bar:

.GncAccountPage {
  background-color: lightgrey;
}

If you want to style the column headers, use the following selector for the full header bar:

#account_tree header button{
}

If you just want to apply font/text rules to the header labels themselves, use:

#account_tree header label {
}

Labels of Toolbar Buttons

Starting with GnuCash 3.3 the toolbar buttons will have their labels enabled. This will widen the buttons, so on some screens that means not all buttons will be visible any more. If you prefer to have no labels under the buttons, you can use the following css snippet to hide them:

toolbar toolbutton label
{
  font-size: 0;
}
which is bad style. Better use
gtk-toolbar-style=0
in your settings.ini. [1]

Toolbar Button spacing

The toolbar buttons are visually very wide apart. This appears to be a conscious design choice in the Gtk default Adwaita theme. If you prefer to have them closer together to fit more buttons on the toolbar, you can use the following snippet to reduce the spacing. There are two css nodes that together make up for the total spacing. Both are set to 8px by default. The snippet below will reduce both of them to 4px. You can reduce them even further to your taste:

toolbar toolbutton button
{
    padding-left: 4px;
    padding-right: 4px;
}

toolbar toolbutton label
{
    padding-left: 4px;
    padding-right: 4px;
}

Scrollbar adjustments

Some sample settings to adjust the scrollbar:
scrollbar {
    /* Just in case another file disabled them */
    -GtkScrollbar-has-backward-stepper: 1;
    -GtkScrollbar-has-forward-stepper: 1;
}

scrollbar slider {
    /* Size of the slider */
    min-width: 12px;
    min-height: 12px;
    border-radius: 22px;

    /* Padding around the slider */
    border: 5px solid transparent;
}


Disable the overlay scrolling

GTK 3.0 has scrollbar overlap setting (default set to Boolean true) which may cause last entry in a list to show behind the scrollbars (specifically on horizontal ones) making it difficult to click on it when not disabled. It can be disabled by editing GTK_CONFIG_HOME/settings.ini file. Create it with a text editor if it does not exist.

[Settings]
gtk-overlay-scrolling = false

Dropdown List of Accounts Transparency Problem

There is a problem with some Linux themes, such as the Ubuntu yaru theme, where the account list dropdown in the register Transfer field has a transparent background in the line under the mouse pointer. This makes it hard to read. See Bug 797493.

The following should fix this:
/* GnuCash 4.x Fix transparent background in register Transfer dropdown Bug 797493 */
gnc-id-sheet-list {
  background-color: @theme_bg_color;
}
Or
/* GnuCash 3.x Fix transparent background in register Transfer dropdown Bug 797493 */
register sheet widget {
  background-color: @theme_bg_color;
}

KDE Register Input Field Black on Dark Background Problem

There is a problem with some Linux themes, such as the Ubuntu breeze-dark theme on the KDE Plasma desktop, where the current register field is black on a dark background. This makes it hard to read. See Bug 798202. This problem is fixed in GnuCash 4.6.

The following should fix this:
/* GnuCash 4.x Fix register black on dark background Bug 798202 */
.gnc-class-register-foreground.flat {                                                                                                                                                     
    background-color: white;                                                                        
}
Or
/* GnuCash 3.x Fix register black on dark background Bug 798202 */
.header-color {
  background-color: #363636;
  color: #c8c8c8;
}

.primary-color {
  background-color: #383838;
}

.primary-color:disabled {
  background-color: #383838;
}

.secondary-color {
  background-color: #323232;
}

.secondary-color:disabled {
  background-color: #323232;
}

.split-color {
  background-color: #474747;
}

.split-color:disabled {
  background-color: #53728e;
}

.cursor-color {
  background-color: #383838;
  color: #c8c8c8;
}

cursor entry {
  background-color: #383838;
  color: #c8c8c8;
}

Sample Style Properties

This is a list of the most likely desired properties you can change in GnuCash with Gtk+3 as of version 3.22. Note, not all properties apply to all selectors (nodes). Properties may also not apply as expected compared to web CSS and may or may not cascade to child nodes.

  • background-blend-mode
  • background-clip
  • background-color
  • background-image
  • background-position
  • background-repeat
  • background-size
  • border-bottom-color
  • border-bottom-left-radius
  • border-bottom-right-radius
  • border-bottom-style
  • border-bottom-width
  • border-image-repeat
  • border-image-slice
  • border-image-source
  • border-image-width
  • border-left-color
  • border-left-style
  • border-left-width
  • border-right-color
  • border-right-style
  • border-right-width
  • border-top-color
  • border-top-left-radius
  • border-top-right-radius
  • border-top-style
  • border-top-width
  • box-shadow
  • color
  • font-family
  • font-size
  • font-stretch
  • font-style
  • font-variant (does not seem to work)
  • font-weight
  • letter-spacing
  • margin-bottom
  • margin-left
  • margin-right
  • margin-top
  • min-height
  • min-width
  • opacity
  • outline-color
  • outline-offset
  • outline-style
  • outline-width
  • padding-bottom
  • padding-left
  • padding-right
  • padding-top
  • text-decoration-color
  • text-decoration-line
  • text-decoration-style
  • text-shadow

Themes

At first a warning about theming: restyling apps at scale.

You can use a predefined GTK3 theme. Note that applying a custom theme will affect all the gtk3-based applications on your system!

Short summary:

  1. download an appropriate GTK3 theme from www.gnome-look.org or other sites
  2. copy the theme into a directory where GTK3 looks for themes (see below)
  3. create or adjust a settings.ini file to instruct GTK3 to use this theme

Some sites which host custom GTK3 themes:

Below is a slightly longer explanation with platform dependent remarks:

  1. Go to the gnome-look.org website.
  2. Click the GTK3 Themes link, not the GTK2 one.
  3. Select a theme you like. Alternatively you can search for keywords (like "dark") in the top right corner and then filter on "GTK3 Theme category".
  4. If you have found a theme you like, download the proper file (in the files section of the theme page). Note depending on your operating system you may not be able to open all theme files. There are, for example, .deb archives which are specifically targeted at the Debian linux distribution and derivates such as Ubuntu. While Ubuntu and Debian users can install those themes via their package manager these themes are not useful for other platforms.
    Theme files ending with .zip, .tar.gz or tar.xz are likely installable on all platforms, although you may have to find a proper application to extract them.
    On Windows 7-Zip is a good candidate, linux users can probably extract the files directly from their file manager.
    Let's take the theme "Eye-friendly Dark RBC" as an example (it's not the best theme but it can serve as an example). The file to download is Eye-friendly-Dark-RBC.tar.gz.
  5. Extract this file using an appropriate tool. This should give you a directory named Eye-friendly-Dark-RBC.
  6. Move this directory to USER_CONFIG_HOME/themes. Note on Windows you'll need to use the %LOCALAPPDATA% variant as we're adjusting

GTK3's configuration.

  1. Next tell GTK to load this theme.

Linux users can probably most easily do this by install the "Gnome Tweak Tool" on their platform and select the new theme there. The manual method is this: Create a file named GTK_CONFIG_HOME/settings.ini.

The contents of this file should be

[Settings]
gtk-theme-name=Eye-friendly-Dark-RBC

And that's it. Note the name is the name of the directory as you put in the themes directory. The next time you start GnuCash it should pick up this theme.

A few extra notes:

  • The default GTK3 theme is called "Adwaita".
  • On linux there's a second default theme called "Adwaita-dark" which should also give you a dark themed GnuCash. Unfortunately, this doesn't work on Windows out-of-the-box but there is a workaround. See under #Dark Themes below.
  • If you're adventurous you can probably also play with customized icon themes which you find on the gnome-look.org website. These themes should be installed in the icons directory next to the themes directory. And to activate them you can add gtk-icon-theme-name=<directory name> in settings.ini.
  • A list of GTK settings that can be adjusted via settings.ini can be found at GTK Settings page.

Dark Themes

It may be possible to get the default dark theme on Windows using the following technique:

[Settings]
gtk-application-prefer-dark-theme=true
If you then want to adjust highlighted text and negative numbers, insert
/* Negative number color */
.gnc-class-negative-numbers {
  color: shade(@negative-numbers, 1.9);
}
gnc-id-sheet .gnc-class-negative-numbers {
  color: @negative-numbers;
}
/* Highlight Text */
.gnc-class-highlight {
  color: shade(blue, 1.6);
}
into your gtk-3.0.css.[2]

If this doesn't work an alternative option is to install a suitable theme as described above. A couple of suggestions for decent dark themes that may apply well to GnuCash:

The adventurous could of course also try and create such a theme from scratch. Below are a few pointers to get started:

Ongoing work on a Dark Solarized theme for use with GnuCash 4.0+ can be found here:

Transparent Dropdown Backgrounds

Some themes attempt to make elements translucent and screw it up. We've had a number of reports of these efforts failing spectacularly, especially on Ubuntu. The symptom is that a drop-down list will have a transparent background either for the selected item or for the whole list box. As one might imagine this make finding the item one wants rather difficult.

The solution is to override the theme's background. The following snippets should be added to the GNC_CONFIG_HOME/gtk-3.0.css. The Gtk one in GTK_CONFIG_HOME/gtk.css is loaded before the theme and will be overridden by loading the theme.

For Ubunutu's

Yaru theme on GnuCash 3.x
register sheet widget {
   background-color: @theme_bg_color;
   }
Yaru on GnuCash 4.x
gnc-id-sheet-list {
   background-color: @theme_bg_color;
   }
KDE Breeze theme on 4.x
treeview.view:hover {
   background-color: @theme_selected_bg_color_breeze;
   }

On GnuCash 3.x you'd change the selector to register sheet widget like the Yaru example- Other themes may not have @theme_bg_color or @theme_selected_bg_color. You'll have to explore your themes css files to find its equivalent. If you can't find the right one you can pick a standard css color like white.

Additional Links

  • Windows page contains some instructions on customization of visual appearance.