gnucash master: Bug 647230 - Display the blank split after the "now" line instead of at the end

Geert Janssens gjanssens at code.gnucash.org
Sat Sep 27 06:45:06 EDT 2014


Updated	 via  https://github.com/Gnucash/gnucash/commit/14c93e73 (commit)
	from  https://github.com/Gnucash/gnucash/commit/0b76b52d (commit)



commit 14c93e737c9323a5208c7b79a0122bc670b91ed9
Author: Simon Arlott <sa.me.uk>
Date:   Wed Sep 17 20:18:38 2014 +0100

    Bug 647230 - Display the blank split after the "now" line instead of at the end
    
    In Preferences -> Register:
     Add "Future transactions after blank transaction" option under "Layout"

diff --git a/src/business/business-ledger/gncEntryLedgerLoad.c b/src/business/business-ledger/gncEntryLedgerLoad.c
index adcdba5..eeac11f 100644
--- a/src/business/business-ledger/gncEntryLedgerLoad.c
+++ b/src/business/business-ledger/gncEntryLedgerLoad.c
@@ -529,6 +529,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
     /* get the current time and reset the dividing row */
     table->model->dividing_row_upper = -1;
     table->model->dividing_row = -1;
+    table->model->dividing_row_lower = -1;
     cursor = gnc_table_layout_get_cursor (table->layout, "cursor");
 
     /* Populate the table */
diff --git a/src/core-utils/gnc-prefs.h b/src/core-utils/gnc-prefs.h
index a499ac9..39f212c 100644
--- a/src/core-utils/gnc-prefs.h
+++ b/src/core-utils/gnc-prefs.h
@@ -76,6 +76,7 @@
 #define GNC_PREF_ALT_COLOR_BY_TRANS  "alternate-color-by-transaction"
 #define GNC_PREF_USE_THEME_COLORS    "use-theme-colors"
 #define GNC_PREF_TAB_TRANS_MEMORISED "tab-to-transfer-on-memorised"
+#define GNC_PREF_FUTURE_AFTER_BLANK  "future-after-blank-transaction"
 /* Date preferences */
 #define GNC_PREF_START_CHOICE_ABS    "start-choice-absolute"
 #define GNC_PREF_START_CHOICE_REL    "start-choice-relative"
diff --git a/src/gnome-utils/gtkbuilder/dialog-preferences.glade b/src/gnome-utils/gtkbuilder/dialog-preferences.glade
index 0cc05ef..83772bc 100644
--- a/src/gnome-utils/gtkbuilder/dialog-preferences.glade
+++ b/src/gnome-utils/gtkbuilder/dialog-preferences.glade
@@ -2239,8 +2239,8 @@ many months before the current month:</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="has_tooltip">True</property>
-                    <property name="tooltip_markup">If checked, pressing the &apos;Enter&apos; key will move to the blank transaction at the bottom of the register. If clear, pressing the &apos;Enter&apos; key will move down one row.</property>
-                    <property name="tooltip_text" translatable="yes">If checked, pressing the 'Enter' key will move to the blank transaction at the bottom of the register. If clear, pressing the 'Enter' key will move down one row.</property>
+                    <property name="tooltip_markup">If checked, pressing the &apos;Enter&apos; key will move to the location of the blank transaction in the register. If clear, pressing the &apos;Enter&apos; key will move down one row.</property>
+                    <property name="tooltip_text" translatable="yes">If checked, pressing the 'Enter' key will move to the location of the blank transaction in the register. If clear, pressing the 'Enter' key will move down one row.</property>
                     <property name="use_underline">True</property>
                     <property name="draw_indicator">True</property>
                   </object>
@@ -2422,6 +2422,56 @@ many months before the current month:</property>
                   </packing>
                 </child>
                 <child>
+                  <object class="GtkLabel" id="label46">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">16</property>
+                    <property name="bottom_attach">17</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"/>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label47">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes"><b>Layout</b></property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">17</property>
+                    <property name="bottom_attach">18</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"/>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="pref/general.register/future-after-blank-transaction">
+                    <property name="label" translatable="yes">_Future transactions after blank transaction</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup">If checked, transactions with a date in the future will be displayed at the bottom of the register after the blank transaction. If clear, the blank transaction will be at the bottom of the register after all transactions.</property>
+                    <property name="tooltip_text" translatable="yes">If checked, transactions with a date in the future will be displayed at the bottom of the register after the blank transaction. If clear, the blank transaction will be at the bottom of the register after all transactions.</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">18</property>
+                    <property name="bottom_attach">19</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"/>
+                    <property name="x_padding">12</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkCheckButton" id="pref/general.register/draw-horizontal-lines">
                     <property name="label" translatable="yes">Draw hori_zontal lines between rows</property>
                     <property name="visible">True</property>
diff --git a/src/gnome/gschemas/org.gnucash.gschema.xml.in.in b/src/gnome/gschemas/org.gnucash.gschema.xml.in.in
index 543843a..da62faa 100644
--- a/src/gnome/gschemas/org.gnucash.gschema.xml.in.in
+++ b/src/gnome/gschemas/org.gnucash.gschema.xml.in.in
@@ -250,6 +250,11 @@
       <summary>Show vertical borders in a register</summary>
       <description>Show vertical borders between columns in a register. If active the border between cells will be indicated with a heavy line. Otherwise the border between cells will not be marked.</description>
     </key>
+    <key name="future-after-blank-transaction" type="b">
+      <default>false</default>
+      <summary>Show future transactions after the blank transaction in a register</summary>
+      <description>Show future transactions after the blank transaction in a register. If active then transactions with a date in the future will be displayed at the bottom of the register after the blank transaction. Otherwise the blank transaction will be at the bottom of the register after all transactions.</description>
+    </key>
     <key name="default-style-ledger" type="b">
       <default>true</default>
       <summary>Show all transactions on one line. (Two in double line mode.)</summary>
diff --git a/src/register/ledger-core/split-register-load.c b/src/register/ledger-core/split-register-load.c
index 042fe3e..a29fdbb 100644
--- a/src/register/ledger-core/split-register-load.c
+++ b/src/register/ledger-core/split-register-load.c
@@ -38,6 +38,7 @@
 #include "split-register.h"
 #include "split-register-p.h"
 #include "engine-helpers.h"
+#include "gnc-prefs.h"
 
 
 /* This static indicates the debugging module that this .o belongs to. */
@@ -354,6 +355,9 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
     gboolean dynamic;
     gboolean we_own_slist = FALSE;
     gboolean use_autoreadonly = qof_book_uses_autoreadonly(gnc_get_current_book());
+    gboolean future_after_blank = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
+                                                     GNC_PREF_FUTURE_AFTER_BLANK);
+    gboolean added_blank_trans = FALSE;
 
     VirtualCellLocation vcell_loc;
     VirtualLocation save_loc;
@@ -486,6 +490,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
 
     table->model->dividing_row_upper = -1;
     table->model->dividing_row = -1;
+    table->model->dividing_row_lower = -1;
 
     // Ensure that the transaction and splits being edited are in the split
     // list we're about to load.
@@ -569,6 +574,39 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
         {
             table->model->dividing_row = vcell_loc.virt_row;
             found_divider = TRUE;
+
+            if (future_after_blank)
+            {
+                if (blank_trans == find_trans)
+                    new_trans_row = vcell_loc.virt_row;
+
+                if (blank_split == find_trans_split)
+                    new_trans_split_row = vcell_loc.virt_row;
+
+                /* go to blank on first pass */
+                if (info->first_pass)
+                {
+                    save_loc.vcell_loc = vcell_loc;
+                    save_loc.phys_row_offset = 0;
+                    save_loc.phys_col_offset = 0;
+                }
+
+                gnc_split_register_add_transaction (reg,
+                                            blank_trans, blank_split,
+                                            lead_cursor, split_cursor,
+                                            multi_line, start_primary_color,
+                                            info->blank_split_edited,
+                                            find_trans, find_split,
+                                            find_class, &new_split_row,
+                                            &vcell_loc);
+
+                table->model->dividing_row_lower = vcell_loc.virt_row;
+
+                if (!multi_line)
+                    start_primary_color = !start_primary_color;
+
+                added_blank_trans = TRUE;
+            }
         }
 
         /* If this is the first load of the register,
@@ -609,12 +647,6 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
         found_divider_upper = TRUE;
     }
 
-    if (blank_trans == find_trans)
-        new_trans_row = vcell_loc.virt_row;
-
-    if (blank_split == find_trans_split)
-        new_trans_split_row = vcell_loc.virt_row;
-
     /* If we didn't find the pending transaction, it was removed
      * from the account. */
     if (!found_pending)
@@ -628,25 +660,41 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
         pending_trans = NULL;
     }
 
+    if (!added_blank_trans) {
+        if (blank_trans == find_trans)
+            new_trans_row = vcell_loc.virt_row;
+
+        if (blank_split == find_trans_split)
+            new_trans_split_row = vcell_loc.virt_row;
+
+        /* go to blank on first pass */
+        if (info->first_pass)
+        {
+            save_loc.vcell_loc = vcell_loc;
+            save_loc.phys_row_offset = 0;
+            save_loc.phys_col_offset = 0;
+        }
+
+        gnc_split_register_add_transaction (reg, blank_trans, blank_split,
+                                            lead_cursor, split_cursor,
+                                            multi_line, start_primary_color,
+                                            info->blank_split_edited,
+                                            find_trans, find_split,
+                                            find_class, &new_split_row,
+                                            &vcell_loc);
+
+        if (future_after_blank)
+            table->model->dividing_row_lower = vcell_loc.virt_row;
+    }
+
     /* go to blank on first pass */
     if (info->first_pass)
     {
         new_split_row = -1;
         new_trans_split_row = -1;
         new_trans_row = -1;
-
-        save_loc.vcell_loc = vcell_loc;
-        save_loc.phys_row_offset = 0;
-        save_loc.phys_col_offset = 0;
     }
 
-    gnc_split_register_add_transaction (reg, blank_trans, blank_split,
-                                        lead_cursor, split_cursor,
-                                        multi_line, start_primary_color,
-                                        info->blank_split_edited, find_trans,
-                                        find_split, find_class, &new_split_row,
-                                        &vcell_loc);
-
     /* resize the table to the sizes we just counted above */
     /* num_virt_cols is always one. */
     gnc_table_set_size (table, vcell_loc.virt_row, 1);
diff --git a/src/register/register-core/table-model.c b/src/register/register-core/table-model.c
index 81f5e7e..19f3ad0 100644
--- a/src/register/register-core/table-model.c
+++ b/src/register/register-core/table-model.c
@@ -143,6 +143,7 @@ gnc_table_model_new (void)
     model->read_only = FALSE;
     model->dividing_row_upper = -1;
     model->dividing_row = -1;
+    model->dividing_row_lower = -1;
 
     return model;
 }
diff --git a/src/register/register-core/table-model.h b/src/register/register-core/table-model.h
index b36d930..741fa9d 100644
--- a/src/register/register-core/table-model.h
+++ b/src/register/register-core/table-model.h
@@ -122,8 +122,11 @@ typedef struct
      * be visually distinguished. */
     int dividing_row;
     /* If positive, denotes a row that marks a boundary that should
-     * be visually distinguished, but different from the other. */
+     * be visually distinguished, but different from the others. */
     int dividing_row_upper;
+    /* If positive, denotes a row that marks a boundary that should
+     * be visually distinguished. */
+    int dividing_row_lower;
 
     VirtCellDataAllocator cell_data_allocator;
     VirtCellDataDeallocator cell_data_deallocator;
diff --git a/src/register/register-gnome/gnucash-grid.c b/src/register/register-gnome/gnucash-grid.c
index f032a9c..412cc08 100644
--- a/src/register/register-gnome/gnucash-grid.c
+++ b/src/register/register-gnome/gnucash-grid.c
@@ -568,7 +568,7 @@ draw_cell (GnucashGrid *grid,
         }
     }
 
-    /* dividing line lower (blue) */
+    /* dividing line (blue) */
     if ((virt_loc.phys_row_offset == 0) &&
             (table->model->dividing_row >= 0))
     {
@@ -597,6 +597,35 @@ draw_cell (GnucashGrid *grid,
         }
     }
 
+    /* dividing line lower (blue) */
+    if ((virt_loc.phys_row_offset == 0) &&
+            (table->model->dividing_row_lower >= 0))
+    {
+        if (virt_loc.vcell_loc.virt_row == table->model->dividing_row_lower)
+        {
+            gdk_gc_set_foreground (grid->gc, &gn_blue);
+            gdk_draw_line (drawable, grid->gc, x, y - 1, x + width, y - 1);
+            gdk_draw_line (drawable, grid->gc, x, y,   x + width, y);
+            gdk_draw_line (drawable, grid->gc, x, y + 1, x + width, y + 1);
+        }
+    }
+
+    if ((virt_loc.phys_row_offset == (block->style->nrows - 1)) &&
+            (table->model->dividing_row_lower >= 0))
+    {
+        if (virt_loc.vcell_loc.virt_row ==
+                (table->model->dividing_row_lower - 1))
+        {
+            gdk_gc_set_foreground (grid->gc, &gn_blue);
+            gdk_draw_line (drawable, grid->gc, x, y + height - 1,
+                           x + width, y + height - 1);
+            gdk_draw_line (drawable, grid->gc, x, y + height,
+                           x + width, y + height);
+            gdk_draw_line (drawable, grid->gc, x, y + height + 1,
+                           x + width, y + height + 1);
+        }
+    }
+
     text = gnc_table_get_entry (table, virt_loc);
 
     layout = gtk_widget_create_pango_layout (GTK_WIDGET (grid->sheet), text);



Summary of changes:
 src/business/business-ledger/gncEntryLedgerLoad.c  |  1 +
 src/core-utils/gnc-prefs.h                         |  1 +
 .../gtkbuilder/dialog-preferences.glade            | 54 +++++++++++++-
 src/gnome/gschemas/org.gnucash.gschema.xml.in.in   |  5 ++
 src/register/ledger-core/split-register-load.c     | 82 +++++++++++++++++-----
 src/register/register-core/table-model.c           |  1 +
 src/register/register-core/table-model.h           |  5 +-
 src/register/register-gnome/gnucash-grid.c         | 31 +++++++-
 8 files changed, 159 insertions(+), 21 deletions(-)



More information about the gnucash-changes mailing list