gnucash unstable: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Fri Sep 29 11:59:31 EDT 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/6b7a06fb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6ffe5ec7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/948ba2ba (commit)
	 via  https://github.com/Gnucash/gnucash/commit/df1953a4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/549b07ae (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3f17ed6c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3c65ac58 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/48e9de5a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ed17cd60 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6ebecea2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/dd56db74 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/858ca1f8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3dac6dfa (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1ed4f3d4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fd0cc1fe (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6d2bc5b0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/244abf75 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/71bf2392 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/cd92fe06 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c3c01f46 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6eeea6fb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0c002682 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0d63bf55 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/98f0b3da (commit)
	 via  https://github.com/Gnucash/gnucash/commit/173805b7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2c5f1aa5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/91c8a56e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6aa09abb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9973bbe6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2d213363 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/87c5a952 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/23e1ed69 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/69dffac5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/70d696ef (commit)
	 via  https://github.com/Gnucash/gnucash/commit/92766a27 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/04c80ddd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/841ff5cc (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1ec2817c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/03dd7ab3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/dff337d7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9382278b (commit)
	from  https://github.com/Gnucash/gnucash/commit/b3b4b20e (commit)



commit 6b7a06fbdb8fe260b5e0e3be7e8cd08cad3f9ae0
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 29 10:52:08 2017 +0100

    Change the item_edit blanking rectangle position and size
    
    Change the position and size of the cell blanking with background colour
     so it does not affect the red and blue horizontal lines.

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 2929d89..d5fd364 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -351,7 +351,7 @@ draw_background_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
     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);
+    gtk_render_background (stylectxt, cr, 0, 1, width, height - 2);
 
     gtk_style_context_restore (stylectxt);
     return FALSE;

commit 6ffe5ec77c07ea0cc2268c170ae69f3448959acb
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 29 10:39:44 2017 +0100

    Change the position of the double row on the cursor
    
    Move the double row down to bottom border + 1 line so it does not
    interfere with the cursor cells.

diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index 86bb688..37fbe7d 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -701,7 +701,7 @@ gnucash_sheet_draw_cursor (GnucashCursor *cursor, cairo_t *cr)
     cairo_stroke (cr);
 
     // make the bottom line thicker
-    cairo_move_to (cr, cursor->x - x + 0.5, cursor->y - y + cursor->h - 3.5);
+    cairo_move_to (cr, cursor->x - x + 0.5, cursor->y - y + cursor->h - 1.5);
     cairo_rel_line_to (cr, cursor->w, 0);
     cairo_set_line_width (cr, 1.0);
     cairo_stroke (cr);

commit 948ba2ba042d817775b9ed6e16535342e7795f7b
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 29 10:27:53 2017 +0100

    Instead of removing a css class, wrap the change in save/restore

diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index a7c6312..981ea1f 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -1131,9 +1131,10 @@ gnucash_sheet_draw_cb (GtkWidget *widget, cairo_t *cr, G_GNUC_UNUSED gpointer da
 
     gtk_widget_get_allocation(widget, &alloc);
 
+    gtk_style_context_save (context);
     gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND);
     gtk_render_background (context, cr, 0, 0, alloc.width, alloc.height);
-    gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BACKGROUND);
+    gtk_style_context_restore (context);
 
 //FIXME what should be done with result being TRUE or FALSE
     result = gnucash_sheet_draw_internal (sheet, cr, &alloc);

commit df1953a44ad441fc9e4be3b49ee22dce2896beae
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 29 10:25:18 2017 +0100

    Rename internal CSS class prefix for the register to 'register-'

diff --git a/gnucash/gnome-utils/ui/gnucash.css b/gnucash/gnome-utils/ui/gnucash.css
index 40ca789..7ed35d1 100644
--- a/gnucash/gnome-utils/ui/gnucash.css
+++ b/gnucash/gnome-utils/ui/gnucash.css
@@ -28,39 +28,39 @@ cursor button {
 @define-color register_split_bg_color #EDE7D3;
 @define-color register_cursor_bg_color #FFEF98;
 
-.app-header {
+.register-header {
   background-color: @register_header_bg_color;
 }
 
-*.app-primary {
+*.register-primary {
   background-color: @register_primary_bg_color;
 }
 
-*.app-primary:insensitive {
+*.register-primary:insensitive {
   background-color: mix (@register_primary_bg_color, grey, 0.2);
 }
 
-*.app-secondary {
+*.register-secondary {
   background-color: @register_secondary_bg_color;
 }
 
-*.app-secondary:insensitive {
+*.register-secondary:insensitive {
   background-color: mix (@register_secondary_bg_color, grey, 0.2);
 }
 
-*.app-split {
+*.register-split {
   background-color: @register_split_bg_color;
 }
 
-*.app-split:insensitive {
+*.register-split:insensitive {
   background-color: mix (@register_split_bg_color, grey, 0.2);
 }
 
-*.app-cursor {
+*.register-cursor {
   background-color: @register_cursor_bg_color;
 }
 
-*.app-cursor:insensitive {
+*.register-cursor:insensitive {
   background-color: mix (@register_cursor_bg_color, grey, 0.2);
 }
 
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 09413e7..a7c6312 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -2462,7 +2462,7 @@ gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
         full_class = g_strconcat (style_class, "-color", NULL);
     }
     else
-        full_class = g_strconcat ("app-", style_class, NULL);
+        full_class = g_strconcat ("register-", style_class, NULL);
 
     gtk_style_context_add_class (stylectxt, full_class);
 

commit 549b07ae66cd6307a8018b5e1146f2054c23c377
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 29 10:15:06 2017 +0100

    Remove the CSS for a dark theme Register
    
    It was decided that this is not required as the user can choose the
    required colours by setting the preference to not use the built in
    register colours.

diff --git a/gnucash/gnome-utils/ui/gnucash.css b/gnucash/gnome-utils/ui/gnucash.css
index 57c897d..40ca789 100644
--- a/gnucash/gnome-utils/ui/gnucash.css
+++ b/gnucash/gnome-utils/ui/gnucash.css
@@ -32,11 +32,6 @@ cursor button {
   background-color: @register_header_bg_color;
 }
 
-.app-header-dark {
-  background-color: shade (@register_header_bg_color, 0.7);
-}
-
-
 *.app-primary {
   background-color: @register_primary_bg_color;
 }
@@ -45,15 +40,6 @@ cursor button {
   background-color: mix (@register_primary_bg_color, grey, 0.2);
 }
 
-*.app-primary-dark {
-  background-color: shade (@register_primary_bg_color, 0.7);
-}
-
-*.app-primary-dark:insensitive {
-  background-color: mix (shade (@register_primary_bg_color, 0.7), grey, 0.3);
-}
-
-
 *.app-secondary {
   background-color: @register_secondary_bg_color;
 }
@@ -62,15 +48,6 @@ cursor button {
   background-color: mix (@register_secondary_bg_color, grey, 0.2);
 }
 
-*.app-secondary-dark {
-  background-color: shade (@register_secondary_bg_color, 0.5);
-}
-
-*.app-secondary-dark:insensitive {
-  background-color: mix (shade (@register_secondary_bg_color, 0.5), grey, 0.3);
-}
-
-
 *.app-split {
   background-color: @register_split_bg_color;
 }
@@ -79,15 +56,6 @@ cursor button {
   background-color: mix (@register_split_bg_color, grey, 0.2);
 }
 
-*.app-split-dark {
-  background-color: shade (@register_split_bg_color, 0.5);
-}
-
-*.app-split-dark:insensitive {
-  background-color: mix (shade (@register_split_bg_color, 0.5), grey, 0.3);
-}
-
-
 *.app-cursor {
   background-color: @register_cursor_bg_color;
 }
@@ -96,11 +64,3 @@ cursor button {
   background-color: mix (@register_cursor_bg_color, grey, 0.2);
 }
 
-*.app-cursor-dark {
-  background-color: shade (@register_cursor_bg_color, 0.6);
-}
-
-*.app-cursor-dark:insensitive {
-  background-color: mix (shade (@register_cursor_bg_color, 0.6), grey, 0.3);
-}
-
diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index 60bd3c7..86bb688 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -497,10 +497,7 @@ draw_cell (GnucashSheet *sheet,
             && (virt_loc.vcell_loc.virt_row < table->model->dividing_row_upper))
     {
         // Make text color greyed
-        if (sheet->dark_theme)
-            gtk_style_context_add_class (stylectxt, "darker-grey-mix");
-        else
-            gtk_style_context_add_class (stylectxt, "lighter-grey-mix");
+        gtk_style_context_add_class (stylectxt, "lighter-grey-mix");
     }
 #endif
 
@@ -515,10 +512,7 @@ draw_cell (GnucashSheet *sheet,
             goto exit;
 
         // Make text color greyed
-        if (sheet->dark_theme)
-            gtk_style_context_add_class (stylectxt, "darker-grey-mix");
-        else
-            gtk_style_context_add_class (stylectxt, "lighter-grey-mix");
+        gtk_style_context_add_class (stylectxt, "lighter-grey-mix");
 
         pango_layout_set_text (layout, text, strlen (text));
         pango_font_description_set_style (font, PANGO_STYLE_ITALIC);
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 40c0542..09413e7 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -1127,15 +1127,12 @@ gnucash_sheet_draw_cb (GtkWidget *widget, cairo_t *cr, G_GNUC_UNUSED gpointer da
     GnucashSheet *sheet = GNUCASH_SHEET (widget);
     GtkStyleContext *context = gtk_widget_get_style_context (widget);
     GtkAllocation alloc;
-    GdkRGBA color;
     gboolean result; //FIXME
 
     gtk_widget_get_allocation(widget, &alloc);
 
     gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND);
     gtk_render_background (context, cr, 0, 0, alloc.width, alloc.height);
-    gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
-    sheet->dark_theme = gnc_is_dark_theme (&color);
     gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BACKGROUND);
 
 //FIXME what should be done with result being TRUE or FALSE
@@ -2465,12 +2462,8 @@ gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
         full_class = g_strconcat (style_class, "-color", NULL);
     }
     else
-    {
-        if (sheet->dark_theme)
-            full_class = g_strconcat ("app-", style_class, "-dark", NULL);
-        else
-            full_class = g_strconcat ("app-", style_class, NULL);
-    }
+        full_class = g_strconcat ("app-", style_class, NULL);
+
     gtk_style_context_add_class (stylectxt, full_class);
 
     g_free (full_class);
diff --git a/gnucash/register/register-gnome/gnucash-sheetP.h b/gnucash/register/register-gnome/gnucash-sheetP.h
index cedcad6..1b9ffe9 100644
--- a/gnucash/register/register-gnome/gnucash-sheetP.h
+++ b/gnucash/register/register-gnome/gnucash-sheetP.h
@@ -66,7 +66,6 @@ struct _GnucashSheet
     gboolean   use_theme_colors;
     gboolean   use_horizontal_lines;
     gboolean   use_vertical_lines;
-    gboolean   dark_theme;
 
     gboolean input_cancelled;
 

commit 3f17ed6c934379dfa303207a5033db8758d880c2
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 29 09:58:42 2017 +0100

    Fix typo in comment

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 2042df5..2929d89 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -730,7 +730,7 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
     else
         popup_w = 0;
 
-    // Adjust the popup_y point based on poping above or below
+    // Adjust the popup_y point based on popping above or below
     if (up_height > down_height)
         popup_y = y - popup_h;
     else

commit 3c65ac589cbb1c203a651ee78bd74a1285e75886
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 23 13:41:03 2017 +0100

    Make sure the sheet has focus at start
    
    On first load of sheet, multiple tabs are ignored so addition makes the
    sheet have the focus.

diff --git a/gnucash/register/register-gnome/gnucash-register.c b/gnucash/register/register-gnome/gnucash-register.c
index e990039..c17fa11 100644
--- a/gnucash/register/register-gnome/gnucash-register.c
+++ b/gnucash/register/register-gnome/gnucash-register.c
@@ -271,6 +271,11 @@ gnucash_register_sheet_resize (GnucashRegister *reg)
     // not get filled on load, this makes sure it does
     if (!reg->hscrollbar_visible)
         gtk_widget_queue_resize (GTK_WIDGET (reg->sheet));
+
+    // Make sure the sheet is the focus
+    if (!gtk_widget_has_focus(GTK_WIDGET (reg->sheet)))
+        gtk_widget_grab_focus (GTK_WIDGET (reg->sheet));
+
     return FALSE;
 }
 

commit 48e9de5aae81182b97b910e0ce158e0e8677c216
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 23 13:33:37 2017 +0100

    Fix problem with scrollbar sliders not tracking value
    
    There seems to be a problem with scrollbar sliders do not track the
    value and also if you try to drag the slider it does not move. This may
    be related to bug https://bugzilla.gnome.org/show_bug.cgi?id=765410
    
    What I have found is that this problem can be overcome by hiding and
    showing the scrollbar so this commit does so.

diff --git a/gnucash/register/register-gnome/gnucash-register.c b/gnucash/register/register-gnome/gnucash-register.c
index 237b176..e990039 100644
--- a/gnucash/register/register-gnome/gnucash-register.c
+++ b/gnucash/register/register-gnome/gnucash-register.c
@@ -486,6 +486,31 @@ gnucash_register_configure (GnucashSheet *sheet, gchar * state_section)
     LEAVE(" ");
 }
 
+static gboolean
+gnucash_register_enter_scrollbar (GtkWidget *widget,
+                                  GdkEvent *event, gpointer user_data)
+{
+    GnucashRegister *reg = user_data;
+    GnucashSheet *sheet = GNUCASH_SHEET(reg->sheet);
+    GtkWidget *vscrollbar = sheet->vscrollbar;
+    GtkWidget *hscrollbar = sheet->hscrollbar;
+
+    // There seems to be a problem with the scrollbar slider not being
+    // updated as the mouse moves possibly related to the following bug
+    // https://bugzilla.gnome.org/show_bug.cgi?id=765410
+    // If they are hidden and shown it seems to fix it.
+
+    gtk_widget_hide (GTK_WIDGET(vscrollbar));
+    gtk_widget_show (GTK_WIDGET(vscrollbar));
+
+    if (gtk_widget_is_visible (hscrollbar))
+    {
+        gtk_widget_hide (GTK_WIDGET(hscrollbar));
+        gtk_widget_show (GTK_WIDGET(hscrollbar));
+    }
+    return FALSE;
+}
+
 
 static GtkWidget *
 gnucash_register_create_widget (Table *table)
@@ -530,6 +555,10 @@ gnucash_register_create_widget (Table *table)
     gtk_widget_set_valign (GTK_WIDGET(scrollbar), GTK_ALIGN_FILL);
     g_object_set (GTK_WIDGET(scrollbar), "margin", 0, NULL);
     gtk_widget_show (scrollbar);
+    GNUCASH_SHEET(sheet)->vscrollbar = scrollbar;
+
+    g_signal_connect(G_OBJECT(scrollbar), "enter-notify-event",
+                      G_CALLBACK(gnucash_register_enter_scrollbar), reg);
 
     scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, GNUCASH_SHEET(sheet)->hadj);
     gtk_grid_attach (GTK_GRID(widget), GTK_WIDGET(scrollbar), 0, 2, 1, 1);
@@ -541,6 +570,10 @@ gnucash_register_create_widget (Table *table)
     reg->hscrollbar = scrollbar;
     gtk_widget_show (reg->hscrollbar);
     reg->hscrollbar_visible = TRUE;
+    GNUCASH_SHEET(sheet)->hscrollbar = scrollbar;
+
+    g_signal_connect(G_OBJECT(scrollbar), "enter-notify-event",
+                      G_CALLBACK(gnucash_register_enter_scrollbar), reg);
 
     g_signal_connect (GNUCASH_SHEET(sheet)->hadj, "changed",
                       G_CALLBACK (gnucash_register_update_hadjustment), reg);
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index df09752..40c0542 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -1356,6 +1356,13 @@ gnucash_scroll_event (GtkWidget *widget, GdkEventScroll *event)
 
     gtk_adjustment_set_value(vadj, v_value);
 
+    if (event->delta_y == 0)
+    {
+        // There are problems with the slider not tracking the value so
+        // when delta_y is 0 hide and showing the scrollbar seems to fix it
+        gtk_widget_hide (GTK_WIDGET(sheet->vscrollbar));
+        gtk_widget_show (GTK_WIDGET(sheet->vscrollbar));
+    }
     return TRUE;
 }
 
diff --git a/gnucash/register/register-gnome/gnucash-sheetP.h b/gnucash/register/register-gnome/gnucash-sheetP.h
index 1681675..cedcad6 100644
--- a/gnucash/register/register-gnome/gnucash-sheetP.h
+++ b/gnucash/register/register-gnome/gnucash-sheetP.h
@@ -90,6 +90,7 @@ struct _GnucashSheet
     guint changed_signal;
 
     GtkAdjustment *hadj, *vadj;
+    GtkWidget *hscrollbar, *vscrollbar;
 
     GFunc moved_cb;
     gpointer moved_cb_data;

commit ed17cd6065fa23f2b697d7e5777ca30e5d993289
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed Sep 13 12:46:16 2017 +0100

    Fix missing hatchings when transaction unbalanced
    
    The gtkrc foreground and background functions did not process hatching
    properly so changed the normal functions to use CSS classes instead and
    remove the gtkrc functions.

diff --git a/gnucash/register/ledger-core/gncEntryLedgerModel.c b/gnucash/register/ledger-core/gncEntryLedgerModel.c
index 3b08fdd..d257c4a 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 ee31252..255a9e9 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,17 +2631,11 @@ 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);
 
     gnc_table_model_set_bg_color_handler(
diff --git a/gnucash/register/register-core/table-allgui.c b/gnucash/register/register-core/table-allgui.c
index f289595..8c0826d 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 3b54d5a..d827fd5 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 feb75f6..be6a462 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 5278748..2042df5 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 1b942ea..60bd3c7 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.

commit 6ebecea263c9221695cff3c0e1cf59b968696786
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed Sep 13 11:38:47 2017 +0100

    When tabbing to the field, text should be highlighted only
    
    When tabbing to a field, the text should be selected but when the mouse
    is used, the cursor should be at the mouse click point.

diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index b770ab0..df09752 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -262,6 +262,68 @@ gnucash_sheet_deactivate_cursor_cell (GnucashSheet *sheet)
 }
 
 
+static gint
+gnucash_sheet_get_text_cursor_position (GnucashSheet *sheet, const VirtualLocation virt_loc)
+{
+    GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
+    Table *table = sheet->table;
+    const char *text = gnc_table_get_entry (table, virt_loc);
+    PangoLayout *layout;
+    PangoRectangle logical_rect;
+    GdkRectangle rect;
+    gint x, y, w, h;
+    gint index, trailing;
+    gboolean result;
+    gint x_offset = 0;
+
+    if ((text == NULL) || (*text == '\0'))
+        return 0;
+
+    // Get the item_edit position
+    gnc_item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h);
+
+    layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), text);
+
+    // We don't need word wrap or line wrap
+    pango_layout_set_width (layout, -1);
+
+    pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+
+    rect.x      = x + CELL_HPADDING;
+    rect.y      = y + CELL_VPADDING;
+    rect.width  = MAX (0, w - (2 * CELL_HPADDING));
+    rect.height = h - 2;
+
+    // Get the alignment of the cell
+    switch (gnc_table_get_align (table, virt_loc))
+    {
+    default:
+    case CELL_ALIGN_LEFT:
+        x_offset = 0;
+        break;
+
+    case CELL_ALIGN_RIGHT:
+        x_offset = w - 2 * CELL_HPADDING - logical_rect.width - 3;
+        break;
+
+    case CELL_ALIGN_CENTER:
+        if (logical_rect.width > w - 2 * CELL_HPADDING)
+            x_offset = 0;
+        else
+            x_offset = (w - 2 * CELL_HPADDING -
+                        logical_rect.width) / 2;
+        break;
+    }
+
+    result = pango_layout_xy_to_index (layout,
+                 PANGO_SCALE * (sheet->button_x - rect.x - x_offset),
+                 PANGO_SCALE * (h/2), &index, &trailing);
+
+    g_object_unref (layout);
+
+    return index + trailing;
+}
+
 static void
 gnucash_sheet_activate_cursor_cell (GnucashSheet *sheet,
                                     gboolean changed_cells)
@@ -310,8 +372,18 @@ gnucash_sheet_activate_cursor_cell (GnucashSheet *sheet,
     {
         gnucash_sheet_im_context_reset(sheet);
         gnucash_sheet_start_editing_at_cursor (sheet);
-        gtk_editable_set_position (editable, cursor_pos);
-        gtk_editable_select_region (editable, start_sel, end_sel);
+
+        // Came here by keyboard, select text, otherwise text cursor to
+        // mouse position
+        if (sheet->button != 1)
+        {
+            gtk_editable_set_position (editable, cursor_pos);
+            gtk_editable_select_region (editable, start_sel, end_sel);
+        }
+        else
+            gtk_editable_set_position (editable,
+                gnucash_sheet_get_text_cursor_position (sheet, virt_loc));
+
         sheet->direct_update_cell =
             gnucash_sheet_check_direct_update_cell (sheet, virt_loc);
     }
@@ -1373,10 +1445,16 @@ gnucash_sheet_button_press_event (GtkWidget *widget, GdkEventButton *event)
 
     gnucash_cursor_get_virt (GNUCASH_CURSOR(sheet->cursor), &cur_virt_loc);
 
+    sheet->button_x = -1;
+    sheet->button_y = -1;
+
     if (!gnucash_sheet_find_loc_by_pixel(sheet,
                                         event->x, event->y, &new_virt_loc))
         return TRUE;
 
+    sheet->button_x = event->x;
+    sheet->button_y = event->y;
+
     vcell = gnc_table_get_virtual_cell (table, new_virt_loc.vcell_loc);
     if (vcell == NULL)
         return TRUE;
diff --git a/gnucash/register/register-gnome/gnucash-sheetP.h b/gnucash/register/register-gnome/gnucash-sheetP.h
index 8925720..1681675 100644
--- a/gnucash/register/register-gnome/gnucash-sheetP.h
+++ b/gnucash/register/register-gnome/gnucash-sheetP.h
@@ -83,6 +83,7 @@ struct _GnucashSheet
 
     guint button; /* mouse button being held down */
     gboolean grabbed; /* has the grab */
+    gdouble button_x, button_y;
 
     guint insert_signal;
     guint delete_signal;

commit dd56db748b1b8d219f32ea2fd766ad936c2783c1
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed Sep 13 11:38:09 2017 +0100

    Remove spaces from blank lines

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 972523c..5278748 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -377,9 +377,9 @@ draw_text_cursor_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
     gdk_rgba_parse (&color, "black");
     gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
     fg_color = &color;
-    
+
     text = gtk_entry_get_text (GTK_ENTRY (widget));
-    
+
     if ((text != NULL) && (*text != '\0'))
     {
         PangoLayout *layout;
@@ -388,7 +388,7 @@ draw_text_cursor_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 
         cursor_pos = gtk_editable_get_position (editable);
         cursor_byte_pos = g_utf8_offset_to_pointer (text, cursor_pos) - text;
-    
+
         gtk_editable_get_selection_bounds (editable, &start_pos, &end_pos);
 
         layout = gtk_entry_get_layout (GTK_ENTRY(widget));
@@ -397,7 +397,7 @@ draw_text_cursor_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
     }
     else
         cursor_x = x_offset;
-    
+
     // Now draw a vertical line
     cairo_set_source_rgb (cr, fg_color->red, fg_color->green, fg_color->blue);
     cairo_set_line_width (cr, 1.0);
@@ -635,7 +635,7 @@ gnc_item_edit_new (GnucashSheet *sheet)
     // Make sure the Entry can not have focus and no frame
     gtk_widget_set_can_focus (GTK_WIDGET(item_edit->editor), FALSE);
     gtk_entry_set_has_frame (GTK_ENTRY(item_edit->editor), FALSE);
-    
+
     // Connect to the draw signal so we can draw a cursor
     g_signal_connect_after (item_edit->editor, "draw",
                             G_CALLBACK (draw_text_cursor_cb), NULL);

commit 858ca1f8bc13bc99a8ee62bcbd04c08189fb8e3b
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed Sep 13 11:37:00 2017 +0100

    Adjust text position to be the same as the item_edit entry

diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index 5f7671e..1b942ea 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -551,7 +551,7 @@ draw_cell (GnucashSheet *sheet,
         break;
 
     case CELL_ALIGN_RIGHT:
-        x_offset = width - 2 * CELL_HPADDING - logical_rect.width;
+        x_offset = width - 2 * CELL_HPADDING - logical_rect.width - 3;
         break;
 
     case CELL_ALIGN_CENTER:
@@ -562,7 +562,7 @@ draw_cell (GnucashSheet *sheet,
                         logical_rect.width) / 2;
         break;
     }
-    gtk_render_layout (stylectxt, cr, rect.x + x_offset, rect.y + 1, layout);
+    gtk_render_layout (stylectxt, cr, rect.x + x_offset + 1, rect.y, layout);
 
     cairo_restore (cr);
 

commit 3dac6dfa161de3c5dd4af0d97f2f844ec852254e
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 9 17:22:21 2017 +0100

    Make sure the cursor background is filled to start to hide whats below it

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 89ab0bd..972523c 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -334,6 +334,31 @@ unblock_toggle_signals(GncItemEdit *item_edit)
 
 
 static gboolean
+draw_background_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
+{
+    GtkStyleContext *stylectxt = gtk_widget_get_style_context (widget);
+    GncItemEdit *item_edit = GNC_ITEM_EDIT (user_data);
+    gint width = gtk_widget_get_allocated_width (widget);
+    gint height = gtk_widget_get_allocated_height (widget);
+    guint32 color_type;
+
+    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);
+    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);
+    gnucash_get_style_classes (item_edit->sheet, stylectxt, color_type);
+
+    gtk_render_background (stylectxt, cr, 0, 0, width, height);
+
+    gtk_style_context_restore (stylectxt);
+    return FALSE;
+}
+
+
+static gboolean
 draw_text_cursor_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 {
     GtkEditable *editable = GTK_EDITABLE(widget);
@@ -615,6 +640,10 @@ gnc_item_edit_new (GnucashSheet *sheet)
     g_signal_connect_after (item_edit->editor, "draw",
                             G_CALLBACK (draw_text_cursor_cb), NULL);
 
+    // Fill in the background so the underlying sheet cell can not be seen
+    g_signal_connect (item_edit, "draw",
+                            G_CALLBACK (draw_background_cb), item_edit);
+
     /* Force padding on the entry to align with the rest of the register this
        is done in the gnucash.css file which should be in line with sheet.h */
 

commit 1ed4f3d4d72da8b40f5276f6c18b488d68af8ee7
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 9 17:21:34 2017 +0100

    Add ability to draw a text cursor for the entry
    
    Most of the call backs and procedures rely on the sheet being the one
    in focus so prevent the entry being in focus. In doing this there is no
    text cursor so add a draw function to draw one after the entry drawn.
    Also remove the frame from the entry.

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 882f94f..89ab0bd 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -334,6 +334,57 @@ unblock_toggle_signals(GncItemEdit *item_edit)
 
 
 static gboolean
+draw_text_cursor_cb (GtkWidget *widget, cairo_t *cr, gpointer user_data)
+{
+    GtkEditable *editable = GTK_EDITABLE(widget);
+    GtkStyleContext *stylectxt = gtk_widget_get_style_context (GTK_WIDGET(widget));
+    gint height = gtk_widget_get_allocated_height (widget);
+    const gchar *text;
+    GdkRGBA *fg_color;
+    GdkRGBA color;
+    gint x_offset;
+    gint cursor_x = 0;
+
+    // Get the layout x offset
+    gtk_entry_get_layout_offsets (GTK_ENTRY(widget), &x_offset, NULL);
+
+    // Get the foreground color
+    gdk_rgba_parse (&color, "black");
+    gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
+    fg_color = &color;
+    
+    text = gtk_entry_get_text (GTK_ENTRY (widget));
+    
+    if ((text != NULL) && (*text != '\0'))
+    {
+        PangoLayout *layout;
+        PangoRectangle strong_pos;
+        gint start_pos, end_pos, cursor_pos, cursor_byte_pos;
+
+        cursor_pos = gtk_editable_get_position (editable);
+        cursor_byte_pos = g_utf8_offset_to_pointer (text, cursor_pos) - text;
+    
+        gtk_editable_get_selection_bounds (editable, &start_pos, &end_pos);
+
+        layout = gtk_entry_get_layout (GTK_ENTRY(widget));
+        pango_layout_get_cursor_pos (layout, cursor_byte_pos, &strong_pos, NULL);
+        cursor_x = x_offset + PANGO_PIXELS (strong_pos.x);
+    }
+    else
+        cursor_x = x_offset;
+    
+    // Now draw a vertical line
+    cairo_set_source_rgb (cr, fg_color->red, fg_color->green, fg_color->blue);
+    cairo_set_line_width (cr, 1.0);
+    cairo_move_to (cr, cursor_x + 0.5, 2);
+    cairo_rel_line_to (cr, 0, height - 4);
+    cairo_stroke (cr);
+
+    return FALSE;
+}
+
+
+static gboolean
 draw_arrow_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
 {
     GncItemEdit *item_edit = GNC_ITEM_EDIT (data);
@@ -556,6 +607,14 @@ gnc_item_edit_new (GnucashSheet *sheet)
     gtk_entry_set_width_chars (GTK_ENTRY(item_edit->editor), 1);
     gtk_box_pack_start (GTK_BOX(item_edit), item_edit->editor,  TRUE, TRUE, 0);
 
+    // Make sure the Entry can not have focus and no frame
+    gtk_widget_set_can_focus (GTK_WIDGET(item_edit->editor), FALSE);
+    gtk_entry_set_has_frame (GTK_ENTRY(item_edit->editor), FALSE);
+    
+    // Connect to the draw signal so we can draw a cursor
+    g_signal_connect_after (item_edit->editor, "draw",
+                            G_CALLBACK (draw_text_cursor_cb), NULL);
+
     /* Force padding on the entry to align with the rest of the register this
        is done in the gnucash.css file which should be in line with sheet.h */
 

commit fd0cc1fe7d1ab0e7782430ea9e0d05a74c24308a
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 9 17:20:36 2017 +0100

    Do not copy the colour and so prevent form having to free it

diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index c987b92..5f7671e 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -418,7 +418,7 @@ draw_cell (GnucashSheet *sheet,
 
     gdk_rgba_parse (&color, "black");
     gnc_style_context_get_background_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
-    bg_color = gdk_rgba_copy (&color);
+    bg_color = &color;
 
     get_cell_borders (sheet, virt_loc, &borders);
 

commit 6d2bc5b0a93b72a3c35efb89a53c1e8fb70c90d3
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 9 17:19:41 2017 +0100

    Allow the sheet to be scrolled with the mouse wheel

diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 6b7964c..b770ab0 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -1270,11 +1270,17 @@ gnucash_scroll_event (GtkWidget *widget, GdkEventScroll *event)
     case GDK_SCROLL_DOWN:
         v_value += gtk_adjustment_get_step_increment (vadj);
         break;
+    case GDK_SCROLL_SMOOTH:
+        if (event->delta_y < 0)
+            v_value -= gtk_adjustment_get_step_increment (vadj);
+        if (event->delta_y > 0)
+            v_value += gtk_adjustment_get_step_increment (vadj);
+        break;
     default:
         return FALSE;
     }
-
-    v_value = CLAMP(v_value, gtk_adjustment_get_lower (vadj), gtk_adjustment_get_upper (vadj) - gtk_adjustment_get_page_size (vadj));
+    v_value = CLAMP(v_value, gtk_adjustment_get_lower (vadj),
+              gtk_adjustment_get_upper (vadj) - gtk_adjustment_get_page_size (vadj));
 
     gtk_adjustment_set_value(vadj, v_value);
 

commit 244abf75cd7f66e6824244cf181ff99eb77722c6
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 9 17:18:49 2017 +0100

    Rename a couple of functions to align with the format of the rest

diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 539cb39..6b7964c 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -1223,7 +1223,7 @@ gnucash_sheet_start_editing_at_cursor (GnucashSheet *sheet)
 }
 
 static gboolean
-gnucash_button_release_event (GtkWidget *widget, GdkEventButton *event)
+gnucash_sheet_button_release_event (GtkWidget *widget, GdkEventButton *event)
 {
     GnucashSheet *sheet;
 
@@ -1314,7 +1314,7 @@ gnucash_sheet_check_grab (GnucashSheet *sheet)
 }
 
 static gboolean
-gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event)
+gnucash_sheet_button_press_event (GtkWidget *widget, GdkEventButton *event)
 {
     GnucashSheet *sheet;
     VirtualCell *vcell;
@@ -1408,6 +1408,7 @@ gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event)
 
     if (abort_move)
         return TRUE;
+
 //FIXME does something need to be done if changed_cells is true or false ?
     changed_cells = gnucash_sheet_cursor_move (sheet, new_virt_loc);
 
@@ -2413,8 +2414,8 @@ gnucash_sheet_class_init (GnucashSheetClass *klass)
 
     widget_class->key_press_event = gnucash_sheet_key_press_event;
     widget_class->key_release_event = gnucash_sheet_key_release_event;
-    widget_class->button_press_event = gnucash_button_press_event;
-    widget_class->button_release_event = gnucash_button_release_event;
+    widget_class->button_press_event = gnucash_sheet_button_press_event;
+    widget_class->button_release_event = gnucash_sheet_button_release_event;
     widget_class->scroll_event = gnucash_scroll_event;
 }
 

commit 71bf2392f516e4cd59fd3e79a88a352b05434ded
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 9 17:14:54 2017 +0100

    Use a higher priority for the idle add when item edit updating

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 0586855..882f94f 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -110,7 +110,6 @@ gnc_item_edit_update (GncItemEdit *item_edit)
     gnc_item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h);
     gtk_layout_move (GTK_LAYOUT(item_edit->sheet),
                      GTK_WIDGET(item_edit), x, y);
-    gtk_widget_queue_resize (GTK_WIDGET (item_edit));
 
     if (item_edit->is_popup)
     {
@@ -223,7 +222,8 @@ gnc_item_edit_configure (GncItemEdit *item_edit)
         gnc_item_edit_set_popup (item_edit, NULL, NULL, NULL,
                                  NULL, NULL, NULL, NULL);
 
-    g_idle_add ((GSourceFunc) gnc_item_edit_update, item_edit);
+    g_idle_add_full (G_PRIORITY_HIGH_IDLE,
+                    (GSourceFunc) gnc_item_edit_update, item_edit, NULL);
 }
 
 

commit cd92fe06aacf523d9f072b7b6e4dbf260ef077a6
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 9 17:11:53 2017 +0100

    Fix problem when sheet first loaded in the register
    
    When the horizontal scroll bar is hidden there is a possibility that
    the space is not taken up by the sheet so request a resize when idle.

diff --git a/gnucash/register/register-gnome/gnucash-register.c b/gnucash/register/register-gnome/gnucash-register.c
index cb6a5e8..237b176 100644
--- a/gnucash/register/register-gnome/gnucash-register.c
+++ b/gnucash/register/register-gnome/gnucash-register.c
@@ -264,6 +264,15 @@ gnucash_register_goto_next_matching_row (GnucashRegister *reg,
     gnucash_sheet_goto_virt_loc (sheet, virt_loc);
 }
 
+static gboolean
+gnucash_register_sheet_resize (GnucashRegister *reg)
+{
+    // Sometimes the space left by the horzontal scrollbar does
+    // not get filled on load, this makes sure it does
+    if (!reg->hscrollbar_visible)
+        gtk_widget_queue_resize (GTK_WIDGET (reg->sheet));
+    return FALSE;
+}
 
 static void
 gnucash_register_update_hadjustment (GtkAdjustment *adj,
@@ -287,6 +296,10 @@ gnucash_register_update_hadjustment (GtkAdjustment *adj,
         {
             gtk_widget_hide(reg->hscrollbar);
             reg->hscrollbar_visible = FALSE;
+            // When sheet first loaded and the scrollbar is hidden, the space left
+            // is not always automaticly taken up by the sheet so queue a resize
+            // when all is idle
+            g_idle_add ((GSourceFunc) gnucash_register_sheet_resize, reg);
         }
     }
 }

commit c3c01f468154b4aff1b15eebad70a4d7f31977dd
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Sep 9 17:09:11 2017 +0100

    Change the line position to make double thickness line on cursor
    
    Move the second line to above the normal one so that it is visible when
    there is a full height sheet

diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index 3cc8614..c987b92 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -707,8 +707,9 @@ gnucash_sheet_draw_cursor (GnucashCursor *cursor, cairo_t *cr)
     cairo_stroke (cr);
 
     // make the bottom line thicker
-    cairo_move_to (cr, cursor->x - x + 0.5, cursor->y - y + cursor->h - 1.5);
+    cairo_move_to (cr, cursor->x - x + 0.5, cursor->y - y + cursor->h - 3.5);
     cairo_rel_line_to (cr, cursor->w, 0);
+    cairo_set_line_width (cr, 1.0);
     cairo_stroke (cr);
 
     /* draw rectangle around the active cell */

commit 6eeea6fb02c5a7fdb88a9037c794a899ec56e66c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 16:33:36 2017 +0100

    Use the background class for the dense-calendar

diff --git a/gnucash/gnome-utils/gnc-dense-cal.c b/gnucash/gnome-utils/gnc-dense-cal.c
index 07f7ee0..8c82273 100644
--- a/gnucash/gnome-utils/gnc-dense-cal.c
+++ b/gnucash/gnome-utils/gnc-dense-cal.c
@@ -918,12 +918,15 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
     stylectxt = gtk_widget_get_style_context (GTK_WIDGET(dcal->cal_drawing_area));
     state_flags = gtk_style_context_get_state (stylectxt);
 
+    gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND);
     gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_CALENDAR);
 
     gtk_render_background (stylectxt, cr, 0, 0,
                            cairo_image_surface_get_width (dcal->surface),
                            cairo_image_surface_get_height (dcal->surface));
 
+    gtk_style_context_remove_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND);
+
     /* get the colors */
     {
          GdkRGBA color;

commit 0c002682ddb006217185001e57372d5efb705ae6
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 16:13:40 2017 +0100

    Change the way negative-numbers class was defined in CSS
    
    After testing with Gtk3.10, needed to change the way the negative
    numbers class was defined.

diff --git a/gnucash/gnome-utils/ui/gnucash-fallback.css b/gnucash/gnome-utils/ui/gnucash-fallback.css
index 8da155d..b08a722 100644
--- a/gnucash/gnome-utils/ui/gnucash-fallback.css
+++ b/gnucash/gnome-utils/ui/gnucash-fallback.css
@@ -33,13 +33,8 @@
 }
 
 /* Negative value label colors */
-.default-color {
-  color: currentColor;
-}
-
-.negative-numbers {
-  color: rgb(75%, 0%, 0%);
-}
+ at define-color default-color currentColor;
+ at define-color negative-numbers rgb(75%, 0%, 0%);
 
 /* Change font color by mixing with grey */
 .lighter-grey-mix {
diff --git a/gnucash/gnome-utils/ui/gnucash.css b/gnucash/gnome-utils/ui/gnucash.css
index e4a985a..57c897d 100644
--- a/gnucash/gnome-utils/ui/gnucash.css
+++ b/gnucash/gnome-utils/ui/gnucash.css
@@ -2,6 +2,16 @@
    unless they have been named or have style classes added. Only 
    the widget type can be configured unless they are named in code */
 
+
+/* Negative value label colors */
+.default-color {
+  color: @default-color;
+}
+
+.negative-numbers {
+  color: @negative-numbers;
+}
+
 /* Register Cursor padding settings, make sure entry matches sheet.h */
 cursor entry {
   padding: 2px 5px 2px 5px;

commit 0d63bf55721af59c8573158d30cb7535ec11edf6
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 16:11:20 2017 +0100

    Remove white space and tabs from split-register-model

diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 861a62a..ee31252 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -167,7 +167,7 @@ gnc_split_register_get_split_commodity (SplitRegister *reg,
 
     if (!account)
         return NULL;
-        
+
     return xaccAccountGetCommodity(account);
 }
 
@@ -972,7 +972,7 @@ gnc_split_register_get_num_entry (VirtualLocation virt_loc,
     split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
     trans = xaccSplitGetParent (split);
 
-    return gnc_get_num_action (trans, split); 
+    return gnc_get_num_action (trans, split);
 }
 
 static const char *
@@ -1164,7 +1164,7 @@ gnc_split_register_get_rate_entry (VirtualLocation virt_loc,
 
     if (info->rate_reset == RATE_RESET_REQD && info->auto_complete)
         return "0";
-        
+
     split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
     if (!split)
         return NULL;
@@ -2132,8 +2132,8 @@ gnc_template_register_get_xfrm_entry (VirtualLocation virt_loc,
      */
     g_free (name);
     qof_instance_get (QOF_INSTANCE (split),
-		      "sx-account", &guid,
-		      NULL);
+              "sx-account", &guid,
+              NULL);
     account = xaccAccountLookup (guid, gnc_get_current_book ());
     name = account ? gnc_get_account_name_for_register (account) : NULL;
 
@@ -2224,7 +2224,7 @@ gnc_split_register_get_default_help (VirtualLocation virt_loc,
  *
  * Now it retrieves the sx-debit-numeric or sx-credit-numeric properties from
  * the split. I'm not sure that it's what was originally intended, but at least
- * it can do something now.	<jralls, 8 June 2015>
+ * it can do something now. <jralls, 8 June 2015>
  */
 static const char *
 gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,

commit 98f0b3dacbff649cab1383efbf7507e9fdade186
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 16:10:33 2017 +0100

    Add a heading for the Rate column.

diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 86e406d..861a62a 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -354,6 +354,13 @@ gnc_split_register_get_type_label (VirtualLocation virt_loc,
 }
 
 static const char *
+gnc_split_register_get_rate_label (VirtualLocation virt_loc,
+                                   gpointer user_data)
+{
+    return _("Rate");
+}
+
+static const char *
 gnc_split_register_get_debit_label (VirtualLocation virt_loc,
                                     gpointer user_data)
 {
@@ -2455,6 +2462,10 @@ gnc_split_register_model_new (void)
                                        PRIC_CELL);
 
     gnc_table_model_set_label_handler (model,
+                                       gnc_split_register_get_rate_label,
+                                       RATE_CELL);
+
+    gnc_table_model_set_label_handler (model,
                                        gnc_split_register_get_shares_label,
                                        SHRS_CELL);
 

commit 173805b79feffd3999f3b9ae248372888bcde36d
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 16:04:15 2017 +0100

    Register in journal mode with rate column, split columns loose alignment
    
    When you add the rate column when the register is in journal view, with
    the splits visible, the alignment of the split columns fails. This seems
     to be caused by the split memo field setup differently to description.

diff --git a/gnucash/register/ledger-core/split-register-layout.c b/gnucash/register/ledger-core/split-register-layout.c
index 74f5c2c..350a53d 100644
--- a/gnucash/register/ledger-core/split-register-layout.c
+++ b/gnucash/register/ledger-core/split-register-layout.c
@@ -737,8 +737,8 @@ gnc_split_register_layout_add_cells (SplitRegister *reg,
                            QUICKFILL_CELL_TYPE_NAME,
                            N_("sample:Memo field sample text string") + 7,
                            CELL_ALIGN_LEFT,
-                           FALSE,
-                           TRUE);
+                           TRUE,
+                           FALSE);
 
     gnc_register_add_cell (layout,
                            DEBT_CELL,

commit 2c5f1aa59b47ee27efa77fd08826d52c02fa72d8
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 16:00:38 2017 +0100

    Redraw the header after size allocation of the sheet.
    
    If the horizontal scrollbar is visible, the header foreground colour is
    wrong so add a redraw of the header at the end of the allocate.

diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 2b17f76..539cb39 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -1118,7 +1118,7 @@ gnucash_sheet_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
             gnucash_sheet_show_row (sheet,
                                     virt_loc.vcell_loc.virt_row);
     }
-
+    gnc_header_request_redraw (GNC_HEADER(sheet->header_item));
     LEAVE(" ");
 }
 

commit 91c8a56eaaedb8e3f661445be12f9afbfa955685
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 15:59:40 2017 +0100

    Add redraw of the header when preference changes

diff --git a/gnucash/register/register-gnome/gnucash-register.c b/gnucash/register/register-gnome/gnucash-register.c
index defe052..cb6a5e8 100644
--- a/gnucash/register/register-gnome/gnucash-register.c
+++ b/gnucash/register/register-gnome/gnucash-register.c
@@ -156,6 +156,7 @@ gnucash_register_refresh_from_prefs (GnucashRegister *reg)
 
     sheet = GNUCASH_SHEET(reg->sheet);
     gnucash_sheet_refresh_from_prefs(sheet);
+    gnc_header_request_redraw (GNC_HEADER(sheet->header_item));
 }
 
 

commit 6aa09abbcd7170d40030101118f85e158fdb6ce2
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 15:58:58 2017 +0100

    Remove the no longer widgets for setting register colours

diff --git a/gnucash/register/register-gnome/gnucash-register.c b/gnucash/register/register-gnome/gnucash-register.c
index dbe9c2a..defe052 100644
--- a/gnucash/register/register-gnome/gnucash-register.c
+++ b/gnucash/register/register-gnome/gnucash-register.c
@@ -528,30 +528,6 @@ gnucash_register_create_widget (Table *table)
     gtk_widget_show (reg->hscrollbar);
     reg->hscrollbar_visible = TRUE;
 
-    /* The gtkrc color helper widgets need to be part of a window
-     * hierarchy so they can be realized. Stick them in a box
-     * underneath the register, but don't show the box to the
-     * user. */
-    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-    gtk_box_set_homogeneous (GTK_BOX (box), FALSE);
-
-    gtk_widget_set_no_show_all(GTK_WIDGET(box), TRUE);
-    gtk_box_pack_start(GTK_BOX(box),
-                                GNUCASH_SHEET(sheet)->header_color, TRUE, TRUE, 0);
-    gtk_box_pack_start(GTK_BOX(box),
-                                GNUCASH_SHEET(sheet)->primary_color, TRUE, TRUE, 0);
-    gtk_box_pack_start(GTK_BOX(box),
-                                GNUCASH_SHEET(sheet)->secondary_color, TRUE, TRUE, 0);
-    gtk_box_pack_start(GTK_BOX(box),
-                                GNUCASH_SHEET(sheet)->split_color, TRUE, TRUE, 0);
-
-    gtk_grid_attach (GTK_GRID(widget), GTK_WIDGET(box), 0, 3, 1, 1);
-    gtk_widget_set_hexpand (GTK_WIDGET(box), TRUE);
-    gtk_widget_set_halign (GTK_WIDGET(box), GTK_ALIGN_FILL);
-    gtk_widget_set_vexpand (GTK_WIDGET(box), TRUE);
-    gtk_widget_set_valign (GTK_WIDGET(box), GTK_ALIGN_FILL);
-    g_object_set (GTK_WIDGET(box), "margin", 0, NULL);
-
     g_signal_connect (GNUCASH_SHEET(sheet)->hadj, "changed",
                       G_CALLBACK (gnucash_register_update_hadjustment), reg);
 
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 090156f..2b17f76 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -2315,17 +2315,6 @@ gnucash_sheet_table_load (GnucashSheet *sheet, gboolean do_scroll)
     gnucash_sheet_activate_cursor_cell (sheet, TRUE);
 }
 
-static void
-gnucash_sheet_realize_entry (GnucashSheet *sheet, GtkWidget *entry)
-{
-    GValue gval = {0,};
-    g_value_init (&gval, G_TYPE_BOOLEAN);
-    g_value_set_boolean (&gval, FALSE);
-    g_object_set_property (G_OBJECT (entry), "editable", &gval);
-
-    gtk_widget_realize (entry);
-}
-
 /*************************************************************/
 
 /** Map a cell type to a css style class. */
@@ -2392,32 +2381,6 @@ gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
     }
     gtk_style_context_add_class (stylectxt, full_class);
 
-/** Create the entries used for nameing register colors in gtkrc. */
-static void
-gnucash_sheet_create_color_hack(GnucashSheet *sheet)
-{
-    sheet->header_color    = gtk_entry_new();
-    sheet->primary_color   = gtk_entry_new();
-    sheet->secondary_color = gtk_entry_new();
-    sheet->split_color     = gtk_entry_new();
-
-    gtk_widget_set_name(sheet->header_color,    "header_color");
-    gtk_widget_set_name(sheet->primary_color,   "primary_color");
-    gtk_widget_set_name(sheet->secondary_color, "secondary_color");
-    gtk_widget_set_name(sheet->split_color,     "split_color");
-
-    g_signal_connect_after(sheet, "realize",
-                           G_CALLBACK(gnucash_sheet_realize_entry),
-                           sheet->header_color);
-    g_signal_connect_after(sheet, "realize",
-                           G_CALLBACK(gnucash_sheet_realize_entry),
-                           sheet->primary_color);
-    g_signal_connect_after(sheet, "realize",
-                           G_CALLBACK(gnucash_sheet_realize_entry),
-                           sheet->secondary_color);
-    g_signal_connect_after(sheet, "realize",
-                           G_CALLBACK(gnucash_sheet_realize_entry),
-                           sheet->split_color);
     g_free (full_class);
 }
 
diff --git a/gnucash/register/register-gnome/gnucash-sheetP.h b/gnucash/register/register-gnome/gnucash-sheetP.h
index 4ae8447..8925720 100644
--- a/gnucash/register/register-gnome/gnucash-sheetP.h
+++ b/gnucash/register/register-gnome/gnucash-sheetP.h
@@ -66,10 +66,6 @@ struct _GnucashSheet
     gboolean   use_theme_colors;
     gboolean   use_horizontal_lines;
     gboolean   use_vertical_lines;
-    GtkWidget *header_color;
-    GtkWidget *primary_color;
-    GtkWidget *secondary_color;
-    GtkWidget *split_color;
     gboolean   dark_theme;
 
     gboolean input_cancelled;

commit 9973bbe6eb1594912703ba91734a545ede752855
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 15:53:08 2017 +0100

    Change the register to be based on CSS
    
    Change the colours of the register to be based on CSS. Use the register
    default colours or by using the preference setting user / theme  set
    ones can be used.

diff --git a/gnucash/gnome-utils/ui/gnucash-fallback.css b/gnucash/gnome-utils/ui/gnucash-fallback.css
index 21cb616..8da155d 100644
--- a/gnucash/gnome-utils/ui/gnucash-fallback.css
+++ b/gnucash/gnome-utils/ui/gnucash-fallback.css
@@ -41,6 +41,15 @@
   color: rgb(75%, 0%, 0%);
 }
 
+/* Change font color by mixing with grey */
+.lighter-grey-mix {
+  color: mix (currentColor, grey, 0.8);
+}
+
+.darker-grey-mix {
+  color: mix (currentColor, grey, 0.2);
+}
+
 /* Register2 grid lines color */
 .register2_grid_lines {
   border-color: black;
diff --git a/gnucash/gnome-utils/ui/gnucash.css b/gnucash/gnome-utils/ui/gnucash.css
index 469de9f..e4a985a 100644
--- a/gnucash/gnome-utils/ui/gnucash.css
+++ b/gnucash/gnome-utils/ui/gnucash.css
@@ -10,3 +10,87 @@ cursor entry {
 cursor button {
   padding: 1px 1px 1px 1px;
 }
+
+/* Register defaults */
+ at define-color register_header_bg_color #96B183;
+ at define-color register_primary_bg_color #BFDEB9;
+ at define-color register_secondary_bg_color #F6FFDA;
+ at define-color register_split_bg_color #EDE7D3;
+ at define-color register_cursor_bg_color #FFEF98;
+
+.app-header {
+  background-color: @register_header_bg_color;
+}
+
+.app-header-dark {
+  background-color: shade (@register_header_bg_color, 0.7);
+}
+
+
+*.app-primary {
+  background-color: @register_primary_bg_color;
+}
+
+*.app-primary:insensitive {
+  background-color: mix (@register_primary_bg_color, grey, 0.2);
+}
+
+*.app-primary-dark {
+  background-color: shade (@register_primary_bg_color, 0.7);
+}
+
+*.app-primary-dark:insensitive {
+  background-color: mix (shade (@register_primary_bg_color, 0.7), grey, 0.3);
+}
+
+
+*.app-secondary {
+  background-color: @register_secondary_bg_color;
+}
+
+*.app-secondary:insensitive {
+  background-color: mix (@register_secondary_bg_color, grey, 0.2);
+}
+
+*.app-secondary-dark {
+  background-color: shade (@register_secondary_bg_color, 0.5);
+}
+
+*.app-secondary-dark:insensitive {
+  background-color: mix (shade (@register_secondary_bg_color, 0.5), grey, 0.3);
+}
+
+
+*.app-split {
+  background-color: @register_split_bg_color;
+}
+
+*.app-split:insensitive {
+  background-color: mix (@register_split_bg_color, grey, 0.2);
+}
+
+*.app-split-dark {
+  background-color: shade (@register_split_bg_color, 0.5);
+}
+
+*.app-split-dark:insensitive {
+  background-color: mix (shade (@register_split_bg_color, 0.5), grey, 0.3);
+}
+
+
+*.app-cursor {
+  background-color: @register_cursor_bg_color;
+}
+
+*.app-cursor:insensitive {
+  background-color: mix (@register_cursor_bg_color, grey, 0.2);
+}
+
+*.app-cursor-dark {
+  background-color: shade (@register_cursor_bg_color, 0.6);
+}
+
+*.app-cursor-dark:insensitive {
+  background-color: mix (shade (@register_cursor_bg_color, 0.6), grey, 0.3);
+}
+
diff --git a/gnucash/register/register-gnome/gnucash-header.c b/gnucash/register/register-gnome/gnucash-header.c
index 14fca91..feb75f6 100644
--- a/gnucash/register/register-gnome/gnucash-header.c
+++ b/gnucash/register/register-gnome/gnucash-header.c
@@ -36,6 +36,7 @@
 #include "gnucash-style.h"
 #include "gnucash-cursor.h"
 #include "gnucash-item-edit.h"
+#include "gnc-gtk-utils.h"
 
 #include "gnucash-header.h"
 
@@ -71,7 +72,9 @@ gnc_header_draw_offscreen (GncHeader *header)
     Table *table = header->sheet->table;
     VirtualLocation virt_loc;
     VirtualCell *vcell;
-    GdkRGBA *fg_color, *bg_color;
+    guint32 color_type;
+    GtkStyleContext *stylectxt = gtk_widget_get_style_context (GTK_WIDGET(header));
+    GdkRGBA color;
     int row_offset;
     CellBlock *cb;
     int i;
@@ -82,22 +85,11 @@ gnc_header_draw_offscreen (GncHeader *header)
     virt_loc.phys_row_offset = 0;
     virt_loc.phys_col_offset = 0;
 
-    if (header->sheet->use_theme_colors)
-    {
-        guint32 color_type;
-        color_type = gnc_table_get_gtkrc_bg_color (table, virt_loc, NULL);
-        bg_color = get_gtkrc_color(header->sheet, color_type);
-        color_type = gnc_table_get_gtkrc_fg_color (table, virt_loc);
-        fg_color = get_gtkrc_color(header->sheet, color_type);
-    }
-    else
-    {
-        guint32 argb;
-        argb = gnc_table_get_bg_color (table, virt_loc, NULL);
-        bg_color = gnucash_color_argb_to_gdk (argb);
-        argb = gnc_table_get_fg_color (table, virt_loc);
-        fg_color = gnucash_color_argb_to_gdk (argb);
-    }
+    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);
+    gnucash_get_style_classes (header->sheet, stylectxt, color_type);
 
     if (header->surface)
         cairo_surface_destroy (header->surface);
@@ -106,13 +98,17 @@ gnc_header_draw_offscreen (GncHeader *header)
                                                 header->height);
 
     cr = cairo_create (header->surface);
+
     // Fill background color of header
+    gtk_render_background (stylectxt, cr, 0, 0, header->width, header->height);
+
+    gdk_rgba_parse (&color, "black");
+    cairo_set_source_rgb (cr, color.red, color.green, color.blue);
     cairo_rectangle (cr, 0.5, 0.5, header->width - 1.0, header->height - 1.0);
-    cairo_set_source_rgb (cr, bg_color->red, bg_color->green, bg_color->blue);
-    cairo_fill_preserve (cr);
+    cairo_set_line_width (cr, 1.0);
+    cairo_stroke (cr);
 
     // Draw bottom horizontal line, makes bottom line thicker
-    cairo_set_source_rgb (cr, fg_color->red, fg_color->green, fg_color->blue);
     cairo_move_to (cr, 0.5, header->height - 1.5);
     cairo_line_to (cr, header->width - 1.0, header->height - 1.5);
     cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
@@ -195,24 +191,19 @@ gnc_header_draw_offscreen (GncHeader *header)
             text_h = h - 2;
             cairo_save (cr);
             cairo_rectangle (cr, text_x, text_y, text_w, text_h);
-            cairo_set_source_rgb (cr, fg_color->red, fg_color->green, fg_color->blue);
             cairo_clip (cr);
-            cairo_move_to (cr, text_x, text_y);
-            pango_cairo_show_layout (cr, layout);
+
+            gtk_render_layout (stylectxt, cr, text_x, text_y, layout);
+
             cairo_restore (cr);
             g_object_unref (layout);
 
             col_offset += w;
         }
-
         row_offset += h;
     }
+    gtk_style_context_restore (stylectxt);
 
-    if (header->sheet->use_theme_colors)
-    {
-        gdk_rgba_free(bg_color);
-        gdk_rgba_free(fg_color);
-    }
     cairo_destroy (cr);
 }
 
diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index 6f20514..3cc8614 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -41,6 +41,7 @@
 #include "gnucash-sheetP.h"
 #include "gnucash-color.h"
 #include "gnucash-style.h"
+#include "gnc-gtk-utils.h"
 
 /*
  * Sets virt_row, virt_col to the block coordinates for the
@@ -390,31 +391,34 @@ draw_cell (GnucashSheet *sheet,
     GdkRGBA *bg_color, *fg_color;
     GdkRectangle rect;
     gboolean hatching;
-    guint32 argb, color_type;
+    guint32 color_type;
     int x_offset;
+    GtkStyleContext *stylectxt = gtk_widget_get_style_context (GTK_WIDGET(sheet));
+    GdkRGBA color;
 
-    if (sheet->use_theme_colors)
-    {
-        color_type = gnc_table_get_gtkrc_bg_color (table, virt_loc,
-                     &hatching);
-        bg_color = get_gtkrc_color(sheet, color_type);
-    }
-    else
-    {
-        argb = gnc_table_get_bg_color (table, virt_loc, &hatching);
-        // Are we in a read-only row? Then make the background color somewhat more gray.
-        if ((virt_loc.phys_row_offset == (block->style->nrows - 1))
+    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);
+    gnucash_get_style_classes (sheet, stylectxt, color_type);
+
+    color_type = gnc_table_get_gtkrc_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.
+    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))
-        {
-            argb = dec_intensity_10percent(argb);
-        }
-        bg_color = gnucash_color_argb_to_gdk (argb);
+    {
+        if (!gtk_style_context_has_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND))
+            gtk_style_context_set_state (stylectxt, GTK_STATE_FLAG_INSENSITIVE);
     }
 
-    cairo_set_source_rgb (cr, bg_color->red, bg_color->green, bg_color->blue);
-    cairo_rectangle (cr, x, y, width, height);
-    cairo_fill (cr);
+    gtk_render_background (stylectxt, cr, x, y, width, height);
+
+    gdk_rgba_parse (&color, "black");
+    gnc_style_context_get_background_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
+    bg_color = gdk_rgba_copy (&color);
 
     get_cell_borders (sheet, virt_loc, &borders);
 
@@ -477,30 +481,28 @@ draw_cell (GnucashSheet *sheet,
     text = gnc_table_get_entry (table, virt_loc);
 
     layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), text);
+
+    if (gtk_style_context_has_class (stylectxt, GTK_STYLE_CLASS_VIEW))
+        gtk_style_context_remove_class (stylectxt, GTK_STYLE_CLASS_VIEW);
+
     // We don't need word wrap or line wrap
     pango_layout_set_width (layout, -1);
     context = pango_layout_get_context (layout);
     font = pango_font_description_copy (pango_context_get_font_description (context));
 
-    if (sheet->use_theme_colors)
+#ifdef READONLY_LINES_WITH_CHANGED_FG_COLOR
+    // Are we in a read-only row? Then make the foreground color somewhat less black
+    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))
     {
-        color_type = gnc_table_get_gtkrc_fg_color (table, virt_loc);
-        fg_color = get_gtkrc_color(sheet, color_type);
+        // Make text color greyed
+        if (sheet->dark_theme)
+            gtk_style_context_add_class (stylectxt, "darker-grey-mix");
+        else
+            gtk_style_context_add_class (stylectxt, "lighter-grey-mix");
     }
-    else
-    {
-        argb = gnc_table_get_fg_color (table, virt_loc);
-#ifdef READONLY_LINES_WITH_CHANGED_FG_COLOR
-        // Are we in a read-only row? Then make the foreground color somewhat less black
-        if ((virt_loc.phys_row_offset == (block->style->nrows - 1))
-                && (table->model->dividing_row_upper >= 0)
-                && (virt_loc.vcell_loc.virt_row < table->model->dividing_row_upper))
-        {
-            argb = inc_intensity_10percent(argb);
-        }
 #endif
-        fg_color = gnucash_color_argb_to_gdk (argb);
-    }
 
     /* If this is the currently open transaction and
        there is no text in this cell */
@@ -511,12 +513,17 @@ draw_cell (GnucashSheet *sheet,
         text = gnc_table_get_label (table, virt_loc);
         if ((text == NULL) || (*text == '\0'))
             goto exit;
-        fg_color = &gn_light_gray;
+
+        // Make text color greyed
+        if (sheet->dark_theme)
+            gtk_style_context_add_class (stylectxt, "darker-grey-mix");
+        else
+            gtk_style_context_add_class (stylectxt, "lighter-grey-mix");
+
         pango_layout_set_text (layout, text, strlen (text));
         pango_font_description_set_style (font, PANGO_STYLE_ITALIC);
         pango_context_set_font_description (context, font);
     }
-    cairo_set_source_rgb (cr, fg_color->red, fg_color->green, fg_color->blue);
 
     if ((text == NULL) || (*text == '\0'))
     {
@@ -555,11 +562,7 @@ draw_cell (GnucashSheet *sheet,
                         logical_rect.width) / 2;
         break;
     }
-
-
-
-    cairo_move_to (cr, rect.x + x_offset, rect.y + 1);
-    pango_cairo_show_layout (cr, layout);
+    gtk_render_layout (stylectxt, cr, rect.x + x_offset, rect.y + 1, layout);
 
     cairo_restore (cr);
 
@@ -569,11 +572,7 @@ exit:
     pango_font_description_free (font);
     g_object_unref (layout);
 
-    if (sheet->use_theme_colors)
-    {
-        gdk_rgba_free(bg_color);
-        gdk_rgba_free(fg_color);
-    }
+    gtk_style_context_restore (stylectxt);
 }
 
 static void
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 4ab7f96..090156f 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -1055,10 +1055,17 @@ gnucash_sheet_draw_cb (GtkWidget *widget, cairo_t *cr, G_GNUC_UNUSED gpointer da
     GnucashSheet *sheet = GNUCASH_SHEET (widget);
     GtkStyleContext *context = gtk_widget_get_style_context (widget);
     GtkAllocation alloc;
+    GdkRGBA color;
     gboolean result; //FIXME
 
     gtk_widget_get_allocation(widget, &alloc);
-    gtk_render_background (context, cr, alloc.x, alloc.y, alloc.width, alloc.height);
+
+    gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND);
+    gtk_render_background (context, cr, 0, 0, alloc.width, alloc.height);
+    gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
+    sheet->dark_theme = gnc_is_dark_theme (&color);
+    gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BACKGROUND);
+
 //FIXME what should be done with result being TRUE or FALSE
     result = gnucash_sheet_draw_internal (sheet, cr, &alloc);
     gnucash_sheet_draw_cursor (sheet->cursor, cr);
@@ -2321,104 +2328,69 @@ gnucash_sheet_realize_entry (GnucashSheet *sheet, GtkWidget *entry)
 
 /*************************************************************/
 
-/* This code is one big hack to use gtkrc to set cell colors in a
- * register.  Because the cells are just boxes drawn on a gnome
- * canvas, there's no way to specify the individual cells in a gtkrc
- * file.  This code creates four hidden GtkEntry widgets and names
- * them so that they *can* be specified in gtkrc.  It then looks up
- * the colors specified on these hidden widgets and uses it for the
- * cells drawn on the canvas.  This code should all go away whenever
- * the register is rewritten.
- */
-
-/** Map a cell type to a gtkrc specified color. */
-GdkRGBA *
-get_gtkrc_color (GnucashSheet *sheet,
-                 RegisterColor field_type)
+/** Map a cell type to a css style class. */
+void
+gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
+                           RegisterColor field_type)
 {
-    GtkWidget *widget = NULL;
-    GtkStyleContext *stylectxt;
-    GdkRGBA color;
+    gchar *full_class, *style_class = NULL;
 
     switch (field_type)
     {
     default:
-        return gdk_rgba_copy (&gn_white);
-
     case COLOR_UNKNOWN_BG:
-        return gdk_rgba_copy (&gn_white);
-
     case COLOR_UNKNOWN_FG:
-        return gdk_rgba_copy (&gn_black);
+        gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_BACKGROUND);
+        return;
 
     case COLOR_NEGATIVE:
-        return gdk_rgba_copy (&gn_red);  // FIXME shouldn't be hardcoded...
+        gtk_style_context_add_class (stylectxt, "negative-numbers");
+        return;
 
     case COLOR_HEADER_BG:
     case COLOR_HEADER_FG:
-        widget = sheet->header_color;
+        style_class = "header";
         break;
 
     case COLOR_PRIMARY_BG:
-    case COLOR_PRIMARY_BG_ACTIVE:
     case COLOR_PRIMARY_FG:
-    case COLOR_PRIMARY_FG_ACTIVE:
-        widget = sheet->primary_color;
+        style_class = "primary";
         break;
 
-    case COLOR_SECONDARY_BG:
+    case COLOR_PRIMARY_BG_ACTIVE:
+    case COLOR_PRIMARY_FG_ACTIVE:
     case COLOR_SECONDARY_BG_ACTIVE:
-    case COLOR_SECONDARY_FG:
     case COLOR_SECONDARY_FG_ACTIVE:
-        widget = sheet->secondary_color;
-        break;
-
-    case COLOR_SPLIT_BG:
     case COLOR_SPLIT_BG_ACTIVE:
-    case COLOR_SPLIT_FG:
     case COLOR_SPLIT_FG_ACTIVE:
-        widget = sheet->split_color;
+        gtk_style_context_set_state (stylectxt, GTK_STATE_FLAG_SELECTED);
+        style_class = "cursor";
         break;
-    }
-
-    stylectxt = gtk_widget_get_style_context (widget);
-    if (!stylectxt)
-        return gdk_rgba_copy (&gn_white);
-
-    switch (field_type)
-    {
-    default:
-        return gdk_rgba_copy (&gn_white);
 
-    case COLOR_HEADER_BG:
-    case COLOR_PRIMARY_BG:
     case COLOR_SECONDARY_BG:
-    case COLOR_SPLIT_BG:
-        gnc_style_context_get_background_color(stylectxt, GTK_STATE_FLAG_NORMAL, &color);
-        break;
-
-    case COLOR_PRIMARY_BG_ACTIVE:
-    case COLOR_SECONDARY_BG_ACTIVE:
-    case COLOR_SPLIT_BG_ACTIVE:
-        gnc_style_context_get_background_color(stylectxt, GTK_STATE_FLAG_SELECTED, &color);
-        break;
-
-    case COLOR_HEADER_FG:
-    case COLOR_PRIMARY_FG:
     case COLOR_SECONDARY_FG:
-    case COLOR_SPLIT_FG:
-        gtk_style_context_get_color(stylectxt, GTK_STATE_FLAG_NORMAL, &color);
+        style_class = "secondary";
         break;
 
-    case COLOR_PRIMARY_FG_ACTIVE:
-    case COLOR_SECONDARY_FG_ACTIVE:
-    case COLOR_SPLIT_FG_ACTIVE:
-        gtk_style_context_get_color(stylectxt, GTK_STATE_FLAG_SELECTED, &color);
+    case COLOR_SPLIT_BG:
+    case COLOR_SPLIT_FG:
+        style_class = "split";
         break;
     }
 
-    return gdk_rgba_copy (&color);
-}
+    if (sheet->use_theme_colors)
+    {
+        gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_VIEW);
+        full_class = g_strconcat (style_class, "-color", NULL);
+    }
+    else
+    {
+        if (sheet->dark_theme)
+            full_class = g_strconcat ("app-", style_class, "-dark", NULL);
+        else
+            full_class = g_strconcat ("app-", style_class, NULL);
+    }
+    gtk_style_context_add_class (stylectxt, full_class);
 
 /** Create the entries used for nameing register colors in gtkrc. */
 static void
@@ -2446,6 +2418,7 @@ gnucash_sheet_create_color_hack(GnucashSheet *sheet)
     g_signal_connect_after(sheet, "realize",
                            G_CALLBACK(gnucash_sheet_realize_entry),
                            sheet->split_color);
+    g_free (full_class);
 }
 
 /*************************************************************/
@@ -2591,7 +2564,6 @@ gnucash_sheet_new (Table *table)
                                    g_free, NULL);
 
     gnucash_sheet_refresh_from_prefs(sheet);
-    gnucash_sheet_create_color_hack(sheet);
 
     return GTK_WIDGET(sheet);
 }
diff --git a/gnucash/register/register-gnome/gnucash-sheet.h b/gnucash/register/register-gnome/gnucash-sheet.h
index 76a81c6..b571d03 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.h
+++ b/gnucash/register/register-gnome/gnucash-sheet.h
@@ -105,7 +105,8 @@ void gnucash_sheet_update_adjustments (GnucashSheet *sheet);
 
 void gnucash_sheet_set_window (GnucashSheet *sheet, GtkWidget *window);
 
-GdkRGBA *get_gtkrc_color (GnucashSheet *sheet, RegisterColor field_type);
+void gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
+                                RegisterColor field_type);
 
 /** @} */
 #endif
diff --git a/gnucash/register/register-gnome/gnucash-sheetP.h b/gnucash/register/register-gnome/gnucash-sheetP.h
index 408b0da..4ae8447 100644
--- a/gnucash/register/register-gnome/gnucash-sheetP.h
+++ b/gnucash/register/register-gnome/gnucash-sheetP.h
@@ -70,6 +70,7 @@ struct _GnucashSheet
     GtkWidget *primary_color;
     GtkWidget *secondary_color;
     GtkWidget *split_color;
+    gboolean   dark_theme;
 
     gboolean input_cancelled;
 

commit 2d213363f0c918a08df7cc52bc8014a12d9f11b5
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 15:16:58 2017 +0100

    Change tabs to spaces in gnucash-style.c

diff --git a/gnucash/register/register-gnome/gnucash-style.c b/gnucash/register/register-gnome/gnucash-style.c
index 97d44a5..243004a 100644
--- a/gnucash/register/register-gnome/gnucash-style.c
+++ b/gnucash/register/register-gnome/gnucash-style.c
@@ -28,7 +28,7 @@
 #include "gnucash-sheet.h"
 #include "gnucash-sheetP.h"
 #include "gnucash-style.h"
-#include "gnc-engine.h"		// For debugging, e.g. ENTER(), LEAVE()
+#include "gnc-engine.h"     // For debugging, e.g. ENTER(), LEAVE()
 
 /** GLOBALS *********************************************************/
 /* This static indicates the debugging module that this .o belongs to.  */

commit 87c5a95211408e1656c33000d6c0434e6be5d377
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 15:15:46 2017 +0100

    Remove trailing white space from gnucash-sheet.c

diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 258e88c..4ab7f96 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -45,7 +45,7 @@
 #include "gnucash-header.h"
 #include "gnucash-item-edit.h"
 #include "split-register.h"
-#include "gnc-engine.h"		// For debugging, e.g. ENTER(), LEAVE()
+#include "gnc-engine.h"     // For debugging, e.g. ENTER(), LEAVE()
 
 #ifdef G_OS_WIN32
 # include <gdk/gdkwin32.h>
@@ -2551,13 +2551,13 @@ gnucash_sheet_get_type (void)
         static const GTypeInfo gnucash_sheet_info =
         {
             sizeof (GnucashSheetClass),
-            NULL,		/* base_init */
-            NULL,		/* base_finalize */
+            NULL,       /* base_init */
+            NULL,       /* base_finalize */
             (GClassInitFunc) gnucash_sheet_class_init,
-            NULL,		/* class_finalize */
-            NULL,		/* class_data */
+            NULL,       /* class_finalize */
+            NULL,       /* class_data */
             sizeof (GnucashSheet),
-            0,		/* n_preallocs */
+            0,      /* n_preallocs */
             (GInstanceInitFunc) gnucash_sheet_init
         };
 
@@ -2582,8 +2582,6 @@ gnucash_sheet_new (Table *table)
     /* The cursor */
     sheet->cursor = gnucash_cursor_new (sheet);
 
-    /*gtk_layout_put (GTK_LAYOUT (sheet), sheet->entry, 0, 0);*/
-
     /* set up the editor */
     sheet->item_editor = gnc_item_edit_new(sheet);
 

commit 23e1ed6904840dbb8c95c78d50e288deeca18f5c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 15:13:26 2017 +0100

    Remove trailing white space from gnucash-item-edit.c

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index f7db891..0586855 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -565,7 +565,7 @@ gnc_item_edit_new (GnucashSheet *sheet)
     item_edit->popup_toggle.tbutton = gtk_toggle_button_new();
     gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (item_edit->popup_toggle.tbutton), FALSE);
 
-    /* Force padding on the button to keep it small and display as much as 
+    /* Force padding on the button to keep it small and display as much as
        possible of the arrow which is done in the gnucash.css file */
 
     /* Wrap the popup button in an event box to give it its own gdkwindow.
@@ -642,7 +642,7 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
     else
         popup_w = 0;
 
-    // Adjust the popup_y point based on poping above or below 
+    // Adjust the popup_y point based on poping above or below
     if (up_height > down_height)
         popup_y = y - popup_h;
     else

commit 69dffac564689d5db0ba8ab16da664781fe8f2be
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Sep 4 15:11:02 2017 +0100

    This dialog-invoice.glade file had missing changes, corrected.

diff --git a/gnucash/gnome/gtkbuilder/dialog-invoice.glade b/gnucash/gnome/gtkbuilder/dialog-invoice.glade
index 1d998e5..cb7315a 100644
--- a/gnucash/gnome/gtkbuilder/dialog-invoice.glade
+++ b/gnucash/gnome/gtkbuilder/dialog-invoice.glade
@@ -2,14 +2,6 @@
 <!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
-  <object class="GtkListStore" id="terms_store">
-    <columns>
-      <!-- column-name label -->
-      <column type="gchararray"/>
-      <!-- column-name rowdata -->
-      <column type="gpointer"/>
-    </columns>
-  </object>
   <object class="GtkWindow" id="invoice_entry_window">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -169,6 +161,8 @@
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="editable">False</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -209,6 +203,8 @@
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="editable">False</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -400,6 +396,8 @@
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="editable">False</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -408,21 +406,17 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkComboBox" id="page_terms_menu">
+                          <object class="GtkEntry" id="page_terms_menu">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="model">terms_store</property>
-                            <signal name="changed" handler="gnc_invoice_terms_changed_cb" swapped="no"/>
-                            <child>
-                              <object class="GtkCellRendererText" id="page_cell_renderer_text"/>
-                              <attributes>
-                                <attribute name="text">0</attribute>
-                              </attributes>
-                            </child>
+                            <property name="editable">False</property>
+                            <property name="invisible_char">●</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
                           </object>
                           <packing>
                             <property name="expand">True</property>
-                            <property name="fill">False</property>
+                            <property name="fill">True</property>
                             <property name="position">3</property>
                           </packing>
                         </child>
@@ -674,6 +668,14 @@
       </object>
     </child>
   </object>
+  <object class="GtkListStore" id="terms_store">
+    <columns>
+      <!-- column-name label -->
+      <column type="gchararray"/>
+      <!-- column-name rowdata -->
+      <column type="gpointer"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="new_invoice_dialog">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -899,6 +901,8 @@
                             <property name="has_focus">True</property>
                             <property name="tooltip_text" translatable="yes">The invoice ID number. If left blank a reasonable number will be chosen for you.</property>
                             <property name="activates_default">True</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
                             <signal name="changed" handler="gnc_invoice_id_changed_cb" swapped="no"/>
                           </object>
                           <packing>
@@ -1063,6 +1067,8 @@
                           <object class="GtkEntry" id="dialog_billing_id_entry">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>

commit 70d696ef313ccd246b122c15f54fb31deef4fc62
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 1 15:57:48 2017 +0100

    This change is needed after all, used when header is resized

diff --git a/gnucash/register/register-gnome/gnucash-header.c b/gnucash/register/register-gnome/gnucash-header.c
index 8e37749..14fca91 100644
--- a/gnucash/register/register-gnome/gnucash-header.c
+++ b/gnucash/register/register-gnome/gnucash-header.c
@@ -386,7 +386,7 @@ gnc_header_resize_column (GncHeader *header, gint col, gint width)
     gnucash_sheet_set_scroll_region (sheet);
     gnucash_sheet_update_adjustments (sheet);
 
-//FIXME Not required?    gnc_header_request_redraw (header);
+    gnc_header_request_redraw (header);
     gnucash_sheet_redraw_all (sheet);
 }
 

commit 92766a27859cdcf568a84d1ce9aed40156460247
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Aug 31 15:45:51 2017 +0100

    Remove white space and change tabs to spaces in gnucash-register.c

diff --git a/gnucash/register/register-gnome/gnucash-register.c b/gnucash/register/register-gnome/gnucash-register.c
index 932f3d1..dbe9c2a 100644
--- a/gnucash/register/register-gnome/gnucash-register.c
+++ b/gnucash/register/register-gnome/gnucash-register.c
@@ -368,13 +368,13 @@ gnucash_register_get_type (void)
         static const GTypeInfo gnucash_register_info =
         {
             sizeof (GnucashRegisterClass),
-            NULL,		/* base_init */
-            NULL,		/* base_finalize */
+            NULL,       /* base_init */
+            NULL,       /* base_finalize */
             (GClassInitFunc) gnucash_register_class_init,
-            NULL,		/* class_finalize */
-            NULL,		/* class_data */
+            NULL,       /* class_finalize */
+            NULL,       /* class_data */
             sizeof (GnucashRegister),
-            0,		/* n_preallocs */
+            0,      /* n_preallocs */
             (GInstanceInitFunc) gnucash_register_init,
         };
 
@@ -563,11 +563,7 @@ GtkWidget *
 gnucash_register_new (Table *table, gchar *state_section)
 {
     GnucashRegister *reg;
-//    GtkWidget *header;
     GtkWidget *widget;
-//    GtkWidget *sheet;
-//    GtkWidget *scrollbar;
-//    GtkWidget *box;
 
     widget = gnucash_register_create_widget(table);
     reg = GNUCASH_REGISTER(widget);

commit 04c80ddd8eabd05d5103dbcf023f67fcf72cd4a6
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Aug 31 15:41:44 2017 +0100

    Rework the item-edit pop up to use sheet width and not move about
    
    The width of an auto width pop up is based on the sheet width and is
    anchored to the column it popped from so horizontal scrolls are aligned.

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 63033f6..f7db891 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -156,8 +156,9 @@ static void
 gnc_item_edit_init (GncItemEdit *item_edit)
 {
     /* Set invalid values so that we know when we have been fully
-    	   initialized */
-    gtk_orientable_set_orientation (GTK_ORIENTABLE(item_edit), GTK_ORIENTATION_HORIZONTAL);
+           initialized */
+    gtk_orientable_set_orientation (GTK_ORIENTABLE(item_edit),
+                                    GTK_ORIENTATION_HORIZONTAL);
 
     item_edit->sheet = NULL;
     item_edit->editor = NULL;
@@ -593,13 +594,11 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
     gint x, y, w, h;
     gint y_offset, x_offset;
     gint popup_x, popup_y;
-    gint popup_w;
-    gint popup_h;
-    gint popup_max_width;
-    gint view_height;
-    gint view_width;
-    gint up_height;
-    gint down_height;
+    gint popup_w = -1, popup_h = -1;
+    gint popup_max_width, popup_max_height;
+    gint view_width, view_height;
+    gint down_height, up_height;
+    gint sheet_width;
 
     g_return_if_fail (item_edit != NULL);
     g_return_if_fail (GNC_IS_ITEM_EDIT(item_edit));
@@ -609,6 +608,8 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
 
     sheet = item_edit->sheet;
 
+    sheet_width = sheet->width;
+
     gtk_widget_get_allocation (GTK_WIDGET (sheet), &alloc);
     view_height = alloc.height;
     view_width  = alloc.width;
@@ -625,22 +626,12 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
     up_height = y - y_offset;
     down_height = view_height - (up_height + h);
 
-    if (up_height > down_height)
-    {
-        popup_y = y + y_offset;
-        popup_h = up_height;
-    }
-    else
-    {
-        popup_y = y + h;
-        popup_h = down_height;
-    }
-
-    popup_max_width = view_width - popup_x + x_offset;
+    popup_max_height = MAX (up_height, down_height);
+    popup_max_width = sheet_width - popup_x + x_offset; // always pops to the right
 
     if (item_edit->popup_get_height)
         popup_h = item_edit->popup_get_height
-                       (item_edit->popup_item, popup_h, h,
+                       (item_edit->popup_item, popup_max_height, h,
                         item_edit->popup_user_data);
 
     if (item_edit->popup_autosize)
@@ -649,15 +640,18 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
                                        popup_max_width,
                                        item_edit->popup_user_data);
     else
-        popup_w = -1;
+        popup_w = 0;
 
+    // Adjust the popup_y point based on poping above or below 
     if (up_height > down_height)
         popup_y = y - popup_h;
+    else
+        popup_y = y + h;
 
     if (!gtk_widget_get_parent (item_edit->popup_item))
-        gtk_layout_put (GTK_LAYOUT(sheet), item_edit->popup_item,
-                        popup_x, popup_y);
-    gtk_widget_set_size_request(item_edit->popup_item, popup_w, popup_h);
+        gtk_layout_put (GTK_LAYOUT(sheet), item_edit->popup_item, popup_x, popup_y);
+
+    gtk_widget_set_size_request (item_edit->popup_item, popup_w - 1, popup_h);
 
     toggle = GTK_TOGGLE_BUTTON(item_edit->popup_toggle.tbutton);
 
@@ -687,6 +681,9 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
                       (item_edit->popup_item,
                        item_edit->popup_user_data);
 
+        if (popup_width > popup_w)
+            popup_width = popup_w;
+
         if (popup_width > popup_max_width)
         {
             popup_x -= popup_width - popup_max_width;

commit 841ff5cc92bf33eeb30f089af31ca099ee37b530
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Aug 31 13:57:49 2017 +0100

    Change gnc_item_edit_update to be used in an idle add function
    
    When columns are being resized, there is too much going on for the
    position of the item-edit to be updated so use g_idle_add to delay these
     updates.

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 8d00bb0..63033f6 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -102,12 +102,11 @@ gnc_item_edit_get_toggle_offset (int row_height)
     return row_height - (2 * (CELL_VPADDING + 1)) + 3;
 }
 
-static void
+static gboolean
 gnc_item_edit_update (GncItemEdit *item_edit)
 {
     gint x, y, w, h;
 
-//FIXME this does not appear to be realiable, widget does not always move to correct place
     gnc_item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h);
     gtk_layout_move (GTK_LAYOUT(item_edit->sheet),
                      GTK_WIDGET(item_edit), x, y);
@@ -119,6 +118,7 @@ gnc_item_edit_update (GncItemEdit *item_edit)
         if (item_edit->show_popup)
             gnc_item_edit_show_popup (item_edit);
     }
+    return FALSE;
 }
 
 void
@@ -222,7 +222,7 @@ gnc_item_edit_configure (GncItemEdit *item_edit)
         gnc_item_edit_set_popup (item_edit, NULL, NULL, NULL,
                                  NULL, NULL, NULL, NULL);
 
-    gnc_item_edit_update (item_edit);
+    g_idle_add ((GSourceFunc) gnc_item_edit_update, item_edit);
 }
 
 

commit 1ec2817c77b766e50e91e66602255cc495ffca59
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Aug 31 13:55:30 2017 +0100

    Move inline css for padding to gnucash.css

diff --git a/gnucash/gnome-utils/ui/gnucash.css b/gnucash/gnome-utils/ui/gnucash.css
index c8cc093..469de9f 100644
--- a/gnucash/gnome-utils/ui/gnucash.css
+++ b/gnucash/gnome-utils/ui/gnucash.css
@@ -2,3 +2,11 @@
    unless they have been named or have style classes added. Only 
    the widget type can be configured unless they are named in code */
 
+/* Register Cursor padding settings, make sure entry matches sheet.h */
+cursor entry {
+  padding: 2px 5px 2px 5px;
+}
+
+cursor button {
+  padding: 1px 1px 1px 1px;
+}
diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 16d86c8..8d00bb0 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -555,18 +555,8 @@ gnc_item_edit_new (GnucashSheet *sheet)
     gtk_entry_set_width_chars (GTK_ENTRY(item_edit->editor), 1);
     gtk_box_pack_start (GTK_BOX(item_edit), item_edit->editor,  TRUE, TRUE, 0);
 
-    /* Force padding on the entry to align with the rest of the register */
-    hpad_str = g_strdup_printf("%i", CELL_HPADDING);
-    vpad_str = g_strdup_printf("%i", CELL_VPADDING);
-    entry_css = g_strconcat ("* { padding: ", vpad_str, "px ", hpad_str, "px ", vpad_str, "px ", hpad_str, "px }", NULL);
-    provider = gtk_css_provider_new();
-    gtk_css_provider_load_from_data (provider, entry_css, -1, NULL);
-    stylecontext = gtk_widget_get_style_context (item_edit->editor);
-    gtk_style_context_add_provider (stylecontext, GTK_STYLE_PROVIDER (provider),
-                                    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-    g_free (hpad_str);
-    g_free (vpad_str);
-    g_free (entry_css);
+    /* Force padding on the entry to align with the rest of the register this
+       is done in the gnucash.css file which should be in line with sheet.h */
 
     /* Create the popup button
        It will only be displayed when the cell being edited provides
@@ -574,14 +564,8 @@ gnc_item_edit_new (GnucashSheet *sheet)
     item_edit->popup_toggle.tbutton = gtk_toggle_button_new();
     gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (item_edit->popup_toggle.tbutton), FALSE);
 
-    /* Force padding on the button to
-       1. keep it small
-       2. display as much as possible of the arrow */
-    provider = gtk_css_provider_new();
-    gtk_css_provider_load_from_data (provider, "* { padding: 1px }", -1, NULL);
-    stylecontext = gtk_widget_get_style_context (item_edit->popup_toggle.tbutton);
-    gtk_style_context_add_provider (stylecontext, GTK_STYLE_PROVIDER (provider),
-                                    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    /* Force padding on the button to keep it small and display as much as 
+       possible of the arrow which is done in the gnucash.css file */
 
     /* Wrap the popup button in an event box to give it its own gdkwindow.
      * Without one the button would disappear behind the grid object. */

commit 03dd7ab3991e47c1b0726650dbe9f9c421c7abfc
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Aug 31 13:53:13 2017 +0100

    Remove an obsolete source comment in gnucash-item-list.c

diff --git a/gnucash/register/register-gnome/gnucash-item-list.c b/gnucash/register/register-gnome/gnucash-item-list.c
index 97e6b19..4560d57 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.c
+++ b/gnucash/register/register-gnome/gnucash-item-list.c
@@ -457,8 +457,6 @@ gnc_item_list_new(GtkListStore *list_store)
         g_object_ref(list_store);
     tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
     g_object_unref(list_store);
-    /* Removed code to enable sorting. Enable it after the list is
-     * fully populated by calling gnc_item_list_finished_loading(). */
 
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
     gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),

commit dff337d72f1230c23f92c2d6d7b31f814a1c1b5c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Aug 31 13:52:12 2017 +0100

    Remove white space and change tabs to spaces in datecell-gnome.c

diff --git a/gnucash/register/register-gnome/datecell-gnome.c b/gnucash/register/register-gnome/datecell-gnome.c
index 453022b..20fc6fc 100644
--- a/gnucash/register/register-gnome/datecell-gnome.c
+++ b/gnucash/register/register-gnome/datecell-gnome.c
@@ -97,28 +97,28 @@ check_readonly_threshold (const gchar *datestr, GDate *d)
     if (g_date_compare(d, readonly_threshold) < 0)
     {
 #if 0
-	gchar *dialog_msg = _("The entered date of the new transaction is "
-			      "older than the \"Read-Only Threshold\" set for "
-			      "this book. This setting can be changed in "
-			      "File -> Properties -> Accounts.");
-	gchar *dialog_title = _("Cannot store a transaction at this date");
-	GtkWidget *dialog = gtk_message_dialog_new(NULL,
-						   0,
-						   GTK_MESSAGE_ERROR,
-						   GTK_BUTTONS_OK,
-						   "%s", dialog_title);
-	gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
-						 "%s", dialog_msg);
-	gtk_dialog_run(GTK_DIALOG(dialog));
-	gtk_widget_destroy(dialog);
+    gchar *dialog_msg = _("The entered date of the new transaction is "
+                  "older than the \"Read-Only Threshold\" set for "
+                  "this book. This setting can be changed in "
+                  "File -> Properties -> Accounts.");
+    gchar *dialog_title = _("Cannot store a transaction at this date");
+    GtkWidget *dialog = gtk_message_dialog_new(NULL,
+                           0,
+                           GTK_MESSAGE_ERROR,
+                           GTK_BUTTONS_OK,
+                           "%s", dialog_title);
+    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+                         "%s", dialog_msg);
+    gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_widget_destroy(dialog);
 #endif
-	g_warning("Entered date %s is before the \"auto-read-only threshold\";"
-		  " resetting to the threshold.", datestr);
+    g_warning("Entered date %s is before the \"auto-read-only threshold\";"
+          " resetting to the threshold.", datestr);
 
-	// Reset the date to the threshold date
-	g_date_set_julian (d, g_date_get_julian (readonly_threshold));
-	g_date_free (readonly_threshold);
-	return TRUE;
+    // Reset the date to the threshold date
+    g_date_set_julian (d, g_date_get_julian (readonly_threshold));
+    g_date_free (readonly_threshold);
+    return TRUE;
     }
     g_date_free (readonly_threshold);
     return FALSE;
@@ -138,7 +138,7 @@ gnc_parse_date (struct tm *parsed, const char * datestr)
         // Couldn't parse date, use today
         struct tm tm_today;
 
-	memset (&tm_today, 0, sizeof (struct tm));
+    memset (&tm_today, 0, sizeof (struct tm));
         gnc_tm_get_today_start (&tm_today);
         day = tm_today.tm_mday;
         month = tm_today.tm_mon + 1;
@@ -150,13 +150,13 @@ gnc_parse_date (struct tm *parsed, const char * datestr)
     if (use_autoreadonly)
     {
         GDate *d = g_date_new_dmy(day, month, year);
-	if (check_readonly_threshold (datestr, d))
-	{
-	    day = g_date_get_day (d);
-	    month = g_date_get_month (d);
-	    year = g_date_get_year (d);
-	}
-	g_date_free (d);
+    if (check_readonly_threshold (datestr, d))
+    {
+        day = g_date_get_day (d);
+        month = g_date_get_month (d);
+        year = g_date_get_year (d);
+    }
+    g_date_free (d);
     }
 
     parsed->tm_mday = day;

commit 9382278b5e8e72546fa6c147d3bb2ab673ef0f4b
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Aug 31 13:48:05 2017 +0100

    Rename various forms of Get Popup Height to Popup Get Height
    
    Change GetPopupHeight to PopupGetHeight and get_popup_height to
    popup_get_height to match other related functions.

diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 581f0ec..dde6dec 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -783,7 +783,7 @@ gnc_combo_cell_gui_move (BasicCell *bcell)
 }
 
 static int
-get_popup_height (G_GNUC_UNUSED GtkWidget *widget,
+popup_get_height (G_GNUC_UNUSED GtkWidget *widget,
                   int space_available,
                   int row_height,
                   gpointer user_data)
@@ -851,7 +851,7 @@ gnc_combo_cell_enter (BasicCell *bcell,
 
     gnc_item_edit_set_popup (box->item_edit,
                              GTK_WIDGET(box->item_list),
-                             get_popup_height, popup_autosize,
+                             popup_get_height, popup_autosize,
                              popup_set_focus, popup_post_show,
                              popup_get_width, box);
 
diff --git a/gnucash/register/register-gnome/datecell-gnome.c b/gnucash/register/register-gnome/datecell-gnome.c
index da6677e..453022b 100644
--- a/gnucash/register/register-gnome/datecell-gnome.c
+++ b/gnucash/register/register-gnome/datecell-gnome.c
@@ -632,7 +632,7 @@ gnc_date_cell_move (BasicCell *bcell)
 }
 
 static int
-get_popup_height (GtkWidget *widget,
+popup_get_height (GtkWidget *widget,
                   G_GNUC_UNUSED int space_available,
                   G_GNUC_UNUSED int row_height,
                   G_GNUC_UNUSED gpointer user_data)
@@ -665,7 +665,7 @@ gnc_date_cell_enter (BasicCell *bcell,
     PopBox *box = bcell->gui_private;
 
     gnc_item_edit_set_popup (box->item_edit, GTK_WIDGET (box->date_picker),
-                             get_popup_height, NULL, popup_set_focus,
+                             popup_get_height, NULL, popup_set_focus,
                              NULL, NULL, NULL);
 
     block_picker_signals (cell);
diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index ba249dd..16d86c8 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -171,7 +171,7 @@ gnc_item_edit_init (GncItemEdit *item_edit)
     item_edit->popup_toggle.signals_connected = FALSE;
 
     item_edit->popup_item = NULL;
-    item_edit->get_popup_height = NULL;
+    item_edit->popup_get_height = NULL;
     item_edit->popup_autosize = NULL;
     item_edit->popup_set_focus = NULL;
     item_edit->popup_post_show = NULL;
@@ -654,8 +654,8 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
 
     popup_max_width = view_width - popup_x + x_offset;
 
-    if (item_edit->get_popup_height)
-        popup_h = item_edit->get_popup_height
+    if (item_edit->popup_get_height)
+        popup_h = item_edit->popup_get_height
                        (item_edit->popup_item, popup_h, h,
                         item_edit->popup_user_data);
 
@@ -742,7 +742,7 @@ gnc_item_edit_hide_popup (GncItemEdit *item_edit)
 void
 gnc_item_edit_set_popup (GncItemEdit    *item_edit,
                          GtkWidget      *popup_item,
-                         GetPopupHeight  get_popup_height,
+                         PopupGetHeight  popup_get_height,
                          PopupAutosize   popup_autosize,
                          PopupSetFocus   popup_set_focus,
                          PopupPostShow   popup_post_show,
@@ -757,7 +757,7 @@ gnc_item_edit_set_popup (GncItemEdit    *item_edit,
     item_edit->is_popup = popup_item != NULL;
 
     item_edit->popup_item       = popup_item;
-    item_edit->get_popup_height = get_popup_height;
+    item_edit->popup_get_height = popup_get_height;
     item_edit->popup_autosize   = popup_autosize;
     item_edit->popup_set_focus  = popup_set_focus;
     item_edit->popup_post_show  = popup_post_show;
diff --git a/gnucash/register/register-gnome/gnucash-item-edit.h b/gnucash/register/register-gnome/gnucash-item-edit.h
index d6b7e73..7b8969a 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.h
+++ b/gnucash/register/register-gnome/gnucash-item-edit.h
@@ -38,7 +38,7 @@
 #define GNC_IS_ITEM_EDIT(o)       (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_ITEM_EDIT))
 
 
-typedef int (*GetPopupHeight) (GtkWidget *item,
+typedef int (*PopupGetHeight) (GtkWidget *item,
                                int space_available,
                                int row_height,
                                gpointer user_data);
@@ -79,7 +79,7 @@ typedef struct
 
     PopupToggle popup_toggle;
     GtkWidget *popup_item;
-    GetPopupHeight   get_popup_height;
+    PopupGetHeight   popup_get_height;
     PopupAutosize    popup_autosize;
     PopupSetFocus    popup_set_focus;
     PopupPostShow    popup_post_show;
@@ -110,7 +110,7 @@ GtkWidget *gnc_item_edit_new (GnucashSheet *sheet);
 
 void gnc_item_edit_set_popup (GncItemEdit    *item_edit,
                               GtkWidget      *popup_item,
-                              GetPopupHeight  get_popup_height,
+                              PopupGetHeight  popup_get_height,
                               PopupAutosize   popup_autosize,
                               PopupSetFocus   popup_set_focus,
                               PopupPostShow   popup_post_show,



Summary of changes:
 gnucash/gnome-utils/gnc-dense-cal.c                |   3 +
 gnucash/gnome-utils/ui/gnucash-fallback.css        |  12 +-
 gnucash/gnome-utils/ui/gnucash.css                 |  62 +++++
 gnucash/gnome/gtkbuilder/dialog-invoice.glade      |  42 ++--
 gnucash/register/ledger-core/gncEntryLedgerModel.c |  46 +---
 .../register/ledger-core/split-register-layout.c   |   4 +-
 .../register/ledger-core/split-register-model.c    | 100 ++++----
 gnucash/register/register-core/table-allgui.c      |  49 ++--
 gnucash/register/register-core/table-allgui.h      |  95 ++------
 gnucash/register/register-gnome/combocell-gnome.c  |   4 +-
 gnucash/register/register-gnome/datecell-gnome.c   |  60 ++---
 gnucash/register/register-gnome/gnucash-header.c   |  51 ++--
 .../register/register-gnome/gnucash-item-edit.c    | 179 +++++++++-----
 .../register/register-gnome/gnucash-item-edit.h    |   6 +-
 .../register/register-gnome/gnucash-item-list.c    |   2 -
 gnucash/register/register-gnome/gnucash-register.c |  88 ++++---
 .../register-gnome/gnucash-sheet-private.c         |  90 ++++---
 gnucash/register/register-gnome/gnucash-sheet.c    | 263 +++++++++++----------
 gnucash/register/register-gnome/gnucash-sheet.h    |   3 +-
 gnucash/register/register-gnome/gnucash-sheetP.h   |   6 +-
 gnucash/register/register-gnome/gnucash-style.c    |   2 +-
 21 files changed, 609 insertions(+), 558 deletions(-)



More information about the gnucash-changes mailing list