r22815 - gnucash/trunk - Register rewrite Update.

Geert Janssens gjanssens at code.gnucash.org
Thu Feb 28 04:52:13 EST 2013


Author: gjanssens
Date: 2013-02-28 04:52:12 -0500 (Thu, 28 Feb 2013)
New Revision: 22815
Trac: http://svn.gnucash.org/trac/changeset/22815

Added:
   gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.c
   gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.h
Modified:
   gnucash/trunk/po/POTFILES.in
   gnucash/trunk/src/engine/Split.c
   gnucash/trunk/src/engine/Split.h
   gnucash/trunk/src/engine/Transaction.c
   gnucash/trunk/src/engine/Transaction.h
   gnucash/trunk/src/gnome-utils/Makefile.am
   gnucash/trunk/src/gnome-utils/dialog-transfer.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.h
   gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.h
   gnucash/trunk/src/gnome-utils/gnc-tree-view.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view.h
   gnucash/trunk/src/gnome/gnc-plugin-page-register2.c
   gnucash/trunk/src/gnome/gnc-plugin-page-register2.h
   gnucash/trunk/src/gnome/gnc-split-reg2.c
   gnucash/trunk/src/gnome/gnc-split-reg2.h
   gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.c
   gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.h
Log:
Register rewrite Update.

The main things in this patch is I think the model is working correctly now,
you can add, change and delete same currency transactions along with different
currencies asking for exchange rates and also share accounts.

Other changes:
- use the default GTK_TREE_VIEW sort mechanism.
- Added cut, copy & paste
- Added right-click context menu.

Author: Robert Fewell Register rewrite Update.

Modified: gnucash/trunk/po/POTFILES.in
===================================================================
--- gnucash/trunk/po/POTFILES.in	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/po/POTFILES.in	2013-02-28 09:52:12 UTC (rev 22815)
@@ -312,6 +312,7 @@
 src/gnome-utils/gnc-splash.c
 src/gnome-utils/gnc-sx-instance-dense-cal-adapter.c
 src/gnome-utils/gnc-sx-list-tree-model-adapter.c
+src/gnome-utils/gnc-tree-control-split-reg.c
 src/gnome-utils/gnc-tree-model-account.c
 src/gnome-utils/gnc-tree-model-account-types.c
 src/gnome-utils/gnc-tree-model-budget.c

Modified: gnucash/trunk/src/engine/Split.c
===================================================================
--- gnucash/trunk/src/engine/Split.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/engine/Split.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -432,6 +432,39 @@
     return split;
 }
 
+
+/*################## Added for Reg2 #################*/
+
+/* This is really a helper for xaccTransCopyOnto. It doesn't reparent
+   the 'to' split to from's transaction, because xaccTransCopyOnto is
+   responsible for parenting the split to the correct transaction.
+   Also, from's parent transaction may not even be a valid
+   transaction, so this function may not modify anything about 'from'
+   or from's transaction.
+*/
+void
+xaccSplitCopyOnto(const Split *from_split, Split *to_split)
+{
+   if (!from_split || !to_split) return;
+   xaccTransBeginEdit (to_split->parent);
+
+   xaccSplitSetMemo(to_split, xaccSplitGetMemo(from_split));
+   xaccSplitSetAction(to_split, xaccSplitGetAction(from_split));
+   xaccSplitSetAmount(to_split, xaccSplitGetAmount(from_split));
+   xaccSplitSetValue(to_split, xaccSplitGetValue(from_split));
+   /* Setting the account is okay here because, even though the from
+      split might not really belong to the account it claims to,
+      setting the account won't cause any event involving from. */
+   xaccSplitSetAccount(to_split, xaccSplitGetAccount(from_split));
+   /* N.B. Don't set parent. */
+
+   qof_instance_set_dirty(QOF_INSTANCE(to_split));
+   xaccTransCommitEdit(to_split->parent);
+}
+
+/*################## Added for Reg2 #################*/
+
+
 #ifdef DUMP_FUNCTIONS
 void
 xaccSplitDump (const Split *split, const char *tag)

Modified: gnucash/trunk/src/engine/Split.h
===================================================================
--- gnucash/trunk/src/engine/Split.h	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/engine/Split.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -113,6 +113,17 @@
  */
 gboolean      xaccSplitDestroy (Split *split);
 
+/*################## Added for Reg2 #################*/
+/** This is really a helper for xaccTransCopyOnto. It doesn't reparent
+ *   the 'to' split to from's transaction, because xaccTransCopyOnto is
+ *   responsible for parenting the split to the correct transaction.
+ *   Also, from's parent transaction may not even be a valid
+ *   transaction, so this function may not modify anything about 'from'
+ *   or from's transaction.
+ */
+void xaccSplitCopyOnto(const Split *from_split, Split *to_split);
+/*################## Added for Reg2 #################*/
+
 /** Returns the book of this split, i.e. the entity where this split
  * is stored. */
 QofBook *   xaccSplitGetBook (const Split *split);

Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/engine/Transaction.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -564,10 +564,10 @@
     return to;
 }
 
-/*
+/********************************************************************\
  * Use this routine to externally duplicate a transaction.  It creates
  * a full fledged transaction with unique guid, splits, etc.
- */
+\********************************************************************/
 Transaction *
 xaccTransClone (const Transaction *from)
 {
@@ -606,10 +606,90 @@
     return to;
 }
 
+/*################## Added for Reg2 #################*/
 
 /********************************************************************\
+ * Copy a transaction to the 'clipboard' transaction using
+ *  xaccDupeTransaction. The 'clipboard' transaction must never
+ *  be dereferenced.
 \********************************************************************/
+Transaction * xaccTransCopyToClipBoard(const Transaction *from_trans)
+{
+    Transaction *to_trans;
 
+    if (!from_trans)
+        return NULL;
+
+    to_trans = xaccDupeTransaction(from_trans);
+    return to_trans;
+}
+
+/********************************************************************\
+ * Copy a transaction to another using the function below without
+ *  changing any account information.
+\********************************************************************/
+void
+xaccTransCopyOnto(const Transaction *from_trans, Transaction *to_trans)
+{
+    xaccTransCopyFromClipBoard(from_trans, to_trans, NULL, NULL);
+}
+
+/********************************************************************\
+ * This function explicitly must robustly handle some unusual input.
+ *
+ *  'from_trans' may be a duped trans (see xaccDupeTransaction), so its
+ *   splits may not really belong to the accounts that they say they do.
+ *
+ *  'from_acc' need not be a valid account. It may be an already freed
+ *   Account. Therefore, it must not be dereferenced at all.
+ *
+ *   Neither 'from_trans', nor 'from_acc', nor any of 'from's splits may be modified
+ *   in any way.
+ *
+ *   The 'to_trans' transaction will end up with valid copies of from's
+ *   splits.  In addition, the copies of any of from's splits that were
+ *   in from_acc (or at least claimed to be) will end up in to_acc.
+\********************************************************************/
+void
+xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
+                           const Account *from_acc, Account *to_acc)
+{
+    Timespec ts = {0,0};
+    gboolean change_accounts = FALSE;
+    GList *node;
+
+    if (!from_trans || !to_trans)
+        return;
+
+    change_accounts = from_acc && GNC_IS_ACCOUNT(to_acc) && from_acc != to_acc;
+    xaccTransBeginEdit(to_trans);
+
+    FOR_EACH_SPLIT(to_trans, xaccSplitDestroy(s));
+
+    xaccTransSetCurrency(to_trans, xaccTransGetCurrency(from_trans));
+    xaccTransSetDescription(to_trans, xaccTransGetDescription(from_trans));
+    xaccTransSetNum(to_trans, xaccTransGetNum(from_trans));
+    xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans));
+    xaccTransGetDatePostedTS(from_trans, &ts);
+    xaccTransSetDatePostedTS(to_trans, &ts);
+
+    /* Each new split will be parented to 'to' */
+    for (node = from_trans->splits; node; node = node->next)
+    {
+        Split *new_split = xaccMallocSplit( qof_instance_get_book(QOF_INSTANCE(from_trans)));
+        xaccSplitCopyOnto(node->data, new_split);
+        if (change_accounts && xaccSplitGetAccount(node->data) == from_acc)
+            xaccSplitSetAccount(new_split, to_acc);
+        xaccSplitSetParent(new_split, to_trans);
+    }
+    xaccTransCommitEdit(to_trans);
+}
+
+/*################## Added for Reg2 #################*/
+
+/********************************************************************\
+ Free the transaction.
+\********************************************************************/
 static void
 xaccFreeTransaction (Transaction *trans)
 {
@@ -1021,36 +1101,42 @@
 gboolean
 xaccTransGetRateForCommodity(const Transaction *trans,
                              const gnc_commodity *split_com,
-                             const Split *split_to_exclude, gnc_numeric *rate)
+                             const Split *split, gnc_numeric *rate)
 {
     GList *splits;
     gnc_commodity *trans_curr;
 
-    trans_curr = xaccTransGetCurrency(trans);
-    if (gnc_commodity_equal(trans_curr, split_com)) {
+    trans_curr = xaccTransGetCurrency (trans);
+    if (gnc_commodity_equal (trans_curr, split_com))
+    {
         if (rate) 
-            *rate = gnc_numeric_create(1, 1);
+            *rate = gnc_numeric_create (1, 1);
         return TRUE;
     }
 
-    for (splits = trans->splits; splits; splits = splits->next) {
+    for (splits = trans->splits; splits; splits = splits->next)
+    {
         Split *s = splits->data;
         gnc_commodity *comm;
 
-        if (s == split_to_exclude) continue;
-        if (!xaccTransStillHasSplit(trans, s)) continue;
+        if (!xaccTransStillHasSplit (trans, s)) continue;
 
-        comm = xaccAccountGetCommodity(xaccSplitGetAccount(s));
-        if (gnc_commodity_equal(split_com, comm)) {
-            gnc_numeric amt = xaccSplitGetAmount(s);
-            gnc_numeric val = xaccSplitGetValue(s);
+        if (s == split)
+        {
+            comm = xaccAccountGetCommodity (xaccSplitGetAccount(s));
+            if (gnc_commodity_equal (split_com, comm))
+            {
+                gnc_numeric amt = xaccSplitGetAmount (s);
+                gnc_numeric val = xaccSplitGetValue (s);
 
-            if (!gnc_numeric_zero_p(xaccSplitGetValue(s)) &&
-                !gnc_numeric_zero_p(xaccSplitGetValue(s))) {
-                if (rate) 
-                    *rate = gnc_numeric_div(amt, val, GNC_DENOM_AUTO,
-                                            GNC_HOW_DENOM_REDUCE);
-                return TRUE;
+                if (!gnc_numeric_zero_p (xaccSplitGetAmount (s)) &&
+                    !gnc_numeric_zero_p (xaccSplitGetValue (s)))
+                {
+                    if (rate)
+                        *rate = gnc_numeric_div (amt, val, GNC_DENOM_AUTO,
+                                                GNC_HOW_DENOM_REDUCE);
+                    return TRUE;
+                }
             }
         }
     }
@@ -1983,6 +2069,14 @@
     return trans ? trans->date_posted.tv_sec : 0;
 }
 
+/*################## Added for Reg2 #################*/
+time64
+xaccTransGetDateEntered (const Transaction *trans)
+{
+    return trans ? trans->date_entered.tv_sec : 0;
+}
+/*################## Added for Reg2 #################*/
+
 void
 xaccTransGetDatePostedTS (const Transaction *trans, Timespec *ts)
 {

Modified: gnucash/trunk/src/engine/Transaction.h
===================================================================
--- gnucash/trunk/src/engine/Transaction.h	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/engine/Transaction.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -220,6 +220,40 @@
 Transaction * xaccTransLookup (const GncGUID *guid, QofBook *book);
 #define xaccTransLookupDirect(g,b) xaccTransLookup(&(g),b)
 
+/*################## Added for Reg2 #################*/
+
+/** Copy a transaction to the 'clipboard' transaction using
+ *  xaccDupeTransaction. The 'clipboard' transaction must never
+ *  be dereferenced.
+ */
+Transaction * xaccTransCopyToClipBoard(const Transaction *from_trans);
+
+/** Copy a transaction to another using the function below without
+ *  changing any account information.
+ */
+void xaccTransCopyOnto(const Transaction *from_trans, Transaction *to_trans);
+
+/** This function explicitly must robustly handle some unusual input.
+ *
+ *  'from_trans' may be a duped trans (see xaccDupeTransaction), so its
+ *   splits may not really belong to the accounts that they say they do.
+ *
+ *  'from_acc' need not be a valid account. It may be an already freed
+ *   Account. Therefore, it must not be dereferenced at all.
+ *
+ *   Neither 'from_trans', nor 'from_acc', nor any of 'from's splits may be modified
+ *   in any way.
+ *
+ *   The 'to_trans' transaction will end up with valid copies of from's
+ *   splits.  In addition, the copies of any of from's splits that were
+ *   in from_acc (or at least claimed to be) will end up in to_acc.
+ */
+void xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
+                           const Account *from_acc, Account *to_acc);
+
+/*################## Added for Reg2 #################*/
+
+
 Split * xaccTransFindSplitByAccount(const Transaction *trans,
                                     const Account *acc);
 
@@ -560,8 +594,13 @@
     the date when this transaction was posted at the bank. */
 GDate      xaccTransGetDatePostedGDate (const Transaction *trans);
 
+/*################## Added for Reg2 #################*/
 /** Retrieve the date of when the transaction was entered. The entered
  * date is the date when the register entry was made.*/
+time64        xaccTransGetDateEntered (const Transaction *trans);
+/*################## Added for Reg2 #################*/
+/** Retrieve the date of when the transaction was entered. The entered
+ * date is the date when the register entry was made.*/
 void          xaccTransGetDateEnteredTS (const Transaction *trans, Timespec *ts);
 /** Retrieve the date of when the transaction was entered. The entered
  * date is the date when the register entry was made.*/

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register2.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register2.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register2.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * gnc-plugin-page-register2.c -- register page functions              *
+ * gnc-plugin-page-register2.c -- register page functions             *
  *                                                                    *
  * Copyright (C) 2003 Jan Arne Petersen <jpetersen at uni-bonn.de>       *
  * Copyright (C) 2003,2005,2006 David Hampton <hampton at employees.org> *
@@ -49,6 +49,7 @@
 #include "gnc-tree-view.h"
 #include "gnc-tree-view-split-reg.h"
 #include "gnc-tree-model-split-reg.h"
+#include "gnc-tree-control-split-reg.h"
 
 #include "dialog-account.h"
 #include "dialog-find-transactions.h"
@@ -97,28 +98,30 @@
 static void gnc_plugin_page_register2_update_edit_menu (GncPluginPage *page, gboolean hide);
 static gboolean gnc_plugin_page_register2_finish_pending (GncPluginPage *page);
 
+static gboolean gnc_plugin_page_register2_button_press_cb (GtkWidget *widget, GdkEventButton *event, GncPluginPage *page);
+
 static gchar *gnc_plugin_page_register2_get_tab_name (GncPluginPage *plugin_page);
 static gchar *gnc_plugin_page_register2_get_tab_color (GncPluginPage *plugin_page);
 static gchar *gnc_plugin_page_register2_get_long_name (GncPluginPage *plugin_page);
 
-static void gnc_plugin_page_register2_summarybar_position_changed(GConfEntry *entry, gpointer user_data);
+static void gnc_plugin_page_register2_summarybar_position_changed (GConfEntry *entry, gpointer user_data);
 
 /* Callbacks for the "Sort By" dialog */
-void gnc_plugin_page_register2_sort_button_cb(GtkToggleButton *button, GncPluginPageRegister2 *page);
-void gnc_plugin_page_register2_sort_response_cb(GtkDialog *dialog, gint response, GncPluginPageRegister2 *plugin_page);
-void gnc_plugin_page_register2_sort_order_save_cb(GtkToggleButton *button, GncPluginPageRegister2 *page);
+void gnc_plugin_page_register2_sort_button_cb (GtkToggleButton *button, GncPluginPageRegister2 *page);
+void gnc_plugin_page_register2_sort_response_cb (GtkDialog *dialog, gint response, GncPluginPageRegister2 *plugin_page);
+void gnc_plugin_page_register2_sort_order_save_cb (GtkToggleButton *button, GncPluginPageRegister2 *page);
 
 static gchar *gnc_plugin_page_register2_get_sort_order (GncPluginPage *plugin_page);
 void gnc_plugin_page_register2_set_sort_order (GncPluginPage *plugin_page, const gchar *sort_order);
 
 /* Callbacks for the "Filter By" dialog */
-void gnc_plugin_page_register2_filter_select_range_cb(GtkRadioButton *button, GncPluginPageRegister2 *page);
-void gnc_plugin_page_register2_filter_start_cb(GtkWidget *radio, GncPluginPageRegister2 *page);
-void gnc_plugin_page_register2_filter_end_cb(GtkWidget *radio, GncPluginPageRegister2 *page);
-void gnc_plugin_page_register2_filter_response_cb(GtkDialog *dialog, gint response, GncPluginPageRegister2 *plugin_page);
-void gnc_plugin_page_register2_filter_status_all_cb(GtkButton *button, GncPluginPageRegister2 *plugin_page);
-void gnc_plugin_page_register2_filter_status_one_cb(GtkToggleButton *button, GncPluginPageRegister2 *page);
-void gnc_plugin_page_register2_filter_save_cb(GtkToggleButton *button, GncPluginPageRegister2 *page);
+void gnc_plugin_page_register2_filter_select_range_cb (GtkRadioButton *button, GncPluginPageRegister2 *page);
+void gnc_plugin_page_register2_filter_start_cb (GtkWidget *radio, GncPluginPageRegister2 *page);
+void gnc_plugin_page_register2_filter_end_cb (GtkWidget *radio, GncPluginPageRegister2 *page);
+void gnc_plugin_page_register2_filter_response_cb (GtkDialog *dialog, gint response, GncPluginPageRegister2 *plugin_page);
+void gnc_plugin_page_register2_filter_status_all_cb (GtkButton *button, GncPluginPageRegister2 *plugin_page);
+void gnc_plugin_page_register2_filter_status_one_cb (GtkToggleButton *button, GncPluginPageRegister2 *page);
+void gnc_plugin_page_register2_filter_save_cb (GtkToggleButton *button, GncPluginPageRegister2 *page);
 
 static time64 gnc_plugin_page_register2_filter_dmy2time (char *date_string);
 static gchar *gnc_plugin_page_register2_filter_time2dmy (time64 raw_time);
@@ -167,7 +170,7 @@
 static void gnc_plugin_page_register2_cmd_account_report (GtkAction *action, GncPluginPageRegister2 *plugin_page);
 static void gnc_plugin_page_register2_cmd_transaction_report (GtkAction *action, GncPluginPageRegister2 *plugin_page);
 
-static void gnc_plugin_page_help_changed_cb( GNCSplitReg2 *gsr, GncPluginPageRegister2 *register_page );
+static void gnc_plugin_page_help_changed_cb (GNCSplitReg2 *gsr, GncPluginPageRegister2 *register_page );
 static void gnc_plugin_page_register2_refresh_cb (GHashTable *changes, gpointer user_data);
 static void gnc_plugin_page_register2_close_cb (gpointer user_data);
 
@@ -237,8 +240,8 @@
         G_CALLBACK (gnc_plugin_page_register2_cmd_paste_transaction)
     },
     {
-        "DuplicateTransactionAction", GTK_STOCK_COPY, N_("Dup_licate Transaction"), "",
-        N_("Make a copy of the current transaction"),
+        "DuplicateTransactionAction", GTK_STOCK_COPY, N_("Dup_licate Selection"), "",
+        N_("Make a copy of the current selected item"),
         G_CALLBACK (gnc_plugin_page_register2_cmd_duplicate_transaction)
     },
     {
@@ -570,8 +573,6 @@
     QofQuery *q;
     Account *account;
 
-//g_print("Register New Common\n");
-
     /* Is there an existing page? */
     gsr = gnc_ledger_display2_get_user_data (ledger);
     if (gsr)
@@ -613,10 +614,9 @@
     priv->component_manager_id = 0;
     return plugin_page;
 }
+
 /*#################################################################################*/
 
-
-
 GncPluginPage *
 gnc_plugin_page_register2_new (Account *account, gboolean subaccounts)
 {
@@ -728,7 +728,7 @@
 {
     GncPluginPageRegister2 *page;
     GncPluginPageRegister2Private *priv;
-//g_print("gnc_plugin_page_register2_finalize\n");
+
     g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (object));
 
     ENTER("object %p", object);
@@ -781,7 +781,7 @@
 };
 
 static void
-gnc_plugin_page_register2_ui_update (gpointer various, GncPluginPageRegister2 *page) /* Working */
+gnc_plugin_page_register2_ui_update (gpointer various, GncPluginPageRegister2 *page) // this works
 {
     GncPluginPageRegister2Private *priv;
     GncTreeViewSplitReg *view;
@@ -790,14 +790,12 @@
     gboolean expanded, voided;
     Transaction *trans;
 
-//g_print("gnc_plugin_page_register2_ui_update\n");
-
     /* Set 'Split Transaction' */
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
     model = gnc_ledger_display2_get_split_model_register (priv->ledger);
     view = gnc_ledger_display2_get_split_view_register (priv->ledger);
 
-    expanded = gnc_tree_view_split_reg_current_trans_expanded (view);
+    expanded = gnc_tree_view_split_reg_trans_expanded (view, NULL);
 
     action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page),
                                          "SplitTransactionAction");
@@ -835,7 +833,7 @@
 }
 
 static void
-gnc_plugin_page_register2_ui_initial_state (GncPluginPageRegister2 *page)
+gnc_plugin_page_register2_ui_initial_state (GncPluginPageRegister2 *page) // this works
 {
     GncPluginPageRegister2Private *priv ;
     GtkActionGroup *action_group;
@@ -898,14 +896,13 @@
     guint numRows;
     GtkWidget *gsr;
 
+    GncTreeViewSplitReg *view;
     GncTreeModelSplitReg *model;
     Account *acct;
     gchar **filter;
     gchar *order;
     int filter_changed = 0;
 
-g_print("Register New Create\n");
-
     ENTER("page %p", plugin_page);
     page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
@@ -914,7 +911,7 @@
         LEAVE("existing widget %p", priv->widget);
         return priv->widget;
     }
-g_print("Register New Create - page %p\n", page);
+
     priv->widget = gtk_vbox_new (FALSE, 0);
     gtk_widget_show (priv->widget);
 
@@ -935,6 +932,12 @@
                       G_CALLBACK ( gnc_plugin_page_help_changed_cb ),
                       page );
 
+    view = gnc_split_reg2_get_register (priv->gsr);
+
+    // Callback for right mouse events
+    g_signal_connect (G_OBJECT (GTK_TREE_VIEW (view)), "button-press-event",
+                      G_CALLBACK (gnc_plugin_page_register2_button_press_cb), page);
+
     model = gnc_ledger_display2_get_split_model_register (priv->ledger);
 
     gnc_tree_model_split_reg_config (model, model->type, model->style, model->use_double_line);
@@ -949,11 +952,11 @@
     {
         /* Set the sort order for the split register and status of save order button */
         priv->sd.save_order = FALSE;
-        order = gnc_plugin_page_register2_get_sort_order(plugin_page);
+        order = gnc_plugin_page_register2_get_sort_order (plugin_page);
 
         PINFO("Loaded Sort order is %s", order);
 
-        gnc_split_reg2_set_sort_type(priv->gsr, SortTypefromString(order));
+        gnc_split_reg2_set_sort_type (priv->gsr, SortTypefromString (order));
 
         if (order && (g_strcmp0 (order, DEFAULT_SORT_ORDER) != 0))
             priv->sd.save_order = TRUE;
@@ -964,11 +967,11 @@
         /* Set the filter for the split register and status of save filter button */
         priv->fd.save_filter = FALSE;
 
-        filter = g_strsplit(gnc_plugin_page_register2_get_filter(plugin_page), ",", -1);
+        filter = g_strsplit(gnc_plugin_page_register2_get_filter (plugin_page), ",", -1);
 
         PINFO("Loaded Filter Status is %s", filter[0]);
 
-        priv->fd.cleared_match = (gint)g_ascii_strtoll( filter[0], NULL, 16 );
+        priv->fd.cleared_match = (gint)g_ascii_strtoll (filter[0], NULL, 16 );
 
         if (filter[0] && (g_strcmp0 (filter[0], DEFAULT_FILTER) != 0))
             filter_changed = filter_changed + 1;
@@ -977,16 +980,16 @@
         {
             PINFO("Loaded Filter Start Date is %s", filter[1]);
 
-            priv->fd.start_time = gnc_plugin_page_register2_filter_dmy2time ( filter[1] );
-            priv->fd.start_time = gnc_time64_get_day_start(priv->fd.start_time);
+            priv->fd.start_time = gnc_plugin_page_register2_filter_dmy2time (filter[1]);
+            priv->fd.start_time = gnc_time64_get_day_start (priv->fd.start_time);
             filter_changed = filter_changed + 1;
 
             if (filter[2] && (g_strcmp0 (filter[2], "0") != 0 ))
             {
                 PINFO("Loaded Filter End Date is %s", filter[2]);
 
-                priv->fd.end_time = gnc_plugin_page_register2_filter_dmy2time ( filter[2] );
-                priv->fd.end_time = gnc_time64_get_day_end(priv->fd.end_time);
+                priv->fd.end_time = gnc_plugin_page_register2_filter_dmy2time (filter[2]);
+                priv->fd.end_time = gnc_time64_get_day_end (priv->fd.end_time);
                 filter_changed = filter_changed + 1;
             }
         }
@@ -995,7 +998,7 @@
             priv->fd.save_filter = TRUE;
 
         priv->fd.original_save_filter = priv->fd.save_filter;
-        g_strfreev(filter);
+        g_strfreev (filter);
 
         /* Update Query with Filter Status and Dates */
         gnc_ppr_update_status_query (page, FALSE);
@@ -1038,11 +1041,34 @@
     LEAVE(" ");
     return priv->widget;
 }
+
 /*#################################################################################*/
 
+/** This button press handler calls the common button press handler
+ *  for all pages.  The GtkTreeView eats all button presses and
+ *  doesn't pass them up the widget tree, even when doesn't do
+ *  anything with them.  The only way to get access to the button
+ *  presses in an account tree page is here on the tree view widget.
+ *  Button presses on all other pages are caught by the signal
+ *  registered in gnc-main-window.c. */
+static gboolean
+gnc_plugin_page_register2_button_press_cb (GtkWidget *widget,
+        GdkEventButton *event,
+        GncPluginPage *page)
+{
 
+    g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
 
+    ENTER("widget %p, event %p, page %p", widget, event, page);
+    gnc_main_window_button_press_cb (widget, event, page);
+    LEAVE(" ");
 
+    /* Always return FALSE.  This will let the tree view callback run as
+     * well which will select the item under the cursor.  By the time
+     * the user sees the menu both callbacks will have run and the menu
+     * actions will operate on the just-selected account. */
+    return FALSE;
+}
 
 static void
 gnc_plugin_page_register2_destroy_widget (GncPluginPage *plugin_page)
@@ -1053,7 +1079,7 @@
     ENTER("page %p", plugin_page);
     page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-//g_print("gnc_plugin_page_register2_destroy_widget\n");
+
     gnc_gconf_general_remove_cb (KEY_SUMMARYBAR_POSITION,
                                 gnc_plugin_page_register2_summarybar_position_changed, page);
 
@@ -1086,20 +1112,23 @@
 
     gtk_widget_hide (priv->widget);
 
+    if (priv->ledger)
+    {
+        gnc_ledger_display2_close (priv->ledger);
+        priv->ledger = NULL;
+    }
+
     if (priv->widget)
     {
         g_object_unref (G_OBJECT(priv->widget));
         priv->widget = NULL;
     }
-
-    gnc_ledger_display2_close (priv->ledger);
-    priv->ledger = NULL;
     LEAVE(" ");
 }
 
 static void
 gnc_plugin_page_register2_window_changed (GncPluginPage *plugin_page,
-        GtkWidget *window)
+        GtkWidget *window) // this works
 {
     GncPluginPageRegister2 *page;
     GncPluginPageRegister2Private *priv;
@@ -1109,9 +1138,8 @@
     page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
 
-/*    priv->gsr->window =
+    priv->gsr->window =
         GTK_WIDGET(gnc_window_get_gtk_window (GNC_WINDOW (window)));
-*/
 }
 
 static const gchar *style_names[] =
@@ -1155,18 +1183,18 @@
     GncTreeModelSplitReg *model;
     Account *leader;
 
-    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
     g_return_if_fail (key_file != NULL);
     g_return_if_fail (group_name != NULL);
 
     ENTER("page %p, key_file %p, group_name %s", plugin_page, key_file,
           group_name);
 
-    page = GNC_PLUGIN_PAGE_REGISTER2(plugin_page);
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
+    page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
 
-    model = gnc_ledger_display2_get_split_model_register(priv->ledger);
-    ledger_type = gnc_ledger_display2_type(priv->ledger);
+    model = gnc_ledger_display2_get_split_model_register (priv->ledger);
+    ledger_type = gnc_ledger_display2_type (priv->ledger);
     if (ledger_type > LD2_GL)
     {
         LEAVE("Unsupported ledger type");
@@ -1177,20 +1205,20 @@
         const gchar *label;
         gchar* name;
         label = (ledger_type == LD2_SINGLE) ? LABEL_ACCOUNT : LABEL_SUBACCOUNT;
-        leader = gnc_ledger_display2_leader(priv->ledger);
-        g_key_file_set_string(key_file, group_name, KEY_REGISTER_TYPE, label);
-        name = gnc_account_get_full_name(leader);
-        g_key_file_set_string(key_file, group_name, KEY_ACCOUNT_NAME, name);
-        g_free(name);
+        leader = gnc_ledger_display2_leader (priv->ledger);
+        g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE, label);
+        name = gnc_account_get_full_name (leader);
+        g_key_file_set_string (key_file, group_name, KEY_ACCOUNT_NAME, name);
+        g_free (name);
     }
     else if (model->type == GENERAL_LEDGER2)
     {
-        g_key_file_set_string(key_file, group_name, KEY_REGISTER_TYPE,
+        g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
                               LABEL_GL);
     }
     else if (model->type == SEARCH_LEDGER2)
     {
-        g_key_file_set_string(key_file, group_name, KEY_REGISTER_TYPE,
+        g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
                               LABEL_SEARCH);
     }
     else
@@ -1199,13 +1227,12 @@
         return;
     }
 
-    g_key_file_set_string(key_file, group_name, KEY_REGISTER_STYLE, style_names[model->style]);
-    g_key_file_set_boolean(key_file, group_name, KEY_DOUBLE_LINE, model->use_double_line);
+    g_key_file_set_string (key_file, group_name, KEY_REGISTER_STYLE, style_names[model->style]);
+    g_key_file_set_boolean (key_file, group_name, KEY_DOUBLE_LINE, model->use_double_line);
 
     LEAVE(" ");
 }
 
-
 /** Read and restore the edit menu settings on the specified register
  *  page.  This function will restore the register style (ledger, auto
  *  ledger, journal) and whether or not the register is in double line
@@ -1231,40 +1258,39 @@
     gboolean use_double_line;
 
     ENTER(" ");
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
 
     /* Convert the style name to an index */
-    style_name = g_key_file_get_string(key_file, group_name,
+    style_name = g_key_file_get_string (key_file, group_name,
                                        KEY_REGISTER_STYLE, &error);
     for (i = 0 ; style_names[i]; i++)
     {
-        if (g_ascii_strcasecmp(style_name, style_names[i]) == 0)
+        if (g_ascii_strcasecmp (style_name, style_names[i]) == 0)
         {
             DEBUG("Found match for style name: %s", style_name);
             break;
         }
     }
-    g_free(style_name);
+    g_free (style_name);
 
     /* Update the style menu action for this page */
     if (i <= REG2_STYLE_JOURNAL)
     {
         DEBUG("Setting style: %d", i);
-        action = gnc_plugin_page_get_action(page, radio_entries_2[i].name);
-        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
+        action = gnc_plugin_page_get_action (page, radio_entries_2[i].name);
+        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
     }
 
-    /* Update the  double line action on this page */
+    /* Update the double line action on this page */
     use_double_line =
-        g_key_file_get_boolean(key_file, group_name, KEY_DOUBLE_LINE, &error);
+        g_key_file_get_boolean (key_file, group_name, KEY_DOUBLE_LINE, &error);
     DEBUG("Setting double_line_mode: %d", use_double_line);
-    action = gnc_plugin_page_get_action(page, "ViewStyleDoubleLineAction");
-    gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_double_line);
+    action = gnc_plugin_page_get_action (page, "ViewStyleDoubleLineAction");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), use_double_line);
 
     LEAVE(" ");
 }
 
-
 /** Create a new register page based on the information saved during a
  *  previous instantiation of gnucash.
  *
@@ -1286,53 +1312,53 @@
     QofBook *book;
     gboolean include_subs;
 
-    g_return_val_if_fail(key_file, NULL);
-    g_return_val_if_fail(group_name, NULL);
+    g_return_val_if_fail (key_file, NULL);
+    g_return_val_if_fail (group_name, NULL);
     ENTER("key_file %p, group_name %s", key_file, group_name);
 
     /* Create the new page. */
-    reg_type = g_key_file_get_string(key_file, group_name,
+    reg_type = g_key_file_get_string (key_file, group_name,
                                      KEY_REGISTER_TYPE, &error);
     DEBUG("Page type: %s", reg_type);
-    if ((g_ascii_strcasecmp(reg_type, LABEL_ACCOUNT) == 0) ||
-            (g_ascii_strcasecmp(reg_type, LABEL_SUBACCOUNT) == 0))
+    if ((g_ascii_strcasecmp (reg_type, LABEL_ACCOUNT) == 0) ||
+            (g_ascii_strcasecmp (reg_type, LABEL_SUBACCOUNT) == 0))
     {
         include_subs = (g_ascii_strcasecmp(reg_type, LABEL_SUBACCOUNT) == 0);
         DEBUG("Include subs: %d", include_subs);
-        acct_name = g_key_file_get_string(key_file, group_name,
+        acct_name = g_key_file_get_string (key_file, group_name,
                                           KEY_ACCOUNT_NAME, &error);
-        book = qof_session_get_book(gnc_get_current_session());
-        account = gnc_account_lookup_by_full_name(gnc_book_get_root_account(book),
+        book = qof_session_get_book (gnc_get_current_session());
+        account = gnc_account_lookup_by_full_name (gnc_book_get_root_account(book),
                   acct_name);
-        g_free(acct_name);
+        g_free (acct_name);
         if (account == NULL)
         {
             LEAVE("Bad account name");
-            g_free(reg_type);
+            g_free (reg_type);
             return NULL;
         }
         page = gnc_plugin_page_register2_new (account, include_subs);
     }
-    else if (g_ascii_strcasecmp(reg_type, LABEL_GL) == 0)
+    else if (g_ascii_strcasecmp (reg_type, LABEL_GL) == 0)
     {
-        page = gnc_plugin_page_register2_new_gl();
+        page = gnc_plugin_page_register2_new_gl ();
     }
     else
     {
         LEAVE("Bad ledger type");
-        g_free(reg_type);
+        g_free (reg_type);
         return NULL;
     }
-    g_free(reg_type);
+    g_free (reg_type);
 
     /* Recreate page in given window */
-    gnc_plugin_page_set_use_new_window(page, FALSE);
+    gnc_plugin_page_set_use_new_window (page, FALSE);
 
     /* Install it now so we can them manipulate the created widget */
-    gnc_main_window_open_page(GNC_MAIN_WINDOW(window), page);
+    gnc_main_window_open_page (GNC_MAIN_WINDOW (window), page);
 
     /* Now update the page to the last state it was in */
-    gnc_plugin_page_register2_restore_edit_menu(page, key_file, group_name);
+    gnc_plugin_page_register2_restore_edit_menu (page, key_file, group_name);
     LEAVE(" ");
     return page;
 }
@@ -1342,20 +1368,25 @@
  * Based on code from Epiphany (src/ephy-window.c)
  */
 static void
-gnc_plugin_page_register2_update_edit_menu (GncPluginPage *page, gboolean hide)
+gnc_plugin_page_register2_update_edit_menu (GncPluginPage *page, gboolean hide) //this works
 {
     GncPluginPageRegister2Private *priv;
     GncPluginPageRegister2 *reg_page;
+    GncTreeViewSplitReg *view;
     GtkAction *action;
     gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
     gboolean has_selection;
-    gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book());
-//g_print("gnc_plugin_page_register2_update_edit_menu\n");
-    reg_page = GNC_PLUGIN_PAGE_REGISTER2(page);
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(reg_page);
-/*FIXME    has_selection = gnucash_register_has_selection (priv->gsr->reg); */
-    has_selection = FALSE;
+    gboolean is_readwrite = !qof_book_is_readonly (gnc_get_current_book());
+    reg_page = GNC_PLUGIN_PAGE_REGISTER2 (page);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (reg_page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
 
+    // This is set while we are editing a cell
+    if (view->editing_now)
+        has_selection = TRUE;
+    else
+        has_selection = FALSE;
+
     can_copy = has_selection;
     can_cut = is_readwrite && has_selection;
     can_paste = is_readwrite;
@@ -1371,27 +1402,29 @@
     gtk_action_set_visible (action,  !hide || can_paste);
 }
 
-
 static gboolean
-gnc_plugin_page_register2_finish_pending (GncPluginPage *page)
+gnc_plugin_page_register2_finish_pending (GncPluginPage *page) //this works
 {
     GncPluginPageRegister2Private *priv;
     GncPluginPageRegister2 *reg_page;
-    GncTreeModelSplitReg *model;
+    GncTreeViewSplitReg *view;
     GtkWidget *dialog, *window;
     const gchar *name;
     gint response;
 
-    reg_page = GNC_PLUGIN_PAGE_REGISTER2(page);
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(reg_page);
-    model = gnc_ledger_display2_get_split_model_register(priv->ledger);
+    reg_page = GNC_PLUGIN_PAGE_REGISTER2 (page);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (reg_page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
 
-/*FIXME    if (!model || !gnc_split_register_changed (model)) */
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
+
+    if (!view || (gnc_tree_view_split_reg_get_dirty_trans (view) == NULL))
         return TRUE;
 
-    name = gnc_plugin_page_register2_get_tab_name(page);
-    window = gnc_plugin_page_get_window(page);
-    dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+    name = gnc_plugin_page_register2_get_tab_name (page);
+    window = gnc_plugin_page_get_window (page);
+    dialog = gtk_message_dialog_new (GTK_WINDOW (window),
                                     GTK_DIALOG_DESTROY_WITH_PARENT,
                                     GTK_MESSAGE_WARNING,
                                     GTK_BUTTONS_NONE,
@@ -1399,30 +1432,28 @@
                                        of the tab page */
                                     _("Save changes to %s?"), name);
     gtk_message_dialog_format_secondary_text
-    (GTK_MESSAGE_DIALOG(dialog),
+    (GTK_MESSAGE_DIALOG (dialog),
      "%s",
      _("This register has pending changes to a transaction.  "
        "Would you like to save the changes to this transaction, "
        "discard the transaction, or cancel the operation?"));
-    gnc_gtk_dialog_add_button(dialog, _("_Discard Transaction"),
+    gnc_gtk_dialog_add_button (dialog, _("_Discard Transaction"),
                               GTK_STOCK_DELETE, GTK_RESPONSE_REJECT);
-    gtk_dialog_add_button(GTK_DIALOG(dialog),
+    gtk_dialog_add_button (GTK_DIALOG (dialog),
                           GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-    gnc_gtk_dialog_add_button(dialog, _("_Save Transaction"),
+    gnc_gtk_dialog_add_button (dialog, _("_Save Transaction"),
                               GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT);
 
-    response = gtk_dialog_run(GTK_DIALOG(dialog));
-    gtk_widget_destroy(dialog);
+    response = gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
 
     switch (response)
     {
     case GTK_RESPONSE_ACCEPT:
-/*FIXME        gnc_split_register_save (model, TRUE); */
-        return TRUE;
+        return (gnc_tree_control_split_reg_save (view, TRUE));
 
     case GTK_RESPONSE_REJECT:
-/*FIXME        gnc_split_register_cancel_cursor_trans_changes (model); */
-/*FIXME        gnc_split_register_save (model, TRUE); */
+        gnc_tree_control_split_reg_cancel_edit (view, TRUE);
         return TRUE;
 
     default:
@@ -1430,7 +1461,6 @@
     }
 }
 
-
 static gchar *
 gnc_plugin_page_register2_get_tab_name (GncPluginPage *plugin_page)
 {
@@ -1664,6 +1694,9 @@
                           (position == GTK_POS_TOP ? 0 : -1) );
 }
 
+/*#################################################################################*/
+/*#################################################################################*/
+
 /************************************************************/
 /*                     "Sort By" Dialog                     */
 /************************************************************/
@@ -1776,6 +1809,8 @@
     LEAVE(" ");
 }
 
+/*#################################################################################*/
+/*#################################################################################*/
 
 /************************************************************/
 /*                    "Filter By" Dialog                    */
@@ -1799,7 +1834,7 @@
     GncPluginPageRegister2Private *priv;
     GSList *param_list;
     Query *query;
-//g_print("gnc_ppr_update_status_query\n");
+
     ENTER(" ");
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
     query = gnc_ledger_display2_get_query (priv->ledger );
@@ -1826,7 +1861,6 @@
     LEAVE(" ");
 }
 
-
 /** This function updates the "date posted" term of the register
  *  query.  It unconditionally removes any old "date posted" query
  *  term, then adds back a new query term if needed.  There seems to
@@ -1883,7 +1917,6 @@
     LEAVE(" ");
 }
 
-
 /* This function converts a time64 value date to a string */
 static gchar *
 gnc_plugin_page_register2_filter_time2dmy ( time64 raw_time)
@@ -1900,7 +1933,6 @@
     return g_strdup(date_string);
 }
 
-
 /* This function converts a string date to a time64 value */
 static time64
 gnc_plugin_page_register2_filter_dmy2time ( char *date_string)
@@ -1918,7 +1950,6 @@
     return gnc_mktime (&when);
 }
 
-
 /** This function is called whenever one of the status entries is
  *  checked or unchecked.  It updates the status value maintained for
  *  the filter dialog, and calls another function to do the work of
@@ -1964,7 +1995,6 @@
     LEAVE(" ");
 }
 
-
 /** This function is called whenever the "select all" status button is
  *  clicked.  It updates all of the checkbox widgets, then updates the
  *  query on the register.
@@ -2003,7 +2033,6 @@
     LEAVE(" ");
 }
 
-
 /** This function computes the starting and ending times for the
  *  filter by examining the dialog widgets to see which ones are
  *  selected, and will pull times out of the data entry boxes if
@@ -2022,16 +2051,16 @@
     GtkWidget *button, *today, *gde;
     time64 time_val;
 
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->fd.start_date_choose)))
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
+    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_choose)))
     {
-        time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(priv->fd.start_date));
-        time_val = gnc_time64_get_day_start(time_val);
+        time_val = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->fd.start_date));
+        time_val = gnc_time64_get_day_start (time_val);
         priv->fd.start_time = time_val;
     }
     else
     {
-        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->fd.start_date_today)))
+        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_today)))
         {
             priv->fd.start_time = gnc_time64_get_today_start();
         }
@@ -2041,15 +2070,15 @@
         }
     }
 
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->fd.end_date_choose)))
+    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.end_date_choose)))
     {
-        time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(priv->fd.end_date));
-        time_val = gnc_time64_get_day_end(time_val);
+        time_val = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->fd.end_date));
+        time_val = gnc_time64_get_day_end (time_val);
         priv->fd.end_time = time_val;
     }
     else
     {
-        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->fd.start_date_today)))
+        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_today)))
         {
             priv->fd.end_time = gnc_time64_get_today_end();
         }
@@ -2060,7 +2089,6 @@
     }
 }
 
-
 /** This function is called when the "select range" radio button
  *  changes state.  Since there are only two choices in this radio
  *  group, this one signal can be used to handle all cases.  This
@@ -2103,7 +2131,6 @@
     LEAVE(" ");
 }
 
-
 /** This function is called when one of the start date entry widgets
  *  is updated.  It simply calls common routines to determine the
  *  start/end times and update the register query.
@@ -2126,7 +2153,6 @@
     LEAVE(" ");
 }
 
-
 /** This function is called when one of the start date radio buttons
  *  is selected.  It updates the sensitivity of the date entry widget,
  *  then calls a common routine to determine the start/end times and
@@ -2173,7 +2199,6 @@
     LEAVE(" ");
 }
 
-
 /** This function is called when one of the end date radio buttons is
  *  selected.  It updates the sensitivity of the date entry widget,
  *  then calls a common routine to determine the start/end times and
@@ -2220,7 +2245,6 @@
     LEAVE(" ");
 }
 
-
 /** This function is called whenever the save status is checked
  *  or unchecked. It will allow saving of the filter if required.
  *
@@ -2249,7 +2273,6 @@
     LEAVE(" ");
 }
 
-
 /** This function is called when the "Filter By..." dialog is closed.
  *  If the dialog was closed by any method other than clicking the OK
  *  button, the original sorting order will be restored.
@@ -2325,6 +2348,8 @@
     LEAVE(" ");
 }
 
+/*#################################################################################*/
+/*#################################################################################*/
 
 /************************************************************/
 /*                  Report Helper Functions                 */
@@ -2481,13 +2506,16 @@
     return scm_to_int (arg);
 }
 
+/*#################################################################################*/
+/*#################################################################################*/
+
 /************************************************************/
 /*                     Command callbacks                    */
 /************************************************************/
 
 static void
 gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
-        GncPluginPageRegister2 *plugin_page)
+        GncPluginPageRegister2 *plugin_page) //FIXME
 {
     GncPluginPageRegister2Private *priv;
     SplitRegister * reg;
@@ -2572,52 +2600,81 @@
     LEAVE(" ");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_cut (GtkAction *action,
-                                  GncPluginPageRegister2 *page)
+                                  GncPluginPageRegister2 *page) //this works
 {
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
+    GtkWidget *window, *widget;
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
 
     ENTER("(action %p, page %p)", action, page);
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    gnucash_register_cut_clipboard(priv->gsr->reg);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+
+    window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page));
+    widget = gtk_window_get_focus (GTK_WINDOW (window));
+
+    DEBUG("(widget name is %s)", gtk_widget_get_name (widget));
+
+    if (GTK_IS_ENTRY(widget))
+        g_signal_emit_by_name(widget, "cut-clipboard", NULL);
+
     LEAVE("");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_copy (GtkAction *action,
-                                   GncPluginPageRegister2 *page)
+                                   GncPluginPageRegister2 *page) //this works
 {
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
+    GtkWidget *window, *widget;
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
 
     ENTER("(action %p, page %p)", action, page);
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    gnucash_register_copy_clipboard(priv->gsr->reg);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+
+    window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page));
+    widget = gtk_window_get_focus (GTK_WINDOW (window));
+
+    DEBUG("(widget name is %s)", gtk_widget_get_name (widget));
+
+    if (GTK_IS_ENTRY(widget))
+        g_signal_emit_by_name (widget, "copy-clipboard", NULL);
+
     LEAVE("");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_paste (GtkAction *action,
-                                    GncPluginPageRegister2 *page)
+                                    GncPluginPageRegister2 *page) //this works
 {
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
+    GtkWidget *window, *widget;
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
 
     ENTER("(action %p, page %p)", action, page);
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    gnucash_register_paste_clipboard(priv->gsr->reg);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+
+    window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page));
+    widget = gtk_window_get_focus (GTK_WINDOW (window));
+
+    DEBUG("(widget name is %s)", gtk_widget_get_name (widget));
+
+    if (GTK_IS_ENTRY(widget))
+        g_signal_emit_by_name (widget, "paste-clipboard", NULL);
+
     LEAVE("");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_edit_account (GtkAction *action,
         GncPluginPageRegister2 *page)
@@ -2633,7 +2690,6 @@
     LEAVE(" ");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_find_transactions (GtkAction *action,
         GncPluginPageRegister2 *page)
@@ -2649,58 +2705,55 @@
     LEAVE(" ");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_cut_transaction (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) // this works
 {
     GncPluginPageRegister2Private *priv;
-    SplitRegister *reg;
+    GncTreeViewSplitReg *view;
 
     g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
 
     ENTER("(action %p, page %p)", action, page);
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    reg = gnc_ledger_display2_get_split_register(priv->ledger);
-    gnc_split_register_cut_current(reg);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    gnc_tree_control_split_reg_cut_trans (view);
+
     LEAVE(" ");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_copy_transaction (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) // this works
 {
     GncPluginPageRegister2Private *priv;
-    SplitRegister *reg;
+    GncTreeViewSplitReg *view;
 
     g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
 
     ENTER("(action %p, page %p)", action, page);
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    reg = gnc_ledger_display2_get_split_register(priv->ledger);
-    gnc_split_register_copy_current(reg);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    gnc_tree_control_split_reg_copy_trans (view);
     LEAVE(" ");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_paste_transaction (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) //this works
 {
     GncPluginPageRegister2Private *priv;
-    SplitRegister *reg;
+    GncTreeViewSplitReg *view;
 
     g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
 
     ENTER("(action %p, page %p)", action, page);
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    reg = gnc_ledger_display2_get_split_register(priv->ledger);
-    gnc_split_register_paste_current(reg);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    gnc_tree_control_split_reg_paste_trans (view);
     LEAVE(" ");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_void_transaction (GtkAction *action,
         GncPluginPageRegister2 *page) //this works
@@ -2744,7 +2797,7 @@
         reason = gtk_entry_get_text (GTK_ENTRY (entry));
         if (reason == NULL)
             reason = "";
-        gnc_tree_view_split_reg_void_current_trans (view, reason);
+        gnc_tree_control_split_reg_void_current_trans (view, reason);
     }
 
     /* All done. Get rid of it. */
@@ -2752,7 +2805,6 @@
     g_object_unref (G_OBJECT(builder));
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_unvoid_transaction (GtkAction *action,
         GncPluginPageRegister2 *page) //this works
@@ -2770,59 +2822,34 @@
     trans = gnc_tree_view_split_reg_get_current_trans (view);
     if (!xaccTransHasSplitsInState (trans, VREC))
         return;
-    gnc_tree_view_split_reg_unvoid_current_trans (view);
+    gnc_tree_control_split_reg_unvoid_current_trans (view);
     LEAVE(" ");
 }
 
-
 static void
 gnc_plugin_page_register2_cmd_reverse_transaction (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) //this works
 {
     GncPluginPageRegister2Private *priv;
-    SplitRegister *reg;
-    GNCSplitReg2 *gsr;
-    Transaction *trans, *new_trans;
+    GncTreeViewSplitReg *view;
 
     ENTER("(action %p, page %p)", action, page);
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
 
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    reg = gnc_ledger_display2_get_split_register(priv->ledger);
-    trans = gnc_split_register_get_current_trans(reg);
-    if (trans == NULL)
-        return;
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
 
-    if (xaccTransGetReversedBy(trans))
-    {
-        gnc_error_dialog(gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page)), "%s",
-                         _("A reversing entry has already been created for this transaction."));
-        return;
-    }
-
-    qof_event_suspend();
-    new_trans = xaccTransReverse(trans);
-
-    /* Clear transaction level info */
-    xaccTransSetDatePostedSecs(new_trans, gnc_time (NULL));
-    xaccTransSetDateEnteredSecs(new_trans, gnc_time (NULL));
-
-    qof_event_resume();
-
-    /* Now jump to new trans */
-    gsr = gnc_plugin_page_register2_get_gsr(GNC_PLUGIN_PAGE(page));
-    gnc_split_reg2_jump_to_split(gsr, xaccTransGetSplit(new_trans, 0));
+    gnc_tree_control_split_reg_reverse_current (view);
     LEAVE(" ");
 }
 
 static void
 gnc_plugin_page_register2_cmd_shift_transaction_forward (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) //this works
 {
     GncPluginPageRegister2Private *priv;
-    SplitRegister *reg;
-    GNCSplitReg2 *gsr;
+    GncTreeViewSplitReg *view;
     Transaction *trans, *new_trans;
     Timespec entered;
 
@@ -2831,21 +2858,24 @@
     g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
 
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    reg = gnc_ledger_display2_get_split_register(priv->ledger);
-    trans = gnc_split_register_get_current_trans(reg);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    trans = gnc_tree_view_split_reg_get_current_trans (view);
     if (trans == NULL)
         return;
 
     qof_event_suspend();
 
-    xaccTransGetDatePostedTS(trans, &entered);
-    xaccTransSetDatePostedSecs(trans, entered.tv_sec + 1);
+    xaccTransGetDatePostedTS (trans, &entered);
+    xaccTransSetDatePostedSecs (trans, entered.tv_sec + 1);
 
     qof_event_resume();
 
     LEAVE(" ");
 }
 
+/*#################################################################################*/
+/*#################################################################################*/
+
 static void
 gnc_plugin_page_register2_cmd_view_sort_by (GtkAction *action,
         GncPluginPageRegister2 *page)
@@ -2998,13 +3028,13 @@
                 sensitive = TRUE;
             }
         }
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
         priv->fd.start_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
-        hbox = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_hbox"));
+        hbox = GTK_WIDGET (gtk_builder_get_object (builder, "start_date_hbox"));
         gtk_box_pack_start (GTK_BOX (hbox), priv->fd.start_date, TRUE, TRUE, 0);
         gtk_widget_show (priv->fd.start_date);
-        gtk_widget_set_sensitive(GTK_WIDGET(priv->fd.start_date), sensitive);
-        gnc_date_edit_set_time (GNC_DATE_EDIT(priv->fd.start_date), time_val);
+        gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.start_date), sensitive);
+        gnc_date_edit_set_time (GNC_DATE_EDIT (priv->fd.start_date), time_val);
         g_signal_connect (G_OBJECT (priv->fd.start_date), "date-changed",
                           G_CALLBACK (gnc_plugin_page_register2_filter_gde_changed_cb),
                           page);
@@ -3035,11 +3065,11 @@
         }
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
         priv->fd.end_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
-        hbox = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_hbox"));
+        hbox = GTK_WIDGET (gtk_builder_get_object (builder, "end_date_hbox"));
         gtk_box_pack_start (GTK_BOX (hbox), priv->fd.end_date, TRUE, TRUE, 0);
         gtk_widget_show (priv->fd.end_date);
-        gtk_widget_set_sensitive(GTK_WIDGET(priv->fd.end_date), sensitive);
-        gnc_date_edit_set_time (GNC_DATE_EDIT(priv->fd.end_date), time_val);
+        gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.end_date), sensitive);
+        gnc_date_edit_set_time (GNC_DATE_EDIT (priv->fd.end_date), time_val);
         g_signal_connect (G_OBJECT (priv->fd.end_date), "date-changed",
                           G_CALLBACK (gnc_plugin_page_register2_filter_gde_changed_cb),
                           page);
@@ -3054,6 +3084,9 @@
     LEAVE(" ");
 }
 
+/*#################################################################################*/
+/*#################################################################################*/
+
 static void
 gnc_plugin_page_register2_cmd_style_changed (GtkAction *action,
         GtkRadioAction *current,
@@ -3202,13 +3235,15 @@
         GncPluginPageRegister2 *plugin_page) //this works
 {
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
 
     ENTER("(action %p, plugin_page %p)", action, plugin_page);
 
     g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
 
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
-    gnc_split_reg2_enter (priv->gsr, FALSE);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    gnc_tree_control_split_reg_enter (view, FALSE);
     LEAVE(" ");
 }
 
@@ -3224,11 +3259,8 @@
     g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
 
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
-
     view = gnc_ledger_display2_get_split_view_register (priv->ledger);
-
-    gnc_tree_view_split_reg_cancel_edit (view);
-
+    gnc_tree_control_split_reg_cancel_edit (view, FALSE);
     LEAVE(" ");
 }
 
@@ -3237,14 +3269,15 @@
         GncPluginPageRegister2 *plugin_page) //this works
 {
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
 
     ENTER("(action %p, plugin_page %p)", action, plugin_page);
 
     g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
 
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
-
-    gsr2_default_delete_handler (priv->gsr, NULL);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    gnc_tree_control_split_reg_delete (view, NULL);
     LEAVE(" ");
 
 }
@@ -3262,24 +3295,24 @@
 
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
     view = gnc_ledger_display2_get_split_view_register (priv->ledger);
-
-    gnc_tree_view_split_reg_jump_to_blank (view);
+    gnc_tree_control_split_reg_jump_to_blank (view);
     LEAVE(" ");
 }
 
 static void
 gnc_plugin_page_register2_cmd_duplicate_transaction (GtkAction *action,
-        GncPluginPageRegister2 *plugin_page)
+        GncPluginPageRegister2 *plugin_page) //this works
 {
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
 
     ENTER("(action %p, plugin_page %p)", action, plugin_page);
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
 
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-    gnc_split_register_duplicate_current
-    (gnc_ledger_display2_get_split_register(priv->ledger));
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    gnc_tree_control_split_reg_duplicate_current (view);
     LEAVE(" ");
 }
 
@@ -3288,13 +3321,15 @@
         GncPluginPageRegister2 *plugin_page) //this works
 {
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
 
     ENTER("(action %p, plugin_page %p)", action, plugin_page);
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
 
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
-    gsr2_default_reinit_handler (priv->gsr, NULL);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    gnc_tree_control_split_reg_reinit (view, NULL);
     LEAVE(" ");
 }
 
@@ -3313,39 +3348,40 @@
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
     view = gnc_ledger_display2_get_split_view_register (priv->ledger);
     expand = gtk_toggle_action_get_active (action);
-    gnc_tree_view_split_reg_expand_current_trans (view, expand);
+    if (expand)
+        gnc_tree_view_split_reg_expand_trans (view, NULL);
+    else
+        gnc_tree_view_split_reg_collapse_trans (view, NULL);
     LEAVE(" ");
 }
 
 static void
 gnc_plugin_page_register2_cmd_exchange_rate (GtkAction *action,
-        GncPluginPageRegister2 *plugin_page)
+        GncPluginPageRegister2 *plugin_page) //this works
 {
     GncPluginPageRegister2Private *priv;
-    SplitRegister *reg;
+    GncTreeViewSplitReg *view;
 
     ENTER("(action %p, plugin_page %p)", action, plugin_page);
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
 
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-    reg = gnc_ledger_display2_get_split_register (priv->ledger);
-
-    /* XXX Ignore the return value -- we don't care if this succeeds */
-    (void)gnc_split_register_handle_exchange (reg, TRUE);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    gnc_tree_control_split_reg_exchange_rate (view);
     LEAVE(" ");
 }
 
 static void
 gnc_plugin_page_register2_cmd_jump (GtkAction *action,
-                                   GncPluginPageRegister2 *plugin_page) //this works
+        GncPluginPageRegister2 *plugin_page) //this works
 {
     GncPluginPageRegister2Private *priv;
     GncPluginPage *new_page;
     GncPluginPageRegister2 *new_reg_page;
     GtkWidget *window;
-    GNCSplitReg2 *gsr;
-    GncTreeViewSplitReg *view;
+    GNCLedgerDisplay2 *ld;
+    GncTreeViewSplitReg *view, *new_view;
     Account *account;
     Account *leader;
     Split *split;
@@ -3371,7 +3407,7 @@
         return;
     }
 
-    if (!gnc_tree_view_split_reg_current_trans_expanded (view))
+    if (!gnc_tree_view_split_reg_trans_expanded (view, NULL))
     {
         Transaction *trans = xaccSplitGetParent (split);
         if (xaccTransCountSplits (trans) > 2)
@@ -3382,7 +3418,7 @@
     }
 
     depth = gnc_tree_view_reg_get_selected_row_depth (view);
-    if (gnc_tree_view_split_reg_current_trans_expanded (view) && depth != SPLIT3)
+    if (gnc_tree_view_split_reg_trans_expanded (view, NULL) && depth != SPLIT3)
     {
         LEAVE("expanded but no split selected");
         return;
@@ -3427,8 +3463,10 @@
     }
 
     gnc_main_window_open_page (GNC_MAIN_WINDOW (window), new_page);
-    gsr = gnc_plugin_page_register2_get_gsr (new_page);
-    gnc_split_reg2_jump_to_split (gsr, split);
+
+    ld = gnc_plugin_page_register2_get_ledger (new_page);
+    new_view = gnc_ledger_display2_get_split_view_register (ld);
+    gnc_tree_control_split_reg_jump_to_split (new_view, split);
     LEAVE(" ");
 }
 
@@ -3581,6 +3619,9 @@
     LEAVE(" ");
 }
 
+/*#################################################################################*/
+/*#################################################################################*/
+
 /************************************************************/
 /*                    Auxiliary functions                   */
 /************************************************************/
@@ -3615,6 +3656,20 @@
     return priv->gsr;
 }
 
+
+GNCLedgerDisplay2 *
+gnc_plugin_page_register2_get_ledger (GncPluginPage *plugin_page)
+{
+    GncPluginPageRegister2 *page;
+    GncPluginPageRegister2Private *priv;
+
+    g_return_val_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page), NULL);
+
+    page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
+
+    return priv->ledger;
+}
 static void
 gnc_plugin_page_help_changed_cb (GNCSplitReg2 *gsr, GncPluginPageRegister2 *register_page) //this works
 {
@@ -3622,7 +3677,7 @@
     GncTreeViewSplitReg *view;
     GncWindow *window;
     char *help;
-//g_print("gnc_plugin_page_help_changed_cb register_page is %p\n", register_page);
+
     g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (register_page));
 
     window = GNC_WINDOW (GNC_PLUGIN_PAGE (register_page)->window);
@@ -3635,20 +3690,23 @@
     /* Get the text from the view */
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (register_page);
     view = gnc_ledger_display2_get_split_view_register (priv->ledger);
-    help = g_strdup (view->help_text); //FIXME might need to be a function
+    help = g_strdup (view->help_text);
     gnc_window_set_status (window, GNC_PLUGIN_PAGE (register_page), help);
     g_free (help);
 }
 
 static void
-gnc_plugin_page_register2_refresh_cb (GHashTable *changes, gpointer user_data)
+gnc_plugin_page_register2_refresh_cb (GHashTable *changes, gpointer user_data) //FIXME does not work ?
 {
     GncPluginPageRegister2 *page = user_data;
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
 //g_print("gnc_plugin_page_register2_refresh_cb\n");
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+//g_print("gnc_plugin_page_register2_refresh_cb 0\n");
     if (changes)
     {
         const EventInfo* ei;
@@ -3670,12 +3728,10 @@
     {
 //g_print("gnc_plugin_page_register2_refresh_cb 2\n");
         /* Force updates */
-
-/*FIXME        gnucash_register_refresh_from_gconf (priv->gsr->reg); */
-        gtk_widget_queue_draw(priv->widget);
+        gnc_tree_view_split_reg_refresh_from_gconf (view);
+        gtk_widget_queue_draw (priv->widget);
     }
-
-    gnc_plugin_page_register2_ui_update(NULL, page);
+    gnc_plugin_page_register2_ui_update (NULL, page);
 }
 
 static void

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register2.h
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register2.h	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register2.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -133,6 +133,14 @@
 gnc_plugin_page_register2_get_gsr (GncPluginPage *plugin_page);
 
 
+/** Get the GNCLedgerDisplay data structure associated with this register page.
+ *
+ *  @param plugin_page A "register" page.
+ */
+GNCLedgerDisplay2 *
+gnc_plugin_page_register2_get_ledger (GncPluginPage *plugin_page);
+
+
 /** Get the Account associated with this register page.
  *
  *  @param page A "register" page.

Modified: gnucash/trunk/src/gnome/gnc-split-reg2.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-split-reg2.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome/gnc-split-reg2.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -1,11 +1,12 @@
 /********************************************************************\
- * gnc-split-reg2.c -- A widget for the common register look-n-feel. *
+ * gnc-split-reg2.c -- A widget for the common register look-n-feel *
  * Copyright (C) 1997 Robin D. Clark                                *
  * Copyright (C) 1997-1998 Linas Vepstas <linas at linas.org>          *
  * Copyright (C) 1998 Rob Browning <rlb at cs.utexas.edu>              *
  * Copyright (C) 1999-2000 Dave Peticolas <dave at krondo.com>         *
  * Copyright (C) 2001 Gnumatic, Inc.                                *
  * Copyright (C) 2002,2006 Joshua Sled <jsled at asynchronous.org>     *
+ * Copyright (C) 2012 Robert Fewell                                 *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -54,12 +55,12 @@
 #include "table-allgui.h"
 
 #include "gnc-tree-view-split-reg.h"
+#include "gnc-tree-control-split-reg.h"
 
 #include "dialog-utils.h"
 
 #define GCONF_SECTION "window/pages/register2"
 
-// static QofLogModule log_module = GNC_MOD_SX;
 static QofLogModule log_module = GNC_MOD_GUI;
 
 /***** PROTOTYPES ***************************************************/
@@ -78,7 +79,6 @@
 static void gsr2_setup_table( GNCSplitReg2 *gsr );
 
 
-
 static void gsr2_setup_status_widgets( GNCSplitReg2 *gsr );
 
 static void gsr2_update_summary_label( GtkWidget *label,
@@ -98,58 +98,27 @@
 static Transaction* create_balancing_transaction(QofBook *book, Account *account,
         time64 statement_date, gnc_numeric balancing_amount);
 
-void gsr2_default_enter_handler    ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_cancel_handler   ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_delete_handler   ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_reinit_handler   ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_dup_handler      ( GNCSplitReg2 *w, gpointer ud );
+
 void gsr2_default_schedule_handler ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_expand_handler   ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_blank_handler    ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_jump_handler     ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_cut_handler      ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_cut_txn_handler  ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_copy_handler     ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_copy_txn_handler ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_paste_handler    ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_paste_txn_handler( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_void_txn_handler ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_unvoid_txn_handler  ( GNCSplitReg2 *w, gpointer ud );
-void gsr2_default_reverse_txn_handler ( GNCSplitReg2 *w, gpointer ud );
 
+
 static void gsr2_emit_simple_signal( GNCSplitReg2 *gsr, const char *sigName );
 static void gsr2_emit_help_changed (GncTreeViewSplitReg *view, gpointer user_data);
 static void gsr2_emit_include_date_signal( GNCSplitReg2 *gsr, time64 date );
 
-void gnc_split_reg2_cut_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_copy_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_paste_cb(GtkWidget *w, gpointer data);
 
-void gnc_split_reg2_cut_trans_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_copy_trans_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_paste_trans_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_void_trans_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_unvoid_trans_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_reverse_trans_cb(GtkWidget *w, gpointer data);
-
 /*FIXME void gnc_split_reg2_record_cb (GncTreeViewSplitReg *view, gpointer data); */
-void gnc_split_reg2_reinitialize_trans_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_delete_trans_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_duplicate_trans_cb(GtkWidget *w, gpointer data);
+
 void gnc_split_reg2_recur_cb(GtkWidget *w, gpointer data);
 void gnc_split_reg2_record_trans_cb(GtkWidget *w, gpointer data);
-void gnc_split_reg2_cancel_trans_cb(GtkWidget *w, gpointer data);
 
-void gnc_split_reg2_expand_trans_menu_cb(GtkWidget *widget, gpointer data);
-void gnc_split_reg2_expand_trans_toolbar_cb(GtkWidget *widget, gpointer data);
-void gnc_split_reg2_new_trans_cb(GtkWidget *widget, gpointer data);
-void gnc_split_reg2_jump_cb(GtkWidget *widget, gpointer data);
 
 void gnc_split_reg2_style_ledger_cb (GtkWidget *w, gpointer data);
 void gnc_split_reg2_style_auto_ledger_cb (GtkWidget *w, gpointer data);
 void gnc_split_reg2_style_journal_cb (GtkWidget *w, gpointer data);
 void gnc_split_reg2_double_line_cb (GtkWidget *w, gpointer data);
 
+
 void gnc_split_reg2_sort_standard_cb (GtkWidget *w, gpointer data);
 void gnc_split_reg2_sort_date_cb (GtkWidget *w, gpointer data);
 void gnc_split_reg2_sort_date_entered_cb (GtkWidget *w, gpointer data);
@@ -161,21 +130,15 @@
 void gnc_split_reg2_sort_action_cb (GtkWidget *w, gpointer data);
 void gnc_split_reg2_sort_notes_cb (GtkWidget *w, gpointer data);
 
-void gnc_split_reg2_destroy_cb(GtkWidget *widget, gpointer data);
-void gnc_split_reg2_size_allocate( GtkWidget *widget,
-                                  GtkAllocation *allocation,
-                                  gpointer user_data );
+void gnc_split_reg2_destroy_cb (GtkWidget *widget, gpointer data);
 
+static void gnc_split_reg2_class_init (GNCSplitReg2Class *class);
+static void gnc_split_reg2_init (GNCSplitReg2 *gsr);
+static void gnc_split_reg2_init2 (GNCSplitReg2 *gsr);
 
-void gnc_split_reg2_handle_exchange_cb (GtkWidget *w, gpointer data);
-
-static void gnc_split_reg2_class_init( GNCSplitReg2Class *class );
-static void gnc_split_reg2_init( GNCSplitReg2 *gsr );
-static void gnc_split_reg2_init2( GNCSplitReg2 *gsr );
-
 #ifdef SKIP
-FROM_STRING_FUNC(SortType, ENUM_LIST_SORTTYPE)
-AS_STRING_FUNC(SortType, ENUM_LIST_SORTTYPE)
+FROM_STRING_FUNC (SortType, ENUM_LIST_SORTTYPE)
+AS_STRING_FUNC (SortType, ENUM_LIST_SORTTYPE)
 #endif
 
 GType
@@ -187,18 +150,18 @@
     {
         GTypeInfo type_info =
         {
-            sizeof(GNCSplitReg2Class),      /* class_size */
-            NULL,   			/* base_init */
+            sizeof(GNCSplitReg2Class),          /* class_size */
+            NULL,   			        /* base_init */
             NULL,				/* base_finalize */
             (GClassInitFunc)gnc_split_reg2_class_init,
             NULL,				/* class_finalize */
             NULL,				/* class_data */
             sizeof(GNCSplitReg2),		/* */
-            0,				/* n_preallocs */
+            0,				        /* n_preallocs */
             (GInstanceInitFunc)gnc_split_reg2_init,
         };
 
-        gnc_split_reg2_type = g_type_register_static( GTK_TYPE_VBOX,
+        gnc_split_reg2_type = g_type_register_static (GTK_TYPE_VBOX,
                              "GNCSplitReg2",
                              &type_info, 0 );
     }
@@ -209,24 +172,9 @@
 /* SIGNALS */
 enum gnc_split_reg2_signal_enum
 {
-    ENTER_ENT_SIGNAL,
-    CANCEL_ENT_SIGNAL,
-    DELETE_ENT_SIGNAL,
-    REINIT_ENT_SIGNAL,
-    DUP_ENT_SIGNAL,
     SCHEDULE_ENT_SIGNAL,
-    EXPAND_ENT_SIGNAL,
-    BLANK_SIGNAL,
-    JUMP_SIGNAL,
-    CUT_SIGNAL,
-    CUT_TXN_SIGNAL,
-    COPY_SIGNAL,
-    COPY_TXN_SIGNAL,
-    PASTE_SIGNAL,
-    PASTE_TXN_SIGNAL,
-    VOID_TXN_SIGNAL,
-    UNVOID_TXN_SIGNAL,
-    REVERSE_TXN_SIGNAL,
+
+
     HELP_CHANGED_SIGNAL,
     INCLUDE_DATE_SIGNAL,
     LAST_SIGNAL
@@ -246,24 +194,9 @@
         guint defaultOffset;
     } signals[] =
     {
-        { ENTER_ENT_SIGNAL,    "enter_ent",    G_STRUCT_OFFSET( GNCSplitReg2Class, enter_ent_cb ) },
-        { CANCEL_ENT_SIGNAL,   "cancel_ent",   G_STRUCT_OFFSET( GNCSplitReg2Class, cancel_ent_cb ) },
-        { DELETE_ENT_SIGNAL,   "delete_ent",   G_STRUCT_OFFSET( GNCSplitReg2Class, delete_ent_cb ) },
-        { REINIT_ENT_SIGNAL,   "reinit_ent",   G_STRUCT_OFFSET( GNCSplitReg2Class, reinit_ent_cb ) },
-        { DUP_ENT_SIGNAL,      "dup_ent",      G_STRUCT_OFFSET( GNCSplitReg2Class, dup_ent_cb ) },
         { SCHEDULE_ENT_SIGNAL, "schedule_ent", G_STRUCT_OFFSET( GNCSplitReg2Class, schedule_ent_cb ) },
-        { EXPAND_ENT_SIGNAL,   "expand_ent",   G_STRUCT_OFFSET( GNCSplitReg2Class, expand_ent_cb ) },
-        { BLANK_SIGNAL,        "blank",        G_STRUCT_OFFSET( GNCSplitReg2Class, blank_cb ) },
-        { JUMP_SIGNAL,         "jump",         G_STRUCT_OFFSET( GNCSplitReg2Class, jump_cb ) },
-        { CUT_SIGNAL,          "cut",          G_STRUCT_OFFSET( GNCSplitReg2Class, cut_cb ) },
-        { CUT_TXN_SIGNAL,      "cut_txn",      G_STRUCT_OFFSET( GNCSplitReg2Class, cut_txn_cb ) },
-        { COPY_SIGNAL,         "copy",         G_STRUCT_OFFSET( GNCSplitReg2Class, copy_cb ) },
-        { COPY_TXN_SIGNAL,     "copy_txn",     G_STRUCT_OFFSET( GNCSplitReg2Class, copy_txn_cb ) },
-        { PASTE_SIGNAL,        "paste",        G_STRUCT_OFFSET( GNCSplitReg2Class, paste_cb ) },
-        { PASTE_TXN_SIGNAL,    "paste_txn",    G_STRUCT_OFFSET( GNCSplitReg2Class, paste_txn_cb ) },
-        { VOID_TXN_SIGNAL,     "void_txn",     G_STRUCT_OFFSET( GNCSplitReg2Class, void_txn_cb ) },
-        { UNVOID_TXN_SIGNAL,   "unvoid_txn",   G_STRUCT_OFFSET( GNCSplitReg2Class, unvoid_txn_cb ) },
-        { REVERSE_TXN_SIGNAL,  "reverse_txn",  G_STRUCT_OFFSET( GNCSplitReg2Class, reverse_txn_cb ) },
+
+
         { HELP_CHANGED_SIGNAL, "help-changed", G_STRUCT_OFFSET( GNCSplitReg2Class, help_changed_cb ) },
         { INCLUDE_DATE_SIGNAL, "include-date", G_STRUCT_OFFSET( GNCSplitReg2Class, include_date_cb ) },
         { LAST_SIGNAL, NULL, 0 }
@@ -296,25 +229,9 @@
     g_assert( i == LAST_SIGNAL );
 
     /* Setup the default handlers. */
-    class->enter_ent_cb    = gsr2_default_enter_handler;
-    class->cancel_ent_cb   = gsr2_default_cancel_handler;
-    class->delete_ent_cb   = gsr2_default_delete_handler;
-    class->reinit_ent_cb   = gsr2_default_reinit_handler;
-    class->dup_ent_cb      = gsr2_default_dup_handler;
     class->schedule_ent_cb = gsr2_default_schedule_handler;
-    class->expand_ent_cb   = gsr2_default_expand_handler;
-    class->blank_cb        = gsr2_default_blank_handler;
-    class->jump_cb         = gsr2_default_jump_handler;
-    class->cut_cb          = gsr2_default_cut_handler;
-    class->cut_txn_cb      = gsr2_default_cut_txn_handler;
-    class->copy_cb         = gsr2_default_copy_handler;
-    class->copy_txn_cb     = gsr2_default_copy_txn_handler;
-    class->paste_cb        = gsr2_default_paste_handler;
-    class->paste_txn_cb    = gsr2_default_paste_txn_handler;
-    class->void_txn_cb     = gsr2_default_void_txn_handler;
-    class->unvoid_txn_cb   = gsr2_default_unvoid_txn_handler;
-    class->reverse_txn_cb  = gsr2_default_reverse_txn_handler;
 
+
     class->help_changed_cb = NULL;
     class->include_date_cb = NULL;
 }
@@ -382,11 +299,9 @@
 
     model = gnc_ledger_display2_get_split_model_register( gsr->ledger );
 
-/*FIXME    gnc_split_register_show_present_divider( model, TRUE ); */
-
     /* events should be sufficient to redraw this */
-    /* gnc_ledger_display2_refresh( gsr->ledger ); */
-    gnc_split_reg2_refresh_toolbar( gsr );
+    /* gnc_ledger_display2_refresh (gsr->ledger); */
+    gnc_split_reg2_refresh_toolbar (gsr);
 
     LEAVE(" ");
 }
@@ -400,28 +315,35 @@
     GncTreeModelSplitReg *model;
     GtkWidget *scrolled_window;
     GtkTreeViewColumn *col;
+    GNCLedgerDisplay2Type ledger_type;
 
     gchar *gconf_key;
     const GncGUID * guid;
     Account * account;
+    const gchar *gconf_section;
+    const gchar *sort_string;
     
     account = gnc_ledger_display2_leader (gsr->ledger);
     guid = xaccAccountGetGUID (account);
     /* Used for saving different register column widths under seperate keys */
-    gconf_key = g_strconcat (GCONF_SECTION,"/", (gchar*)guid_to_string (guid), NULL); 
+    gconf_key = g_strconcat (GCONF_SECTION,"/", (gchar*)guid_to_string (guid), NULL);
 
-    ENTER("gsr=%p", gsr);
-g_print("gsr2_create_table\n");
+    ENTER("create table gsr=%p", gsr);
+
     gnc_ledger_display2_set_user_data (gsr->ledger, (gpointer)gsr );
     gnc_ledger_display2_set_handlers (gsr->ledger,
                                      gnc_split_reg2_ld_destroy,
                                      gnc_split_reg2_get_parent );
 
+    ledger_type = gnc_ledger_display2_type (gsr->ledger);
+
     model = gnc_ledger_display2_get_split_model_register (gsr->ledger );
     view = gnc_tree_view_split_reg_new_with_model (model);
 
     g_object_unref(G_OBJECT(model));
 
+    gnc_tree_model_split_reg_set_display (model, ((ledger_type == LD2_SUBACCOUNT)?TRUE:FALSE), ((ledger_type == LD2_GL)?TRUE:FALSE));
+
     scrolled_window = gtk_scrolled_window_new (NULL, NULL);
     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                    GTK_POLICY_AUTOMATIC,
@@ -431,36 +353,50 @@
 
     gnc_ledger_display2_set_split_view_register (gsr->ledger, view);
 
+    /* Restore the sort depth from gconf */
+    view->sort_depth = gnc_gconf_get_int (gconf_key, "sort_depth", NULL);
+
+    /* Restore the sort order from gconf */
+    sort_string = gnc_gconf_get_string (gconf_key, "sort_order", NULL);
+    if (g_strcmp0 ("ascending", sort_string) == 0)
+        view->sort_direction = 1;
+    else
+        view->sort_direction = -1;
+
     g_object_set (G_OBJECT (view), "gconf-section", gconf_key, 
-                 "show-column-menu", TRUE, NULL);
+                 "show-column-menu", FALSE, NULL);
 
     gnc_tree_view_configure_columns (GNC_TREE_VIEW (view));
 
-    gnc_tree_view_set_show_column_menu (GNC_TREE_VIEW (view), FALSE);
+    if (ledger_type == LD2_GL)
+        gnc_tree_view_set_show_column_menu (GNC_TREE_VIEW (view), TRUE);
+    else
+        gnc_tree_view_set_show_column_menu (GNC_TREE_VIEW (view), FALSE);
 
     /* This column gets all the free space */
     gnc_tree_view_expand_columns (GNC_TREE_VIEW (view), "descnotes", NULL);
 
     /*FIXME is this OK ? - Set the Reconcile column width */
-    col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW (view), "recn");
-    if (col != NULL)
-        g_object_set (G_OBJECT(col),
-                     "resizable", FALSE,
-                     "sizing",      GTK_TREE_VIEW_COLUMN_FIXED,
-                     "fixed-width", 15,
-                     NULL);
+//    col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW (view), "recn");
+//    if (col != NULL)
+//        g_object_set (G_OBJECT(col),
+//                     "resizable", FALSE,
+//                     "sizing", GTK_TREE_VIEW_COLUMN_FIXED,
+//                     "fixed-width", 15,
+//                      NULL);
 
-    /* This sets the right color column, 4 is the minimum */
+    /* This sets the status color column, 4 is the minimum */
     col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW (view), "status");
     if (col != NULL)
         g_object_set (G_OBJECT(col),
                      "resizable", FALSE,
-                     "sizing",      GTK_TREE_VIEW_COLUMN_FIXED,
+                     "sizing", GTK_TREE_VIEW_COLUMN_FIXED,
                      "fixed-width", 4,
-                     NULL);
+                      NULL);
 
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), TRUE);
     gtk_widget_show (GTK_WIDGET (view));
+
     gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (view));
     gtk_widget_show (GTK_WIDGET (gsr));
 
@@ -470,16 +406,11 @@
     /* This tells the ledger that we have a valid tree view */
     gnc_ledger_display2_set_split_view_refresh (gsr->ledger, TRUE);
 
-/*
-    g_signal_connect (gsr->reg, "activate_cursor",
-                      G_CALLBACK(gnc_split_reg2_record_cb), gsr); */
+    /* This triggers the update of the summary bar */
+    g_signal_connect_after (model, "refresh_status_bar",
+                      G_CALLBACK(gsr2_redraw_all_cb), gsr); //this works
 
-/*FIXME This triggers the update of the summary bar, we need to connect this to some thing
-
-    g_signal_connect (gsr->reg, "redraw_all",
-                      G_CALLBACK(gsr2_redraw_all_cb), gsr); */
-
-
+    /* This triggers the update of the help text */
     g_signal_connect (view, "help_signal",
                       G_CALLBACK (gsr2_emit_help_changed), gsr); // this works
 
@@ -503,7 +434,6 @@
 void
 gnc_split_reg2_destroy_cb (GtkWidget *widget, gpointer data)
 {
-//g_print("gnc_split_reg2_destroy_cb - does not do any thing\n");
 }
 
 /**
@@ -767,7 +697,7 @@
 }
 
 static void
-gnc_split_reg2_ld_destroy( GNCLedgerDisplay2 *ledger )
+gnc_split_reg2_ld_destroy (GNCLedgerDisplay2 *ledger)
 {
     GNCSplitReg2 *gsr = gnc_ledger_display2_get_user_data( ledger );
     
@@ -786,7 +716,8 @@
 
         model = gnc_ledger_display2_get_split_model_register (ledger);
 
-/*FIXME        if (model && model->table)
+/*FIXME This may not be required
+        if (model && model->table)
             gnc_table_save_state (model->table, gconf_key);
 */
         /*
@@ -798,478 +729,10 @@
 }
 
 
-/* ######## Handlers ############ */
+/* ########################### Handlers ############################### */
 
 
-void
-gsr2_default_cut_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnucash_register_cut_clipboard( gsr->reg );*/
-}
-
 /**
- * Cut the selection to the clipboard.  This refers to the Split.
- **/
-void
-gnc_split_reg2_cut_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "cut" );*/
-}
-
-void
-gsr2_default_copy_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnucash_register_copy_clipboard( gsr->reg );*/
-}
-
-/**
- * Copy the selection to the clipboard.  This refers to the Split.
- **/
-void
-gnc_split_reg2_copy_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "copy" );*/
-}
-
-void
-gsr2_default_paste_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnucash_register_paste_clipboard( gsr->reg );*/
-}
-
-/**
- * Paste the clipboard to the selection.  This refers to the Split.
- **/
-void
-gnc_split_reg2_paste_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "paste" );*/
-}
-
-void
-gsr2_default_cut_txn_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnc_split_register_cut_current
-    (gnc_ledger_display2_get_split_register( gsr->ledger ));*/
-}
-
-/**
- * Cut the current transaction  to the clipboard.
- **/
-void
-gnc_split_reg2_cut_trans_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "cut_txn" );*/
-}
-
-void
-gsr2_default_copy_txn_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnc_split_register_copy_current
-    (gnc_ledger_display2_get_split_register( gsr->ledger ));*/
-}
-
-/**
- * Copy the current transaction to the clipboard.
- **/
-void
-gnc_split_reg2_copy_trans_cb(GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "copy_txn" );*/
-}
-
-void
-gsr2_default_paste_txn_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnc_split_register_paste_current
-    (gnc_ledger_display2_get_split_register( gsr->ledger ));*/
-}
-
-/**
- * Paste the transaction clipboard to the selection.
- **/
-void
-gnc_split_reg2_paste_trans_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "paste_txn" );*/
-}
-
-/********************************************************************\
- * gnc_split_reg2_void_trans_cb                                      *
- *                                                                  *
- * Args:   widget - the widget that called us                       *
- *         data   - the data struct for this register               *
- * Return: none                                                     *
-\********************************************************************/
-void
-gsr2_default_void_txn_handler (GNCSplitReg2 *gsr, gpointer data)
-{
-    // Override this function.
-}
-
-void
-gnc_split_reg2_void_trans_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "void_txn" );*/
-}
-
-/********************************************************************\
- * gnc_split_reg2_unvoid_trans_cb                                      *
- *                                                                  *
- * Args:   widget - the widget that called us                       *
- *         data   - the data struct for this register               *
- * Return: none                                                     *
-\********************************************************************/
-void
-gsr2_default_unvoid_txn_handler (GNCSplitReg2 *gsr, gpointer data)
-{
-    // Override this function.
-}
-
-void
-gnc_split_reg2_unvoid_trans_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "unvoid_txn" );*/
-}
-
-/********************************************************************\
- * gnc_split_reg2_reverse_trans_cb                                   *
- *                                                                  *
- * Args:   widget - the widget that called us                       *
- *         data   - the data struct for this register               *
- * Return: none                                                     *
-\********************************************************************/
-void
-gsr2_default_reverse_txn_handler (GNCSplitReg2 *gsr, gpointer data)
-{
-/*FIXME*/
-#ifdef skip
-    SplitRegister *reg;
-    Transaction *trans, *new_trans;
-
-    reg = gnc_ledger_display2_get_split_register( gsr->ledger );
-    trans = gnc_split_register_get_current_trans (reg);
-    if (trans == NULL)
-        return;
-
-    if (xaccTransGetReversedBy(trans))
-    {
-        gnc_error_dialog(gsr->window, "%s",
-                         _("A reversing entry has already been created for this transaction."));
-        return;
-    }
-
-    new_trans = xaccTransReverse(trans);
-
-    /* Clear transaction level info */
-    xaccTransSetDatePostedSecs(new_trans, gnc_time (NULL));
-    xaccTransSetDateEnteredSecs(new_trans, gnc_time (NULL));
-
-    /* Now jump to new trans */
-    gnc_split_reg2_jump_to_split(gsr, xaccTransGetSplit(new_trans, 0));
-#endif
-}
-
-void
-gnc_split_reg2_reverse_trans_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "reverse_txn" ); */
-}
-
-
-static gboolean
-is_trans_readonly_and_warn (const Transaction *trans) //this works
-{
-    GtkWidget *dialog;
-    const gchar *reason;
-    const gchar *title = _("Cannot modify or delete this transaction.");
-    const gchar *message =
-        _("This transaction is marked read-only with the comment: '%s'");
-
-    if (!trans) return FALSE;
-
-    if (xaccTransIsReadonlyByPostedDate (trans))
-    {
-        dialog = gtk_message_dialog_new (NULL,
-                                        0,
-                                        GTK_MESSAGE_ERROR,
-                                        GTK_BUTTONS_OK,
-                                        "%s", title);
-        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                "%s", _("The date of this transaction is older than the \"Read-Only Threshold\" set for this book.  "
-                        "This setting can be changed in File -> Properties -> Accounts."));
-        gtk_dialog_run (GTK_DIALOG (dialog));
-        gtk_widget_destroy (dialog);
-        return TRUE;
-    }
-
-    reason = xaccTransGetReadOnly (trans);
-    if (reason)
-    {
-        dialog = gtk_message_dialog_new (NULL,
-                                        0,
-                                        GTK_MESSAGE_ERROR,
-                                        GTK_BUTTONS_OK,
-                                        "%s", title);
-        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                message, reason);
-        gtk_dialog_run (GTK_DIALOG (dialog));
-        gtk_widget_destroy (dialog);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-
-void
-gsr2_default_reinit_handler ( GNCSplitReg2 *gsr, gpointer data ) //this works
-{
-    GncTreeViewSplitReg *view;
-    Transaction *trans;
-    Split *split;
-    GtkWidget *dialog;
-    gint response;
-    const gchar *warning;
-
-    const char *title = _("Remove the splits from this transaction?");
-    const char *recn_warn = _("This transaction contains reconciled splits. "
-                              "Modifying it is not a good idea because that will "
-                              "cause your reconciled balance to be off.");
-
-    view = gnc_ledger_display2_get_split_view_register ( gsr->ledger );
-
-    trans = gnc_tree_view_split_reg_get_current_trans (view);
-    if (is_trans_readonly_and_warn (trans))
-        return;
-    dialog = gtk_message_dialog_new (GTK_WINDOW (gsr->window),
-                                    GTK_DIALOG_DESTROY_WITH_PARENT,
-                                    GTK_MESSAGE_WARNING,
-                                    GTK_BUTTONS_NONE,
-                                    "%s", title);
-    if (xaccTransHasReconciledSplits (trans))
-    {
-        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                "%s", recn_warn);
-        warning = "register_remove_all_splits2";
-    }
-    else
-    {
-        warning = "register_remove_all_splits";
-    }
-
-    gtk_dialog_add_button (GTK_DIALOG (dialog),
-                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-    gnc_gtk_dialog_add_button(dialog, _("_Remove Splits"),
-                              GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
-    response = gnc_dialog_run (GTK_DIALOG(dialog), warning);
-    gtk_widget_destroy (dialog);
-    if (response != GTK_RESPONSE_ACCEPT)
-        return;
-
-    gnc_tree_view_split_reg_reinit_trans (view);
-}
-
-/**
- * "Reinitializes" the current transaction.
- **/
-void
-gnc_split_reg2_reinitialize_trans_cb(GtkWidget *widget, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "reinit_ent" ); */
-}
-
-void
-gsr2_default_delete_handler (GNCSplitReg2 *gsr, gpointer data) //this works
-{
-    GncTreeViewSplitReg *view;
-    RowDepth depth;
-    Transaction *trans;
-    Split *split;
-    GtkWidget *dialog;
-    gint response;
-    const gchar *warning;
-
-    view = gnc_ledger_display2_get_split_view_register (gsr->ledger);
-
-    /* get the current split based on cursor position */
-    split = gnc_tree_view_split_reg_get_current_split (view);
-    if (split == NULL)
-    {
-        return;
-    }
-
-    trans = xaccSplitGetParent (split);
-    depth = gnc_tree_view_reg_get_selected_row_depth (view);
-
-    /* Deleting the blank split just cancels */
-    {
-        Split *blank_split = gnc_tree_view_split_reg_get_blank_split (view);
-
-        if (split == blank_split)
-        {
-            return;
-        }
-    }
-
-    if (is_trans_readonly_and_warn (trans))
-        return;
-
-    /* On a split cursor, just delete the one split. */
-    if (depth == SPLIT3)
-    {
-        const char *format = _("Delete the split '%s' from the transaction '%s'?");
-        const char *recn_warn = _("You would be deleting a reconciled split! "
-                                  "This is not a good idea as it will cause your "
-                                  "reconciled balance to be off.");
-        const char *anchor_error = _("You cannot delete this split.");
-        const char *anchor_split = _("This is the split anchoring this transaction "
-                                     "to the register. You may not delete it from "
-                                     "this register window.  You may delete the "
-                                     "entire transaction from this window, or you "
-                                     "may navigate to a register that shows "
-                                     "another side of this same transaction and "
-                                     "delete the split from that register.");
-        char *buf = NULL;
-        const char *memo;
-        const char *desc;
-        char recn;
-
-        if (split == gnc_tree_view_reg_get_current_trans_split (view))
-        {
-            dialog = gtk_message_dialog_new (GTK_WINDOW (gsr->window),
-                                            GTK_DIALOG_MODAL
-                                            | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                            GTK_MESSAGE_ERROR,
-                                            GTK_BUTTONS_OK,
-                                            "%s", anchor_error);
-            gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                    "%s", anchor_split);
-            gtk_dialog_run (GTK_DIALOG (dialog));
-            gtk_widget_destroy (dialog);
-            return;
-        }
-
-        memo = xaccSplitGetMemo (split);
-        memo = (memo && *memo) ? memo : _("(no memo)");
-
-        desc = xaccTransGetDescription (trans);
-        desc = (desc && *desc) ? desc : _("(no description)");
-
-        /* ask for user confirmation before performing permanent damage */
-        buf = g_strdup_printf (format, memo, desc);
-        dialog = gtk_message_dialog_new (GTK_WINDOW (gsr->window),
-                                        GTK_DIALOG_MODAL
-                                        | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                        GTK_MESSAGE_QUESTION,
-                                        GTK_BUTTONS_NONE,
-                                        "%s", buf);
-        g_free(buf);
-        recn = xaccSplitGetReconcile (split);
-        if (recn == YREC || recn == FREC)
-        {
-            gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                    "%s", recn_warn);
-            warning = "register_delete_split2";
-        }
-        else
-        {
-            warning = "register_delete_split";
-        }
-
-        gtk_dialog_add_button (GTK_DIALOG (dialog),
-                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-        gnc_gtk_dialog_add_button (dialog, _("_Delete Split"),
-                                  GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
-        response = gnc_dialog_run (GTK_DIALOG (dialog), warning);
-        gtk_widget_destroy (dialog);
-        if (response != GTK_RESPONSE_ACCEPT)
-            return;
-
-        gnc_tree_view_split_reg_delete_current_split (view);
-        return;
-    }
-
-    g_return_if_fail (depth == TRANS1 || depth == TRANS2);
-
-    /* On a transaction cursor with 2 or fewer splits in single or double
-     * mode, we just delete the whole transaction, kerblooie */
-    {
-        const char *title = _("Delete the current transaction?");
-        const char *recn_warn = _("You would be deleting a transaction "
-                                  "with reconciled splits! "
-                                  "This is not a good idea as it will cause your "
-                                  "reconciled balance to be off.");
-
-        dialog = gtk_message_dialog_new (GTK_WINDOW (gsr->window),
-                                        GTK_DIALOG_MODAL
-                                        | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                        GTK_MESSAGE_WARNING,
-                                        GTK_BUTTONS_NONE,
-                                        "%s", title);
-        if (xaccTransHasReconciledSplits (trans))
-        {
-            gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                    "%s", recn_warn);
-            warning = "register_delete_trans2";
-        }
-        else
-        {
-            warning = "register_delete_trans";
-        }
-        gtk_dialog_add_button (GTK_DIALOG (dialog),
-                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-        gnc_gtk_dialog_add_button (dialog, _("_Delete Transaction"),
-                                  GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
-        response =  gnc_dialog_run (GTK_DIALOG (dialog), warning);
-        gtk_widget_destroy (dialog);
-        if (response != GTK_RESPONSE_ACCEPT)
-            return;
-
-        gnc_tree_view_split_reg_delete_current_trans (view);
-        return;
-    }
-}
-
-/**
- * Deletes the current transaction.
- **/
-void
-gnc_split_reg2_delete_trans_cb(GtkWidget *widget, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "delete_ent" );*/
-}
-
-
-void
-gsr2_default_dup_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnc_split_register_duplicate_current
-    (gnc_ledger_display2_get_split_register( gsr->ledger ));*/
-}
-
-
-/**
- * Duplicates the current transaction in the register.
- **/
-void
-gnc_split_reg2_duplicate_trans_cb(GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "dup_ent" );*/
-}
-
-/**
  * Schedules the current transaction for recurring-entry.
  * If the selected transaction was created from a scheduled transaction,
  * opens the editor for that Scheduled Transaction.
@@ -1340,139 +803,8 @@
     gsr2_emit_simple_signal( gsr, "enter_ent" );*/
 }
 
-void
-gsr2_default_cancel_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnc_split_register_cancel_cursor_trans_changes
-    (gnc_ledger_display2_get_split_register( gsr->ledger ));*/
-}
 
-/**
- * Cancels the edits of the currently-selected transaction.
- **/
 void
-gnc_split_reg2_cancel_trans_cb(GtkWidget *w, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "cancel_ent" );*/
-}
-
-void
-gsr2_default_expand_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME*/
-#ifdef skip
-    gint activeCount;
-    gboolean expand;
-    SplitRegister *reg;
-
-    if (!gsr)
-        return;
-
-    reg = gnc_ledger_display2_get_split_register (gsr->ledger);
-
-    /* These should all be in agreement. */
-    activeCount =
-        ( ( GTK_CHECK_MENU_ITEM(gsr->split_menu_check)->active ? 1 : -1 )
-          + ( GTK_CHECK_MENU_ITEM(gsr->split_popup_check)->active ? 1 : -1 )
-          + ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(gsr->split_button) )
-              ? 1 : -1 ) );
-
-    /* If activeCount > 0, then there's more active than inactive; otherwise,
-     * more inactive than active.  Both determine which state the user is
-     * attempting to get to. */
-    expand = ( activeCount < 0 );
-
-    /* The ledger's invocation of 'redraw_all' will force the agreement in the
-     * other split state widgets, so we neglect doing it here.  */
-    gnc_split_register_expand_current_trans (reg, expand);
-#endif
-}
-
-void
-gnc_split_reg2_expand_trans_menu_cb (GtkWidget *widget, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "expand_ent" );*/
-}
-
-void
-gnc_split_reg2_expand_trans_toolbar_cb (GtkWidget *widget, gpointer data)
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "expand_ent" );*/
-}
-
-/**
- * move the cursor to the split, if present in register
-**/
-void
-gnc_split_reg2_jump_to_split (GNCSplitReg2 *gsr, Split *split) //this works
-{
-    GncTreeViewSplitReg *view;
-
-//FIXME maybe collapse this back to plugin-page-register
-
-    view = gnc_ledger_display2_get_split_view_register (gsr->ledger);
-
-    gnc_tree_view_split_reg_jump_to_split (view, split);
-
-}
-
-
-/**
- * Move the cursor to the split in the non-blank amount column.
- **/
-void
-gnc_split_reg2_jump_to_split_amount(GNCSplitReg2 *gsr, Split *split)
-{
-/*FIXME*/
-#ifdef skip
-    VirtualLocation virt_loc;
-    SplitRegister *reg;
-    Transaction *trans;
-
-    if (!gsr) return;
-
-    trans = xaccSplitGetParent(split);
-    gsr2_emit_include_date_signal( gsr, xaccTransGetDate(trans) );
-
-    reg = gnc_ledger_display2_get_split_register (gsr->ledger);
-
-    if (gnc_split_register_get_split_amount_virt_loc (reg, split, &virt_loc))
-        gnucash_register_goto_virt_loc (gsr->reg, virt_loc);
-
-    gnc_ledger_display2_refresh (gsr->ledger);
-#endif
-}
-
-void
-gnc_split_reg2_jump_to_blank (GNCSplitReg2 *gsr)
-{
-/*FIXME*/
-#ifdef skip
-    SplitRegister *reg = gnc_ledger_display2_get_split_register (gsr->ledger);
-    VirtualCellLocation vcell_loc;
-    Split *blank;
-
-    ENTER("gsr=%p", gsr);
-
-    blank = gnc_split_register_get_blank_split (reg);
-    if (blank == NULL)
-    {
-        LEAVE("no blank split");
-        return;
-    }
-
-    if (gnc_split_register_get_split_virt_loc (reg, blank, &vcell_loc))
-        gnucash_register_goto_virt_cell (gsr->reg, vcell_loc);
-
-    gnc_ledger_display2_refresh (gsr->ledger);
-    LEAVE(" ");
-#endif
-}
-
-void
 gnc_split_reg2_balancing_entry(GNCSplitReg2 *gsr, Account *account,
                               time64 statement_date, gnc_numeric balancing_amount)
 {
@@ -1482,118 +814,73 @@
     Split *split;
 
     // create transaction
-    transaction = create_balancing_transaction(gnc_get_current_book(),
+    transaction = create_balancing_transaction (gnc_get_current_book(),
                   account, statement_date, balancing_amount);
 
     // jump to transaction
-    split = xaccTransFindSplitByAccount(transaction, account);
+    split = xaccTransFindSplitByAccount (transaction, account);
     if (split == NULL)
     {
         // default behaviour: jump to blank split
         g_warning("create_balancing_transaction failed");
-        gnc_split_reg2_jump_to_blank(gsr);
+        gnc_split_reg2_jump_to_blank (gsr);
     }
     else
     {
         // goto balancing transaction
-        gnc_split_reg2_jump_to_split(gsr, split );
+        gnc_split_reg2_jump_to_split (gsr, split );
     }
 #endif
 }
 
 static Transaction*
-create_balancing_transaction(QofBook *book, Account *account,
+create_balancing_transaction (QofBook *book, Account *account,
                              time64 statement_date, gnc_numeric balancing_amount)
 {
-/*FIXME*/
-#ifdef skip
     Transaction *trans;
     Split *split;
 
     if (!account)
         return NULL;
-    if (gnc_numeric_zero_p(balancing_amount))
+    if (gnc_numeric_zero_p (balancing_amount))
         return NULL;
 
-    xaccAccountBeginEdit(account);
+    xaccAccountBeginEdit (account);
 
-    trans = xaccMallocTransaction(book);
+    trans = xaccMallocTransaction (book);
 
-    xaccTransBeginEdit(trans);
+    xaccTransBeginEdit (trans);
 
     // fill Transaction
-    xaccTransSetCurrency(trans, xaccAccountGetCommodity(account));
-    xaccTransSetDatePostedSecs(trans, statement_date);
-    xaccTransSetDescription(trans, _("Balancing entry from reconcilation"));
+    xaccTransSetCurrency (trans, xaccAccountGetCommodity (account));
+    xaccTransSetDatePostedSecs (trans, statement_date);
+    xaccTransSetDescription (trans, _("Balancing entry from reconcilation"));
 
     // 1. Split
-    split = xaccMallocSplit(book);
-    xaccTransAppendSplit(trans, split);
-    xaccAccountInsertSplit(account, split);
-    xaccSplitSetAmount(split, balancing_amount);
-    xaccSplitSetValue(split, balancing_amount);
+    split = xaccMallocSplit (book);
+    xaccTransAppendSplit (trans, split);
+    xaccAccountInsertSplit  (account, split);
+    xaccSplitSetAmount (split, balancing_amount);
+    xaccSplitSetValue (split, balancing_amount);
 
     // 2. Split (no account is defined: split goes to orphan account)
-    split = xaccMallocSplit(book);
-    xaccTransAppendSplit(trans, split);
+    split = xaccMallocSplit (book);
+    xaccTransAppendSplit (trans, split);
 
-    balancing_amount = gnc_numeric_neg(balancing_amount);
-    xaccSplitSetAmount(split, balancing_amount);
-    xaccSplitSetValue(split, balancing_amount);
+    balancing_amount = gnc_numeric_neg (balancing_amount);
+    xaccSplitSetAmount (split, balancing_amount);
+    xaccSplitSetValue (split, balancing_amount);
 
-    xaccTransCommitEdit(trans);
-    xaccAccountCommitEdit(account);
+    xaccTransCommitEdit (trans);
+    xaccAccountCommitEdit (account);
     return trans;
-#endif
-return NULL;
 }
 
-void
-gsr2_default_blank_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME*/
-#ifdef skip
-    SplitRegister *reg;
 
-    ENTER("gsr=%p, gpointer=%p", gsr, data);
+/* ############################## End Handlers ############################ */
 
-    reg = gnc_ledger_display2_get_split_register (gsr->ledger);
 
-    if (gnc_split_register_save (reg, TRUE))
-        gnc_split_register_redraw (reg);
-
-    gnc_split_reg2_jump_to_blank (gsr);
-    LEAVE(" ");
-#endif
-}
-
 void
-gnc_split_reg2_new_trans_cb (GtkWidget *widget, gpointer data)
-{
-/*FIXME   GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "blank" );*/
-}
-
-void
-gsr2_default_jump_handler( GNCSplitReg2 *gsr, gpointer data )
-{
- /*FIXME   g_assert_not_reached();*/
-}
-
-void
-gnc_split_reg2_jump_cb( GtkWidget *widget, gpointer data )
-{
-/*FIXME    GNCSplitReg2 *gsr = data;
-    gsr2_emit_simple_signal( gsr, "jump" ); */
-}
-
-/* ###### End Handlers ##### */
-
-
-
-
-
-void
 gnc_split_reg2_change_style (GNCSplitReg2 *gsr, SplitRegisterStyle2 style)
 {
     GncTreeModelSplitReg *model = gnc_ledger_display2_get_split_model_register (gsr->ledger);
@@ -1610,7 +897,7 @@
 {
     GNCSplitReg2 *gsr = data;
 
-    if (!GTK_CHECK_MENU_ITEM(w)->active)
+    if (!GTK_CHECK_MENU_ITEM (w)->active)
         return;
 
     gnc_split_reg2_change_style (gsr, REG2_STYLE_LEDGER);
@@ -1621,7 +908,7 @@
 {
     GNCSplitReg2 *gsr = data;
 
-    if (!GTK_CHECK_MENU_ITEM(w)->active)
+    if (!GTK_CHECK_MENU_ITEM (w)->active)
         return;
 
     gnc_split_reg2_change_style (gsr, REG2_STYLE_AUTO_LEDGER);
@@ -1632,7 +919,7 @@
 {
     GNCSplitReg2 *gsr = data;
 
-    if (!GTK_CHECK_MENU_ITEM(w)->active)
+    if (!GTK_CHECK_MENU_ITEM (w)->active)
         return;
 
     gnc_split_reg2_change_style (gsr, REG2_STYLE_JOURNAL);
@@ -1645,18 +932,18 @@
     GncTreeModelSplitReg *model = gnc_ledger_display2_get_split_model_register (gsr->ledger);
     gboolean use_double_line;
 
-    use_double_line = GTK_CHECK_MENU_ITEM(w)->active;
-    if ( use_double_line == model->use_double_line )
+    use_double_line = GTK_CHECK_MENU_ITEM (w)->active;
+    if (use_double_line == model->use_double_line)
         return;
 
-    gnc_tree_model_split_reg_config( model, model->type, model->style, use_double_line );
-    gnc_ledger_display2_refresh( gsr->ledger );
+    gnc_tree_model_split_reg_config (model, model->type, model->style, use_double_line);
+    gnc_ledger_display2_refresh (gsr->ledger);
 }
 
 static void
-gnc_split_reg2_sort( GNCSplitReg2 *gsr, SortType sort_code )
+gnc_split_reg2_sort (GNCSplitReg2 *gsr, SortType sort_code)
 {
-    Query *query = gnc_ledger_display2_get_query( gsr->ledger );
+    Query *query = gnc_ledger_display2_get_query (gsr->ledger);
     gboolean show_present_divider = FALSE;
     GSList *p1 = NULL, *p2 = NULL, *p3 = NULL, *standard;
     GncTreeModelSplitReg *model;
@@ -1664,7 +951,7 @@
     if (gsr->sort_type == sort_code)
         return;
 
-    standard = g_slist_prepend( NULL, QUERY_DEFAULT_SORT );
+    standard = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
 
     switch (sort_code)
     {
@@ -1721,99 +1008,82 @@
         break;
     }
 
-    qof_query_set_sort_order( query, p1, p2, p3 );
-    model = gnc_ledger_display2_get_split_model_register( gsr->ledger );
-/*FIXME    gnc_split_register_show_present_divider( model, show_present_divider ); */
+    qof_query_set_sort_order (query, p1, p2, p3);
+    model = gnc_ledger_display2_get_split_model_register (gsr->ledger);
     gsr->sort_type = sort_code;
-    gnc_ledger_display2_refresh( gsr->ledger );
+    gnc_ledger_display2_refresh (gsr->ledger);
 }
 
 void
-gnc_split_reg2_sort_standard_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_standard_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_STANDARD);
+    gnc_split_reg2_sort (gsr, BY_STANDARD);
 }
 
 void
-gnc_split_reg2_sort_date_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_date_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_DATE);
+    gnc_split_reg2_sort (gsr, BY_DATE);
 }
 
 void
-gnc_split_reg2_sort_date_entered_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_date_entered_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_DATE_ENTERED);
+    gnc_split_reg2_sort (gsr, BY_DATE_ENTERED);
 }
 
 void
-gnc_split_reg2_sort_date_reconciled_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_date_reconciled_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_DATE_RECONCILED);
+    gnc_split_reg2_sort (gsr, BY_DATE_RECONCILED);
 }
 
 void
-gnc_split_reg2_sort_num_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_num_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_NUM);
+    gnc_split_reg2_sort (gsr, BY_NUM);
 }
 
 void
-gnc_split_reg2_sort_amount_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_amount_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_AMOUNT);
+    gnc_split_reg2_sort (gsr, BY_AMOUNT);
 }
 
 void
-gnc_split_reg2_sort_memo_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_memo_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_MEMO);
+    gnc_split_reg2_sort (gsr, BY_MEMO);
 }
 
 void
-gnc_split_reg2_sort_desc_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_desc_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_DESC);
+    gnc_split_reg2_sort (gsr, BY_DESC);
 }
 
 void
-gnc_split_reg2_sort_action_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_action_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_ACTION);
+    gnc_split_reg2_sort (gsr, BY_ACTION);
 }
 
 void
-gnc_split_reg2_sort_notes_cb(GtkWidget *w, gpointer data)
+gnc_split_reg2_sort_notes_cb (GtkWidget *w, gpointer data)
 {
     GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort(gsr, BY_NOTES);
+    gnc_split_reg2_sort (gsr, BY_NOTES);
 }
 
-
-
-void
-gnc_split_reg2_handle_exchange_cb (GtkWidget *w, gpointer data)
-{
-/*FIXME*/
-#ifdef skip
-    GNCSplitReg2 *gsr = data;
-    SplitRegister *reg = gnc_ledger_display2_get_split_register (gsr->ledger);
-
-    /* XXX Ignore the return value -- we don't care if this succeeds */
-    (void)gnc_split_register_handle_exchange (reg, TRUE);
-#endif
-}
-
-
 static void
 gnc_split_reg2_record (GNCSplitReg2 *gsr)
 {
@@ -1873,67 +1143,7 @@
 #endif
 }
 
-void
-gnc_split_reg2_enter (GNCSplitReg2 *gsr, gboolean next_transaction) //this works
-{
-    GncTreeViewSplitReg *view = gnc_ledger_display2_get_split_view_register (gsr->ledger);
-    GncTreeModelSplitReg *model;
-    gboolean goto_blank;
 
-    ENTER("gsr=%p, next_transaction=%s", gsr, next_transaction ? "TRUE" : "FALSE");
-
-    model = gnc_ledger_display2_get_split_model_register (gsr->ledger);
-
-    goto_blank = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER,
-                                    "enter_moves_to_end", NULL);
-
-    /* If we are in single or double line mode and we hit enter
-     * on the blank split, go to the blank split instead of the
-     * next row. This prevents the cursor from jumping around
-     * when you are entering transactions. */
-    if ( !goto_blank && !next_transaction )
-    {
-        SplitRegisterStyle2 style = model->style;
-
-        if (style == REG2_STYLE_LEDGER)
-        {
-            Split *blank_split;
-
-            blank_split = gnc_tree_view_split_reg_get_blank_split (view);
-            if (blank_split != NULL)
-            {
-                Split *current_split;
-
-                current_split = gnc_tree_view_split_reg_get_current_split (view);
-
-                if (blank_split == current_split)
-                    goto_blank = TRUE;
-            }
-        }
-    }
-
-    /* First record the transaction */
-    if (gnc_tree_view_split_reg_enter (view))
-    {
-        if (!goto_blank && next_transaction)
-            gnc_tree_view_split_reg_expand_current_trans (view, FALSE);
-
-        /* Now move. */
-        if (goto_blank)
-            gnc_tree_view_split_reg_jump_to_blank (view);
-        else if (next_transaction)
-            gnc_tree_view_split_reg_goto_rel_trans_row (view, 1);
-    }
-    LEAVE(" ");
-}
-
-void
-gsr2_default_enter_handler( GNCSplitReg2 *gsr, gpointer data )
-{
-/*FIXME    gnc_split_reg2_enter( gsr, FALSE );*/
-}
-
-
 #ifdef skip
 void
 gnc_split_reg2_record_cb (GnucashRegister *reg, gpointer data)
@@ -1942,17 +1152,6 @@
 }
 #endif
 
-
-void
-gnc_split_reg2_size_allocate (GtkWidget *widget,
-                             GtkAllocation *allocation,
-                             gpointer user_data)
-{
-    GNCSplitReg2 *gsr = user_data;
-    gsr->width = allocation->width;
-    gtk_window_set_default_size( GTK_WINDOW(gsr->window), gsr->width, 0 );
-}
-
 static
 GtkWidget*
 add_summary_label (GtkWidget *summarybar, const char *label_str)
@@ -1975,7 +1174,7 @@
 }
 
 GtkWidget *
-gsr2_create_summary_bar( GNCSplitReg2 *gsr )
+gsr2_create_summary_bar (GNCSplitReg2 *gsr)
 {
     GtkWidget *summarybar;
 
@@ -1987,7 +1186,7 @@
     gsr->shares_label     = NULL;
     gsr->value_label      = NULL;
 
-    if ( gnc_ledger_display2_type(gsr->ledger) >= LD2_SUBACCOUNT )
+    if (gnc_ledger_display2_type (gsr->ledger) >= LD2_SUBACCOUNT)
     {
         gsr->summarybar = NULL;
         return NULL;
@@ -2024,7 +1223,7 @@
  **/
 static
 GNCPlaceholderType
-gnc_split_reg2_get_placeholder( GNCSplitReg2 *gsr )
+gnc_split_reg2_get_placeholder (GNCSplitReg2 *gsr)
 {
     Account *leader;
     GncTreeModelSplitReg *model;
@@ -2033,7 +1232,7 @@
     if (gsr == NULL)
         return PLACEHOLDER_NONE;
 
-    model = gnc_ledger_display2_get_split_model_register( gsr->ledger );
+    model = gnc_ledger_display2_get_split_model_register (gsr->ledger);
 
     switch (model->type)
     {
@@ -2048,17 +1247,17 @@
         break;
     }
 
-    leader = gnc_ledger_display2_leader( gsr->ledger );
+    leader = gnc_ledger_display2_leader (gsr->ledger);
 
     if (leader == NULL)
         return PLACEHOLDER_NONE;
     if (single_account)
     {
-        if (xaccAccountGetPlaceholder( leader ))
+        if (xaccAccountGetPlaceholder (leader))
             return PLACEHOLDER_THIS;
         return PLACEHOLDER_NONE;
     }
-    return xaccAccountGetDescendantPlaceholder( leader );
+    return xaccAccountGetDescendantPlaceholder (leader);
 }
 
 /**
@@ -2083,16 +1282,16 @@
     const gchar *read_only = _("This account register is read-only.");
     GtkWidget *dialog;
 
-    dialog = gtk_message_dialog_new(GTK_WINDOW(args->gsr->window),
+    dialog = gtk_message_dialog_new (GTK_WINDOW(args->gsr->window),
                                     GTK_DIALOG_DESTROY_WITH_PARENT,
                                     GTK_MESSAGE_WARNING,
                                     GTK_BUTTONS_CLOSE,
                                     "%s", read_only);
-    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
             "%s", args->string);
-    gnc_dialog_run(GTK_DIALOG(dialog), "register_read_only");
-    gtk_widget_destroy(dialog);
-    g_free(args);
+    gnc_dialog_run (GTK_DIALOG (dialog), "register_read_only");
+    gtk_widget_destroy (dialog);
+    g_free (args);
     return FALSE;
 }
 
@@ -2101,9 +1300,9 @@
  **/
 static
 void
-gnc_split_reg2_determine_read_only( GNCSplitReg2 *gsr )
+gnc_split_reg2_determine_read_only (GNCSplitReg2 *gsr) //this works
 {
-    dialog_args *args = g_malloc(sizeof(dialog_args));
+    dialog_args *args = g_malloc (sizeof (dialog_args));
     GncTreeViewSplitReg *view;
 
     if (qof_book_is_readonly (gnc_get_current_book()))
@@ -2147,10 +1346,10 @@
 
 static
 GtkWidget *
-gnc_split_reg2_get_parent( GNCLedgerDisplay2 *ledger )
+gnc_split_reg2_get_parent (GNCLedgerDisplay2 *ledger)
 {
     GNCSplitReg2 *gsr =
-        GNC_SPLIT_REG2(gnc_ledger_display2_get_user_data( ledger ));
+        GNC_SPLIT_REG2 (gnc_ledger_display2_get_user_data (ledger));
 
     if (gsr == NULL)
         return NULL;
@@ -2160,7 +1359,7 @@
 
 static
 void
-gsr2_emit_help_changed (GncTreeViewSplitReg *view, gpointer user_data ) //this works
+gsr2_emit_help_changed (GncTreeViewSplitReg *view, gpointer user_data) //this works
 {
     gsr2_emit_simple_signal ((GNCSplitReg2*)user_data, "help-changed" );
 }
@@ -2174,7 +1373,7 @@
 
 static
 void
-gsr2_emit_simple_signal( GNCSplitReg2 *gsr, const char *sigName ) //this works
+gsr2_emit_simple_signal (GNCSplitReg2 *gsr, const char *sigName) //this works
 {
     g_signal_emit_by_name( gsr, sigName, NULL );
 }
@@ -2189,35 +1388,34 @@
 }
 
 SortType
-gnc_split_reg2_get_sort_type( GNCSplitReg2 *gsr )
+gnc_split_reg2_get_sort_type (GNCSplitReg2 *gsr)
 {
-    g_assert( gsr );
+    g_assert (gsr);
     return gsr->sort_type;
 }
 
 void
-gnc_split_reg2_set_sort_type( GNCSplitReg2 *gsr, SortType t )
+gnc_split_reg2_set_sort_type (GNCSplitReg2 *gsr, SortType t)
 {
-    gnc_split_reg2_sort( gsr, t );
+    gnc_split_reg2_sort (gsr, t);
 }
 
 GtkWidget*
-gnc_split_reg2_get_summarybar( GNCSplitReg2 *gsr )
+gnc_split_reg2_get_summarybar (GNCSplitReg2 *gsr)
 {
-    if ( !gsr ) return NULL;
+    if (!gsr) return NULL;
     return gsr->summarybar;
 }
 
 gboolean
-gnc_split_reg2_get_read_only( GNCSplitReg2 *gsr )
+gnc_split_reg2_get_read_only (GNCSplitReg2 *gsr)
 {
-    g_assert( gsr );
+    g_assert (gsr);
     return gsr->read_only;
 }
 
 void
-gnc_split_reg2_set_moved_cb( GNCSplitReg2 *gsr, GFunc cb, gpointer cb_data ) //this works
+gnc_split_reg2_set_moved_cb (GNCSplitReg2 *gsr, GFunc cb, gpointer cb_data ) //this works
 {
-g_print("gnc_split_reg2_set_moved_cb\n");
     gnc_tree_view_split_reg_moved_cb (gnc_ledger_display2_get_split_view_register(gsr->ledger), cb, cb_data);
 }

Modified: gnucash/trunk/src/gnome/gnc-split-reg2.h
===================================================================
--- gnucash/trunk/src/gnome/gnc-split-reg2.h	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome/gnc-split-reg2.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -6,6 +6,7 @@
  * Copyright (C) 1999-2000 Dave Peticolas <dave at krondo.com>         *
  * Copyright (C) 2001 Gnumatic, Inc.                                *
  * Copyright (C) 2002,2006 Joshua Sled <jsled at asynchronous.org>     *
+ * Copyright (C) 2012 Robert Fewell                                 *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -95,24 +96,9 @@
     GtkVBoxClass parent_class;
 
     /* Signal defaults */
-    void (*enter_ent_cb)    ( GNCSplitReg2 *w, gpointer user_data );
-    void (*cancel_ent_cb)   ( GNCSplitReg2 *w, gpointer user_data );
-    void (*delete_ent_cb)   ( GNCSplitReg2 *w, gpointer user_data );
-    void (*reinit_ent_cb)   ( GNCSplitReg2 *w, gpointer user_data );
-    void (*dup_ent_cb)      ( GNCSplitReg2 *w, gpointer user_data );
+
     void (*schedule_ent_cb) ( GNCSplitReg2 *w, gpointer user_data );
-    void (*expand_ent_cb)   ( GNCSplitReg2 *w, gpointer user_data );
-    void (*blank_cb)        ( GNCSplitReg2 *w, gpointer user_data );
-    void (*jump_cb)         ( GNCSplitReg2 *w, gpointer user_data );
-    void (*cut_cb)          ( GNCSplitReg2 *w, gpointer user_data );
-    void (*cut_txn_cb)      ( GNCSplitReg2 *w, gpointer user_data );
-    void (*copy_cb)         ( GNCSplitReg2 *w, gpointer user_data );
-    void (*copy_txn_cb)     ( GNCSplitReg2 *w, gpointer user_data );
-    void (*paste_cb)        ( GNCSplitReg2 *w, gpointer user_data );
-    void (*paste_txn_cb)    ( GNCSplitReg2 *w, gpointer user_data );
-    void (*void_txn_cb)     ( GNCSplitReg2 *w, gpointer user_data );
-    void (*unvoid_txn_cb)   ( GNCSplitReg2 *w, gpointer user_data );
-    void (*reverse_txn_cb)  ( GNCSplitReg2 *w, gpointer user_data );
+
     void (*help_changed_cb) ( GNCSplitReg2 *w, gpointer user_data );
     void (*include_date_cb) ( GNCSplitReg2 *w, time64 date, gpointer user_data );
 };
@@ -120,21 +106,8 @@
 #ifdef skip // Coming from original gnc-split-reg.h
 typedef enum
 {
-    ENTER,
-    CANCEL,
-    DELETE,
-    REINIT,
-    DUPLICATE,
     SCHEDULE,
     SPLIT,
-    BLANK,
-    JUMP,
-    CUT,
-    CUT_TXN,
-    COPY,
-    COPY_TXN,
-    PASTE,
-    PASTE_TXN,
     SORT_ORDER_SUBMENU,
     STYLE_SUBMENU,
 } GNC_SPLIT_REG2_ITEM;
@@ -212,13 +185,6 @@
  **/
 GtkWidget *gnc_split_reg2_get_summarybar (GNCSplitReg2 *gsr );
 
-/**
- * These will manipulate the in-GNCSplitReg state-reflecting widgets as
- * appropriate.
- **/
-void gnc_split_reg2_set_split_state (GNCSplitReg2 *gsr, gboolean split );
-void gnc_split_reg2_set_double_line (GNCSplitReg2 *gsr, gboolean doubleLine );
-
 void gnc_split_reg2_raise (GNCSplitReg2 *gsr );
 
 /**
@@ -229,13 +195,6 @@
 gboolean gnc_split_reg2_get_read_only (GNCSplitReg2 *gsr );
 
 /*
- * Function to jump to various places in the register
- */
-void gnc_split_reg2_jump_to_blank (GNCSplitReg2 *gsr);
-void gnc_split_reg2_jump_to_split (GNCSplitReg2 *gsr, Split *split);
-void gnc_split_reg2_jump_to_split_amount (GNCSplitReg2 *gsr, Split *split);
-
-/*
  * Create a transaction entry with given amount and date. One account is
  * specified, the other is undefined i.e. it defaults to orphan account.
  * Jump to the transaction entry in the register.
@@ -245,11 +204,6 @@
 void gnc_split_reg2_balancing_entry (GNCSplitReg2 *gsr, Account *account,
                                     time64 statement_date, gnc_numeric balancing_amount);
 
-void gsr2_default_delete_handler (GNCSplitReg2 *gsr, gpointer data );
-void gnc_split_reg2_enter (GNCSplitReg2 *gsr, gboolean next_transaction );
-void gsr2_default_delete_handler (GNCSplitReg2 *gsr, gpointer data );
-void gsr2_default_reinit_handler (GNCSplitReg2 *gsr, gpointer data );
-void gsr2_default_expand_handler (GNCSplitReg2 *gsr, gpointer data );
 void gsr2_default_schedule_handler (GNCSplitReg2 *gsr, gpointer data );
 
 void gnc_split_reg2_set_moved_cb (GNCSplitReg2 *gsr, GFunc cb, gpointer cb_data );

Modified: gnucash/trunk/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/Makefile.am	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome-utils/Makefile.am	2013-02-28 09:52:12 UTC (rev 22815)
@@ -83,6 +83,7 @@
   gnc-splash.c \
   gnc-sx-instance-dense-cal-adapter.c \
   gnc-sx-list-tree-model-adapter.c \
+  gnc-tree-control-split-reg.c \
   gnc-tree-model.c \
   gnc-tree-model-account-types.c \
   gnc-tree-model-account.c \
@@ -160,6 +161,7 @@
   gnc-splash.h \
   gnc-sx-instance-dense-cal-adapter.h \
   gnc-sx-list-tree-model-adapter.h \
+  gnc-tree-control-split-reg.h \
   gnc-tree-model.h \
   gnc-tree-model-account-types.h \
   gnc-tree-model-account.h \

Modified: gnucash/trunk/src/gnome-utils/dialog-transfer.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -1695,6 +1695,7 @@
     SCM quotes_func;
     SCM book_scm;
     SCM scm_window;
+    gboolean have_price = FALSE;
 
     g_return_if_fail (xferData);
 
@@ -1736,8 +1737,24 @@
         rate = gnc_price_get_value (prc);
         gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit), rate);
         gnc_price_unref (prc);
+        have_price = TRUE;
     }
 
+    /* Lets try reversing the commodities */
+    if(!have_price)
+    {
+        prc = gnc_pricedb_lookup_latest (xferData->pricedb, to, from);
+        if (prc)
+        {
+            rate = gnc_numeric_div (gnc_numeric_create (1, 1), gnc_price_get_value (prc),
+                                 GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
+
+            gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit), rate);
+            gnc_price_unref (prc);
+            have_price = TRUE;
+        }
+    }
+
     LEAVE("quote retrieved");
 
 }

Added: gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.c	                        (rev 0)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -0,0 +1,1718 @@
+/********************************************************************\
+ * gnc-tree-control-split-reg.c -- GtkTreeView implementation       *
+ *                     to display registers in a GtkTreeView.       *
+ *                                                                  *
+ * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <libguile.h>
+#include <string.h>
+
+#include "gnc-tree-control-split-reg.h"
+#include "gnc-tree-model-split-reg.h"
+#include "gnc-tree-view-split-reg.h"
+#include "gnc-component-manager.h"
+#include "gnc-ui.h"
+#include "gnc-gconf-utils.h"
+#include "gnc-gdate-utils.h"
+#include "dialog-utils.h"
+#include "guile-util.h"
+#include "dialog-dup-trans.h"
+
+#include "Transaction.h"
+#include "engine-helpers.h"
+
+/** Static Globals *******************************************************/
+static QofLogModule log_module = GNC_MOD_LEDGER;
+
+static gboolean gtc_scroll_to_cell (GncTreeViewSplitReg *view);
+static GncTreeModelSplitReg *gtc_get_model_split_reg_from_view (GncTreeViewSplitReg *view);
+
+static SCM copied_item = SCM_UNDEFINED;
+
+/** implementations *******************************************************/
+
+/* Uses the scheme split copying routines */
+static void
+gtc_copy_split_onto_split (Split *from, Split *to, gboolean use_cut_semantics)
+{
+    SCM split_scm;
+
+    if ((from == NULL) || (to == NULL))
+        return;
+
+    split_scm = gnc_copy_split(from, use_cut_semantics);
+    if (split_scm == SCM_UNDEFINED)
+        return;
+
+    gnc_copy_split_scm_onto_split (split_scm, to, gnc_get_current_book ());
+}
+
+/* Uses the scheme transaction copying routines */
+static void
+gtc_copy_trans_onto_trans (Transaction *from, Transaction *to,
+                          gboolean use_cut_semantics,
+                          gboolean do_commit)
+{
+    SCM trans_scm;
+
+    if ((from == NULL) || (to == NULL))
+        return;
+
+    trans_scm = gnc_copy_trans(from, use_cut_semantics);
+    if (trans_scm == SCM_UNDEFINED)
+        return;
+
+    gnc_copy_trans_scm_onto_trans (trans_scm, to, do_commit,
+                                  gnc_get_current_book ());
+}
+
+
+/*************************************************************************/
+//FIXME For convienience, these functions are duplicates, needs changing
+
+static GncTreeModelSplitReg *
+gtc_get_model_split_reg_from_view (GncTreeViewSplitReg *view)
+{
+    GtkTreeModelSort *s_model = GTK_TREE_MODEL_SORT(
+        gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
+    return GNC_TREE_MODEL_SPLIT_REG (gtk_tree_model_sort_get_model (s_model));
+}
+
+
+/* Scroll the view to show selected row based on sort direction */
+static gboolean
+gtc_scroll_to_cell (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    GtkTreePath *mpath, *spath;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    mpath = gnc_tree_view_split_reg_get_current_path (view);
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+
+    if (view->sort_direction == 1)
+        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 0.0, 0.0);
+    else
+    {
+        if (model->use_double_line)
+        {
+            gtk_tree_path_down (spath); // move to the second row of transaction
+            gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 1.0, 0.0);
+            gtk_tree_path_up (spath); // back to first row of transaction
+        }
+        else
+            gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 1.0, 0.0);
+    }
+    gtk_tree_path_free (mpath);
+    gtk_tree_path_free (spath);
+    return (FALSE);
+}
+
+
+/* Returns a Split that matches the current Account */
+static Split *
+gtc_get_this_split (GncTreeViewSplitReg *view, Transaction *trans)
+{
+    GncTreeModelSplitReg *model;
+    int i;
+    Split *split = NULL;
+    Account *anchor;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    anchor = gnc_tree_model_split_reg_get_anchor (model);
+
+    for (i = 0; (split = xaccTransGetSplit (trans, i)); i++) {
+        if (anchor == xaccSplitGetAccount (split))
+            return split;
+    }
+    return NULL;
+}
+
+
+/*********************************************************************************/
+
+/* Read only dialoue */
+static gboolean
+gtc_is_trans_readonly_and_warn (const Transaction *trans)
+{
+    GtkWidget *dialog;
+    const gchar *reason;
+    const gchar *title = _("Cannot modify or delete this transaction.");
+    const gchar *message =
+        _("This transaction is marked read-only with the comment: '%s'");
+
+    if (!trans) return FALSE;
+
+    if (xaccTransIsReadonlyByPostedDate (trans))
+    {
+        dialog = gtk_message_dialog_new (NULL,
+                                        0,
+                                        GTK_MESSAGE_ERROR,
+                                        GTK_BUTTONS_OK,
+                                        "%s", title);
+        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                "%s", _("The date of this transaction is older than the \"Read-Only Threshold\" set for this book.  "
+                        "This setting can be changed in File -> Properties -> Accounts."));
+        gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+        return TRUE;
+    }
+
+    reason = xaccTransGetReadOnly (trans);
+    if (reason)
+    {
+        dialog = gtk_message_dialog_new (NULL,
+                                        0,
+                                        GTK_MESSAGE_ERROR,
+                                        GTK_BUTTONS_OK,
+                                        "%s", title);
+        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                message, reason);
+        gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+        return TRUE;
+    }
+    return FALSE;
+}
+
+
+/* Cancel the edit and Rollback */
+void
+gnc_tree_control_split_reg_cancel_edit (GncTreeViewSplitReg *view, gboolean reg_closing)
+{
+//g_print("gnc_tree_control_split_reg_cancel_edit\n");
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
+
+    gnc_tree_view_split_reg_cancel_edit (view, reg_closing);
+}
+
+
+/* Amend the Exchange Rate of the transaction */
+void
+gnc_tree_control_split_reg_exchange_rate (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    GtkWidget *window;
+    Account *anchor;
+    Transaction *trans;
+    Split *split = NULL;
+    Split *osplit = NULL;
+    gnc_numeric value;
+    gboolean expanded;
+    gint depth;
+    gint num_splits;
+    const char *message;
+    gnc_commodity *txn_com;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    trans = gnc_tree_view_split_reg_get_current_trans (view);
+    expanded = gnc_tree_view_split_reg_trans_expanded (view, NULL);
+    depth = gnc_tree_view_reg_get_selected_row_depth (view);
+    num_splits = xaccTransCountSplits (trans);
+    anchor = gnc_tree_model_split_reg_get_anchor (model);
+    txn_com = xaccTransGetCurrency (trans);
+
+    if (gtc_is_trans_readonly_and_warn (trans))
+        return;
+
+    if (num_splits < 2)
+        return;
+
+    window = gnc_tree_view_split_reg_get_parent (view);
+
+    /* If the anchor commodity is not a currency, cancel */
+    if (anchor && !gnc_commodity_is_currency (xaccAccountGetCommodity (anchor)))
+    {
+        message = _("This register does not support editing exchange rates.");
+        gnc_error_dialog (window, "%s", message);
+        return;
+    }
+
+    /* If we're not expanded AND number of splits greater than two, nothing to do */
+    if ((num_splits > 2) && !expanded)
+    {
+        message = _("You need to expand the transaction in order to modify its "
+                    "exchange rates.");
+        gnc_error_dialog (window, "%s", message);
+        return;
+    }
+
+    if (num_splits == 2 && anchor != NULL && !expanded)
+    {
+        split = gnc_tree_control_split_reg_get_current_trans_split (view);
+        osplit = xaccSplitGetOtherSplit (split);
+
+        value = xaccSplitGetValue (split);
+
+        xaccTransBeginEdit (trans);
+        gnc_tree_view_split_reg_set_dirty_trans (view, trans);
+
+        if (txn_com == xaccAccountGetCommodity (xaccSplitGetAccount(split)))
+           gnc_tree_view_split_reg_set_value_for (view, trans, osplit, gnc_numeric_neg (value), TRUE);
+        else
+           gnc_tree_view_split_reg_set_value_for (view, trans, split, value, TRUE);
+
+        xaccTransCommitEdit (trans);
+        gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
+    }
+
+    if (num_splits > 1 && expanded && depth == 3)
+    {
+        split = gnc_tree_view_split_reg_get_current_split (view);
+
+        value = xaccSplitGetValue (split);
+
+        if (txn_com == xaccAccountGetCommodity (xaccSplitGetAccount(split)))
+        {
+            message = _("The two currencies involved equal each other.");
+            gnc_error_dialog (window, "%s", message);
+            return;
+        }
+        else
+        {
+            gnc_tree_view_split_reg_set_dirty_trans (view, trans);
+            xaccTransBeginEdit (trans);
+
+            gnc_tree_view_split_reg_set_value_for (view, trans, split, value, TRUE);
+
+            xaccTransCommitEdit (trans);
+            gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
+        }
+    }
+}
+
+
+/* Void current transaction */
+void
+gnc_tree_control_split_reg_void_current_trans (GncTreeViewSplitReg *view, const char *reason)
+{
+    Transaction *trans;
+    Split *blank_split;
+    Split *split;
+
+    if (!view) return;
+
+    blank_split = gnc_tree_control_split_reg_get_blank_split (view);
+
+    /* get the current split based on cursor position */
+    split = gnc_tree_view_split_reg_get_current_split (view);
+    if (split == NULL)
+        return;
+
+    /* Bail if trying to void the blank split. */
+    if (split == blank_split)
+        return;
+
+    /* already voided. */
+    if (xaccSplitGetReconcile (split) == VREC)
+        return;
+
+    trans = xaccSplitGetParent (split);
+
+    gnc_tree_view_split_reg_set_dirty_trans (view, trans);
+
+    xaccTransVoid (trans, reason);
+
+    if (xaccTransIsOpen (trans))
+    {
+        PERR("We should not be voiding an open transaction.");
+        xaccTransCommitEdit (trans);
+    }
+    gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
+}
+
+
+/* Unvoid current transaction */
+void
+gnc_tree_control_split_reg_unvoid_current_trans (GncTreeViewSplitReg *view)
+{
+    Transaction *trans;
+    Split *blank_split;
+    Split *split;
+
+    if (!view) return;
+
+    blank_split = gnc_tree_control_split_reg_get_blank_split (view);
+
+    /* get the current split based on cursor position */
+    split = gnc_tree_view_split_reg_get_current_split (view);
+    if (split == NULL)
+        return;
+
+    /* Bail if trying to unvoid the blank split. */
+    if (split == blank_split)
+        return;
+
+    /* not voided. */
+    if (xaccSplitGetReconcile (split) != VREC)
+        return;
+
+    trans = xaccSplitGetParent (split);
+
+    gnc_tree_view_split_reg_set_dirty_trans (view, trans);
+
+    xaccTransUnvoid (trans);
+
+    gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
+}
+
+
+/* Jump to the Blank transaction, i.e. last in list */
+void
+gnc_tree_control_split_reg_jump_to_blank (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    GtkTreePath *mpath, *spath;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, NULL);
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+
+    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
+
+    gtk_tree_path_free (spath);
+    gtk_tree_path_free (mpath);
+
+    /* scroll when view idle */
+    g_idle_add ((GSourceFunc)gtc_scroll_to_cell, view );
+}
+
+
+/* Jump to split */
+void
+gnc_tree_control_split_reg_jump_to_split (GncTreeViewSplitReg *view, Split *split)
+{
+    GncTreeModelSplitReg *model;
+    GtkTreePath *mpath, *spath;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, split, NULL);
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+
+    gnc_tree_view_split_reg_set_current_path (view, spath);
+
+    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
+
+    gtk_tree_path_free (spath);
+    gtk_tree_path_free (mpath);
+
+    /* scroll when view idle */
+    g_idle_add ((GSourceFunc)gtc_scroll_to_cell, view );
+}
+
+
+/* Returns the Blank Transaction */
+Transaction *
+gnc_tree_control_split_reg_get_blank_trans (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    return gnc_tree_model_split_get_blank_trans (model);
+}
+
+
+/* Return the Split for the current Transaction */
+Split *
+gnc_tree_control_split_reg_get_current_trans_split (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    Split *split = NULL;
+    Transaction *trans = NULL;
+    gboolean is_trow1, is_trow2, is_split, is_blank;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    path = gnc_tree_view_split_reg_get_current_path (view);
+
+    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+
+    gnc_tree_model_split_reg_get_split_and_trans (
+            GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+
+    split = gtc_get_this_split (view, trans);
+
+    gtk_tree_path_free (path);
+
+    return split;
+}
+
+
+/* Returns the Blank Split */
+Split *
+gnc_tree_control_split_reg_get_blank_split (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    return gnc_tree_model_split_get_blank_split (model);
+}
+
+
+/* Move to the relative transaction */
+void
+gnc_tree_control_split_reg_goto_rel_trans_row (GncTreeViewSplitReg *view, gint relative)
+{
+    GncTreeModelSplitReg *model;
+    GtkTreePath *mpath, *spath;
+    GtkTreePath *new_path;
+    gint *indices;
+
+    ENTER("Move relative, view is %p, relative is %d", view, relative);
+
+//FIXME Do we need to do some checks on relative maybe  -1,0,1 ??
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    mpath = gnc_tree_view_split_reg_get_current_path (view);
+
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+
+    indices = gtk_tree_path_get_indices (spath);
+
+    new_path = gtk_tree_path_new_from_indices (indices[0] + (relative * view->sort_direction), -1);
+
+    gnc_tree_view_split_reg_set_current_path (view, new_path);
+
+    gnc_tree_view_split_reg_block_selection (view, TRUE);
+    gtk_tree_selection_unselect_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
+    gnc_tree_view_split_reg_block_selection (view, FALSE);
+    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), new_path);
+
+    LEAVE("new_path is %s", gtk_tree_path_to_string (new_path));
+
+    gtk_tree_path_free (new_path);
+    gtk_tree_path_free (spath);
+    gtk_tree_path_free (mpath);
+}
+
+
+/* Enter the transaction */
+void
+gnc_tree_control_split_reg_enter (GncTreeViewSplitReg *view, gboolean next_transaction)
+{
+    GncTreeModelSplitReg *model;
+    gboolean goto_blank;
+
+    ENTER("view=%p, next_transaction=%s", view, next_transaction ? "TRUE" : "FALSE");
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    goto_blank = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER,
+                                    "enter_moves_to_end", NULL);
+
+    /* If we are in single or double line mode and we hit enter
+     * on the blank split, go to the blank split instead of the
+     * next row. This prevents the cursor from jumping around
+     * when you are entering transactions. */
+    if ( !goto_blank && !next_transaction )
+    {
+        SplitRegisterStyle2 style = model->style;
+
+        if (style == REG2_STYLE_LEDGER)
+        {
+            Split *blank_split;
+
+            blank_split = gnc_tree_control_split_reg_get_blank_split (view);
+            if (blank_split != NULL)
+            {
+                Split *current_split;
+
+                current_split = gnc_tree_view_split_reg_get_current_split (view);
+
+                if (blank_split == current_split)
+                    goto_blank = TRUE;
+            }
+        }
+    }
+
+    /* First record the transaction */
+    if (gnc_tree_view_split_reg_enter (view))
+    {
+        if (!goto_blank && next_transaction)
+            gnc_tree_view_split_reg_collapse_trans (view, NULL);
+
+        /* Now move. */
+        if (goto_blank)
+            gnc_tree_control_split_reg_jump_to_blank (view);
+        else if (next_transaction)
+            gnc_tree_control_split_reg_goto_rel_trans_row (view, 1);
+    }
+    LEAVE(" ");
+}
+
+
+/* Reinit the transaction */
+void
+gnc_tree_control_split_reg_reinit (GncTreeViewSplitReg *view, gpointer data)
+{
+    Transaction *trans;
+    Split *split;
+    GtkWidget *dialog, *window;
+    gint response;
+    const gchar *warning;
+
+    const char *title = _("Remove the splits from this transaction?");
+    const char *recn_warn = _("This transaction contains reconciled splits. "
+                              "Modifying it is not a good idea because that will "
+                              "cause your reconciled balance to be off.");
+
+    trans = gnc_tree_view_split_reg_get_current_trans (view);
+    if (gtc_is_trans_readonly_and_warn (trans))
+        return;
+
+    window = gnc_tree_view_split_reg_get_parent (view);
+
+    dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                    GTK_DIALOG_DESTROY_WITH_PARENT,
+                                    GTK_MESSAGE_WARNING,
+                                    GTK_BUTTONS_NONE,
+                                    "%s", title);
+    if (xaccTransHasReconciledSplits (trans))
+    {
+        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                "%s", recn_warn);
+        warning = "register_remove_all_splits2";
+    }
+    else
+    {
+        warning = "register_remove_all_splits";
+    }
+
+    gtk_dialog_add_button (GTK_DIALOG (dialog),
+                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+    gnc_gtk_dialog_add_button(dialog, _("_Remove Splits"),
+                              GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
+    response = gnc_dialog_run (GTK_DIALOG(dialog), warning);
+    gtk_widget_destroy (dialog);
+    if (response != GTK_RESPONSE_ACCEPT)
+        return;
+
+    gnc_tree_view_split_reg_reinit_trans (view);
+}
+
+
+/* Delete the currently selected item */
+void
+gnc_tree_control_split_reg_delete (GncTreeViewSplitReg *view, gpointer data)
+{
+    RowDepth depth;
+    Transaction *trans;
+    Split *split;
+    GtkWidget *dialog, *window;
+    gint response;
+    const gchar *warning;
+
+    /* get the current split based on cursor position */
+    split = gnc_tree_view_split_reg_get_current_split (view);
+    if (split == NULL)
+    {
+        return;
+    }
+
+    trans = xaccSplitGetParent (split);
+    depth = gnc_tree_view_reg_get_selected_row_depth (view);
+
+    /* Deleting the blank split just cancels */
+    {
+        Split *blank_split = gnc_tree_control_split_reg_get_blank_split (view);
+
+        if (split == blank_split)
+        {
+            return;
+        }
+    }
+
+    if (gtc_is_trans_readonly_and_warn (trans))
+        return;
+
+    window = gnc_tree_view_split_reg_get_parent (view);
+
+    /* On a split cursor, just delete the one split. */
+    if (depth == SPLIT3)
+    {
+        const char *format = _("Delete the split '%s' from the transaction '%s'?");
+        const char *recn_warn = _("You would be deleting a reconciled split! "
+                                  "This is not a good idea as it will cause your "
+                                  "reconciled balance to be off.");
+        const char *anchor_error = _("You cannot delete this split.");
+        const char *anchor_split = _("This is the split anchoring this transaction "
+                                     "to the register. You may not delete it from "
+                                     "this register window.  You may delete the "
+                                     "entire transaction from this window, or you "
+                                     "may navigate to a register that shows "
+                                     "another side of this same transaction and "
+                                     "delete the split from that register.");
+        char *buf = NULL;
+        const char *memo;
+        const char *desc;
+        char recn;
+
+        if (split == gnc_tree_control_split_reg_get_current_trans_split (view))
+        {
+            dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                            GTK_DIALOG_MODAL
+                                            | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                            GTK_MESSAGE_ERROR,
+                                            GTK_BUTTONS_OK,
+                                            "%s", anchor_error);
+            gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                    "%s", anchor_split);
+            gtk_dialog_run (GTK_DIALOG (dialog));
+            gtk_widget_destroy (dialog);
+            return;
+        }
+
+        memo = xaccSplitGetMemo (split);
+        memo = (memo && *memo) ? memo : _("(no memo)");
+
+        desc = xaccTransGetDescription (trans);
+        desc = (desc && *desc) ? desc : _("(no description)");
+
+        /* ask for user confirmation before performing permanent damage */
+        buf = g_strdup_printf (format, memo, desc);
+        dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                        GTK_DIALOG_MODAL
+                                        | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                        GTK_MESSAGE_QUESTION,
+                                        GTK_BUTTONS_NONE,
+                                        "%s", buf);
+        g_free(buf);
+        recn = xaccSplitGetReconcile (split);
+        if (recn == YREC || recn == FREC)
+        {
+            gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                    "%s", recn_warn);
+            warning = "register_delete_split2";
+        }
+        else
+        {
+            warning = "register_delete_split";
+        }
+
+        gtk_dialog_add_button (GTK_DIALOG (dialog),
+                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+        gnc_gtk_dialog_add_button (dialog, _("_Delete Split"),
+                                  GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
+        response = gnc_dialog_run (GTK_DIALOG (dialog), warning);
+        gtk_widget_destroy (dialog);
+        if (response != GTK_RESPONSE_ACCEPT)
+            return;
+
+        gnc_tree_view_split_reg_delete_current_split (view);
+        return;
+    }
+
+    g_return_if_fail (depth == TRANS1 || depth == TRANS2);
+
+    /* On a transaction cursor with 2 or fewer splits in single or double
+     * mode, we just delete the whole transaction, kerblooie */
+    {
+        const char *title = _("Delete the current transaction?");
+        const char *recn_warn = _("You would be deleting a transaction "
+                                  "with reconciled splits! "
+                                  "This is not a good idea as it will cause your "
+                                  "reconciled balance to be off.");
+
+        dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                        GTK_DIALOG_MODAL
+                                        | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                        GTK_MESSAGE_WARNING,
+                                        GTK_BUTTONS_NONE,
+                                        "%s", title);
+        if (xaccTransHasReconciledSplits (trans))
+        {
+            gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                    "%s", recn_warn);
+            warning = "register_delete_trans2";
+        }
+        else
+        {
+            warning = "register_delete_trans";
+        }
+        gtk_dialog_add_button (GTK_DIALOG (dialog),
+                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+        gnc_gtk_dialog_add_button (dialog, _("_Delete Transaction"),
+                                  GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
+        response =  gnc_dialog_run (GTK_DIALOG (dialog), warning);
+        gtk_widget_destroy (dialog);
+        if (response != GTK_RESPONSE_ACCEPT)
+            return;
+
+        gnc_tree_view_split_reg_delete_current_trans (view);
+        return;
+    }
+}
+
+
+/* Add Reverse Transaction */
+void
+gnc_tree_control_split_reg_reverse_current (GncTreeViewSplitReg *view)
+{
+    GtkWidget *window;
+    Transaction *trans = NULL, *new_trans = NULL;
+
+    trans = gnc_tree_view_split_reg_get_current_trans (view);
+
+    if (trans == NULL)
+        return;
+
+//FIXME Need same tests as duplicate ?????
+
+    window = gnc_tree_view_split_reg_get_parent (view);
+
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
+
+    /* See if we were asked to reverse a blank trans. */
+    if (trans == gnc_tree_control_split_reg_get_blank_trans (view))
+    {
+        LEAVE("skip blank trans");
+        return;
+    }
+
+    if (xaccTransGetReversedBy (trans))
+    {
+        gnc_error_dialog (window, "%s",
+                         _("A reversing entry has already been created for this transaction."));
+        return;
+    }
+
+    xaccTransBeginEdit (trans);
+
+    gnc_tree_view_split_reg_set_dirty_trans (view, trans);
+
+    new_trans = xaccTransReverse (trans);
+
+    /* Clear transaction level info */
+    xaccTransSetDatePostedSecs (new_trans, gnc_time (NULL));
+    xaccTransSetDateEnteredSecs (new_trans, gnc_time (NULL));
+
+    xaccTransCommitEdit (trans);
+
+    gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
+
+    /* Now jump to new trans */
+    gnc_tree_control_split_reg_jump_to_split (view, xaccTransGetSplit (new_trans, 0));
+}
+
+
+/* Duplicate the current selection */
+gboolean
+gnc_tree_control_split_reg_duplicate_current (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    GtkWidget *window;
+    RowDepth depth;
+    Transaction *trans;
+    Split *blank_split;
+    Split *split, *trans_split;
+    gboolean changed = FALSE;
+
+    ENTER("");
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    blank_split = gnc_tree_control_split_reg_get_blank_split (view);
+    split = gnc_tree_view_split_reg_get_current_split (view);
+    trans_split = gnc_tree_control_split_reg_get_current_trans_split (view);
+    trans = gnc_tree_view_split_reg_get_current_trans (view);
+    depth = gnc_tree_view_reg_get_selected_row_depth (view);
+
+    /* This shouldn't happen, but be paranoid. */
+    if (trans == NULL)
+    {
+        LEAVE("no transaction");
+        return FALSE;
+    }
+
+    if (gtc_is_trans_readonly_and_warn (trans))
+        return FALSE;
+
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
+
+    /* See if we are editing this transcation all ready */
+    if (trans == gnc_tree_view_split_reg_get_dirty_trans (view))
+        changed = TRUE;
+
+    /* See if we were asked to duplicate a blank split. */
+    if (split == gnc_tree_control_split_reg_get_blank_split (view))
+    {
+        LEAVE("skip blank split");
+        return FALSE;
+    }
+
+    /* See if we were asked to duplicate a blank trans. */
+    if (trans == gnc_tree_control_split_reg_get_blank_trans (view))
+    {
+        LEAVE("skip blank trans");
+        return FALSE;
+    }
+
+    gnc_suspend_gui_refresh ();
+
+    window = gnc_tree_view_split_reg_get_parent (view);
+
+    /* If the cursor has been edited, we are going to have to commit
+     * it before we can duplicate. Make sure the user wants to do that. */
+    if (changed)
+    {
+        GtkWidget *dialog;
+        gint response;
+        const char *title = _("Save transaction before duplicating?");
+        const char *message =
+            _("The current transaction has been changed. Would you like to "
+              "record the changes before duplicating the transaction, or "
+              "cancel the duplication?");
+
+        dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                        GTK_MESSAGE_QUESTION,
+                                        GTK_BUTTONS_CANCEL,
+                                        "%s", title);
+        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                "%s", message);
+        gtk_dialog_add_button (GTK_DIALOG (dialog),
+                              _("_Record"), GTK_RESPONSE_ACCEPT);
+        response = gnc_dialog_run (GTK_DIALOG (dialog), "transaction_duplicated");
+        gtk_widget_destroy (dialog);
+
+        if (response != GTK_RESPONSE_ACCEPT)
+        {
+            gnc_resume_gui_refresh ();
+            LEAVE("save cancelled");
+            return FALSE;
+        }
+
+        xaccTransCommitEdit (trans);
+        gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
+    }
+
+    /* Ok, we are now ready to make the copy. */
+
+    if (depth == SPLIT3)
+    {
+        Split *new_split;
+
+        /* We are on a split in an expanded transaction.
+         * Just copy the split and add it to the transaction. */
+
+        if (split != trans_split)
+        {
+            new_split = xaccMallocSplit (gnc_get_current_book ());
+
+            xaccTransBeginEdit (trans);
+            xaccSplitSetParent (new_split, trans);
+            gtc_copy_split_onto_split (split, new_split, FALSE);
+            xaccTransCommitEdit (trans);
+        }
+        else
+        {
+            gnc_error_dialog (window, "%s",
+                         _("This is the split anchoring this transaction to the register."
+                           " You can not duplicate it from this register window."));
+            return FALSE;
+        }
+    }
+    else
+    {
+        Transaction *new_trans;
+        const char *in_num = NULL;
+        const char *in_tnum = NULL;
+        char *out_num;
+        char *out_tnum;
+        time64 date;
+        gboolean use_autoreadonly = qof_book_uses_autoreadonly (gnc_get_current_book());
+        gboolean use_split_action_for_num_field = qof_book_use_split_action_for_num_field
+                           (gnc_get_current_book());
+
+        /* We are on a transaction row. Copy the whole transaction. */
+
+        date = time (0);
+        if (gnc_strisnum (xaccTransGetNum (trans)))
+        {
+            Account *account = gnc_tree_model_split_reg_get_anchor (model);
+            if (account)
+                in_num = xaccAccountGetLastNum (account);
+            else
+                in_num = xaccTransGetNum (trans);
+            in_tnum = (use_split_action_for_num_field
+                                        ? NULL
+                                        : gnc_get_num_action (trans, NULL)); //FIXME is this right way round ?
+        }
+
+        if (!gnc_dup_trans_dialog (window, NULL, TRUE,
+                                   &date, in_num, &out_num, in_tnum, &out_tnum))
+        {
+            gnc_resume_gui_refresh ();
+            LEAVE("dup cancelled");
+            return FALSE;
+        }
+
+        if (use_autoreadonly)
+        {
+            GDate d;
+            GDate *readonly_threshold = qof_book_get_autoreadonly_gdate (gnc_get_current_book());
+            gnc_gdate_set_time64 (&d, date);
+            if (g_date_compare (&d, readonly_threshold) < 0)
+            {
+                GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                    0,
+                                    GTK_MESSAGE_ERROR,
+                                    GTK_BUTTONS_OK,
+                                    "%s", _("Cannot store a transaction at this date"));
+                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                        "%s", _("The entered date of the duplicated transaction is older than the \"Read-Only Threshold\" set for this book.  "
+                                "This setting can be changed in File -> Properties -> Accounts."));
+                gtk_dialog_run (GTK_DIALOG (dialog));
+                gtk_widget_destroy (dialog);
+
+                g_date_free (readonly_threshold);
+                return FALSE;
+            }
+            g_date_free (readonly_threshold);
+        }
+
+        new_trans = xaccMallocTransaction (gnc_get_current_book ());
+
+        xaccTransBeginEdit (new_trans);
+        gtc_copy_trans_onto_trans (trans, new_trans, FALSE, FALSE);
+        xaccTransSetDatePostedSecs (new_trans, date);
+        xaccTransSetNum (new_trans, out_num);
+        xaccTransCommitEdit (new_trans);
+    }
+
+    /* Refresh the GUI. */
+    gnc_resume_gui_refresh ();
+
+    LEAVE(" ");
+    return TRUE;
+}
+
+
+/* Save any open edited transactions on closing register */
+gboolean
+gnc_tree_control_split_reg_save (GncTreeViewSplitReg *view, gboolean reg_closing)
+{
+    GncTreeModelSplitReg *model;
+    RowDepth depth;
+    Transaction *pending_trans;
+    Transaction *blank_trans;
+    Transaction *trans;
+    Account *account;
+    Split *blank_split;
+    const char *memo;
+    const char *desc;
+    Split *split, *current_trans_split;
+
+    ENTER("view=%p, reg_closing=%s", view, reg_closing ? "TRUE" : "FALSE");
+
+    if (!view)
+    {
+        LEAVE("no view");
+        return FALSE;
+    }
+
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
+
+    if (reg_closing)
+        view->reg_closing = TRUE;
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    blank_split = gnc_tree_control_split_reg_get_blank_split (view);
+    pending_trans = gnc_tree_view_split_reg_get_dirty_trans (view);
+    blank_trans = gnc_tree_control_split_reg_get_blank_trans (view);
+
+    /* get the handle to the current split and transaction */
+    split = gnc_tree_view_split_reg_get_current_split (view);
+    trans = gnc_tree_view_split_reg_get_current_trans (view);
+
+    current_trans_split = gnc_tree_control_split_reg_get_current_trans_split (view);
+
+    if (trans == NULL)
+    {
+        LEAVE("no transaction");
+        return FALSE;
+    }
+
+    if (!xaccTransIsOpen (trans))
+    {
+        LEAVE("transaction not open");
+        return FALSE;
+    }
+
+    if (trans == pending_trans )
+    {
+        if (trans != blank_trans)
+        {
+           /* Existing Transaction, we are going to commit. */
+
+            PINFO("committing trans (%p)", trans);
+            xaccTransCommitEdit (trans);
+            gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
+
+            LEAVE("Existing Transaction committed");
+            return TRUE;
+        }
+        else
+        {
+           /* Blank Transaction, we are going to commit. */
+
+            PINFO("start committing blank trans (%p)", trans);
+//FIXME More stuff ?
+
+            if (xaccTransCountSplits (trans) == 0)
+            {
+                GtkWidget *dialog, *window;
+                gint response;
+                const char *title = _("Not enough information for Blank Transaction?");
+                const char *message =
+                    _("The blank transaction does not have enough information to save it. Would you like to "
+                      "return to the transaction to update, or cancel the save?");
+                window = gnc_tree_view_split_reg_get_parent (view);
+                dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                        GTK_MESSAGE_QUESTION,
+                                        GTK_BUTTONS_CANCEL,
+                                        "%s", title);
+                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                        "%s", message);
+                gtk_dialog_add_button (GTK_DIALOG (dialog),
+                              _("_Return"), GTK_RESPONSE_ACCEPT);
+
+                gtk_widget_grab_focus (gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT));
+
+                response = gtk_dialog_run (GTK_DIALOG (dialog));
+//                response = gnc_dialog_run (GTK_DIALOG (dialog), "transaction_incomplete");
+                gtk_widget_destroy (dialog);
+
+                if (response != GTK_RESPONSE_ACCEPT)
+                {
+                    LEAVE("save cancelled");
+                    return TRUE;
+                }
+
+                return FALSE;
+            }
+
+            xaccTransCommitEdit (trans);
+            gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
+
+            LEAVE("Blank Transaction committed");
+            return TRUE;
+        }
+    }
+
+    LEAVE(" ");
+    return TRUE;
+}
+
+
+/* Allow the reconcile flag to be changed */
+gboolean
+gnc_tree_control_split_reg_recn_change (GncTreeViewSplitReg *view)
+{
+    GtkWidget *dialog, *window;
+    gint response;
+    Transaction *trans;
+    Split *split;
+    RowDepth depth;
+    char rec;
+    const gchar *title = _("Mark split as unreconciled?");
+    const gchar *message =
+        _("You are about to mark a reconciled split as unreconciled.  Doing "
+          "so might make future reconciliation difficult!  Continue "
+          "with this change?");
+
+    ENTER(" ");
+
+    depth = gnc_tree_view_reg_get_selected_row_depth (view);
+
+    if (depth == SPLIT3)
+        split = gnc_tree_view_split_reg_get_current_split (view);
+    else
+        split = gnc_tree_control_split_reg_get_current_trans_split (view);
+
+    rec = xaccSplitGetReconcile (split);
+
+    if (rec != YREC)
+    {
+        LEAVE("Not reconciled");
+        return TRUE;
+    }
+
+    /* Does the user want to be warned? */
+    window = gnc_tree_view_split_reg_get_parent (view);
+    dialog =
+        gtk_message_dialog_new (GTK_WINDOW (window),
+                               GTK_DIALOG_DESTROY_WITH_PARENT,
+                               GTK_MESSAGE_WARNING,
+                               GTK_BUTTONS_CANCEL,
+                               "%s", title);
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+            "%s", message);
+    gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Unreconcile"),
+                          GTK_RESPONSE_YES);
+    response = gnc_dialog_run (GTK_DIALOG (dialog), "mark_split_unreconciled");
+    gtk_widget_destroy (dialog);
+
+    if (response == GTK_RESPONSE_YES)
+    {
+        char rec = 'n';
+        trans = xaccSplitGetParent (split);
+
+        gnc_tree_view_split_reg_set_dirty_trans (view, trans);
+        xaccTransBeginEdit (trans);
+
+        xaccSplitSetReconcile (split, rec);
+
+        LEAVE("mark split unreconciled");
+        return FALSE;
+    }
+    LEAVE("Canceled split unreconciled");
+    return TRUE;
+}
+
+
+/* Test for splits being reconciled and decide to allow changes */
+gboolean
+gnc_tree_control_split_reg_recn_test (GncTreeViewSplitReg *view)
+{
+    Transaction *trans;
+    Split *split;
+    RowDepth depth;
+    char recn;
+
+    ENTER(" ");
+
+    /* This assumes we reset the flag whenever we change splits. */
+    if (view->change_allowed)
+        return TRUE;
+
+    depth = gnc_tree_view_reg_get_selected_row_depth (view);
+
+    if (depth == SPLIT3)
+        split = gnc_tree_view_split_reg_get_current_split (view);
+    else
+        split = gnc_tree_control_split_reg_get_current_trans_split (view);
+
+    if (!split)
+        return TRUE;
+
+    trans = xaccSplitGetParent (split);
+
+    recn = xaccSplitGetReconcile (split);
+
+    if (recn == YREC || xaccTransHasReconciledSplits (trans))
+    {
+        GtkWidget *dialog, *window;
+        gint response;
+        const gchar *title;
+        const gchar *message;
+
+        if(recn == YREC)
+        {
+            title = _("Change reconciled split?");
+            message =
+             _("You are about to change a reconciled split.  Doing so might make "
+               "future reconciliation difficult!  Continue with this change?");
+        }
+        else
+        {
+            title = _("Change split linked to a reconciled split?");
+            message =
+            _("You are about to change a split that is linked to a reconciled split.  "
+              "Doing so might make future reconciliation difficult!  Continue with this change?");
+        }
+
+        /* Does the user want to be warned? */
+        window = gnc_tree_view_split_reg_get_parent (view);
+        dialog =
+            gtk_message_dialog_new (GTK_WINDOW (window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_WARNING,
+                                   GTK_BUTTONS_CANCEL,
+                                   "%s", title);
+        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                "%s", message);
+        gtk_dialog_add_button (GTK_DIALOG (dialog), _("Chan_ge Split"),
+                              GTK_RESPONSE_YES);
+        response = gnc_dialog_run (GTK_DIALOG (dialog), "change_reconciled_split");
+        gtk_widget_destroy (dialog);
+
+        if (response != GTK_RESPONSE_YES)
+            return FALSE;
+    }
+    view->change_allowed = TRUE;
+    return TRUE;
+}
+
+
+/*****************************************************************************
+ *                         ClipBoard Functions                               *
+ *****************************************************************************/
+static Transaction *clipboard_trans = NULL;
+/* Must never dereference. */
+static const Account *clipboard_acct = NULL;
+
+
+void
+gnc_tree_control_split_reg_cut_trans (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    Transaction *from_trans;
+
+    g_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (view));
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    from_trans = gnc_tree_view_split_reg_get_current_trans (view);
+    if (!from_trans)
+        return;
+
+    if (gnc_tree_model_split_reg_get_read_only (model, from_trans))
+    {
+        GtkWidget *window;
+
+        window = gnc_tree_view_split_reg_get_parent (view);
+        gnc_error_dialog (window, "%s",
+                         _("You can not cut from a read only transaction or register."));
+        return;
+    }
+
+    xaccTransBeginEdit (clipboard_trans);
+    if (clipboard_trans)
+        xaccTransDestroy (clipboard_trans);
+
+    clipboard_trans = xaccTransCopyToClipBoard (from_trans);
+    clipboard_acct = gnc_tree_model_split_reg_get_anchor (model);
+
+    gnc_tree_view_split_reg_delete_current_trans (view);
+}
+
+void
+gnc_tree_control_split_reg_copy_trans (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    Transaction *from_trans;
+
+    g_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (view));
+
+    model = gtc_get_model_split_reg_from_view (view);
+
+    from_trans = gnc_tree_view_split_reg_get_current_trans (view);
+    if (!from_trans)
+        return;
+
+    //FIXME You can not copy from a sub account register, is this too simplistic
+    //      May be we should search for anchor as a parent of splits to identify
+    //      the correct anchor for this transaction ?
+    if (gnc_tree_model_split_reg_get_sub_account (model))
+    {
+        GtkWidget *window;
+
+        window = gnc_tree_view_split_reg_get_parent (view);
+        gnc_error_dialog (window, "%s",
+                         _("You can not copy from a sub account register."));
+        return;
+    }
+
+    xaccTransBeginEdit (clipboard_trans);
+    if (clipboard_trans)
+        xaccTransDestroy (clipboard_trans);
+
+    clipboard_trans = xaccTransCopyToClipBoard (from_trans);
+
+    clipboard_acct = gnc_tree_model_split_reg_get_anchor (model);
+}
+
+void
+gnc_tree_control_split_reg_paste_trans (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    Account *anchor_acct;
+    Transaction *to_trans;
+
+    g_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (view));
+
+    model = gtc_get_model_split_reg_from_view (view);
+    anchor_acct = gnc_tree_model_split_reg_get_anchor (model);
+
+    to_trans = gnc_tree_view_split_reg_get_current_trans (view);
+    if (!to_trans || !clipboard_trans)
+        return;
+
+    if (gnc_tree_model_split_reg_get_read_only (model, to_trans))
+    {
+        GtkWidget *window;
+
+        window = gnc_tree_view_split_reg_get_parent (view);
+        gnc_error_dialog (window, "%s",
+                         _("You can not paste to a read only transaction or register."));
+        return;
+    }
+
+    //FIXME You can not paste from gl to a register, is this too simplistic
+    if (clipboard_acct == NULL && anchor_acct != NULL)
+    {
+        GtkWidget *window;
+
+        window = gnc_tree_view_split_reg_get_parent (view);
+        gnc_error_dialog (window, "%s",
+                         _("You can not paste from the general ledger to a register."));
+        return;
+    }
+
+    xaccTransBeginEdit (to_trans);
+    gnc_tree_view_split_reg_set_dirty_trans (view, to_trans);
+
+    // Remove the blank split
+    gnc_tree_model_split_reg_set_blank_split_parent (model, to_trans, TRUE);
+
+    xaccTransCopyFromClipBoard (clipboard_trans, to_trans, clipboard_acct, anchor_acct);
+
+    // Add the blank split back
+    gnc_tree_model_split_reg_set_blank_split_parent (model, to_trans, FALSE);
+
+    // Refresh the view
+    g_signal_emit_by_name (model, "refresh_view", NULL);
+}
+
+
+/*****************************************************************************
+ *                             Sort Functions                                *
+ *****************************************************************************/
+
+/* Sort changed callback */
+void
+gnc_tree_control_split_reg_sort_changed_cb (GtkTreeSortable *sortable, gpointer user_data)
+{
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    GtkSortType   type;
+    gint          sortcol;
+    gint          sort_depth;
+    const gchar  *gconf_section;
+
+    gtk_tree_sortable_get_sort_column_id (sortable, &sortcol, &type);
+    ENTER("sortcol is %d", sortcol);
+
+    sort_depth = gnc_tree_view_reg_get_selected_row_depth (view);
+    if (sort_depth != 0)
+        view->sort_depth = sort_depth;
+
+    view->sort_col = sortcol - 1;
+
+    if (type == GTK_SORT_ASCENDING)
+        view->sort_direction = 1;
+    else
+        view->sort_direction = -1;
+
+    /* Save the sort depth to gconf */
+    gconf_section = gnc_tree_view_get_gconf_section (GNC_TREE_VIEW (view));
+    gnc_gconf_set_int (gconf_section, "sort_depth", view->sort_depth, NULL);
+
+    LEAVE("sort_col %d, sort_direction is %d  sort_depth is %d", view->sort_col, view->sort_direction, view->sort_depth );
+
+}
+
+
+/* Sort function for Date column */
+gint
+gnc_tree_control_split_reg_sort_by_date (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+                  gpointer user_data)
+{
+    GncTreeModelSplitReg *model  = GNC_TREE_MODEL_SPLIT_REG (tm);
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    GList *tnode;
+    Transaction *transa, *transb;
+    int depth;
+    time64 i, j;
+    int retval;
+
+    if (gnc_tree_model_split_reg_is_blank_trans (model, a)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, b)) return -1;
+
+    tnode = a->user_data2;
+    transa = tnode->data;
+
+    tnode = b->user_data2;
+    transb = tnode->data;
+
+    depth = view->sort_depth;
+
+    switch (depth) {
+        case 1: // Date Posted
+        retval = xaccTransOrder (transa, transb);
+        if (retval)
+           return retval;
+
+        break;
+        case 2: // Date Entered
+        i = xaccTransGetDateEntered (transa);
+        j = xaccTransGetDateEntered (transb);
+
+        if ((gint)(i - j) == 0)
+        {
+            i = xaccTransGetDate (transb);
+            j = xaccTransGetDate (transa);
+        }
+
+        return (gint)(i - j);
+        break;
+    }
+    return 0;
+}
+
+
+/* Sort function for Number / Action column */
+gint
+gnc_tree_control_split_reg_sort_by_numact (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+                  gpointer user_data)
+{
+    GncTreeModelSplitReg *model  = GNC_TREE_MODEL_SPLIT_REG (tm);
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    GList *tnode;
+    Transaction *transa, *transb;
+    Account *anchor;
+    int depth;
+    time64 i, j;
+    int na, nb, retval;
+    const char *ca, *cb;
+
+    if (gnc_tree_model_split_reg_is_blank_trans (model, a)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, b)) return -1;
+
+    tnode = a->user_data2;
+    transa = tnode->data;
+
+    tnode = b->user_data2;
+    transb = tnode->data;
+
+    depth = view->sort_depth;
+
+    switch (depth) {
+        case 1: // Number
+
+        na = atoi (xaccTransGetNum (transa));
+        nb = atoi (xaccTransGetNum (transb));
+
+        if (na < nb) return -1;
+        if (na > nb) return +1;
+
+        break;
+        case 2: // Action
+//FIXME this may be needed for this one (!qof_book_use_split_action_for_num_field (gnc_get_current_book()))
+
+        anchor = gnc_tree_model_split_reg_get_anchor (model);
+
+        if (anchor != NULL)
+        {
+            ca = xaccSplitGetAction (xaccTransFindSplitByAccount (transa, anchor))
+               ? xaccSplitGetAction (xaccTransFindSplitByAccount (transa, anchor)) : "";
+            cb = xaccSplitGetAction (xaccTransFindSplitByAccount (transb, anchor))
+               ? xaccSplitGetAction (xaccTransFindSplitByAccount (transb, anchor)) : "";
+        }
+        else
+            ca = cb = "Text";
+
+        retval = g_utf8_collate (ca, cb);
+        if (retval)
+           return retval;
+        break;
+    }
+    return 0;
+}
+
+
+/* Sort function for 'Description / Notes / Memo' column */
+gint
+gnc_tree_control_split_reg_sort_by_dnm (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+                  gpointer user_data)
+{
+    GncTreeModelSplitReg *model  = GNC_TREE_MODEL_SPLIT_REG (tm);
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    Transaction *transa, *transb;
+    Account *anchor;
+    GList *tnode;
+    const char *ca, *cb;
+    int depth;
+    int retval;
+
+    if (gnc_tree_model_split_reg_is_blank_trans (model, a)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, b)) return -1;
+
+    tnode = a->user_data2;
+    transa = tnode->data;
+
+    tnode = b->user_data2;
+    transb = tnode->data;
+
+    depth = view->sort_depth;
+
+    switch (depth) {
+        case 1: // Description
+        ca = xaccTransGetDescription (transa) ? xaccTransGetDescription (transa) : "";
+        cb = xaccTransGetDescription (transb) ? xaccTransGetDescription (transb) : "";
+
+        retval = g_utf8_collate (ca, cb);
+        if (retval)
+           return retval;
+
+        break;
+        case 2: // Notes
+        ca = xaccTransGetNotes (transa) ? xaccTransGetNotes (transa) : "";
+        cb = xaccTransGetNotes (transb) ? xaccTransGetNotes (transb) : "";
+
+        retval = g_utf8_collate (ca, cb);
+        if (retval)
+           return retval;
+
+        break;
+        case 3: // Memo
+        anchor = gnc_tree_model_split_reg_get_anchor (model);
+
+        if (anchor != NULL)
+        {
+            ca = xaccSplitGetMemo (xaccTransFindSplitByAccount (transa, anchor))
+               ? xaccSplitGetMemo (xaccTransFindSplitByAccount (transa, anchor)) : "";
+            cb = xaccSplitGetMemo (xaccTransFindSplitByAccount (transb, anchor))
+               ? xaccSplitGetMemo (xaccTransFindSplitByAccount (transb, anchor)) : "";
+        }
+        else
+            ca = cb = "Text";
+
+        retval = g_utf8_collate (ca, cb);
+        if (retval)
+           return retval;
+
+        break;
+    }
+    return 0;
+}
+
+
+/* Sort function for Reconcile column */
+gint
+gnc_tree_control_split_reg_sort_by_recn (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+                  gpointer user_data)
+{
+    GncTreeModelSplitReg *model  = GNC_TREE_MODEL_SPLIT_REG (tm);
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    GList *tnode;
+    Transaction *transa, *transb;
+
+    Account *anchor;
+    int depth;
+
+    int na = 0, nb = 0, retval;
+
+    if (gnc_tree_model_split_reg_is_blank_trans (model, a)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, b)) return -1;
+
+    tnode = a->user_data2;
+    transa = tnode->data;
+
+    tnode = b->user_data2;
+    transb = tnode->data;
+
+    depth = view->sort_depth;
+
+    anchor = gnc_tree_model_split_reg_get_anchor (model);
+
+    if (anchor != NULL)
+    {
+        Split *splita, *splitb;
+
+        splita = xaccTransFindSplitByAccount (transa, anchor);
+        splitb = xaccTransFindSplitByAccount (transb, anchor);
+
+        switch (xaccSplitGetReconcile (splita))
+        {
+        case YREC:
+            na = 4;
+            break;
+        case FREC:
+            na = 3;
+            break;
+        case VREC:
+            na = 2;
+            break;
+        case NREC:
+            na = 1;
+            break;
+        case CREC:
+            na = 0;
+            break;
+
+        default:
+            break;
+        }
+
+        switch (xaccSplitGetReconcile (splitb))
+        {
+        case YREC:
+            nb = 4;
+            break;
+        case FREC:
+            nb = 3;
+            break;
+        case VREC:
+            nb = 2;
+            break;
+        case NREC:
+            nb = 1;
+            break;
+        case CREC:
+            nb = 0;
+            break;
+
+        default:
+            break;
+        }
+
+        if (na < nb) return -1;
+        if (na > nb) return +1;
+
+        retval = xaccTransOrder (transa, transb);
+        if (retval)
+           return retval;
+    }
+    return 0;
+}

Added: gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.h	                        (rev 0)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -0,0 +1,110 @@
+/********************************************************************\
+ * gnc-tree-control-split-reg.h -- GtkTreeView implementation       *
+ *                     to display registers   in a GtkTreeView.     *
+ *                                                                  *
+ * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+
+#ifndef __GNC_TREE_CONTROL_SPLIT_REG_H
+#define __GNC_TREE_CONTROL_SPLIT_REG_H
+
+#include "gnc-tree-model-split-reg.h"
+#include "gnc-tree-view-split-reg.h"
+
+G_BEGIN_DECLS
+
+/*****************************************************************************/
+
+void gnc_tree_control_split_reg_exchange_rate (GncTreeViewSplitReg *view);
+
+void gnc_tree_control_split_reg_void_current_trans (GncTreeViewSplitReg *view, const char *reason);
+
+void gnc_tree_control_split_reg_unvoid_current_trans (GncTreeViewSplitReg *view);
+
+void gnc_tree_control_split_reg_jump_to_blank (GncTreeViewSplitReg *view);
+
+void gnc_tree_control_split_reg_jump_to_split (GncTreeViewSplitReg *view, Split *split);
+
+void gnc_tree_control_split_reg_cancel_edit (GncTreeViewSplitReg *view, gboolean reg_closing);
+
+void gnc_tree_control_split_reg_goto_rel_trans_row (GncTreeViewSplitReg *view, gint relative);
+
+void gnc_tree_control_split_reg_enter (GncTreeViewSplitReg *view, gboolean next_transaction);
+
+void gnc_tree_control_split_reg_reinit (GncTreeViewSplitReg *view, gpointer data);
+
+void gnc_tree_control_split_reg_reverse_current (GncTreeViewSplitReg *view);
+
+void gnc_tree_control_split_reg_delete (GncTreeViewSplitReg *view, gpointer data);
+
+Transaction * gnc_tree_control_split_reg_get_blank_trans (GncTreeViewSplitReg *view);
+
+Split * gnc_tree_control_split_reg_get_current_trans_split (GncTreeViewSplitReg *view);
+
+Split * gnc_tree_control_split_reg_get_blank_split (GncTreeViewSplitReg *view);
+
+gboolean gnc_tree_control_split_reg_duplicate_current (GncTreeViewSplitReg *view);
+
+gboolean gnc_tree_control_split_reg_save (GncTreeViewSplitReg *view, gboolean reg_closing);
+
+gboolean gnc_tree_control_split_reg_recn_change (GncTreeViewSplitReg *view);
+
+gboolean gnc_tree_control_split_reg_recn_test (GncTreeViewSplitReg *view);
+
+/*****************************************************************************/
+
+/* Cut transaction and copy to clipboard */
+void gnc_tree_control_split_reg_cut_trans (GncTreeViewSplitReg *view);
+
+/* Copy transaction to clipboard */
+void gnc_tree_control_split_reg_copy_trans (GncTreeViewSplitReg *view);
+
+/* Paste transaction from clipboard */
+void gnc_tree_control_split_reg_paste_trans (GncTreeViewSplitReg *view);
+
+/*****************************************************************************/
+
+/* Sort changed callback */
+void gnc_tree_control_split_reg_sort_changed_cb (GtkTreeSortable *sortable, gpointer user_data);
+
+/* Sort by date */
+gint gnc_tree_control_split_reg_sort_by_date (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
+                       gpointer user_data);
+
+/* Sort by Description / Notes / Memo */
+gint gnc_tree_control_split_reg_sort_by_dnm (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
+                       gpointer user_data);
+
+/* Sort function for Number / Action column */
+gint gnc_tree_control_split_reg_sort_by_numact (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+                  gpointer user_data);
+
+/* Sort function for Reconcile column */
+gint gnc_tree_control_split_reg_sort_by_recn (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+                  gpointer user_data);
+
+/*****************************************************************************/
+
+G_END_DECLS
+
+#endif /* __GNC_TREE_CONTROL_SPLIT_REG_H */

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -1,9 +1,9 @@
 /********************************************************************\
  * gnc-tree-model-split-reg.c -- GtkTreeView implementation to      *
- *                     display registers   in a GtkTreeView.        *
+ *                       display registers in a GtkTreeView.        *
  *                                                                  *
+ * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
  * Copyright (C) 2012 Robert Fewell                                 *
- * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -49,12 +49,14 @@
 /* Signal codes */
 enum
 {
-    REFRESH_SIGNAL,
+    REFRESH_VIEW,
+    REFRESH_STATUS_BAR,
+    TRANS_DELETE,
     LAST_SIGNAL
 };
 
 /** Static Globals *******************************************************/
-static QofLogModule log_module = GNC_MOD_GUI;
+static QofLogModule log_module = GNC_MOD_LEDGER;
 
 /** Declarations *********************************************************/
 static void gnc_tree_model_split_reg_class_init (GncTreeModelSplitRegClass *klass);
@@ -81,7 +83,7 @@
 static int gnc_tree_model_split_reg_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter);
 static gboolean	gnc_tree_model_split_reg_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, int n);
 static gboolean	gnc_tree_model_split_reg_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child);
-static void increment_stamp (GncTreeModelSplitReg *model);
+static void gtm_increment_stamp (GncTreeModelSplitReg *model);
 
 /** Component Manager Callback ******************************************/
 static void gnc_tree_model_split_reg_event_handler (QofInstance *entity, QofEventId event_type, GncTreeModelSplitReg *model, GncEventData *ed);
@@ -103,7 +105,8 @@
     GList *bsplit_parent_node;  // this equals the tnode of the transaction with the blank split
 
 
-    gboolean include_subacc;    //FIXME this is just placed here as the QOF Event is testing for it
+    gboolean display_subacc;    // Are we displaying subaccounts
+    gboolean display_gl;        // Is this the General ledger
 
 
 
@@ -113,10 +116,10 @@
     GncGUID template_account;
 
     /* User data for users of SplitRegisters */
-    gpointer user_data;
+    gpointer user_data; //FIXME This is used to get parent window, maybe move to view
 
     /* hook to get parent widget */
-    SRGetParentCallback2 get_parent;
+    SRGetParentCallback2 get_parent; //FIXME This is used to get parent window, maybe move to view
 
 /* ^^^^ #### This is stuff I have dumped here from old reg #### ^^^^ */
 
@@ -130,16 +133,17 @@
 };
 
 
+/* Define some background colors for the rows */
 #define GREENROW "#BFDEB9"
 #define TANROW "#F6FFDA"
 #define SPLITROW "#EDE7D3"
 #define YELLOWROW "#FFEF98"
 
 
-#define TROW1 0x1
-#define TROW2 0x2
-#define SPLIT 0x4
-#define BLANK 0x8
+#define TROW1 0x1 // Transaction row 1 depth 1
+#define TROW2 0x2 // Transaction row 2 depth 2
+#define SPLIT 0x4 // Split row         depth 3
+#define BLANK 0x8 // Blank tow
 #define IS_TROW1(x) (GPOINTER_TO_INT((x)->user_data) & TROW1)
 #define IS_TROW2(x) (GPOINTER_TO_INT((x)->user_data) & TROW2)
 #define IS_BLANK(x) (GPOINTER_TO_INT((x)->user_data) & BLANK)
@@ -148,12 +152,13 @@
 #define IS_BLANK_TRANS(x) (IS_BLANK(x) && !IS_SPLIT(x))
 /* Meaning of user_data fields in iter struct:
  *
- * user_data:  a bitfield for BLANK, SPLIT, TROW1, TROW2
+ * user_data:  a bitfield for TROW1, TROW2, SPLIT, BLANK
  * user_data2: a pointer to a node in a GList of Transactions               
  * user_data3: a pointer to a node in a GList of Splits.
  *            
  */
 
+
 /*FIXME This is the original define 
 #define VALID_ITER(model, iter) \
     (GNC_IS_TREE_MODEL_TRANSACTION(model) &&                            \
@@ -174,6 +179,15 @@
    (!IS_SPLIT (iter) && (iter).user_data2) || (IS_BLANK_TRANS (iter) && (iter).user_data3 == NULL)))
 
 
+/* Used in the sort functions */
+gboolean
+gnc_tree_model_split_reg_is_blank_trans (GncTreeModelSplitReg *model, GtkTreeIter *iter)
+{
+    return IS_BLANK_TRANS (iter);
+}
+
+
+/* Validate the iter */
 static gboolean
 gtm_valid_iter (GncTreeModelSplitReg *model, GtkTreeIter *iter)
 {
@@ -186,8 +200,9 @@
 }
 
 
+/* Make an iter from the given parameters */
 static GtkTreeIter
-make_iter (GncTreeModelSplitReg *model, gint f, GList *tnode, GList *snode)
+gtm_make_iter (GncTreeModelSplitReg *model, gint f, GList *tnode, GList *snode)
 {
     GtkTreeIter iter, *iter_p;
     iter_p = &iter;
@@ -272,17 +287,38 @@
     o_class->finalize = gnc_tree_model_split_reg_finalize;
     o_class->dispose = gnc_tree_model_split_reg_dispose;
 
-    gnc_tree_model_split_reg_signals[REFRESH_SIGNAL] =
-        g_signal_new("refresh_signal",
+    gnc_tree_model_split_reg_signals[REFRESH_VIEW] =
+        g_signal_new("refresh_view",
                      G_TYPE_FROM_CLASS (o_class),
                      G_SIGNAL_RUN_LAST,
-                     G_STRUCT_OFFSET (GncTreeModelSplitRegClass, refresh_signal),
+                     G_STRUCT_OFFSET (GncTreeModelSplitRegClass, refresh_view),
                      NULL, NULL,
                      g_cclosure_marshal_VOID__VOID,
                      G_TYPE_NONE, 0);
 
-    klass->refresh_signal = NULL;
+    gnc_tree_model_split_reg_signals[REFRESH_STATUS_BAR] =
+        g_signal_new("refresh_status_bar",
+                     G_TYPE_FROM_CLASS (o_class),
+                     G_SIGNAL_RUN_LAST,
+                     G_STRUCT_OFFSET (GncTreeModelSplitRegClass, refresh_status_bar),
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE, 0);
 
+    gnc_tree_model_split_reg_signals[TRANS_DELETE] =
+        g_signal_new("trans_delete",
+                     G_TYPE_FROM_CLASS (o_class),
+                     G_SIGNAL_RUN_FIRST,
+                     G_STRUCT_OFFSET (GncTreeModelSplitRegClass, trans_delete),
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__POINTER,
+                     G_TYPE_NONE,
+                     1,
+                     G_TYPE_POINTER);
+
+    klass->refresh_view = NULL;
+    klass->refresh_status_bar = NULL;
+    klass->trans_delete = NULL;
 }
 
 
@@ -328,10 +364,10 @@
 
     model->priv = g_new0 (GncTreeModelSplitRegPrivate, 1);
 
-    gnc_gconf_general_register_cb(KEY_ACCOUNTING_LABELS,
+    gnc_gconf_general_register_cb (KEY_ACCOUNTING_LABELS,
                                   gnc_tree_model_split_reg_gconf_changed,
                                   model);
-    gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
+    gnc_gconf_general_register_cb (KEY_ACCOUNT_SEPARATOR,
                                   gnc_tree_model_split_reg_gconf_changed,
                                   model);
     LEAVE(" ");
@@ -343,13 +379,12 @@
 {
     GncTreeModelSplitReg *model;
 
-    ENTER("model %p", object);
+    ENTER("model split reg %p", object);
     g_return_if_fail (object != NULL);
     g_return_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (object));
-//g_print("gnc_tree_model_split_reg_finalize\n");
+
     model = GNC_TREE_MODEL_SPLIT_REG (object);
 
-
     if (G_OBJECT_CLASS (parent_class)->finalize)
         G_OBJECT_CLASS (parent_class)->finalize (object);
     LEAVE(" ");
@@ -362,8 +397,7 @@
     GncTreeModelSplitRegPrivate *priv;
     GncTreeModelSplitReg *model;
 
-//g_print("gnc_tree_model_split_reg_dispose\n");
-    ENTER("model %p", object);
+    ENTER("model split reg %p", object);
     g_return_if_fail (object != NULL);
     g_return_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (object));
 
@@ -400,6 +434,7 @@
 /************************************************************/
 /*                   New Model Creation                     */
 /************************************************************/
+/* Create a new tree model */
 GncTreeModelSplitReg *
 gnc_tree_model_split_reg_new (SplitRegisterType2 reg_type, SplitRegisterStyle2 style,
                         gboolean use_double_line, gboolean is_template)
@@ -412,10 +447,10 @@
 
     model = g_object_new (GNC_TYPE_TREE_MODEL_SPLIT_REG, NULL);
 
-g_print("gnc_tree_model_split_reg_new and Model pointer is %p\n", model);
-
     priv = model->priv;
     priv->book = gnc_get_current_book();
+    priv->display_gl = FALSE;
+    priv->display_subacc = FALSE;
 
     model->type = reg_type;
     model->style = style;
@@ -431,8 +466,7 @@
 
     /* Setup some config entries */
     model->use_accounting_labels = gnc_gconf_get_bool (GCONF_GENERAL, KEY_ACCOUNTING_LABELS, NULL);
-    model->use_colors = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "use_theme_colors", NULL);
-/*    model->use_double_line = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "double_line_mode", NULL); */
+    model->use_theme_colors = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "use_theme_colors", NULL);
     model->alt_colors_by_txn = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "alternate_color_by_transaction", NULL);
     model->read_only = FALSE;
 
@@ -443,7 +477,6 @@
     priv->num_list = gtk_list_store_new (1, G_TYPE_STRING);
     priv->numact_list = gtk_list_store_new (1, G_TYPE_STRING);
 
-
     priv->event_handler_id = qof_event_register_handler
                              ((QofEventHandler)gnc_tree_model_split_reg_event_handler, model);
 
@@ -452,28 +485,31 @@
 }
 
 
+/* ForEach function to remove all model entries */
 static gboolean
-remove_foreach_func (GtkTreeModel *model,
+gtm_remove_foreach_func (GtkTreeModel *model,
               GtkTreePath  *path,
               GtkTreeIter  *iter,
               GList       **rowref_list)
 {
     GtkTreeRowReference  *rowref;
     g_assert ( rowref_list != NULL );
-//g_print("for path is %s\n", gtk_tree_path_to_string (path));
+
     rowref = gtk_tree_row_reference_new (model, path);
     *rowref_list = g_list_append (*rowref_list, rowref);
 
     return FALSE; /* do not stop walking the store, call us with next row */
 }
 
+
+/* Remove all model entries */
 static void
-gtv_remove_all_rows (GncTreeModelSplitReg *model)
+gtm_remove_all_rows (GncTreeModelSplitReg *model)
 {
     GList *rr_list = NULL;    /* list of GtkTreeRowReferences to remove */
     GList *node;
 
-    gtk_tree_model_foreach (GTK_TREE_MODEL(model), (GtkTreeModelForeachFunc)remove_foreach_func, &rr_list);
+    gtk_tree_model_foreach (GTK_TREE_MODEL(model), (GtkTreeModelForeachFunc)gtm_remove_foreach_func, &rr_list);
 
     rr_list = g_list_reverse (rr_list);
 
@@ -484,7 +520,6 @@
 
         if (path)
         {
-//g_print("rem row path is %s\n", gtk_tree_path_to_string (path));
             gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
             gtk_tree_path_free (path);
         }
@@ -494,57 +529,54 @@
 }
 
 
+/* Load the model with unique transactions based on a GList of splits */
 void
 gnc_tree_model_split_reg_load (GncTreeModelSplitReg *model, GList *slist, Account *default_account)
 {
     GncTreeModelSplitRegPrivate *priv;
-    GList *tlist;
-    gint no_rows = 0;
 
-    ENTER("Load Model");
+    ENTER("Load ModelSplitReg = %p and slist length is %d", model, g_list_length (slist));
 
     priv = model->priv;
 
     /* Clear the treeview */
-    gtv_remove_all_rows (model);
+    gtm_remove_all_rows (model);
     priv->tlist = NULL;
 
-g_print("Model load pointer is %p and slist length is %d\n", model, g_list_length (slist));
-
     /* Get a list of Unique Transactions from an slist */
-    tlist = xaccSplitListGetUniqueTransactions (slist);
+    priv->tlist = xaccSplitListGetUniqueTransactions (slist);
 
+    /* Add the blank transaction to the tlist */
+    priv->tlist = g_list_append (priv->tlist, priv->btrans);
+
     /* Update the completion model liststores */
     gnc_tree_model_split_reg_update_completion (model);
 
-    /* Add the blank transaction to the tlist */
-    tlist = g_list_append (tlist, priv->btrans);
-
     priv->anchor = default_account;
     priv->bsplit_parent_node = NULL;
-    priv->tlist = tlist;
 
     LEAVE("Leave Model Load");
 }
 
 
+/*FIXME Not sure about this */
 void
 gnc_tree_model_split_reg_set_template_account (GncTreeModelSplitReg *model, Account *template_account)
 {
     GncTreeModelSplitRegPrivate *priv;
 
-g_print("gnc_tree_model_split_reg_set_template_account\n");
+//g_print("gnc_tree_model_split_reg_set_template_account\n");
     priv = model->priv;
     priv->template_account = *xaccAccountGetGUID (template_account);
 }
 
 
+/* Destroy the model */
 void
 gnc_tree_model_split_reg_destroy (GncTreeModelSplitReg *model)
 {
 
-    ENTER("reg=%p", model);
-g_print("gnc_tree_model_split_reg_destroy\n");
+    ENTER("Model is %p", model);
 
     gnc_gconf_general_remove_cb (KEY_ACCOUNTING_LABELS,
                                 gnc_tree_model_split_reg_gconf_changed,
@@ -556,13 +588,14 @@
 }
 
 
+/* Setup the data to obtain the parent window */
 void
 gnc_tree_model_split_reg_set_data (GncTreeModelSplitReg *model, gpointer user_data,
                                   SRGetParentCallback2 get_parent)
 {
     GncTreeModelSplitRegPrivate *priv;
-g_print("gnc_tree_model_split_reg_set_data user_data %p\n", user_data);
-/*FIXME Not sure if this is needed or what it is for */
+
+/*FIXME This is used to get the parent window, mabe move to view */
     priv = model->priv;
 
     priv->user_data = user_data;
@@ -570,12 +603,11 @@
 }
 
 
+/* Update the config of this model */
 void
 gnc_tree_model_split_reg_config (GncTreeModelSplitReg *model, SplitRegisterType2 newtype,
                                  SplitRegisterStyle2 newstyle, gboolean use_double_line)
 {
-g_print("gnc_tree_model_split_reg_config\n");
-
     model->type = newtype;
 
     if (model->type >= NUM_SINGLE_REGISTER_TYPES2)
@@ -585,22 +617,14 @@
     model->use_double_line = use_double_line;
 }
 
-/* Returns a Split that matches the current Account */
-static Split *
-get_account_split (GncTreeModelSplitReg *model, Transaction *trans)
+
+//FIXME this may not be required in the long run, return TRUE if this is a sub account view
+gboolean
+gnc_tree_model_split_reg_get_sub_account (GncTreeModelSplitReg *model)
 {
-    int i;
-    Split *split = NULL;
-    Account *anchor = model->priv->anchor;
-
-    for (i = 0; (split = xaccTransGetSplit (trans, i)); i++) {
-        if (anchor == xaccSplitGetAccount (split))
-            return split;
-    }
-    return NULL;
+    return model->priv->display_subacc;
 }
 
-
 /************************************************************/
 /*        Gnc Tree Model Debugging Utility Function         */
 /************************************************************/
@@ -713,8 +737,6 @@
     case GNC_TREE_MODEL_SPLIT_REG_COL_DESCNOTES:
     case GNC_TREE_MODEL_SPLIT_REG_COL_TRANSVOID:
     case GNC_TREE_MODEL_SPLIT_REG_COL_RECN:
-
-    case GNC_TREE_MODEL_SPLIT_REG_COL_COLOR:
         return G_TYPE_STRING;
 
     case GNC_TREE_MODEL_SPLIT_REG_COL_RO:
@@ -734,10 +756,10 @@
 {
     /* Sets iter to a valid iterator pointing to path. */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
-    Account *account;
     GList *tnode;
     SplitList *slist;
     GList *snode;
+    Split *split;
     gint depth, *indices, flags = 0;
 
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (tree_model), FALSE);
@@ -748,8 +770,6 @@
         g_free (path_string);
     }
 
-    account = model->priv->anchor;
-
     depth = gtk_tree_path_get_depth (path);
 
     indices = gtk_tree_path_get_indices (path);
@@ -772,14 +792,11 @@
         }
         else
         {
-            if (account != NULL)
-            {
-                Split *split = get_account_split (model, tnode->data); // get account split
-                snode = g_list_find (slist, split);
-            }
-            else
-                snode = g_list_nth (slist, 0); // else first split
+            split = xaccTransGetSplit (tnode->data, 0); // else first split
+            snode = g_list_find (slist, split);
         }
+
+
     }
     else if (depth == 2) { /* Trans Row 2 */
         flags = TROW2;
@@ -790,13 +807,8 @@
         }
         else
         {
-            if (account != NULL)
-            {
-                Split *split = get_account_split (model, tnode->data); // get account split
-                snode = g_list_find (slist, split);
-            }
-            else
-                snode = g_list_nth (slist, 0); // else first split
+            split = xaccTransGetSplit (tnode->data, 0); // else first split
+            snode = g_list_find (slist, split);
         }
     }
     else if (depth == 3) /* Split */
@@ -810,7 +822,10 @@
             snode = model->priv->bsplit_node;
         }
         else
-            snode = g_list_nth (slist, indices[2]);
+        {
+            split = xaccTransGetSplit (tnode->data, indices[2]);
+            snode = g_list_find (slist, split);
+        }
 
         if (!snode) {
             DEBUG("path index off end of slist");
@@ -823,7 +838,7 @@
         goto fail;
     }
 
-    *iter = make_iter (model, flags, tnode, snode);
+    *iter = gtm_make_iter (model, flags, tnode, snode);
 /*    g_assert(VALID_ITER(model, iter)); */
     LEAVE("True");
     return TRUE;
@@ -843,7 +858,6 @@
     GtkTreePath *path;
     gint tpos, spos;
     GList *tnode, *snode;
-    GList *slist;
 
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), NULL);
 
@@ -854,7 +868,6 @@
 
     tnode = iter->user_data2;
 
-    slist = xaccTransGetSplitList (tnode->data);
     snode = iter->user_data3;
 
     /* Level 1 */
@@ -878,10 +891,15 @@
             spos = xaccTransCountSplits (tnode->data);
         }
         else
-            spos = g_list_position (slist, snode);
+        {
+            /* Can not use snode position directly as slist length does not follow
+               number of splits exactly, especailly if you delete a split */
+            spos = xaccTransGetSplitIndex (tnode->data, snode->data);
+        }
 
         if (spos == -1)
             goto fail;
+
         gtk_tree_path_append_index (path, 0); /* Add the Level 2 part */
         gtk_tree_path_append_index (path, spos);
     }
@@ -899,10 +917,9 @@
 }
 
 
-
 /* Return TRUE if this row should be marked read only */
-static gboolean
-gtm_get_read_only (GncTreeModelSplitReg *model, Transaction *trans)
+gboolean
+gnc_tree_model_split_reg_get_read_only (GncTreeModelSplitReg *model, Transaction *trans)
 {
     QofBook *book;
     GList *tnode, *tnode_last = NULL;
@@ -918,6 +935,14 @@
     if (model->read_only) // register is read only
         return TRUE;
 
+    /* This may be wrong but I thought it was mentioned on news list that you should not change these */
+    if (model->type == RECEIVABLE_REGISTER2 || model->type == PAYABLE_REGISTER2)
+        return TRUE;
+
+    /* Voided Transaction. */
+    if (xaccTransHasSplitsInState (trans, VREC))
+        return TRUE;
+
     if (qof_book_uses_autoreadonly (book)) // use auto read only
     {
         if (tnode == tnode_last) // blank transaction
@@ -925,18 +950,18 @@
         else
             return xaccTransIsReadonlyByPostedDate (trans);
     }
-
     return FALSE;
 }
 
+
 /* Returns the row color */
-static gchar*
-gtm_get_row_color (GncTreeModelSplitReg *model, gboolean is_trow1, gboolean is_trow2, gboolean is_split, gint num)
+gchar*
+gnc_tree_model_split_reg_get_row_color (GncTreeModelSplitReg *model, gboolean is_trow1, gboolean is_trow2, gboolean is_split, gint num)
 {
 
     gchar *cell_color = NULL;
 
-    if(!model->use_colors)
+    if(!model->use_theme_colors)
     {
         if(model->use_double_line)
         {
@@ -1029,10 +1054,6 @@
     case GNC_TREE_MODEL_SPLIT_REG_COL_DUEDATE:
         break;
 
-    case GNC_TREE_MODEL_SPLIT_REG_COL_COLOR:
-            g_value_set_string (value, gtm_get_row_color (model, IS_TROW1 (iter), IS_TROW2 (iter), IS_SPLIT (iter), indices[0]));
-        break;
-
     case GNC_TREE_MODEL_SPLIT_REG_COL_NUMACT:
         break;
 
@@ -1046,7 +1067,7 @@
         break;
 
     case GNC_TREE_MODEL_SPLIT_REG_COL_RO:
-            g_value_set_boolean (value, gtm_get_read_only (model, trans));
+            g_value_set_boolean (value, gnc_tree_model_split_reg_get_read_only (model, trans));
         break;
 
     default:
@@ -1065,8 +1086,8 @@
        If there is no next iter, FALSE is returned and iter is set to be
        invalid */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
-    Account *account;
     Transaction *trans;
+    Split *split;
     SplitList *slist;
     GList *tnode = NULL, *snode = NULL;
     gint flags = 0;
@@ -1085,8 +1106,6 @@
         goto fail;
     }
 
-    account = model->priv->anchor;
-
     if (IS_TROW1 (iter)) {
         flags = TROW1;
         tnode = iter->user_data2;
@@ -1106,23 +1125,25 @@
         }
         else
         {
-            if (account != NULL)
-            {
-                Split *split = get_account_split (model, tnode->data); // get account split
-                snode = g_list_find (slist, split);
-            }
-            else
-                snode = g_list_nth (slist, 0); // else first split
+            split = xaccTransGetSplit (tnode->data, 0);
+            snode = g_list_find (slist, split);
         }
     }
 
     if (IS_SPLIT (iter)) {
 
+        gint i = 0;
         flags = SPLIT;
         tnode = iter->user_data2;
+
+        slist = xaccTransGetSplitList (tnode->data);
         snode = iter->user_data3;
-        snode = g_list_next (snode);
 
+        i = xaccTransGetSplitIndex (tnode->data, snode->data);
+        i++;
+        split = xaccTransGetSplit (tnode->data, i);
+        snode = g_list_find (slist, split);
+
         if (!snode) {
             if (tnode == model->priv->bsplit_parent_node) {
                 snode = model->priv->bsplit_node;
@@ -1134,7 +1155,7 @@
         }
     }
 
-    *iter = make_iter (model, flags, tnode, snode);
+    *iter = gtm_make_iter (model, flags, tnode, snode);
     LEAVE("iter %s", iter_to_string (iter));
     return TRUE;
  fail:
@@ -1152,18 +1173,16 @@
        FALSE is returned and iter is set to be invalid. Parent will remain a valid
        node after this function has been called. */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
-    Account *account;
     GList *tnode = NULL, *snode = NULL;
     gint flags = 0;
     Transaction *trans;
+    Split *split;
     SplitList *slist;
 
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (tree_model), FALSE);
-    ENTER("model %p, iter %p (to be filed in), parent %s",
+    ENTER("model %p, iter %p , parent %s",
           tree_model, iter, (parent_iter ? iter_to_string(parent_iter) : "(null)"));
 
-    account = model->priv->anchor;
-
     if (!parent_iter)
     {
         /* Get the very first iter */
@@ -1179,17 +1198,12 @@
             }
             else
             {
-                if (account != NULL)
-                {
-                    Split *split = get_account_split (model, tnode->data); // get account split
-                    snode = g_list_find (slist, split);
-                }
-                else
-                    snode = g_list_nth (slist, 0); // else first split
+                split = xaccTransGetSplit (tnode->data, 0);
+                snode = g_list_find (slist, split);
             }
 
-            *iter = make_iter (model, flags, tnode, snode);
-            LEAVE("iter (2) %s", iter_to_string (iter));
+            *iter = gtm_make_iter (model, flags, tnode, snode);
+            LEAVE("Parent iter NULL, First iter is %s", iter_to_string (iter));
             return TRUE;
         }
         else
@@ -1214,13 +1228,8 @@
         }
         else
         {
-            if (account != NULL)
-            {
-                Split *split = get_account_split (model, tnode->data); // get account split
-                snode = g_list_find (slist, split);
-            }
-            else
-                snode = g_list_nth (slist, 0); // else first split
+            split = xaccTransGetSplit (tnode->data, 0);
+            snode = g_list_find (slist, split);
         }
     }
 
@@ -1228,38 +1237,34 @@
     {
         tnode = parent_iter->user_data2;
 
-        if ((tnode->data == model->priv->btrans) && (tnode != model->priv->bsplit_parent_node)) // blank trans has no splits to start with
+        if ((tnode->data == model->priv->btrans) && (tnode != model->priv->bsplit_parent_node)) // blank trans has no split to start with
             goto fail;
-    }
-
-    if (IS_TROW2 (parent_iter))
-    {
-        flags = SPLIT;
-        tnode = parent_iter->user_data2;
-        slist = xaccTransGetSplitList (tnode->data);
-
-        if ((tnode->data == model->priv->btrans) && (tnode == model->priv->bsplit_parent_node))
-        {
-            flags |= BLANK;
-            snode = model->priv->bsplit_node;
-        }
+        else if ((tnode->data != model->priv->btrans) && (xaccTransCountSplits (tnode->data) == 0) && (tnode != model->priv->bsplit_parent_node)) // trans has no splits after trans reinit.
+            goto fail;
         else
         {
-            if (account != NULL)
+            flags = SPLIT;
+            tnode = parent_iter->user_data2;
+            slist = xaccTransGetSplitList (tnode->data);
+
+            if (((tnode->data == model->priv->btrans) || (xaccTransCountSplits (tnode->data) == 0)) && (tnode == model->priv->bsplit_parent_node))
             {
-                Split *split = get_account_split (model, tnode->data); // get account split
+                flags |= BLANK;
+                snode = model->priv->bsplit_node;
+            }
+            else
+            {
+                split = xaccTransGetSplit (tnode->data, 0);
                 snode = g_list_find (slist, split);
             }
-            else
-                snode = g_list_nth (slist, 0); // else first split
         }
     }
 
     if (IS_SPLIT (parent_iter)) // Splits do not have children
         goto fail;
 
-    *iter = make_iter (model, flags, tnode, snode);
-    LEAVE("iter %s", iter_to_string (iter));
+    *iter = gtm_make_iter (model, flags, tnode, snode);
+    LEAVE("First Child iter is %s", iter_to_string (iter));
     return TRUE;
  fail:
     LEAVE("iter has no children");
@@ -1273,20 +1278,40 @@
 {
     /* Returns TRUE if iter has children, FALSE otherwise. */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
+    GList *tnode;
 
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (tree_model), FALSE);
 
     ENTER("model %p, iter %s", tree_model, iter_to_string (iter));
 
-    if (IS_TROW1 (iter))
+    tnode = iter->user_data2;
+
+    if (IS_TROW1 (iter)) //Normal Transaction TROW1
     {
         LEAVE ("Transaction Row 1 is yes");
         return TRUE;
     }
 
-    if (IS_TROW2 (iter))
+    if (IS_TROW2 (iter) && !(IS_BLANK (iter))) //Normal Transaction TROW2
     {
-        LEAVE ("Transaction Row 2 is yes");
+        if (xaccTransCountSplits (tnode->data) != 0) // with splits
+	{
+            LEAVE ("Transaction Row 2 is yes");
+            return TRUE;
+        }
+        else
+        {
+            if (tnode == model->priv->bsplit_parent_node) // with no splits, just blank split
+	    {
+                LEAVE ("Transaction Row 2 is yes, blank split");
+                return TRUE;
+            }
+        }
+    }
+
+    if (IS_TROW2 (iter) && IS_BLANK (iter) && (tnode == model->priv->bsplit_parent_node)) //Blank Transaction TROW2
+    {
+        LEAVE ("Blank Transaction Row 2 is yes");
         return TRUE;
     }
 
@@ -1342,8 +1367,8 @@
 {
     /* Sets iter to be the n'th child of parent, using the given index. 0 > */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
-    Account *account;
     Transaction *trans;
+    Split *split;
     SplitList *slist;
     GList *tnode, *snode;
     gint flags = 0;
@@ -1351,8 +1376,6 @@
     ENTER("model %p, iter %s, n %d", tree_model, iter_to_string (parent_iter), n);
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (tree_model), FALSE);
 
-    account = model->priv->anchor;
-
     if (parent_iter == NULL) {  /* Top-level */
         flags = TROW1;
         tnode = g_list_nth (model->priv->tlist, n);
@@ -1372,21 +1395,15 @@
         }
         else
         {
-            if (account != NULL)
-            {
-                Split *split = get_account_split (model, tnode->data); // get account split
-                snode = g_list_find (slist, split);
-            }
-            else
-                snode = g_list_nth (slist, 0); // else first split
+            split = xaccTransGetSplit (tnode->data, 0);
+            snode = g_list_find (slist, split);
         }
 
-        *iter = make_iter (model, flags, tnode, snode);
+        *iter = gtm_make_iter (model, flags, tnode, snode);
         LEAVE ("iter (2) %s", iter_to_string (iter));
         return TRUE;
     }
 
-    DEBUG("parent iter %s", iter_to_string (parent_iter));
 /*    g_assert(VALID_ITER(model, parent_iter)); */
 
     if (IS_SPLIT (parent_iter))
@@ -1416,7 +1433,7 @@
         {
             snode = NULL;
         }
-        else if ((tnode == model->priv->bsplit_parent_node) && (xaccTransCountSplits(trans) == n))
+        else if ((tnode == model->priv->bsplit_parent_node) && (xaccTransCountSplits (trans) == n))
         {
             flags = SPLIT | BLANK;
             snode = model->priv->bsplit_node;
@@ -1425,11 +1442,12 @@
         {
             flags = SPLIT;
             slist = xaccTransGetSplitList (trans);
-            snode = g_list_nth (slist, n);
+            split = xaccTransGetSplit (trans, n);
+            snode = g_list_find (slist, split);
         }
     }
 
-    *iter = make_iter (model, flags, tnode, snode);
+    *iter = gtm_make_iter (model, flags, tnode, snode);
     LEAVE("iter of child with index %u is %s", n, iter_to_string (iter));
     return TRUE;
  fail:
@@ -1471,7 +1489,7 @@
     if (tnode->data == model->priv->btrans)
         flags |= BLANK;
 
-    *iter = make_iter (model, flags, tnode, snode);
+    *iter = gtm_make_iter (model, flags, tnode, snode);
     LEAVE("parent iter is %s", iter_to_string (iter));
     return TRUE;
  fail:
@@ -1481,16 +1499,17 @@
 }
 
 
-/*###################################################################*/
-
+/*##########################################################################*/
+/* increment the stamp of the model */
 static void
-increment_stamp (GncTreeModelSplitReg *model)
+gtm_increment_stamp (GncTreeModelSplitReg *model)
 {
     do model->stamp++;
     while (model->stamp == 0);
 }
 
 
+/* Return these values based on the model and iter provided */
 gboolean
 gnc_tree_model_split_reg_get_split_and_trans (
     GncTreeModelSplitReg *model, GtkTreeIter *iter,
@@ -1535,7 +1554,7 @@
     GList *slist;
     gint tpos, spos, number;
 
-//g_print("gnc_tree_model_split_reg_get_path_to_split_and_trans\n");
+    ENTER("transaction is %p, split is %p", trans, split);
 
     path = gtk_tree_path_new();
 
@@ -1544,11 +1563,17 @@
     if (trans == NULL && split == NULL)
     {
         gtk_tree_path_append_index (path, number);
+        LEAVE("path is %s", gtk_tree_path_to_string (path));
         return path;
     }
 
     if (trans == NULL && split != NULL)
-        trans = xaccSplitGetParent (split);
+    {
+        if (split == model->priv->bsplit)
+            trans = model->priv->bsplit_parent_node->data;
+        else
+            trans = xaccSplitGetParent (split);
+    }
 
     if (trans != NULL)
     {
@@ -1559,21 +1584,23 @@
         gtk_tree_path_append_index (path, tpos);
     }
 
-    if (trans == NULL && split != NULL)
+    if (split != NULL)
     {
         slist = xaccTransGetSplitList (trans);
         /* Level 3 */
-        spos = g_list_index (slist, split);
+        spos = xaccTransGetSplitIndex (trans, split);
         if (spos == -1)
         {
             if (model->priv->bsplit == split) // test for blank split
-                spos = g_list_length (slist);
+                spos = xaccTransCountSplits (trans);
             else
-                spos = 0;
+                spos = -1;
         }
         gtk_tree_path_append_index (path, 0); /* Level 2 */
-        gtk_tree_path_append_index (path, spos);
+        if (spos != -1)
+            gtk_tree_path_append_index (path, spos);
     }
+    LEAVE("path is %s", gtk_tree_path_to_string (path));
     return path;
 }
 
@@ -1592,16 +1619,15 @@
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), FALSE);
     g_return_val_if_fail (iter1, FALSE);
     g_return_val_if_fail (iter2, FALSE);
+    PINFO("get_iter model %p, trans %p, split %p\n", model, trans, split);
 
-//g_print("get_iter model %p, trans %p, split %p\n", model, trans, split);
-
     priv = model->priv;
     if (split && !trans)
         trans = xaccSplitGetParent (split);
 
     if (trans && priv->book != xaccTransGetBook (trans)) return FALSE;
     if (split && priv->book != xaccSplitGetBook (split)) return FALSE;    
-    if (split && !xaccTransStillHasSplit(trans, split)) return FALSE;
+    if (split && !xaccTransStillHasSplit (trans, split)) return FALSE;
 
     tnode = g_list_find (priv->tlist, trans);
     if (!tnode) return FALSE;
@@ -1625,92 +1651,106 @@
         if (!snode) return FALSE;
     }
 
-    *iter1 = make_iter (model, flags1, tnode, snode);
-    *iter2 = make_iter (model, flags2, tnode, snode);
+    *iter1 = gtm_make_iter (model, flags1, tnode, snode);
+    *iter2 = gtm_make_iter (model, flags2, tnode, snode);
 
     return TRUE;
 }
 
 
+/* Return the blank split */
 Split *
 gnc_tree_model_split_get_blank_split (GncTreeModelSplitReg *model)
 {
     return model->priv->bsplit;
 }
 
-/*###################################################################*/
 
+/* Return the blank transaction */
+Transaction *
+gnc_tree_model_split_get_blank_trans (GncTreeModelSplitReg *model)
+{
+    return model->priv->btrans;
+}
+
+/*##########################################################################*/
+
+/* Update the parent when row changes made */
 static void
-update_parent (GncTreeModelSplitReg *model, GtkTreePath *path)
+gtm_update_parent (GncTreeModelSplitReg *model, GtkTreePath *path)
 {
     GList *tnode;
     GtkTreeIter iter;
 
-//g_print("update_parent - '%s'\n", gtk_tree_path_to_string (path));
-
+    ENTER(" ");
     if (gtk_tree_path_up (path) && gnc_tree_model_split_reg_get_iter (GTK_TREE_MODEL (model), &iter, path))
     {
+        PINFO("row_changed - '%s'", gtk_tree_path_to_string (path));
         gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
 
         tnode = iter.user_data2;
 
-        /* If this is the blank transaction, the only split will be deleteted, hence toggle has child */ 
+        /* If this is the blank transaction, the only split will be deleted, hence toggle has child */
         if (IS_BLANK_TRANS (&iter) && (tnode->data == model->priv->btrans) && (xaccTransCountSplits (model->priv->btrans) == 0))
         {
-            gchar *path_string = gtk_tree_path_to_string (path);
-            PINFO("toggling has_child at row %s\n", path_string);
-            g_free (path_string);
-
-            increment_stamp (model);
+            PINFO("toggling has_child at row '%s'", gtk_tree_path_to_string (path));
+            gtm_increment_stamp (model);
             gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
         }
     }
+    LEAVE(" ");
 }
 
 
+/* Insert row at iter */
 static void
-insert_row_at (GncTreeModelSplitReg *model, GtkTreeIter *iter)
+gtm_insert_row_at (GncTreeModelSplitReg *model, GtkTreeIter *iter)
 {
     GtkTreePath *path;
-//g_print("insert_row_at\n");
+
 //    g_assert (VALID_ITER (model, iter));
+    ENTER(" ");
     path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), iter);
-//g_print("insert_row_at - Path is '%s'\n", gtk_tree_path_to_string (path));
     if (!path)
         PERR("Null path");
 
-    increment_stamp (model);
+    gtm_increment_stamp (model);
     if (gnc_tree_model_split_reg_get_iter (GTK_TREE_MODEL (model), iter, path))
     {
-//g_print("insert_row_at - Path is '%s' valid iter\n", gtk_tree_path_to_string (path));
         gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, iter);
     }
     else
         PERR("Tried to insert with invalid iter.");
 
-    update_parent (model, path);
+    gtm_update_parent (model, path);
     gtk_tree_path_free (path);
+    LEAVE(" ");
 }
 
+
+/* Delete row at path */
 static void
-delete_row_at_path (GncTreeModelSplitReg *model, GtkTreePath *path)
+gtm_delete_row_at_path (GncTreeModelSplitReg *model, GtkTreePath *path)
 {
     gint depth;
 
+    ENTER(" ");
+
     if (!path)
         PERR("Null path");
-    increment_stamp (model);
+
+    gtm_increment_stamp (model);
     gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
 
     depth = gtk_tree_path_get_depth (path);
-//g_print("delete_row_at_path %s and depth %d\n", gtk_tree_path_to_string (path), depth);
+
     if (depth == 2)
     {
-        update_parent (model, path);
+        gtm_update_parent (model, path);
     }
     else if (depth == 3)
     {
-        update_parent (model, path);
+        gtm_update_parent (model, path);
     }
     else
     {
@@ -1719,42 +1759,43 @@
         { 
             GList *tnode = iter.user_data2;
             GncTreeModelSplitRegPrivate *priv = model->priv;
-//g_print("delete_row_at_path bsplit - Path is '%s'\n", gtk_tree_path_to_string (path));
             if (tnode == priv->bsplit_parent_node)
                 priv->bsplit_parent_node = NULL;
         }
     }
+    LEAVE(" ");
 }
 
 
+/* Delete row at iter */
 static void
-delete_row_at (GncTreeModelSplitReg *model, GtkTreeIter *iter)
+gtm_delete_row_at (GncTreeModelSplitReg *model, GtkTreeIter *iter)
 {
     GtkTreePath *path;
 //    g_assert(VALID_ITER (model, iter));
 
-//g_print("delete_row_at\n");
+    ENTER(" ");
     path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), iter);
-//g_print("delete_row_at - Path is '%s'\n", gtk_tree_path_to_string (path));
-    delete_row_at_path (model, path);
+    gtm_delete_row_at_path (model, path);
     gtk_tree_path_free (path);
+    LEAVE(" ");
 }
 
 
+/* Change row at iter */
 static void
-changed_row_at (GncTreeModelSplitReg *model, GtkTreeIter *iter)
+gtm_changed_row_at (GncTreeModelSplitReg *model, GtkTreeIter *iter)
 {
     GtkTreePath *path;
 //    g_assert(VALID_ITER (model, iter));
-//g_print("changed_row_at\n");
+
     path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), iter);
     if (!path)
         PERR ("Null path");
-//g_print("changed_row_at - Path is '%s'\n", gtk_tree_path_to_string (path));
-    increment_stamp (model);
+
+    gtm_increment_stamp (model);
     if (gnc_tree_model_split_reg_get_iter (GTK_TREE_MODEL (model), iter, path))
     {
-//g_print("changed_row_at - Path is '%s' valid iter\n", gtk_tree_path_to_string (path));
         gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, iter);
     }
     else 
@@ -1764,57 +1805,61 @@
 }
 
 
+/* Insert transaction into model */
 static void
-insert_trans (GncTreeModelSplitReg *model, Transaction *trans)
+gtm_insert_trans (GncTreeModelSplitReg *model, Transaction *trans)
 {
     GtkTreeIter iter;
     GtkTreePath *path;
     GList *tnode = NULL, *snode = NULL;
-//g_print("insert_trans %p\n", trans);
+
+    ENTER("insert transaction %p into model %p", trans, model);
     model->priv->tlist = g_list_prepend (model->priv->tlist, trans);
     tnode = g_list_find (model->priv->tlist, trans);
 
-    iter = make_iter (model, TROW1, tnode, NULL);
-    insert_row_at (model, &iter);
+    iter = gtm_make_iter (model, TROW1, tnode, NULL);
+    gtm_insert_row_at (model, &iter);
     path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), &iter);
     gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
     gtk_tree_path_free (path);
 
-    iter = make_iter (model, TROW2, tnode, NULL);
-    insert_row_at (model, &iter);
+    iter = gtm_make_iter (model, TROW2, tnode, NULL);
+    gtm_insert_row_at (model, &iter);
     path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), &iter);
     gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
     gtk_tree_path_free (path);
 
-//g_print("insert count splits %p %d\n", trans, xaccTransCountSplits (trans));
+    DEBUG("insert %d splits for transaction %p\n", xaccTransCountSplits (trans), trans);
 
     for (snode = xaccTransGetSplitList (trans); snode; snode = snode->next)
     {
         if (xaccTransStillHasSplit (trans, snode->data))
         {
-            iter = make_iter (model, SPLIT, tnode, snode);
-            insert_row_at (model, &iter);
+            iter = gtm_make_iter (model, SPLIT, tnode, snode);
+            gtm_insert_row_at (model, &iter);
         }
     }
+    LEAVE(" ");
 }
 
+
+/* Delete transaction from model */
 static void
-delete_trans (GncTreeModelSplitReg *model, Transaction *trans)
+gtm_delete_trans (GncTreeModelSplitReg *model, Transaction *trans)
 {
     GtkTreeIter iter;
     GList *tnode = NULL, *snode = NULL;
-//g_print("delete_trans %p\n", trans);
+
+    ENTER("delete trans %p", trans);
     tnode = g_list_find (model->priv->tlist, trans);
-//g_print("tlist length is %d\n", g_list_length (model->priv->tlist));
 
-//g_print("delete count splits %p %d\n", trans, xaccTransCountSplits (trans));
+    DEBUG("tlist length is %d and no of splits is %d", g_list_length (model->priv->tlist), xaccTransCountSplits (trans));
 
     if (tnode == model->priv->bsplit_parent_node)
     {
-//g_print("a delete blank split\n");
         /* Delete the row where the blank split is. */
-        iter = make_iter (model, SPLIT | BLANK, tnode, model->priv->bsplit_node);
-        delete_row_at (model, &iter);
+        iter = gtm_make_iter (model, SPLIT | BLANK, tnode, model->priv->bsplit_node);
+        gtm_delete_row_at (model, &iter);
         model->priv->bsplit_parent_node = NULL;
     }
 
@@ -1822,24 +1867,25 @@
     {
         if (xaccTransStillHasSplit (trans, snode->data))
         {
-            iter = make_iter (model, SPLIT, tnode, snode);
-            delete_row_at (model, &iter);
+            iter = gtm_make_iter (model, SPLIT, tnode, snode);
+            gtm_delete_row_at (model, &iter);
         }
     }
 
-    iter = make_iter (model, TROW2, tnode, NULL);
-    delete_row_at (model, &iter);
+    iter = gtm_make_iter (model, TROW2, tnode, NULL);
+    gtm_delete_row_at (model, &iter);
 
-    iter = make_iter (model, TROW1, tnode, NULL);
-    delete_row_at (model, &iter);
+    iter = gtm_make_iter (model, TROW1, tnode, NULL);
+    gtm_delete_row_at (model, &iter);
 
     model->priv->tlist = g_list_delete_link (model->priv->tlist, tnode);
+    LEAVE(" ");
 }
 
 
 /* Moves the blank split to 'trans' and remove old one. */
 gboolean
-gnc_tree_model_split_reg_set_blank_split_parent (GncTreeModelSplitReg *model, Transaction *trans)
+gnc_tree_model_split_reg_set_blank_split_parent (GncTreeModelSplitReg *model, Transaction *trans, gboolean remove_only)
 {
     GList *tnode, *bs_parent_node;
     GncTreeModelSplitRegPrivate *priv;
@@ -1853,53 +1899,57 @@
     else
         tnode = g_list_find (priv->tlist, trans);
 
-g_print("gnc_tree_model_split_reg_set_blank_split_parent bsplit %p and trans %p\n", priv->bsplit, trans);
+    ENTER("set blank split parent bsplit %p and trans %p and remove_only is %d", priv->bsplit, trans, remove_only);
 
-//g_print("tnode pointer is %p\n", tnode);
-
     bs_parent_node = priv->bsplit_parent_node;
 
-//g_print("bs_parent_node pointer is %p\n", bs_parent_node);
-
-    if (tnode != bs_parent_node)
+    if (tnode != bs_parent_node || remove_only == TRUE)
     {
-        moved = (bs_parent_node != NULL);
+        moved = (bs_parent_node != NULL || remove_only == TRUE);
         if (moved)
         {
             /* Delete the row where the blank split used to be. */
-            iter = make_iter (model, SPLIT | BLANK, bs_parent_node, priv->bsplit_node);
-            delete_row_at (model, &iter);
+            iter = gtm_make_iter (model, SPLIT | BLANK, bs_parent_node, priv->bsplit_node);
+            gtm_delete_row_at (model, &iter);
             priv->bsplit_parent_node = NULL;
         }
-        priv->bsplit_parent_node = tnode;
-        iter = make_iter (model, SPLIT | BLANK, tnode, priv->bsplit_node);
-        insert_row_at (model, &iter);
-        xaccSplitReinit (priv->bsplit); // set split back to default entries
-    } else
+        if (remove_only == FALSE)
+        {
+            /* Create the row where the blank split will be. */
+            priv->bsplit_parent_node = tnode;
+            iter = gtm_make_iter (model, SPLIT | BLANK, tnode, priv->bsplit_node);
+            gtm_insert_row_at (model, &iter);
+            xaccSplitReinit (priv->bsplit); // set split back to default entries
+        }
+    }
+    else
         moved = FALSE;
 
+    LEAVE(" ");
     return moved;
 }
 
 
+/* Make a new blank split and insert at iter */
 static void
-make_new_blank_split (GncTreeModelSplitReg *model)
+gtm_make_new_blank_split (GncTreeModelSplitReg *model)
 {
     GtkTreeIter iter;
     Split *split;
     GList *tnode = model->priv->bsplit_parent_node;
 
-//g_print("make_new_blank_split");
+    ENTER("");
 
     split = xaccMallocSplit (model->priv->book);
     model->priv->bsplit = split;
     model->priv->bsplit_node->data = model->priv->bsplit;
 
-//g_print(" new bsplit is %p\n", split);
+    DEBUG("make new blank split %p and insert at trans %p", split, tnode->data);
 
-    /* Insert the new row */
-    iter = make_iter (model, BLANK|SPLIT, tnode, model->priv->bsplit_node);
-    insert_row_at (model, &iter);
+    /* Insert the new blank split */
+    iter = gtm_make_iter (model, BLANK|SPLIT, tnode, model->priv->bsplit_node);
+    gtm_insert_row_at (model, &iter);
+    LEAVE("");
 }
 
 
@@ -1908,7 +1958,7 @@
  * function is called from the treeview to tell the model to commit
  * the blank split.
  */
-static void
+void
 gnc_tree_model_split_reg_commit_blank_split (GncTreeModelSplitReg *model)
 {
     Split *bsplit;
@@ -1916,7 +1966,7 @@
     GList *tnode, *snode;
     GtkTreeIter iter;
 
-g_print("gnc_tree_model_split_reg_commit_blank_split\n");
+    ENTER(" ");
 
     tnode = model->priv->bsplit_parent_node;
     bsplit = model->priv->bsplit;
@@ -1925,25 +1975,23 @@
         PERR("blank split has no trans");
         return;
     }
+
     trans = tnode->data;
     if (xaccTransGetSplitIndex (trans, bsplit) == -1) {
         PINFO("blank split has been removed from this trans");
         return;
     }
+
     snode = g_list_find (xaccTransGetSplitList (trans), bsplit);
     if (!snode) {
         PERR("Failed to turn blank split into real split");
         return;
     }
 
-    if (xaccSplitGetAccount (bsplit) == NULL) //FIXME this would make sure we have an account, not sure its valid.
-        xaccTransScrubOrphans (trans);
-
     /* If we haven't set an amount yet, and there's an imbalance, use that. */
     if (gnc_numeric_zero_p (xaccSplitGetAmount (bsplit)))
     {
         gnc_numeric imbal = gnc_numeric_neg (xaccTransGetImbalanceValue (trans));
-
         if (!gnc_numeric_zero_p (imbal))
         {
             gnc_numeric amount, rate;
@@ -1966,24 +2014,28 @@
         }
     }
     /* Mark the old blank split as changed */
-    iter = make_iter (model, SPLIT, tnode, snode);
-    changed_row_at (model, &iter);
-    make_new_blank_split (model);
+    iter = gtm_make_iter (model, SPLIT, tnode, snode);
+    gtm_changed_row_at (model, &iter);
+    gtm_make_new_blank_split (model);
+
+    LEAVE(" ");
 }
 
 
+/* Update the dsiplay sub account and general ledger settings */
 void
-gnc_tree_model_split_reg_commit_split (GncTreeModelSplitReg *model, Split *split)
+gnc_tree_model_split_reg_set_display (GncTreeModelSplitReg *model, gboolean subacc, gboolean gl)
 {
-g_print("gnc_tree_model_split_reg_commit_split %p\n", split);
-    if (split == model->priv->bsplit)
-        gnc_tree_model_split_reg_commit_blank_split (model);
+    GncTreeModelSplitRegPrivate *priv = model->priv;
+
+    priv->display_subacc = subacc;
+    priv->display_gl = gl;
 }
 
 
 /* Returns just the path to the transaction if idx_of_split is -1. */
 static GtkTreePath *
-get_removal_path (GncTreeModelSplitReg *model, Transaction *trans,
+gtm_get_removal_path (GncTreeModelSplitReg *model, Transaction *trans,
                  gint idx_of_split)
 {
     GncTreeModelSplitRegPrivate *priv;
@@ -1991,18 +2043,18 @@
     GtkTreeIter iter;
     GtkTreePath *path;
 
-//g_print("get_removal_path trans is %p idx of split is %d\n", trans, idx_of_split);
-
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), NULL);
     g_return_val_if_fail (trans, NULL);
 
     priv = model->priv;
-    if (priv->book != xaccTransGetBook (trans)) return FALSE;
+    if (priv->book != xaccTransGetBook (trans))
+        return FALSE;
 
     tnode = g_list_find (priv->tlist, trans);
-    if (!tnode) return FALSE;
+    if (!tnode)
+        return FALSE;
 
-    iter = make_iter (model, TROW1, tnode, NULL); // TROW1
+    iter = gtm_make_iter (model, TROW1, tnode, NULL); // TROW1
     path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), &iter);
 
     if (idx_of_split >= 0)
@@ -2013,17 +2065,13 @@
     else if (idx_of_split != -1)
         PERR("Invalid idx_of_split");
 
-//g_print("get_removal_path - Return Path is '%s'\n", gtk_tree_path_to_string (path));
-
     return path;
 }
 
 
+/*##########################################################################*/
+/*             Combo and Autocompletion ListStore functions                 */
 
-
-/*###################################################################*/
-/* Combo and Autocompletion ListStore functions */
-
 Account *
 gnc_tree_model_split_reg_get_anchor (GncTreeModelSplitReg *model)
 {
@@ -2031,7 +2079,6 @@
     return model->priv->anchor;
 }
 
-
 GtkListStore *
 gnc_tree_model_split_reg_get_description_list (GncTreeModelSplitReg *model)
 {
@@ -2039,7 +2086,6 @@
     return model->priv->description_list;
 }
 
-
 GtkListStore *
 gnc_tree_model_split_reg_get_notes_list (GncTreeModelSplitReg *model)
 {
@@ -2047,7 +2093,6 @@
     return model->priv->notes_list;
 }
 
-
 GtkListStore *
 gnc_tree_model_split_reg_get_memo_list (GncTreeModelSplitReg *model)
 {
@@ -2055,7 +2100,6 @@
     return model->priv->memo_list;
 }
 
-
 GtkListStore *
 gnc_tree_model_split_reg_get_numact_list (GncTreeModelSplitReg *model)
 {
@@ -2064,7 +2108,7 @@
 }
 
 
-/* Return TRUE if string all ready exists in the list */
+/* Return TRUE if string already exists in the list */
 static gboolean
 gtm_check_for_duplicates (GtkListStore *liststore, const gchar *string)
 {
@@ -2091,7 +2135,7 @@
 }
 
 
-/* Create the Auto Complete List Stores.... */
+/* Update the Auto Complete List Stores.... */
 void
 gnc_tree_model_split_reg_update_completion (GncTreeModelSplitReg *model)
 {
@@ -2100,6 +2144,8 @@
     GList *tlist, *tnode, *slist, *snode;
     int cnt, nSplits;
 
+    ENTER(" ");
+
     priv = model->priv;
     tlist = priv->tlist;
 
@@ -2179,6 +2225,10 @@
             snode = snode->next;
          }
     }
+    DEBUG("desc list is %d long", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->description_list), NULL));
+    DEBUG("notes list is %d long", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->notes_list), NULL));
+    DEBUG("memo list is %d long", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->memo_list), NULL));
+    LEAVE(" ");
 }
 
 
@@ -2193,7 +2243,7 @@
     priv = model->priv;
     store = priv->numact_list;
 
-//FIXME This may need more thought ???
+//FIXME This may need some more thought ???
 
     /* Clear the liststore */
     gtk_list_store_clear (store);
@@ -2445,8 +2495,6 @@
 
     g_return_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model));
 
-//g_print("\n\n--gnc_tree_model_split_reg_event_handler\n");
-
     if (qof_instance_get_book (entity) != priv->book)
         return;
     type = entity->e_type;
@@ -2460,12 +2508,10 @@
         switch (event_type)
         {
         case QOF_EVENT_MODIFY:
-//g_print("--gnc_tree_model_split_reg_event_handler - Modify Split\n");
             if (get_iter (model, NULL, split, &iter1, &iter2))
             {
-//g_print("--Change model %p split %p\n", model, split); //works
                 DEBUG ("change split %p (%s)", split, name);
-                changed_row_at (model, &iter1);
+                gtm_changed_row_at (model, &iter1);
 
                 /* If we change split to different account, remove from view */
                 if (priv->anchor != NULL)
@@ -2475,7 +2521,7 @@
                     trans = xaccSplitGetParent (split);
                     find_split = xaccTransFindSplitByAccount (trans, priv->anchor);
                     if (find_split == NULL)
-                        delete_trans (model, trans);
+                        gtm_delete_trans (model, trans);
                 }
             }
             break;
@@ -2492,7 +2538,6 @@
         switch (event_type)
         {
         case GNC_EVENT_ITEM_ADDED:
-//g_print("--gnc_tree_model_split_reg_event_handler - Add Split\n");
             split = (Split *) ed->node;
             /* The blank split will be added to the transaction when
                it's first edited.  That will generate an event, but
@@ -2505,31 +2550,27 @@
             /* Tell the filters/views where the new row was added. */
             if (get_iter (model, trans, split, &iter1, &iter2))
             {
-//g_print("--Insert model %p split %p\n", model, split); //works
                 DEBUG ("add split %p (%s)", split, name);
-                insert_row_at (model, &iter1);
+                gtm_insert_row_at (model, &iter1);
             }
             break;
         case GNC_EVENT_ITEM_REMOVED:
-//g_print("--gnc_tree_model_split_reg_event_handler - Remove Split\n");
             split = (Split *) ed->node;
 
-            path = get_removal_path (model, trans, ed->idx);
+            path = gtm_get_removal_path (model, trans, ed->idx);
             if (path)
             {
-//g_print("--Delete model %p split %p\n", model, split); //works
                 DEBUG ("remove split %p from trans %p (%s)", split, trans, name);
                 if (ed->idx == -1)
-                    delete_trans (model, trans); //Not sure when this would be so
+                    gtm_delete_trans (model, trans); //Not sure when this would be so
                 else
-                    delete_row_at_path (model, path);
+                    gtm_delete_row_at_path (model, path);
                 gtk_tree_path_free (path);
             }
             if (split == priv->bsplit)
-                make_new_blank_split (model);
+                gtm_make_new_blank_split (model);
             break;
         case QOF_EVENT_MODIFY:
-//g_print("--gnc_tree_model_split_reg_event_handler - Modify Trans\n");
             /* The blank trans won't emit MODIFY until it's committed */
             if (priv->btrans == trans)
             {
@@ -2537,43 +2578,40 @@
                 priv->tlist = g_list_append (priv->tlist, priv->btrans);
 
                 tnode = g_list_find (priv->tlist, priv->btrans);
-//g_print("--Insert model %p Blank trans %p\n", model, priv->btrans); //works
                 /* Insert a new blank trans */
-                iter1 = make_iter (model, TROW1 | BLANK, tnode, NULL);
-                insert_row_at (model, &iter1);
-                iter2 = make_iter (model, TROW2 | BLANK, tnode, NULL);
-                insert_row_at (model, &iter2);
+                iter1 = gtm_make_iter (model, TROW1 | BLANK, tnode, NULL);
+                gtm_insert_row_at (model, &iter1);
+                iter2 = gtm_make_iter (model, TROW2 | BLANK, tnode, NULL);
+                gtm_insert_row_at (model, &iter2);
+                g_signal_emit_by_name (model, "refresh_view", NULL);
             }
 
             if (get_iter (model, trans, NULL, &iter1, &iter2))
             {
-//g_print("--Change model %p trans %p\n", model, trans); //works
                 DEBUG ("change trans %p (%s)", trans, name);
-                changed_row_at (model, &iter1);
-                changed_row_at (model, &iter2);
-                g_signal_emit_by_name (model, "refresh_signal", NULL);
+                gtm_changed_row_at (model, &iter1);
+                gtm_changed_row_at (model, &iter2);
+                g_signal_emit_by_name (model, "refresh_view", NULL);
             }
 
             break;
         case QOF_EVENT_DESTROY:
-//g_print("--gnc_tree_model_split_reg_event_handler - Destroy Trans\n");
             if (priv->btrans == trans)
             {
                 tnode = g_list_find (priv->tlist, priv->btrans);
                 priv->btrans = xaccMallocTransaction (priv->book);
                 tnode->data = priv->btrans;
-g_print("--Change blank trans %p\n",priv->btrans); // Not sure this is ever used
-                iter1 = make_iter (model, TROW1 | BLANK, tnode, NULL);
-                changed_row_at (model, &iter1);
-                iter2 = make_iter (model, TROW2 | BLANK, tnode, NULL);
-                changed_row_at (model, &iter2);
+                iter1 = gtm_make_iter (model, TROW1 | BLANK, tnode, NULL);
+                gtm_changed_row_at (model, &iter1);
+                iter2 = gtm_make_iter (model, TROW2 | BLANK, tnode, NULL);
+                gtm_changed_row_at (model, &iter2);
             }
             else if (get_iter (model, trans, NULL, &iter1, &iter2))
             {
-//g_print("--Delete model %p trans %p\n", model, trans); //works
                 DEBUG("destroy trans %p (%s)", trans, name);
-                delete_trans (model, trans);
-                g_signal_emit_by_name (model, "refresh_signal", NULL);
+                g_signal_emit_by_name (model, "trans_delete", trans);
+                gtm_delete_trans (model, trans);
+                g_signal_emit_by_name (model, "refresh_view", NULL);
             }
             break;
         default:
@@ -2586,22 +2624,43 @@
         {
             Account *acc;
         case GNC_EVENT_ITEM_ADDED:
-//g_print("--gnc_tree_model_split_reg_event_handler - Add Account\n");
             split = (Split *) ed;
             acc = xaccSplitGetAccount (split);
             trans = xaccSplitGetParent (split);
-            if (!g_list_find (priv->tlist, trans) &&
-                ((xaccAccountHasAncestor (acc, priv->anchor) &&
-                  priv->include_subacc) || acc == priv->anchor))
+
+            if (!g_list_find (priv->tlist, trans) && priv->display_gl)
             {
-//g_print("--Insert model %p trans %p\n", model, trans); //works
+                DEBUG("Insert trans %p for gl (%s)", trans, name);
+                gtm_insert_trans (model, trans);
+                g_signal_emit_by_name (model, "refresh_view", NULL);
+            }
+            else if (!g_list_find (priv->tlist, trans) && ((xaccAccountHasAncestor (acc, priv->anchor) && priv->display_subacc) || acc == priv->anchor ))
+            {
                 DEBUG("Insert trans %p (%s)", trans, name);
-                insert_trans (model, trans);
-                g_signal_emit_by_name (model, "refresh_signal", NULL);
+                gtm_insert_trans (model, trans);
+                g_signal_emit_by_name (model, "refresh_view", NULL);
             }
             break;
         default:
             ;
         }
+        /* Lets refresh the status bar */
+        g_signal_emit_by_name (model, "refresh_status_bar", NULL);
     }
 }
+
+
+/* Returns the parent Window of the register */
+GtkWidget *
+gnc_tree_model_split_reg_get_parent (GncTreeModelSplitReg *model)
+{
+    GncTreeModelSplitRegPrivate *priv;
+    GtkWidget *parent = NULL;
+
+    priv = model->priv;
+
+    if (priv->get_parent)
+        parent = priv->get_parent (priv->user_data);
+
+    return parent;
+}

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.h	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -2,8 +2,8 @@
  * gnc-tree-model-split-reg.h -- GtkTreeView implementation to      *
  *                     display registers   in a GtkTreeView.        *
  *                                                                  *
+ * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
  * Copyright (C) 2012 Robert Fewell                                 *
- * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -33,7 +33,6 @@
 #include "Query.h"
 
 
-
 G_BEGIN_DECLS
 
 /* type macros */
@@ -98,10 +97,9 @@
     GNC_TREE_MODEL_SPLIT_REG_COL_LAST_VISIBLE = GNC_TREE_MODEL_SPLIT_REG_COL_RECN, //6
 
     /* internal hidden columns */
-    GNC_TREE_MODEL_SPLIT_REG_COL_COLOR,     //7
-    GNC_TREE_MODEL_SPLIT_REG_COL_RO,        //8
+    GNC_TREE_MODEL_SPLIT_REG_COL_RO,        //7
 
-    GNC_TREE_MODEL_SPLIT_REG_NUM_COLUMNS    //9
+    GNC_TREE_MODEL_SPLIT_REG_NUM_COLUMNS    //8
 } GncTreeModelSplitRegColumn;
 
 /* typedefs & structures */
@@ -120,31 +118,36 @@
 
     gboolean                     is_template;
 
-    gboolean                     do_auto_complete;      /**<FIXME Not setup - whether to use auto-competion */
     gboolean                     use_accounting_labels; /**< whether to use accounting Labels */
     gboolean                     separator_changed;     /**< whether the separator has changed */ 
     gboolean                     alt_colors_by_txn;     /**< whether to use alternative colors by transaction */ 
-    gboolean                     use_colors;            /**< whether to use theme colors */
+    gboolean                     use_theme_colors;      /**< whether to use theme colors */
 
     gboolean                     read_only;             /**< register is read only */
 
 
-
 }GncTreeModelSplitReg;
 
 
 /** The class data structure for an account tree model. */
 typedef struct
 {
-    GncTreeModelClass gnc_tree_model;   /**< The parent object data. */
+    GncTreeModelClass gnc_tree_model;                   /**< The parent object data. */
 
     /* This signal is emitted to refresh the view */
-    void (*refresh_signal) (GncTreeModelSplitReg *model, gpointer user_data);
+    void (*refresh_view) (GncTreeModelSplitReg *model, gpointer user_data);
 
+    /* This signal is emitted to refresh the status bar */
+    void (*refresh_status_bar) (GncTreeModelSplitReg *model, gpointer user_data);
+
+    /* This signal is emitted before a transaction delete, the pointer has
+       the transaction */
+    void (*trans_delete) (GncTreeModelSplitReg *model, gpointer item);
+
 } GncTreeModelSplitRegClass;
 
-/** Callback function type */
-/*FIXME Not sure if this is needed or what it is for yet*/
+
+/** Callback function type - Used to get parent window */
 typedef GtkWidget *(*SRGetParentCallback2) (gpointer user_data);
 
 /** Get the type of split register tree plugin.
@@ -153,84 +156,101 @@
  */
 GType gnc_tree_model_split_reg_get_type (void);
 
-
+/** Create new model and set options for register. */
 GncTreeModelSplitReg *
 gnc_tree_model_split_reg_new (SplitRegisterType2 reg_type, SplitRegisterStyle2 style,
                         gboolean use_double_line, gboolean is_template);
 
-
+/** Load the model from a slist and set default account for register. */
 void gnc_tree_model_split_reg_load (GncTreeModelSplitReg *model, GList * slist, Account *default_account);
 
+/** FIXME Not sure what this is for yet. */
 void gnc_tree_model_split_reg_set_template_account (GncTreeModelSplitReg *model, Account *template_account);
 
+/** Destroy the model. */
 void gnc_tree_model_split_reg_destroy (GncTreeModelSplitReg *model);
 
 /** Sets the user data and callback hooks for the register. */
 void gnc_tree_model_split_reg_set_data (GncTreeModelSplitReg *model, gpointer user_data,
                                   SRGetParentCallback2 get_parent);
 
+/** Returns the parent Window of the register. */
+GtkWidget * gnc_tree_model_split_reg_get_parent (GncTreeModelSplitReg *model);
+
+/** Set style and type for register. */
 void gnc_tree_model_split_reg_config (GncTreeModelSplitReg *model, SplitRegisterType2 newtype,
                                       SplitRegisterStyle2 newstyle, gboolean use_double_line);
 
+/** Return the default account for this register model. */
 Account * gnc_tree_model_split_reg_get_anchor (GncTreeModelSplitReg *model);
 
-void gnc_tree_model_split_reg_commit_split (GncTreeModelSplitReg *model, Split *split);
+/** Commit the blank split. */
+void gnc_tree_model_split_reg_commit_blank_split (GncTreeModelSplitReg *model);
 
+/** Set display general ledger and show sub accounts. */
+void gnc_tree_model_split_reg_set_display (GncTreeModelSplitReg *model, gboolean subacc, gboolean gl);
+
 /* These are to do with autocompletion */
-GtkListStore *
-gnc_tree_model_split_reg_get_description_list (GncTreeModelSplitReg *model);
+GtkListStore * gnc_tree_model_split_reg_get_description_list (GncTreeModelSplitReg *model);
 
-GtkListStore *
-gnc_tree_model_split_reg_get_notes_list (GncTreeModelSplitReg *model);
+GtkListStore * gnc_tree_model_split_reg_get_notes_list (GncTreeModelSplitReg *model);
 
-GtkListStore *
-gnc_tree_model_split_reg_get_memo_list (GncTreeModelSplitReg *model);
+GtkListStore * gnc_tree_model_split_reg_get_memo_list (GncTreeModelSplitReg *model);
 
-GtkListStore *
-gnc_tree_model_split_reg_get_numact_list (GncTreeModelSplitReg *model);
+GtkListStore * gnc_tree_model_split_reg_get_numact_list (GncTreeModelSplitReg *model);
 
-GtkListStore *
-gnc_tree_model_split_reg_get_acct_list (GncTreeModelSplitReg *model);
+GtkListStore * gnc_tree_model_split_reg_get_acct_list (GncTreeModelSplitReg *model);
 
-void
-gnc_tree_model_split_reg_get_num_list (GncTreeModelSplitReg *model);
+void gnc_tree_model_split_reg_get_num_list (GncTreeModelSplitReg *model);
 
-void
-gnc_tree_model_split_reg_get_action_list (GncTreeModelSplitReg *model);
+void gnc_tree_model_split_reg_get_action_list (GncTreeModelSplitReg *model);
 
-void
-gnc_tree_model_split_reg_update_completion (GncTreeModelSplitReg *model);
+void gnc_tree_model_split_reg_update_completion (GncTreeModelSplitReg *model);
 
 
 /* Get the split and transaction */
-gboolean
-gnc_tree_model_split_reg_get_split_and_trans (
-    GncTreeModelSplitReg *model, GtkTreeIter *iter,
-    gboolean *is_trow1, gboolean *is_trow2, gboolean *is_split,
-    gboolean *is_blank, Split **split, Transaction **trans);
+gboolean gnc_tree_model_split_reg_get_split_and_trans (
+          GncTreeModelSplitReg *model, GtkTreeIter *iter,
+          gboolean *is_trow1, gboolean *is_trow2, gboolean *is_split,
+          gboolean *is_blank, Split **split, Transaction **trans);
 
 /* Return FALSE if failure */
-gboolean 
-gnc_tree_model_split_reg_set_blank_split_parent (
-    GncTreeModelSplitReg *model, Transaction *trans);
+gboolean gnc_tree_model_split_reg_set_blank_split_parent (
+          GncTreeModelSplitReg *model, Transaction *trans, gboolean remove_only);
 
 /* Return the blank split */
-Split *
-gnc_tree_model_split_get_blank_split (GncTreeModelSplitReg *model);
+Split * gnc_tree_model_split_get_blank_split (GncTreeModelSplitReg *model);
 
+/* Return the blank trans */
+Transaction * gnc_tree_model_split_get_blank_trans (GncTreeModelSplitReg *model);
 
 /* If 'trans' is NULL, use split's parent.  If 'split' is NULL, just
    get the transaction iter. */
+gboolean gnc_tree_model_split_reg_get_iter_from_trans_and_split (
+          GncTreeModelSplitReg *model, Transaction *trans, Split *split,
+          GtkTreeIter *iter1, GtkTreeIter *iter2);
+
+/* Return the row color for the view */
+gchar * gnc_tree_model_split_reg_get_row_color (GncTreeModelSplitReg *model, gboolean is_trow1,
+         gboolean is_trow2, gboolean is_split, gint num);
+
+/* Return TRUE if this transaction is read only for the view */
 gboolean
-gnc_tree_model_split_reg_get_iter_from_trans_and_split (
-    GncTreeModelSplitReg *model, Transaction *trans, Split *split, 
-    GtkTreeIter *iter1, GtkTreeIter *iter2);
+gnc_tree_model_split_reg_get_read_only (GncTreeModelSplitReg *model, Transaction *trans);
 
+/*FIXME this may not be required in the long run, return TRUE if this is a sub account view */
+gboolean
+gnc_tree_model_split_reg_get_sub_account (GncTreeModelSplitReg *model);
 
 /* Return the tree path, if split and trans are null, last in list returned */
-GtkTreePath *
-gnc_tree_model_split_reg_get_path_to_split_and_trans (GncTreeModelSplitReg *model, Split *split, Transaction *trans);
+GtkTreePath * gnc_tree_model_split_reg_get_path_to_split_and_trans (
+               GncTreeModelSplitReg *model, Split *split, Transaction *trans);
 
+/* Returns TRUE if iter is a blank transaction */
+gboolean gnc_tree_model_split_reg_is_blank_trans (GncTreeModelSplitReg *model, GtkTreeIter *iter);
+
+/*****************************************************************************/
+
 G_END_DECLS
 
 #endif /* __GNC_TREE_MODEL_SPLIT_REG_H */

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -2,8 +2,8 @@
  * gnc-tree-view-split-reg.c -- GtkTreeView implementation to       *
  *                     display registers   in a GtkTreeView.        *
  *                                                                  *
+ * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
  * Copyright (C) 2012 Robert Fewell                                 *
- * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -34,6 +34,8 @@
 #include "gnc-tree-view.h"
 #include "gnc-tree-view-split-reg.h"
 #include "gnc-tree-model-split-reg.h"
+#include "gnc-tree-control-split-reg.h"
+#include "gnc-ui.h"
 #include "dialog-utils.h"
 #include "gnc-gconf-utils.h"
 #include "Transaction.h"
@@ -41,6 +43,7 @@
 #include "Scrub.h"
 #include "gnc-exp-parser.h"
 #include "dialog-transfer.h"
+#include "gnc-amount-edit.h"
 
 
 /* Signal codes */
@@ -62,17 +65,22 @@
 static guint gnc_tree_view_split_reg_signals[LAST_SIGNAL] = {0};
 
 static void cdf (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model,
-                		GtkTreeIter  *iter, gpointer user_data);
+				GtkTreeIter *iter, gpointer user_data);
 
+static void control_cdf (GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                 GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data);
+
 static void gtv_split_reg_edited_cb (GtkCellRendererText *cell, const gchar *path_string,
                           	const gchar *new_text, gpointer _model);
 
 static void start_edit (GtkCellRenderer *cr, GtkCellEditable *editable,
-                       		const gchar *path, gpointer user_data);
+				const gchar *path, gpointer user_data); //FIXME This may not be needed
 
-static void begin_edit (GncTreeViewSplitReg *view, Split *split, Transaction *trans);
+static void gtv_begin_edit (GncTreeViewSplitReg *view, Split *split, Transaction *trans);
 
-static void get_editable_start_editing_cb (GtkCellRenderer *cr, GtkCellEditable *editable,
+static void gtv_finish_edit (GncTreeViewSplitReg *view);
+
+static void gtv_get_editable_start_editing_cb (GtkCellRenderer *cr, GtkCellEditable *editable,
    				const gchar *path, gpointer user_data);
 
 static void get_editable_start_editing_recn_cb (GtkCellRenderer *cr, GtkCellEditable *editable,
@@ -81,15 +89,21 @@
 static void gtv_split_reg_editing_canceled_cb (GtkCellRenderer *cr, gpointer user_data);
 
 static void gtv_split_reg_match_selected_cb (GtkEntryCompletion *widget, GtkTreeModel *model,
-                        GtkTreeIter *iter, gpointer user_data);
+                        GtkTreeIter *iter, gpointer user_data); //FIXME This may not be needed
 
 static void gtv_split_reg_changed_cb (GtkCellRendererCombo *widget, gchar *path_string,
-                        GtkTreeIter *iter, gpointer user_data);
+                        GtkTreeIter *iter, gpointer user_data); //FIXME This may not be needed
 
+static void gtv_split_reg_trans_delete_cb (GncTreeModelSplitReg *model, gpointer item, gpointer user_data);
+
 static gboolean gtv_split_reg_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
 
+static gboolean gtv_split_reg_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data);
+
 static void gtv_split_reg_motion_cb (GtkTreeSelection *sel, gpointer user_data);
 
+static void gtv_split_reg_refresh_cb (GncTreeModelSplitReg *model, gpointer user_data);
+
 static gboolean gtv_scroll_to_cell (GncTreeViewSplitReg *view);
 
 static void gtv_split_reg_double_click_cb (GtkTreeView *treeview,
@@ -97,6 +111,8 @@
                                              GtkTreeViewColumn *column,
                                              gpointer           user_data);
 
+
+
 static gboolean transaction_changed_confirm (GncTreeViewSplitReg *view, Transaction *new_trans);
 
 typedef enum {
@@ -116,6 +132,7 @@
     COL_CREDIT,    //13
     COL_BALANCE,   //14
     COL_STATUS,    //15
+    COL_COMM,      //16
 } ViewCol;
 
 typedef struct {
@@ -137,72 +154,76 @@
     {COL_DATE, GNC_TREE_MODEL_SPLIT_REG_COL_DATE,
      "Date", "date", "00/00/0000xxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
+     gnc_tree_control_split_reg_sort_by_date},
 
     {COL_DUEDATE, GNC_TREE_MODEL_SPLIT_REG_COL_DUEDATE,
      "Due Date", "duedate", "00/00/0000xxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_NUMACT, GNC_TREE_MODEL_SPLIT_REG_COL_NUMACT,
-     "Num / Act", "numact", "0000xxx",
+     "Num / Act / Act", "numact", "0000xxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
+     gnc_tree_control_split_reg_sort_by_numact},
 
     {COL_DESCNOTES, GNC_TREE_MODEL_SPLIT_REG_COL_DESCNOTES,
      "Description / Notes / Memo", "descnotes", "xxxxxxxxxxxxxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
+     gnc_tree_control_split_reg_sort_by_dnm},
 
-    {COL_TRANSVOID, GNC_TREE_MODEL_SPLIT_REG_COL_TRANSVOID,
+    {COL_TRANSVOID, -1,
      "Transfer / Void", "transvoid", "xxxxxxxxxxxxxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
-    {COL_RECN, -1,
+    {COL_RECN, GNC_TREE_MODEL_SPLIT_REG_COL_RECN,
      "R", "recn", "x",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
+     gnc_tree_control_split_reg_sort_by_recn},
 
     {COL_TYPE, -1,
      "Type", "type", "x",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_VALUE, -1,
      "Value", "value", "xxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_AMOUNT, -1,
      "Amount", "amount", "xxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_AMTVAL, -1,
      "Amount / Value", "amtval", "xxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_RATE, -1,
      "Rate", "rate", "xxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_PRICE, -1,
      "Price", "price", "xxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_DEBIT, -1,
      "Debit", "debit", "xxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_CREDIT, -1,
      "Credit", "credit", "xxxxxxxx",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, get_editable_start_editing_cb, NULL},
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_BALANCE, -1,
      "Balance", "balance", "xxxxxxxx",
@@ -213,49 +234,59 @@
      " ", "status", "x",
      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
      NULL, NULL, NULL},
+
+    {COL_COMM, -1,
+     "Commodity", "commodity", "xxxxxxx",
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     NULL, NULL, NULL},
 };
 
 
 struct GncTreeViewSplitRegPrivate
 {
-    gboolean         disposed;
+    gboolean             disposed;
   
-    Account         *anchor;
-    gnc_commodity   *reg_comm;
+    Account             *anchor;              // The register default Account
+    gnc_commodity       *reg_comm;            // The register commodity
 
-    Split           *dirty_split;         // set when split is changed
-    Transaction     *dirty_trans;         // set when transaction is changed
+    Transaction         *current_trans;       // The current highlighted transaction
+    Split               *current_split;       // The current highlighted split
+    RowDepth             current_depth;       // The current depth 1=TROW1, 2=TROW2, 3=SPLIT3
+    GtkTreeRowReference *current_ref;         // The current model path reference
 
-    GtkTreePath     *acct_edit_path;      // remember which row's account we're editing
+    Transaction         *dirty_trans;         // Set when transaction is changed
+    GtkTreeRowReference *edit_ref;            // The model edit path reference
 
-    GtkTreePath     *current_path;        // remember what the current path is.
+    GtkCellRenderer     *temp_cr;             // Pointer to Temp Cell Renderer
+    gulong               fo_handler_id;       // Focus out callback id
 
-    GtkCellRenderer *temp_cr;             // Temp Cell Renderer reference
+    gboolean             acct_short_names;    // Use account short names
+    gboolean             double_line;         // Use double line mode
+    gboolean             expanded;            // Are we expanded to splits
 
-    gboolean         has_rate;            // if set, the transfer dialog will never automatically pop-up
-
-    gboolean         full_refresh;
-
-    gboolean         acct_short_names;
-    gboolean         double_line;
-
-
-    gboolean         default_set;          // wether default selection has been run
-    gint             row_old;              // old top level row
-    gint             row_now;              // current top level row
-
 };
 
 
 #define SPLIT_TRANS_STR _("-- Split Transaction --")
 
+/* Define some cell colors */
 #define PINKCELL "#F8BEC6"
 #define REDCELL "#F34943"
 #define BLUECELL "#1D80DF"
 #define BLACKCELL "#CBCBD2"
+#define YELLOWCELL "#FFEF98"
 
-/* This could be a preference setting, The minimum length of characters in order to start completing */
+
+/* This could be a preference setting, the minimum length of characters in order to start completing */
 #define KEY_LENGTH 2
+/* This could be a preference setting, use calendar buttons in tree view */
+#define CAL_USE_BUTTONS TRUE
+/* This could be a preference setting, show currency / commodity symbols */
+#define SHOW_SYMBOL FALSE
+/* This could be a preference setting, move selection to blank split on expand */
+#define SELECTION_TO_BLANK_ON_EXPAND FALSE
+/* This could be a preference setting, display the entered date */
+#define SHOW_ENTERED_DATE FALSE
 
 #define GNC_TREE_VIEW_SPLIT_REG_GET_PRIVATE(o)  \
    (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_TREE_VIEW_SPLIT_REG, GncTreeViewSplitRegPrivate))
@@ -329,13 +360,27 @@
 }
 
 
+/* Return the tree model from the tree view */
+static GncTreeModelSplitReg *
+get_split_reg_model_from_view (GncTreeViewSplitReg *view)
+{
+    GtkTreeModelSort *s_model = GTK_TREE_MODEL_SORT(
+        gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
+    return GNC_TREE_MODEL_SPLIT_REG (gtk_tree_model_sort_get_model (s_model));
+}
+
+
 static void
 gnc_tree_view_split_reg_init (GncTreeViewSplitReg *view)
 {
     view->priv = g_new0 (GncTreeViewSplitRegPrivate, 1);
 
-    view->priv->current_path = gtk_tree_path_new_from_string ("99999");
-    view->priv->full_refresh = TRUE;
+    view->priv->current_trans = NULL;
+    view->priv->current_split = NULL;
+    view->priv->current_depth = 0;
+    view->reg_closing = FALSE;
+    view->priv->fo_handler_id = 0;
+    view->sort_depth = 1;
 
     view->priv->acct_short_names = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "show_leaf_account_names", NULL);
 }
@@ -349,7 +394,9 @@
 
     gnc_leave_return_if_fail (object != NULL);
     gnc_leave_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (object));
-//g_print("gnc_tree_view_split_reg_dispose\n");
+
+    ENTER("split reg view %p", object);
+
     view = GNC_TREE_VIEW_SPLIT_REG (object);
     priv = GNC_TREE_VIEW_SPLIT_REG_GET_PRIVATE (view);
 
@@ -357,8 +404,22 @@
         return;
     priv->disposed = TRUE;
 
+    if(view->priv->current_ref != NULL)
+    {
+        gtk_tree_row_reference_free (view->priv->current_ref);
+        view->priv->current_ref = NULL;
+    }
+
+    if(view->priv->edit_ref != NULL)
+    {
+        gtk_tree_row_reference_free (view->priv->edit_ref);
+        view->priv->edit_ref = NULL;
+    }
+
     if (G_OBJECT_CLASS (parent_class)->dispose)
         (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+
+    LEAVE(" ");
 }
 
 
@@ -369,20 +430,41 @@
 
     gnc_leave_return_if_fail(object != NULL);
     gnc_leave_return_if_fail(GNC_IS_TREE_VIEW_SPLIT_REG (object));
-//g_print("gnc_tree_view_split_reg_finalize\n");
+
+    ENTER("split reg view %p", object);
+
     view = GNC_TREE_VIEW_SPLIT_REG (object);
 
     if (G_OBJECT_CLASS(parent_class)->finalize)
         (* G_OBJECT_CLASS(parent_class)->finalize) (object);
+
+    LEAVE(" ");
 }
 
 
-static GncTreeModelSplitReg *
-get_split_reg_model_from_view (GncTreeViewSplitReg *view)
+/* Update some settings from gconf */
+void
+gnc_tree_view_split_reg_refresh_from_gconf (GncTreeViewSplitReg *view) //FIXME Need to test and change.
 {
-    GtkTreeModelSort *s_model = GTK_TREE_MODEL_SORT(
-        gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
-    return GNC_TREE_MODEL_SPLIT_REG (gtk_tree_model_sort_get_model (s_model));
+    GncTreeModelSplitReg *model;
+
+//g_print("gnc_tree_view_split_reg_refresh_from_gconf\n");
+
+    model = get_split_reg_model_from_view (view);
+
+    model->use_theme_colors = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+                              "use_theme_colors", NULL);
+    model->use_accounting_labels = gnc_gconf_get_bool (GCONF_GENERAL,
+                               KEY_ACCOUNTING_LABELS, NULL);
+
+    model->alt_colors_by_txn = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER,
+                               "alternate_color_by_transaction", NULL);
+
+//    sheet->use_horizontal_lines = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+//                                  "draw_horizontal_lines", NULL);
+
+//    sheet->use_vertical_lines = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+//                                "draw_vertical_lines", NULL);
 }
 
 
@@ -399,10 +481,11 @@
 };
 
 
+/* Define which columns are in which views */
 static ViewCol *
 gnc_tree_view_split_reg_get_colummn_list (GncTreeModelSplitReg *model)
 {
-g_print("Model-type is %d\n", model->type);
+    DEBUG("Model-type is %d", model->type);
     switch (model->type)
     {
     case BANK_REGISTER2:
@@ -415,7 +498,6 @@
     case EQUITY_REGISTER2:
     case TRADING_REGISTER2:
     case INCOME_LEDGER2:
-    case GENERAL_LEDGER2:
         {
         static ViewCol col_list[] = {
         COL_DATE, COL_NUMACT, COL_DESCNOTES, COL_TRANSVOID, COL_RECN,
@@ -424,12 +506,21 @@
         }
         break;
 
+    case GENERAL_LEDGER2:
+        {
+        static ViewCol col_list[] = {
+        COL_DATE, COL_NUMACT, COL_DESCNOTES, COL_TRANSVOID, COL_RECN,
+        COL_STATUS, COL_COMM, COL_VALUE, COL_RATE, COL_AMOUNT, COL_DEBIT, COL_CREDIT, -1};
+        return col_list;
+        }
+        break;
+
     case STOCK_REGISTER2:
     case CURRENCY_REGISTER2:
         {
         static ViewCol col_list[] = {
         COL_DATE, COL_NUMACT, COL_DESCNOTES, COL_TRANSVOID, COL_RECN,
-        COL_STATUS, COL_AMTVAL, COL_PRICE, COL_DEBIT, COL_CREDIT, COL_BALANCE, -1};
+        COL_STATUS, COL_COMM, COL_AMTVAL, COL_PRICE, COL_DEBIT, COL_CREDIT, COL_BALANCE, -1};
         return col_list;
         }
         break;
@@ -447,7 +538,7 @@
         {
         static ViewCol col_list[] = {
         COL_DATE, COL_NUMACT, COL_DESCNOTES, COL_TRANSVOID, COL_RECN,
-        COL_STATUS, COL_AMTVAL, COL_PRICE, COL_DEBIT, COL_CREDIT, -1};
+        COL_STATUS, COL_AMOUNT, COL_PRICE, COL_DEBIT, COL_CREDIT, -1};
         return col_list;
         }
 
@@ -520,15 +611,21 @@
 
         g_object_set_data (G_OBJECT (col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
 
-        renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col)); //FIXME I am only looking at one renderer per cell.
+        renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col));
         g_assert (g_list_length (renderers) == 1);
         cr = g_list_nth_data (renderers, 0);
         g_list_free (renderers);
 
         /* Setup cell background color and default alignment */
         g_object_set (cr, "xalign", 1.0, NULL);
-        gtk_tree_view_column_add_attribute (col, cr, "cell-background", GNC_TREE_MODEL_SPLIT_REG_COL_COLOR);
 
+        /* Add the full title for status column to the object for menu creation */
+        if (col_list[i] == COL_STATUS)
+            g_object_set_data_full(G_OBJECT(col), REAL_TITLE, g_strdup(_("Status Bar")), g_free);
+
+        /* This sets the background of the treeview control columns */
+        gnc_tree_view_set_control_column_background (GNC_TREE_VIEW (view), 0, control_cdf);
+
         if (def.editing_started_cb) {
             //Store the position of the column in the model
             g_object_set_data (G_OBJECT(cr), "model_column", GINT_TO_POINTER (def.modelcol));
@@ -536,7 +633,7 @@
             g_signal_connect (G_OBJECT(cr), "editing-started", (GCallback) def.editing_started_cb, view);
         }
 
-        //Connect editing-canceled signal so that edit-cancelled can be set appropriately
+        // Connect editing-canceled signal so that edit-cancelled can be set appropriately
         g_signal_connect (G_OBJECT(cr), "editing-canceled", G_CALLBACK (gtv_split_reg_editing_canceled_cb), view);
 
         // Set Columns to be resizable default.
@@ -553,9 +650,18 @@
         gtk_tree_view_column_set_cell_data_func ( col, cr, cdf, view, NULL);
         i++;
     }
-    gtk_tree_selection_set_mode(gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), GTK_SELECTION_BROWSE);
+    gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), GTK_SELECTION_BROWSE);
 
-    /* This will expand to splits on double clicking at current position */
+    // Default the sorting to date.
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(gtk_tree_view_get_model (GTK_TREE_VIEW (view))),
+                                         GNC_TREE_MODEL_SPLIT_REG_COL_DATE,
+                                         GTK_SORT_ASCENDING);
+
+    // Connect a call back to update the sort settings.
+    g_signal_connect (GTK_TREE_SORTABLE (gtk_tree_view_get_model (GTK_TREE_VIEW (view))),
+        "sort-column-changed", G_CALLBACK (gnc_tree_control_split_reg_sort_changed_cb), view);
+
+    // This will expand to splits on double clicking at current position.
     g_signal_connect (GTK_TREE_VIEW (view), "row-activated", G_CALLBACK (gtv_split_reg_double_click_cb), NULL);
 
     g_signal_connect(gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), "changed", G_CALLBACK (gtv_split_reg_motion_cb), view);
@@ -563,82 +669,75 @@
     //Add a data-edited property to keep track of transaction edits
     g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
 
+    // This is used to move the selected item if the selected transaction is deleted
+    g_signal_connect (G_OBJECT (model), "trans_delete", G_CALLBACK (gtv_split_reg_trans_delete_cb), view);
+
+    // This will refresh the view
+    g_signal_connect (G_OBJECT (model), "refresh_view", G_CALLBACK (gtv_split_reg_refresh_cb), view);
+
+    // This should be for key navigation, tabbing...
     g_signal_connect_after (G_OBJECT (view), "key-press-event", G_CALLBACK (gtv_split_reg_key_press_cb), NULL);
+
     return view;
 }
 
 
+/* Set up the view */
 static gboolean
 gnc_tree_view_split_reg_set_format (GncTreeViewSplitReg *view)
 {
+    GncTreeViewSplitRegPrivate *priv;
     GncTreeModelSplitReg *model;
-    GtkTreePath *path;
-    RowDepth depth;
-    gint index = 0;
+    GtkTreePath *mpath, *spath;
     gint total_num = 0;
-    gint *indices;
-    gint row_now;
-    gint row_old;
 
+    ENTER(" ");
+
     model = get_split_reg_model_from_view (view);
 
-    row_now = view->priv->row_now;
-    row_old = view->priv->row_old;
+    priv = view->priv;
+
     total_num = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL);
-    depth = gnc_tree_view_reg_get_selected_row_depth (view);
 
-g_print("gnc_tree_view_split_reg_set_format row_now is %d, row_old is %d, total is %d\n", row_now, row_old, total_num);
+    mpath = gtk_tree_row_reference_get_path (view->priv->current_ref);
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
-    /* scroll the view */
-    if (row_now == total_num -1)
-        gtv_scroll_to_cell (view);
+    priv->expanded = FALSE;
 
-    if ((row_now != row_old) || (view->priv->default_set == TRUE))
     {
-    view->priv->default_set = FALSE;
-
         if (model->style == REG2_STYLE_JOURNAL)
         {
-g_print("gnc_tree_view_split_reg_set_format journal\n");
-            path = gtk_tree_path_new_first ();
-            indices = gtk_tree_path_get_indices (view->priv->current_path);
+            gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
 
-            /* we need do this when we remove the blank split from the last transaction */
-            if (indices[0] != total_num -1)
-                total_num = total_num -1;
+            priv->expanded = TRUE;
 
-            while (index < total_num)
-            {
-                gtk_tree_path_down (path); //TROW2
-                gtk_tree_view_expand_to_path (GTK_TREE_VIEW (view), path);
-                gtk_tree_path_up (path);   //TROW1
+            /* This updates the plugin page gui */
+            if (view->moved_cb)
+                (view->moved_cb)(view, view->moved_cb_data);
 
-                index = index + 1;
-                if (index == total_num)
-                    break;
-
-                gtk_tree_path_next (path); //Next Transaction
-            }
-            gtk_tree_path_free (path);
+            LEAVE("journal foramt");
             return (FALSE);
         }
 
         if (!model->use_double_line)
         {
-g_print("gnc_tree_view_split_reg_set_format single\n");
-            path = gtk_tree_path_new_first ();
-            while (index < total_num)
-            {
-                gtk_tree_view_collapse_row (GTK_TREE_VIEW (view), path);
-                gtk_tree_path_next (path); //Next Transaction
-                index = index + 1;
-            }
-            gtk_tree_path_free (path);
+            gtk_tree_view_collapse_all (GTK_TREE_VIEW (view));
+
+            priv->expanded = FALSE;
+
+            /* This updates the plugin page gui */
+            if (view->moved_cb)
+                (view->moved_cb)(view, view->moved_cb_data);
+
+            LEAVE("single line foramt");
+            return (FALSE);
         }
 
         if (model->use_double_line)
         {
-g_print("gnc_tree_view_split_reg_set_format double\n");
+            gint index = 0;
+            GtkTreePath *path;
+
             path = gtk_tree_path_new_first ();
             while (index < total_num)
             {
@@ -650,22 +749,43 @@
                 index = index + 1;
             }
             gtk_tree_path_free (path);
+            LEAVE("double line format");
         }
 
         /* This expands to split from top level auto.. */
         if ((model->style == REG2_STYLE_AUTO_LEDGER) || (model->style == REG2_STYLE_JOURNAL))
         {
-            GtkTreePath *expand_path;
-g_print("gnc_tree_view_split_reg_set_format auto\n");
-            expand_path = gtk_tree_path_new_from_indices (row_now, -1);
-            gtk_tree_view_expand_row (GTK_TREE_VIEW (view), expand_path, TRUE);
-            gtk_tree_path_free (expand_path);
+            gtk_tree_view_expand_row (GTK_TREE_VIEW (view), spath, TRUE);
+
+            priv->expanded = TRUE;
+            LEAVE("auto expand line format");
         }
     }
+
+    gtk_tree_path_free (mpath);
+    gtk_tree_path_free (spath);
+
+    /* This updates the plugin page gui */
+    if (view->moved_cb)
+        (view->moved_cb)(view, view->moved_cb_data);
+
     return (FALSE);
 }
 
 
+/* Callback to update the view after transactions are added or deleted */
+static void
+gtv_split_reg_refresh_cb (GncTreeModelSplitReg *model, gpointer user_data)
+{
+    GncTreeViewSplitReg *view = user_data;
+
+    if (view->reg_closing != TRUE)
+        /* Set the view format */
+        g_idle_add ((GSourceFunc)gnc_tree_view_split_reg_set_format, view);
+}
+
+
+/* Create a tree view from a given model */
 GncTreeViewSplitReg*
 gnc_tree_view_split_reg_new_with_model (GncTreeModelSplitReg *model)
 {
@@ -686,9 +806,11 @@
     gnc_tree_view_set_model (GNC_TREE_VIEW (view), s_model);
     g_object_unref (G_OBJECT (s_model));
 
+    /* Set the user_data for the sort callback */
+    gnc_tree_view_set_sort_user_data (GNC_TREE_VIEW (view), view);
+
     view->priv->anchor = gnc_tree_model_split_reg_get_anchor (model);
     view->priv->reg_comm = xaccAccountGetCommodity (view->priv->anchor);
-    view->priv->has_rate = TRUE; //FIXME - replace has_rate with price visibility test / from original
     view->help_text = NULL;
 
     gnc_tree_view_split_reg_set_cols (view, gnc_tree_view_split_reg_get_colummn_list (model));
@@ -737,44 +859,54 @@
 gnc_tree_view_split_reg_default_selection (GncTreeViewSplitReg *view)
 {
     GncTreeModelSplitReg *model;
-    GtkTreeIter iter;
-    GtkTreePath *path, *path_temp;
+    GtkTreePath *new_mpath, *mpath, *spath;
     gint *indices;
-    gint top_row;
 
+    ENTER(" ");
+
     model = get_split_reg_model_from_view (view);
 
-    view->priv->default_set = TRUE;
-
     /* Set the default start position to end of list */
-    if (gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, view->priv->current_path))
+    if (view->priv->current_trans == NULL)
     {
-        indices = gtk_tree_path_get_indices (view->priv->current_path);
-        top_row = indices[0];
+        /* both values NULL will return last in list */
+        mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, NULL);
+        view->priv->current_trans = gnc_tree_control_split_reg_get_blank_trans (view);
     }
     else
+        mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, view->priv->current_split, view->priv->current_trans);
+
+    indices = gtk_tree_path_get_indices (mpath);
+
+    new_mpath = gtk_tree_path_new_from_indices (indices[0], -1);
+
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), new_mpath);
+
+    DEBUG("default_selection mpath is %s, spath is %s, new path is %s", gtk_tree_path_to_string (mpath),
+                                    gtk_tree_path_to_string (spath), gtk_tree_path_to_string (new_mpath));
+
+    view->priv->current_depth = gtk_tree_path_get_depth (spath);
+
+    if (view->priv->current_ref != NULL)
     {
-        /* both values NULL will return last in list */
-        path_temp = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, NULL);
-        indices = gtk_tree_path_get_indices (path_temp);
-        top_row = indices[0]; // we do this because freeing the path screws the indices
-        gtk_tree_path_free (path_temp);
+        gtk_tree_row_reference_free (view->priv->current_ref);
+        view->priv->current_ref = NULL;
     }
+    view->priv->current_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), new_mpath);
 
-    path = gtk_tree_path_new_from_indices (top_row, -1);
+    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
 
-//g_print("gnc_tree_view_split_reg_default_selection current_path is %s, new path is %s\n", gtk_tree_path_to_string (view->priv->current_path),
-//        gtk_tree_path_to_string (path));
+    gtk_tree_path_free (mpath);
+    gtk_tree_path_free (spath);
+    gtk_tree_path_free (new_mpath);
 
-    gtk_tree_path_free (view->priv->current_path);
-    view->priv->current_path = gtk_tree_path_copy (path);
+    /* Set the view format */
+    g_idle_add ((GSourceFunc)gnc_tree_view_split_reg_set_format, view);
 
-    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), path);
+    /* scroll window to show selection when view is idle */
+    g_idle_add ((GSourceFunc)gtv_scroll_to_cell, view );
 
-    gtk_tree_path_free (path);
-
-    /* scroll when view is idle */
-    g_idle_add ((GSourceFunc)gtv_scroll_to_cell, view );
+    LEAVE(" ");
 }
 
 
@@ -795,32 +927,72 @@
 needs_exchange_rate (GncTreeViewSplitReg *view, Transaction *trans, Split *split)
 {
     gnc_commodity *split_com, *txn_curr, *reg_com;
-g_print("needs_exchange_rate - trans %p and split %p\n", trans, split);
-//    if (view->priv->has_rate) return FALSE;
 
+    ENTER("needs_exchange_rate - trans %p and split %p", trans, split);
+
     txn_curr = xaccTransGetCurrency (trans);
     split_com = xaccAccountGetCommodity (xaccSplitGetAccount (split));
     if (split_com && txn_curr && !gnc_commodity_equiv (split_com, txn_curr))
     {
-g_print("needs_exchange_rate split_com return TRUE\n");
+        LEAVE("needs_exchange_rate split_com to txn_curr return TRUE");
         return TRUE;
     }
 
     reg_com = view->priv->reg_comm;
-    if (reg_com && split_com && !gnc_commodity_equiv (reg_com, split_com))
+    if (split_com && reg_com && !gnc_commodity_equiv (split_com, reg_com))
     {
-g_print("needs_exchange_rate reg_com return TRUE\n");
+        LEAVE("needs_exchange_rate split_com and reg_com return TRUE");
         return TRUE;
     }
-
+    LEAVE("No Exchange rate needed");
     return FALSE;
 }
 
 
+/* Get the rate from the price db */
+static gnc_numeric
+gtv_get_rate_from_db (gnc_commodity *from, gnc_commodity *to)
+{
+    GNCPrice *prc;
+    gnc_numeric rate_split;
+    gboolean have_rate = FALSE;
+    QofBook *book = gnc_get_current_book ();
+
+    /* Do we have a rate allready */
+    prc = gnc_pricedb_lookup_latest (gnc_pricedb_get_db (book), from, to);
+    if (prc)
+    {
+        rate_split = gnc_price_get_value (prc);
+        gnc_price_unref (prc);
+        have_rate = TRUE;
+    }
+
+    /* Lets try reversing the commodities */
+    if (!have_rate)
+    {
+        prc = gnc_pricedb_lookup_latest (gnc_pricedb_get_db (book), to, from);
+        if (prc)
+        {
+            rate_split = gnc_numeric_div (gnc_numeric_create (1, 1), gnc_price_get_value (prc),
+                                 GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
+
+            gnc_price_unref (prc);
+            have_rate = TRUE;
+        }
+    }
+
+    /* No rate, set to 1/1 */
+    if (!have_rate)
+        rate_split = gnc_numeric_create (1, 1);
+
+    return rate_split;
+}
+
+
 /* Either sets the value and amount for split and returns TRUE, or
    does nothing and returns FALSE. */
 static gboolean
-handle_exchange_rate (GncTreeViewSplitReg *view, gnc_numeric amount, Transaction *trans, Split *split)
+handle_exchange_rate (GncTreeViewSplitReg *view, gnc_numeric amount, Transaction *trans, Split *split, gboolean force)
 {
     XferDialog *xfer;
     gboolean rate_split_ok, rate_reg_ok;
@@ -830,92 +1002,99 @@
     gnc_commodity *reg_comm = view->priv->reg_comm;
     gnc_commodity *trans_curr = xaccTransGetCurrency (trans);
     gboolean expanded;
+    gboolean have_rate = TRUE;
 
-g_print("handle_exchange_rate trans %p and split %p\n", trans, split);
 
+    ENTER("handle_exchange_rate amount %s, trans %p and split %p force %d", gnc_numeric_to_string (amount), trans, split, force);
+
     /* Rate from trans-curr to split-comm */
     rate_split_ok = xaccTransGetRateForCommodity (trans, xfer_comm, split, &rate_split);
 
     /* Rate from trans-curr to reg-comm */
     rate_reg_ok = xaccTransGetRateForCommodity (trans, reg_comm, split, &rate_reg);
 
-    /* Are we expnded */
-    expanded = gnc_tree_view_split_reg_current_trans_expanded (view);
+    /* Are we expanded */
+    expanded = view->priv->expanded;
 
-    if (rate_reg_ok && rate_split_ok)
+    if (rate_reg_ok && rate_split_ok && !force)
     {
         value = gnc_numeric_div (amount, rate_reg, gnc_commodity_get_fraction (trans_curr), GNC_HOW_DENOM_REDUCE);
         amount = gnc_numeric_mul (value, rate_split, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
     }
     else
     {
-        rate_split = gnc_numeric_create (1, 1);
+        if (!rate_split_ok)
+            rate_split = gtv_get_rate_from_db (reg_comm, xfer_comm);
 
-        //g_message("reg amt: %s", gnc_numeric_to_string(amount));
         /* create the exchange-rate dialog */
         xfer = gnc_xfer_dialog (NULL, NULL);
+
         gnc_xfer_dialog_is_exchange_dialog (xfer, &rate_split);
 
         /* fill in the dialog entries */
         gnc_xfer_dialog_set_description (xfer, xaccTransGetDescription (trans));
         gnc_xfer_dialog_set_memo (xfer, xaccSplitGetMemo (split));
+
         /* Get per book option */
         gnc_xfer_dialog_set_num (xfer, gnc_get_num_action (trans, split));
         gnc_xfer_dialog_set_date (xfer, timespecToTime64 (xaccTransRetDatePostedTS (trans)));
 
         value = amount;
-        if (gnc_xfer_dialog_run_exchange_dialog (
-                xfer, &rate_split, value, reg_acc, trans, xfer_comm, expanded))
-            return FALSE;
+        if (gnc_xfer_dialog_run_exchange_dialog (xfer, &rate_split, value, reg_acc, trans, xfer_comm, expanded))
+        {
+            if (!rate_split_ok)
+                rate_split = gnc_numeric_create (1, 1);
+            have_rate = FALSE;
+        }
+        else
+            have_rate = TRUE;
+
         amount = gnc_numeric_mul (value, rate_split, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
     }
     xaccSplitSetAmount (split, amount);
     xaccSplitSetValue (split, value);
-    g_message ("split amt=%s; split val=%s", gnc_numeric_to_string (amount), gnc_numeric_to_string (value));
-g_print("handle_exchange_rate split amt=%s; split val=%s\n", gnc_numeric_to_string (amount), gnc_numeric_to_string (value));
-    return TRUE;
+
+    LEAVE("handle_exchange_rate set split %p amt=%s; and val=%s", split, gnc_numeric_to_string (amount), gnc_numeric_to_string (value));
+    return have_rate;
 }
 
 
-
-
-static void
-set_value_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input)
+#define set_value_for gnc_tree_view_split_reg_set_value_for
+void
+gnc_tree_view_split_reg_set_value_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input, gboolean force)
 {
+    GtkWidget *window;
     Account *anchor = view->priv->anchor;
     Account *acct = xaccSplitGetAccount (split);
     gnc_commodity *currency;
     gnc_numeric value, amount, rate;
 
-g_print("set_value_for trans %p and split %p input %s\n", trans, split, gnc_numeric_to_string (input));
-g_print("anchor is %p and acct is %p\n", anchor, acct);
+    ENTER("set_value_for trans %p and split %p input %s force %d", trans, split, gnc_numeric_to_string (input), force);
 
-    if (xaccSplitGetAccount (split) == NULL) //FIXME this would make sure we have an account, not sure its valid.
-        xaccTransScrubOrphans (trans);
+    currency = xaccTransGetCurrency (trans);
 
     if (gnc_numeric_zero_p (input))
     {
         xaccSplitSetValue (split, input);
         xaccSplitSetAmount (split, input);
+        LEAVE("input is zero");
         return;
     }
 
-    if (!xaccTransGetCurrency (trans))
-    {
-        if (anchor)
-            xaccTransSetCurrency (trans, view->priv->reg_comm);
-        else
-            xaccTransSetCurrency (trans, xaccAccountGetCommodity (acct));
-    }
+    window = gnc_tree_view_split_reg_get_parent (view);
 
-    currency = xaccTransGetCurrency (trans);
-
     if (needs_exchange_rate (view, trans, split))
     {
-        if (handle_exchange_rate (view, input, trans, split))
+        if (handle_exchange_rate (view, input, trans, split, force))
         {
             ; //FIXME ??????
         }
+        else
+        {
+            gnc_error_dialog (window, "%s",
+                         _("Exchange Rate Canceled, using existing rate or default 1 to 1 rate if this is a new transaction."));
+        }
+        LEAVE("used exchange rate");
         return;
     }
 
@@ -927,33 +1106,38 @@
     {
         gnc_commodity *reg_com = view->priv->reg_comm;
         gnc_commodity *split_com = xaccAccountGetCommodity (acct);
-        /* Convert from the anchor account's commodity to
-           trans currency */
-        //xaccSplitSetAmount (split, input);
+
+        /* Convert from the anchor account's commodity to trans currency */
         if (gnc_commodity_equiv (currency, reg_com))
             value = input;
         else 
-       {
+        {
             if (!xaccTransGetRateForCommodity (trans, reg_com, NULL, &rate))
+            {
+                LEAVE("");
                 return;
-            //rate = xaccTransGetAccountConvRate(trans, anchor);
+            }
+
             if (gnc_numeric_zero_p (rate))
             {
-                // FIXME: probably wrong.
                 xaccTransSetCurrency (trans, reg_com);
                 value = input;
             }
             else
+            {
                 value = gnc_numeric_div (
                     input, rate,
                     GNC_DENOM_AUTO, //?
                     //gnc_commodity_get_fraction(currency),
                     GNC_HOW_RND_ROUND);
+            }
         }
         xaccSplitSetValue (split, value);
-        //return;
+
         if (gnc_commodity_equiv (split_com, reg_com))
+        {
             amount = input;
+        }
         else
         {
             rate = xaccTransGetAccountConvRate (trans, acct);
@@ -963,13 +1147,9 @@
     }
     else
     {
-        //FIXME: untested; assumes entry in the trans currency
-        //gnc_commodity *split_com = xaccAccountGetCommodity(acct);
         value = input;
         xaccSplitSetValue (split, value);
-        //g_assert (split_com == currency);
-        //FIXME: obsolete
-        /* For a split belonging to another account */
+
         rate = xaccTransGetAccountConvRate (trans, acct);
         amount = gnc_numeric_mul (value, rate, xaccAccountGetCommoditySCU (acct), GNC_HOW_RND_ROUND);
         if (gnc_numeric_check (amount) == GNC_ERROR_OK)
@@ -977,6 +1157,7 @@
             xaccSplitSetAmount (split, amount);
         }
     }
+    LEAVE(" ");
 }
 
 
@@ -987,18 +1168,21 @@
     gnc_commodity *currency = xaccTransGetCurrency (trans);
     gnc_numeric total;
 
-// g_print("get_value_for trans %p and split %p is_blank %d\n", trans, split, is_blank);
+    ENTER("get_value_for trans %p and split %p is_blank %d", trans, split, is_blank);
 
     total = xaccSplitGetValue (split);
 
-    if (is_blank && gnc_numeric_zero_p (total))
+    if (is_blank && gnc_numeric_zero_p (total)) //blank split and total zero
     {
         gnc_numeric rate;
         total = gnc_numeric_neg (xaccTransGetImbalanceValue (trans));
         if (!gnc_numeric_zero_p (total))
         {
             if (!xaccTransGetRateForCommodity (trans, view->priv->reg_comm, NULL, &rate))
+            {
+                LEAVE("zero");
                 return gnc_numeric_zero();
+            }
 
             total = gnc_numeric_mul (
                 total, rate,
@@ -1012,126 +1196,393 @@
         {
             /* if needs conversion? */
             gnc_commodity *commodity = view->priv->reg_comm;
-            if (commodity && !gnc_commodity_equiv (commodity, currency))
-                total = xaccSplitConvertAmount (split, view->priv->anchor);
+            if (commodity && gnc_commodity_is_currency (view->priv->reg_comm)) //test for a currency register
+            {
+                if (!gnc_commodity_equiv (commodity, currency))
+                {
+                    total = xaccSplitConvertAmount (split, view->priv->anchor);
+                }
+            }
         }
     }
+    LEAVE("return value is %s", gnc_numeric_to_string (total));
     return total;
 }
 
 
-static void
-set_amount_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input)
+/* Returns the other Split based on the current Account */
+/* Only used with two split transactions */
+static Split *
+get_other_split (GncTreeViewSplitReg *view, Transaction *trans)
 {
-    Account *acct = xaccSplitGetAccount (split);
-    gnc_commodity *split_com = xaccAccountGetCommodity (acct);
-    gnc_commodity *currency = xaccTransGetCurrency (trans);
+    int i;
+    Split *split = NULL;
+    Account *anchor = view->priv->anchor;
 
-g_print("set_amount_for trans %p and split %p and input is %s\n", trans, split, gnc_numeric_to_string (input));
+    for (i = 0; (split = xaccTransGetSplit(trans, i)); i++) {
+        if (anchor == xaccSplitGetAccount(split))
+            return xaccSplitGetOtherSplit(split);
+    }
+    return NULL;
+}
 
-    xaccSplitSetAmount (split, input);
-    if (gnc_commodity_equiv (currency, split_com))
-        xaccSplitSetValue (split, input);
 
-    return;
+/* Returns a Split that matches the current Account */
+static Split *
+get_this_split (GncTreeViewSplitReg *view, Transaction *trans)
+{
+    int i;
+    Split *split = NULL;
+    Account *anchor = view->priv->anchor;
+
+    for (i = 0; (split = xaccTransGetSplit (trans, i)); i++) {
+        if (anchor == xaccSplitGetAccount (split))
+            return split;
+    }
+    return NULL;
 }
 
 
-static gnc_numeric
-get_rate_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gboolean is_blank)
+/* Returns the value denom */
+static int
+gnc_tree_view_split_reg_get_value_denom (Split *split)
 {
-    gnc_numeric num;
+    gnc_commodity *currency;
+    int denom;
 
-//g_print("get_rate_for trans %p and split %p is_blank %d\n", trans, split, is_blank);
+    currency = xaccTransGetCurrency (xaccSplitGetParent (split));
+    denom = gnc_commodity_get_fraction (currency);
+    if (denom == 0)
+    {
+        gnc_commodity *commodity = gnc_default_currency ();
+        denom = gnc_commodity_get_fraction (commodity);
+        if (denom == 0)
+            denom = 100;
+    }
+    return denom;
+}
 
-    num = get_value_for (view, trans, split, is_blank);
-//g_print("get_rate_for get_value_for is %s\n", gnc_numeric_to_string (num));
-    num = gnc_numeric_div ( xaccSplitGetAmount (split), num, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
-//g_print("get_rate_for return is %s\n", gnc_numeric_to_string (num));
-    return num;
+
+/* Returns the amount denom */
+static int
+gnc_tree_view_split_reg_get_amount_denom (Split *split)
+{
+    int denom;
+
+    denom = xaccAccountGetCommoditySCU (xaccSplitGetAccount (split));
+    if (denom == 0)
+    {
+        gnc_commodity *commodity = gnc_default_currency ();
+        denom = gnc_commodity_get_fraction (commodity);
+        if (denom == 0)
+            denom = 100;
+    }
+    return denom;
 }
 
 
+/* Takes the input with column and sets the price / amount / value so they are consistent */
 static void
-set_rate_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input, gboolean is_blank)
+set_number_for_input (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input, gint viewcol)
 {
-    gnc_commodity *split_comm;
+    gnc_numeric  price;
+    gnc_numeric  amount;
+    gnc_numeric  value;
 
-    gnc_numeric old_rate = get_rate_for (view, trans, split, is_blank);
-    gnc_numeric factor = gnc_numeric_div (input, old_rate, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
-    split_comm = xaccAccountGetCommodity (xaccSplitGetAccount (split));
-/*FIXME     xaccTransAdjustRateForCommodity (trans, split_comm, factor); */
+    gboolean price_changed = FALSE;   // Price of each share
+    gboolean value_changed = FALSE;   // Total value of shares
+    gboolean amount_changed = FALSE;  // No of shares
 
-//g_print("set_rate_for trans %p and split %p is_blank %d\n", trans, split, is_blank);
+    gboolean recalc_amount = FALSE;
+    gboolean recalc_price = FALSE;
+    gboolean recalc_value = FALSE;
+    int denom;
 
-#if JUNK
-    // This is from original 
-    reg_comm = view->priv->reg_comm;
-    if (xaccTransGetRateForCommodity (trans, reg_comm, split, &reg_rate))
+    ENTER("set_number_for_input trans %p and split %p and input is %s and viewcol is %d", trans, split, gnc_numeric_to_string (input), viewcol);
+
+    if (gnc_numeric_zero_p (input))
     {
-        input = gnc_numeric_div (input, reg_rate, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
-        /* input is now the rate from the transaction currency to the
-           split_com */
+        xaccSplitSetValue (split, input);
+        xaccSplitSetAmount (split, input);
+        LEAVE("zero");
+        return;
     }
 
-    if (gnc_numeric_zero_p (val) && gnc_numeric_zero_p (amt))
+    amount = xaccSplitGetAmount (split);
+    value = xaccSplitGetValue (split);
+
+    if (viewcol == COL_AMTVAL && !view->priv->expanded)
     {
-        gnc_numeric one = gnc_numeric_create (1, 1);
-        xaccSplitSetAmount (split, one);
-        amt = one;
+        value_changed = TRUE;
+        if (gnc_numeric_zero_p (amount))
+        {
+            xaccSplitSetValue (split, input);
+            xaccSplitSetAmount (split, input);
+            LEAVE("");
+            return;
+        }
     }
+    else if (viewcol == COL_AMTVAL && view->priv->expanded)
+    {
+        amount_changed = TRUE;
+        if (gnc_numeric_zero_p (value))
+        {
+            xaccSplitSetValue (split, input);
+            xaccSplitSetAmount (split, input);
+            LEAVE("");
+            return;
+        }
+    }
 
-    if (gnc_numeric_zero_p (val))
+    if (viewcol == COL_PRICE)
     {
-        val = gnc_numeric_div (input, amt, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
+        price_changed = TRUE;
+        if (gnc_numeric_zero_p (value))
+        {
+            amount = gnc_numeric_create (1,1);
+            value = gnc_numeric_mul (input, amount, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
+            xaccSplitSetValue (split, input);
+            xaccSplitSetAmount (split, amount);
+            LEAVE("");
+            return;
+        }
     }
-    else
+
+    if (viewcol == COL_CREDIT || viewcol == COL_DEBIT)
     {
-        amt = gnc_numeric_mul (input, val, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
+        amount_changed = TRUE;
+        if (gnc_numeric_zero_p (value))
+        {
+            xaccSplitSetValue (split, input);
+            xaccSplitSetAmount (split, input);
+            LEAVE("");
+            return;
+        }
     }
 
-    amt = gnc_numeric_mul (get_value_for(view, trans, split, FALSE /*FIXME*/),
-                          input,
-                          GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
-    set_amount_for (view, trans, split, amt);
+    DEBUG("value_changed %d, price_changed %d, amount_changed %d", value_changed, price_changed, amount_changed);
 
-    //xaccSplitSetValue (split, val);
-    //xaccSplitSetAmount (split, amt);
+    {
+        int choice;
+        int default_value;
+        GList *node;
+        GList *radio_list = NULL;
+        const char *title = _("Recalculate Transaction");
+        const char *message = _("The values entered for this transaction "
+                                "are inconsistent. Which value would you "
+                                "like to have recalculated?");
 
-#endif
+        if (amount_changed)
+            radio_list = g_list_append (radio_list,
+                                        g_strdup_printf ("%s (%s)",
+                                                _("_Shares"), _("Changed")));
+        else
+            radio_list = g_list_append (radio_list, g_strdup (_("_Shares")));
+
+        if (price_changed)
+            radio_list = g_list_append (radio_list,
+                                        g_strdup_printf ("%s (%s)",
+                                                _("_Price"), _("Changed")));
+        else
+            radio_list = g_list_append (radio_list, g_strdup (_("_Price")));
+
+        if (value_changed)
+            radio_list = g_list_append (radio_list,
+                                        g_strdup_printf ("%s (%s)",
+                                                _("_Value"), _("Changed")));
+        else
+            radio_list = g_list_append (radio_list, g_strdup (_("_Value")));
+
+        if (price_changed)
+            default_value = 0;  /* change the amount / shares */
+        else
+            default_value = 1;  /* change the value */
+
+        choice = gnc_choose_radio_option_dialog
+                 (gnc_tree_view_split_reg_get_parent (view),
+                  title,
+                  message,
+                  _("_Recalculate"),
+                  default_value,
+                  radio_list);
+
+        for (node = radio_list; node; node = node->next)
+            g_free (node->data);
+
+        g_list_free (radio_list);
+
+        switch (choice)
+        {
+        case 0: /* Modify number of shares */
+            recalc_amount = TRUE;
+            break;
+        case 1: /* Modify the share price */
+            recalc_price = TRUE;
+            break;
+        case 2: /* Modify total value */
+            recalc_value = TRUE;
+            break;
+        default: /* Cancel */
+            return;
+        }
+    }
+
+    DEBUG("recalc_value %d, recalc_price %d, recalc_amount %d", recalc_value, recalc_price, recalc_amount);
+
+    if (recalc_amount)
+    {
+        denom = gnc_tree_view_split_reg_get_amount_denom (split);
+
+        if (amount_changed)
+        {
+            LEAVE("");
+            return;
+        }
+
+        if (price_changed)
+            price = input;
+        else
+            price = gnc_numeric_div (value, amount, GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
+
+        if (value_changed)
+        {
+            xaccSplitSetValue (split, input);
+            amount = gnc_numeric_div (input, price, denom, GNC_HOW_RND_ROUND_HALF_UP);
+            xaccSplitSetAmount (split, amount);
+        }
+        else
+        {
+            amount = gnc_numeric_div (value, price, denom, GNC_HOW_RND_ROUND_HALF_UP);
+            xaccSplitSetAmount (split, amount);
+        }
+    }
+
+    if (recalc_price)
+    {
+        if (price_changed)
+        {
+            LEAVE("");
+            return;
+        }
+
+        if (amount_changed)
+        {
+            xaccSplitSetAmount (split, input);
+            xaccSplitSetValue (split, value);
+        }
+
+        if (value_changed)
+        {
+            xaccSplitSetValue (split, input);
+            xaccSplitSetAmount (split, amount);
+        }
+    }
+
+    if (recalc_value)
+    {
+        denom = gnc_tree_view_split_reg_get_value_denom (split);
+
+        if (value_changed)
+        {
+            LEAVE("");
+            return;
+        }
+
+        if (price_changed)
+            price = input;
+        else
+            price = gnc_numeric_div (value, amount, GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
+
+        if (amount_changed)
+        {
+            xaccSplitSetAmount (split, input);
+            value = gnc_numeric_mul (input, price, denom, GNC_HOW_RND_ROUND_HALF_UP);
+            xaccSplitSetValue (split, value);
+        }
+        else
+        {
+            value = gnc_numeric_mul (amount, price, denom, GNC_HOW_RND_ROUND_HALF_UP);
+            xaccSplitSetValue (split, value);
+        }
+
+        /* If the number of splits is two, change other split to balance */
+        if ((xaccTransCountSplits (trans) == 2) && view->priv->expanded)
+        {
+            Split *osplit;
+            gnc_commodity *split_com;
+
+            osplit = get_other_split (view, trans);
+
+            split_com = xaccAccountGetCommodity (xaccSplitGetAccount (osplit));
+
+            if (gnc_commodity_is_currency (split_com))
+            {
+                if (gnc_numeric_negative_p (value))
+                {
+                    xaccSplitSetValue (osplit, gnc_numeric_neg (value));
+                    xaccSplitSetAmount (osplit, gnc_numeric_neg (value));
+                }
+                else
+                {
+                    xaccSplitSetValue (osplit, value);
+                    xaccSplitSetAmount (osplit, value);
+                }
+            }
+        }
+    }
+    LEAVE("");
 }
 
 
-/* Returns the other Split based on the current Account */
-/* Only used with two split transactions */
-static Split *
-get_other_split (GncTreeViewSplitReg *view, Transaction *trans)
+/* Set the value for the given input amount */
+static void
+set_value_for_amount (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input)
 {
-    int i;
-    Split *split = NULL;
-    Account *anchor = view->priv->anchor;
+    gnc_numeric  split_rate;
+    gnc_numeric  amount;
+    gnc_numeric  value, new_value;
+    int denom;
 
-    for (i = 0; (split = xaccTransGetSplit(trans, i)); i++) {
-        if (anchor == xaccSplitGetAccount(split))
-            return xaccSplitGetOtherSplit(split);
+    ENTER("set_value_for_amount trans %p and split %p and input is %s", trans, split, gnc_numeric_to_string (input));
+
+    if (gnc_numeric_zero_p (input))
+    {
+        xaccSplitSetValue (split, input);
+        xaccSplitSetAmount (split, input);
+        LEAVE("zero");
+        return;
     }
-    return NULL;
+
+    amount = xaccSplitGetAmount (split);
+    value = xaccSplitGetValue (split);
+
+    denom = gnc_tree_view_split_reg_get_value_denom (split);
+
+    split_rate = gnc_numeric_div (value, amount, GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
+    if (gnc_numeric_check (split_rate) != GNC_ERROR_OK)
+        split_rate = gnc_numeric_create (1,1);
+
+    new_value = gnc_numeric_mul (input, split_rate, denom, GNC_HOW_RND_ROUND_HALF_UP);
+
+    xaccSplitSetValue (split, new_value);
+    xaccSplitSetAmount (split, input);
+
+    LEAVE("");
 }
 
 
-/* Returns a Split that matches the current Account */
-static Split *
-get_this_split (GncTreeViewSplitReg *view, Transaction *trans)
+/* Get the rate */
+static gnc_numeric
+get_rate_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gboolean is_blank)
 {
-    int i;
-    Split *split = NULL;
-    Account *anchor = view->priv->anchor;
+    gnc_numeric num;
 
-    for (i = 0; (split = xaccTransGetSplit (trans, i)); i++) {
-        if (anchor == xaccSplitGetAccount (split))
-            return split;
-    }
-    return NULL;
+    ENTER("get_rate_for trans %p and split %p is_blank %d", trans, split, is_blank);
+
+    num = get_value_for (view, trans, split, is_blank);
+    num = gnc_numeric_div ( xaccSplitGetAmount (split), num, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
+    LEAVE("get_rate_for split amount is %s and return num is %s", gnc_numeric_to_string (xaccSplitGetAmount (split)), gnc_numeric_to_string (num));
+    return num;
 }
 
 
@@ -1139,17 +1590,13 @@
 static gboolean
 get_split_pair (GncTreeViewSplitReg *view, Transaction *trans, Split **osplit, Split **split)
 {
-    QofBook       *book; //do we have this
+    QofBook       *book;
 
     gint count = xaccTransCountSplits (trans);
     Account *anchor = view->priv->anchor;
 
-//FIXME Probably needs more work 
-
     book = gnc_get_current_book();
 
-g_print("get_split_pair trans is %p, osplit is %p and split is %p and count is %d\n", trans, *osplit, *split, count);
-
     if (count == 0)
     {
         *split = xaccMallocSplit (book);
@@ -1178,49 +1625,11 @@
     }
     else
         return FALSE;
-g_print("get_split_pair return - trans is %p, osplit is %p and split %p is set to anchor %p\n", trans, *osplit, *split, anchor);
+    DEBUG("get_split_pair return - trans is %p, osplit is %p and split %p is set to anchor %p", trans, *osplit, *split, anchor);
     return TRUE;
 }
 
 
-/* poor name: really means: If this is the blank split, it may now
-   eventually graduate to a real split. The trans must already be
-   opened for editing because the split will be added to the
-   transaction if hasn't been already. */
-static void
-mark_split_dirty (GncTreeViewSplitReg *view, Transaction *trans, Split *split)
-{
-g_print("mark_split_dirty trans %p and split %p\n", trans, split);
-//    if (split != view->priv->dirty_split && view->priv->dirty_split)
-  
-
-    if (split != view->priv->dirty_split)
-    {
-g_print("mark_split_dirty1\n");
-        if ((view->priv->dirty_split) && (xaccSplitGetAccount (view->priv->dirty_split) != NULL))
-//        if (view->priv->dirty_split)
-        {
-g_print("mark_split_dirty2\n");
-            gnc_tree_model_split_reg_commit_split (get_split_reg_model_from_view (view), view->priv->dirty_split);
-        }
-    }
-
-    if (split && trans && xaccSplitGetParent (split) != trans)
-    {
-g_print("mark_split_dirty3\n");
-
-        if ((xaccTransCountSplits (trans) == 0) && (view->priv->anchor != NULL))
-        {
-g_print("mark_split_dirty4\n");
-            xaccSplitSetAccount (split, view->priv->anchor);
-        }
-        xaccSplitSetParent (split, trans);
-    }
-
-    view->priv->dirty_split = split;
-}
-
-
 /* Does this transaction have any Imbalance splits */
 static gboolean
 get_imbalance (Transaction *trans)
@@ -1244,6 +1653,7 @@
 }
 
 
+/* Get the model iter from the view path string */
 static gboolean
 get_model_iter_from_view_string (GncTreeViewSplitReg *view,
                                 const gchar *path_string, GtkTreeIter *iter)
@@ -1263,6 +1673,7 @@
 }
 
 
+/* Get the model iter from the selection */
 static gboolean
 get_model_iter_from_selection (GncTreeViewSplitReg *view,
                               GtkTreeSelection *sel, GtkTreeIter *iter)
@@ -1279,31 +1690,78 @@
 }
 
 
+/* Only allow changes to values if we have valid split accounts */
 static gboolean
-gtv_have_account (GncTreeViewSplitReg *view, RowDepth depth, gboolean expanded, Transaction *trans, Split *split)
+have_account (GncTreeViewSplitReg *view, RowDepth depth, gboolean expanded, Transaction *trans, Split *split)
 {
-    gboolean have_account = TRUE;
+    gboolean have_account = FALSE;
 
-    /* Only allow changes to values if we have a valid split accounts */
-    if ((depth == TRANS1) && !expanded && (xaccTransCountSplits (trans) == 2))
+    DEBUG("have_account trans %p, split %p, expanded %d, depth %d", trans, split, expanded, depth);
+
+    if ((depth == TRANS1) && !expanded && (xaccTransCountSplits (trans) == 2)) // normal trans
     {
-        if (xaccSplitGetAccount (get_other_split (view, trans)) == NULL)
-            have_account = FALSE;
+        if (xaccSplitGetAccount (get_other_split (view, trans)) != NULL)
+            have_account = TRUE;
     }
 
-    if ((depth == TRANS1) && !expanded && (xaccTransCountSplits (trans) == 0))
-            have_account = FALSE;
+    if ((depth == SPLIT3) && (xaccTransCountSplits (trans) == 0)) // blank trans, blank split
+        have_account = TRUE;
 
-    if ((depth == SPLIT3) && (xaccTransCountSplits (trans) != 0))
+    if (depth == SPLIT3) // normal split
     {
-        if (xaccSplitGetAccount (split) == NULL)
-            have_account = FALSE;
+        if (xaccSplitGetAccount (split) != NULL)
+            have_account = TRUE;
     }
-    
+
     return have_account;
 }
 
 
+/* This cellDataFunc is to set the cell-background property of the control columns. */
+static void
+control_cdf (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_model,
+    GtkTreeIter *s_iter, gpointer user_data)
+{
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    GncTreeModelSplitReg *model;
+    GtkTreeIter iter;
+    GtkTreePath *mpath, *spath;
+    Transaction *trans;
+    Split *split;
+    gboolean is_split, is_blank, is_trow1, is_trow2;
+    const gchar *row_color;
+
+    gint *indices;
+
+    ENTER("");
+
+    model = get_split_reg_model_from_view (view);
+
+    gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model), &iter, s_iter);
+
+    g_return_if_fail (gnc_tree_model_split_reg_get_split_and_trans (
+                         GNC_TREE_MODEL_SPLIT_REG (model), &iter,
+                          &is_trow1, &is_trow2, &is_split, &is_blank,
+                          &split, &trans));
+
+    mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+
+    indices = gtk_tree_path_get_indices (spath);
+
+    row_color = gnc_tree_model_split_reg_get_row_color (model, is_trow1, is_trow2, is_split, indices[0]);
+
+    gtk_tree_path_free (spath);
+    gtk_tree_path_free (mpath);
+
+    /* Set the background color / this works for sorting and deleting transactions */
+    g_object_set (cell, "cell-background", row_color, (gchar*)NULL);
+
+    LEAVE("");
+}
+
+
 /* Instead of setting a different cellDataFunc for each column, we just
    collect everything here and use this one func. */
 static void
@@ -1313,16 +1771,18 @@
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
     GncTreeModelSplitReg *model;
     GtkTreeIter iter;
-    GtkTreePath *path, *temp_path;
+    GtkTreePath *path, *mpath, *spath;
     ViewCol viewcol;
     Transaction *trans;
     Split *split;
     gboolean is_split, is_blank, is_trow1, is_trow2;
     gboolean editable = FALSE, expanded = FALSE;
     gboolean read_only = FALSE;
+    gboolean open_edited = FALSE;
     gint num_of_splits = 0;
     gnc_numeric num;
     const gchar *s = "";
+    const gchar *row_color;
 
     RowDepth depth;
 
@@ -1343,28 +1803,32 @@
                           &is_trow1, &is_trow2, &is_split, &is_blank,
                           &split, &trans));
 
-    temp_path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+    mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
 
-    depth = gtk_tree_path_get_depth (temp_path);
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
-    indices = gtk_tree_path_get_indices (temp_path);
+    depth = gtk_tree_path_get_depth (spath);
 
-    gtk_tree_path_free (temp_path);
+    indices = gtk_tree_path_get_indices (spath);
 
-// g_print("cdf split %p, trans %p, is_trow1 = %d, is_trow2 = %d, is_split = %d, is_blank = %d\n",
-//                                        split, trans, is_trow1, is_trow2, is_split, is_blank);
+    row_color = gnc_tree_model_split_reg_get_row_color (model, is_trow1, is_trow2, is_split, indices[0]);
 
-//g_print(" cdf depth is %d\n", depth);
+    gtk_tree_path_free (spath);
+    gtk_tree_path_free (mpath);
 
+    /* Set the background color / this works for sorting and deleting of transactions */
+    g_object_set (cell, "cell-background", row_color, (gchar*)NULL);
+
     /* Get the read only model setting */
     gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, GNC_TREE_MODEL_SPLIT_REG_COL_RO, &read_only, -1);
 
-    /* Voided Transaction. */
-    if (xaccTransHasSplitsInState (trans, VREC))
+    /* Are we being edited in other register */
+    if (xaccTransIsOpen (trans) && (view->priv->dirty_trans != trans))
+    {
         read_only = TRUE;
+        open_edited = TRUE;
+    }
 
-//g_print(" cdf path is %s\n", gtk_tree_path_to_string (gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter)));
-
     /* Lets see if the splits are expanded and count them */
     if (is_trow1 || is_trow2)
     {
@@ -1375,6 +1839,11 @@
         expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path);
         gtk_tree_path_free (path);
     }
+    else
+    {
+        num_of_splits = xaccTransCountSplits (trans);
+        expanded = TRUE;
+    }
 
     switch (viewcol) {
     case COL_DATE:
@@ -1382,6 +1851,9 @@
         if (is_split)
             g_object_set (cell, "cell-background", "white", (gchar*)NULL);
 
+        if (is_trow2 && SHOW_ENTERED_DATE)
+            g_object_set (cell, "cell-background", YELLOWCELL, (gchar*)NULL);
+
         if (is_trow1) {
             Timespec ts = {0,0};
             xaccTransGetDatePostedTS (trans, &ts);
@@ -1396,6 +1868,20 @@
             s = gnc_print_date(ts);
             editable = TRUE;
         }
+        else if (is_trow2 && SHOW_ENTERED_DATE) {
+            Timespec ts = {0,0};
+            xaccTransGetDateEnteredTS (trans, &ts);
+            //If the time returned by xaccTransGetDateEnteredTS is 0 then assume it
+            //is a new transaction and set the time to current time to show current
+            //date on new transactions
+            if (ts.tv_sec == 0)
+            {
+                ts.tv_sec = gnc_time (NULL);
+                //xaccTransSetDateEnteredSecs(trans, ts.tv_sec);
+            }//if
+            s = gnc_print_date(ts);
+            editable = FALSE;
+        }
         else {
             s = "";
             editable = FALSE;
@@ -1403,8 +1889,8 @@
 
         editable = (read_only == TRUE) ? FALSE : editable;
 
-        /*FIXME This will remove the calander buttons if FALSE, preference may be ? */
-        g_object_set (cell, "use_buttons", TRUE, NULL ); 
+        /* This will remove the calander buttons if FALSE */
+        g_object_set (cell, "use_buttons", CAL_USE_BUTTONS, NULL );
         g_object_set (cell, "text", s, "editable", editable, NULL);
         break;
 
@@ -1446,9 +1932,12 @@
         if (is_trow1)
             /* Get per book option */
             s = gnc_get_num_action (trans, get_this_split (view, trans));
-        else if (is_trow2 && !expanded)
+        else if (is_trow2 && (qof_book_use_split_action_for_num_field (gnc_get_current_book())))
             /* Get per book option */
             s = gnc_get_action_num (trans, get_this_split (view, trans));
+        else if (is_trow2 && !expanded && (!qof_book_use_split_action_for_num_field (gnc_get_current_book())))
+            /* Get per book option */
+            s = gnc_get_action_num (trans, get_this_split (view, trans));
         else if (is_split)
             /* Get split-action with gnc_get_num_action which is the same as
              * xaccSplitGetAction with these arguments */
@@ -1553,7 +2042,7 @@
         /* Column is RECN */
         if (is_trow1 && !expanded) {
             char rec = xaccSplitGetReconcile (get_this_split (view, trans));
-            if (rec == VREC || rec == FREC || rec == YREC)
+            if (rec == VREC || rec == FREC)
                 editable = FALSE;
             else
                 editable = TRUE;
@@ -1573,7 +2062,7 @@
 
         if (is_split) {
             char rec = xaccSplitGetReconcile (split);
-            if (rec == VREC || rec == FREC || rec == YREC)
+            if (rec == VREC || rec == FREC)
                 editable = FALSE;
             else
                 editable = TRUE;
@@ -1621,9 +2110,12 @@
         /* Column is VALUE */
         if (is_split)
         {
-            gnc_numeric amt = xaccSplitGetValue (split);
-            s = xaccPrintAmount (amt, gnc_commodity_print_info (xaccTransGetCurrency (trans), FALSE));
-            editable = TRUE;
+            gnc_numeric val = xaccSplitGetValue (split);
+            s = xaccPrintAmount (val, gnc_commodity_print_info (xaccTransGetCurrency (trans), SHOW_SYMBOL));
+            editable = FALSE;
+
+            if (get_imbalance (trans))
+                g_object_set (cell, "cell-background", PINKCELL, (gchar*)NULL);
         }
         else
         {
@@ -1631,10 +2123,6 @@
             editable = FALSE;
         }
 
-        /* Only allow changes to values if we have a valid split accounts */
-        if (!(gtv_have_account (view, depth, expanded, trans, split)))
-            editable = FALSE;
-
         editable = (read_only == TRUE) ? FALSE : editable;
 
         g_object_set (cell, "text", s, "editable", editable, NULL);
@@ -1651,24 +2139,22 @@
         {
             gnc_commodity *split_com = xaccAccountGetCommodity (xaccSplitGetAccount (split));
             num = get_rate_for (view, trans, split, is_blank);
-            if (gnc_numeric_check(num) == GNC_ERROR_OK)
+            if (gnc_numeric_check (num) == GNC_ERROR_OK)
             {
-                s = xaccPrintAmount (num, gnc_split_amount_print_info (split, FALSE));
-                editable = !gnc_numeric_zero_p (num) &&
-                    gnc_commodity_equiv (split_com, view->priv->reg_comm);
-g_print("zero %d and equiv %d\n", gnc_numeric_zero_p (num), gnc_commodity_equiv (split_com, view->priv->reg_comm));
+                s = xaccPrintAmount (num, gnc_split_amount_print_info (split, SHOW_SYMBOL));
+                editable = !gnc_numeric_zero_p (num) && gnc_commodity_equiv (split_com, view->priv->reg_comm);
+                editable = FALSE;
             }
             else
             {
                 s = "";
                 editable = FALSE;
             }
+
+            if (get_imbalance (trans))
+                g_object_set (cell, "cell-background", PINKCELL, (gchar*)NULL);
         }
 
-        /* Only allow changes to values if we have a valid split accounts */
-        if (!(gtv_have_account (view, depth, expanded, trans, split)))
-            editable = FALSE;
-
         editable = (read_only == TRUE) ? FALSE : editable;
 
         g_object_set (cell, "text", s, "editable", editable, NULL);
@@ -1676,22 +2162,36 @@
 
     case COL_AMOUNT:
         /* Column is AMOUNT */
-       if (is_split)
-       {
+        if (is_split && (anchor == NULL))
+        {
             gnc_numeric amt = xaccSplitGetAmount (split);
-            s = xaccPrintAmount (amt, gnc_account_print_info (xaccSplitGetAccount (split), FALSE));
-            editable = TRUE;
+            s = xaccPrintAmount (amt, gnc_account_print_info (xaccSplitGetAccount (split), SHOW_SYMBOL));
+            editable = FALSE;
+
+            if (get_imbalance (trans))
+                g_object_set (cell, "cell-background", PINKCELL, (gchar*)NULL);
         }
+        else if (is_split && (anchor))
+        {
+            gnc_commodity *split_comm;
+            split_comm = xaccAccountGetCommodity (xaccSplitGetAccount (split));
+
+            if (!gnc_commodity_is_currency (split_comm) || (is_blank))
+            {
+                gnc_numeric amt = xaccSplitGetAmount (split);
+                s = xaccPrintAmount (amt, gnc_account_print_info (xaccSplitGetAccount (split), SHOW_SYMBOL));
+                editable = FALSE;
+            }
+
+            if (get_imbalance (trans))
+                g_object_set (cell, "cell-background", PINKCELL, (gchar*)NULL);
+        }
         else
         {
             s = "";
             editable = FALSE;
         }
 
-        /* Only allow changes to values if we have a valid split accounts */
-        if (!(gtv_have_account (view, depth, expanded, trans, split)))
-            editable = FALSE;
-
         editable = (read_only == TRUE) ? FALSE : editable;
 
         g_object_set (cell, "text", s, "editable", editable, NULL);
@@ -1708,12 +2208,12 @@
         {
             if (anchor)
             {
-                gnc_numeric amt = xaccSplitGetValue (get_this_split (view, trans));
+                gnc_numeric val = xaccSplitGetValue (get_this_split (view, trans));
                 editable = !expanded && (num_of_splits < 3);
-                if(expanded)
+                if (expanded)
                     s = "";
                 else
-                    s = xaccPrintAmount (amt, gnc_commodity_print_info( xaccTransGetCurrency (trans), FALSE));
+                    s = xaccPrintAmount (val, gnc_commodity_print_info (xaccTransGetCurrency (trans), SHOW_SYMBOL));
             }
             else
             {
@@ -1724,24 +2224,36 @@
 
         if (is_split)
         {
-            if (split == get_this_split (view, trans))
+            if (anchor == NULL)
             {
                 gnc_numeric amt = xaccSplitGetAmount (split);
-                s = xaccPrintAmount (amt, gnc_account_print_info (xaccSplitGetAccount (split), FALSE));
+                s = xaccPrintAmount (amt, gnc_account_print_info (xaccSplitGetAccount (split), SHOW_SYMBOL));
                 editable = TRUE;
             }
+            else if (anchor)
+            {
+                gnc_commodity *split_comm;
+                split_comm = xaccAccountGetCommodity (xaccSplitGetAccount (split));
+
+                if (!gnc_commodity_is_currency (split_comm) || (is_blank))
+                {
+                    gnc_numeric amt = xaccSplitGetAmount (split);
+                    s = xaccPrintAmount (amt, gnc_account_print_info (xaccSplitGetAccount (split), SHOW_SYMBOL));
+                    editable = TRUE;
+                }
+            }
             else
             {
                 s = "";
                 editable = FALSE;
             }
+
             if (get_imbalance (trans))
                 g_object_set (cell, "cell-background", PINKCELL, (gchar*)NULL);
         }
 
         /* Only allow changes to values if we have a valid split accounts */
-        if (!(gtv_have_account (view, depth, expanded, trans, split)))
-            editable = FALSE;
+        editable = have_account (view, depth, expanded, trans, split);
 
         editable = (read_only == TRUE) ? FALSE : editable;
 
@@ -1767,7 +2279,7 @@
                 {
                     if (gnc_numeric_check (num) == GNC_ERROR_OK)
                     {
-                        s = xaccPrintAmount (num, gnc_split_amount_print_info (split, FALSE));
+                        s = xaccPrintAmount (num, gnc_split_amount_print_info (split, SHOW_SYMBOL));
                     }
                     else
                     {
@@ -1785,13 +2297,16 @@
 
         if (is_split)
         {
-            if (split == get_this_split (view, trans))
+            gnc_commodity *split_comm;
+            split_comm = xaccAccountGetCommodity (xaccSplitGetAccount (split));
+
+            if (!gnc_commodity_is_currency (split_comm) || (is_blank))
             {
                 num = xaccSplitGetSharePrice (split);
 
                 if (gnc_numeric_check (num) == GNC_ERROR_OK)
                 {
-                    s = xaccPrintAmount (num, gnc_split_amount_print_info (split, FALSE));
+                    s = xaccPrintAmount (num, gnc_split_amount_print_info (split, SHOW_SYMBOL));
                     editable = TRUE;
                 }
                 else
@@ -1805,13 +2320,13 @@
                 s = "";
                 editable = FALSE;
             }
+
             if (get_imbalance (trans))
                 g_object_set(cell, "cell-background", PINKCELL, (gchar*)NULL);
         }
 
         /* Only allow changes to values if we have a valid split accounts */
-        if (!(gtv_have_account (view, depth, expanded, trans, split)))
-            editable = FALSE;
+        editable = have_account (view, depth, expanded, trans, split);
 
         editable = (read_only == TRUE) ? FALSE : editable;
 
@@ -1856,16 +2371,15 @@
         }
         else
         {
-            if (expanded)
+            if ((is_trow1 || is_trow2) && expanded)
                 s = "";
             else
                 s = xaccPrintAmount (gnc_numeric_abs (num),
-                                gnc_account_print_info (anchor, FALSE));
+                                gnc_account_print_info (anchor, SHOW_SYMBOL));
         }
 
         /* Only allow changes to values if we have a valid split accounts */
-        if (!(gtv_have_account (view, depth, expanded, trans, split)))
-            editable = FALSE;
+        editable = have_account (view, depth, expanded, trans, split);
 
         editable = (read_only == TRUE) ? FALSE : editable;
 
@@ -1895,13 +2409,35 @@
 
     case COL_STATUS:
         /* Column is STATUS */
-        if (read_only)
+        if (read_only && !open_edited)
             g_object_set(cell, "cell-background", REDCELL, (gchar*)NULL);
+        else if (read_only && open_edited)
+            g_object_set(cell, "cell-background", YELLOWCELL, (gchar*)NULL);
         else if (xaccTransInFutureByPostedDate (trans))
             g_object_set(cell, "cell-background", BLUECELL, (gchar*)NULL);
         else
             g_object_set(cell, "cell-background", BLACKCELL, (gchar*)NULL);
+        break;
 
+    case COL_COMM:
+        /* Column COMMODITY */
+        if (is_split)
+        {
+            gnc_commodity *split_com, *txn_com;
+
+            split_com = xaccAccountGetCommodity (xaccSplitGetAccount(split));
+            txn_com = xaccTransGetCurrency (trans);
+            if ( split_com == txn_com)
+               s = g_strconcat (gnc_commodity_get_printname (split_com), "*", NULL);
+            else
+               s = gnc_commodity_get_printname (split_com);
+        }
+        else
+            s = "";
+
+        g_object_set (cell, "text", s, "editable", FALSE, NULL);
+        break;
+
     default:
         break;
     }
@@ -1918,27 +2454,43 @@
            const gchar *path_string, gpointer user_data)
 {
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
-g_print("\n\nstart_edit\n");
+    GncTreeModelSplitReg *model;
+    GtkTreePath         *path;
+//g_print("\n\nstart_edit\n");
 /*FIXME Not sure if this is required, leave for now ? */
-    get_editable_start_editing_cb (cr, editable, path_string, user_data);
+
+    model = get_split_reg_model_from_view (view);
+
+    gtv_get_editable_start_editing_cb (cr, editable, path_string, user_data);
 /*    g_signal_connect(G_OBJECT(editable), "editing-done", (GCallback) editing_done_cb, view); */
-    view->priv->acct_edit_path = gtk_tree_path_new_from_string (path_string);
 
+//FIXME this could be the sort path instead of model path / check !!
+    path = gtk_tree_path_new_from_string (path_string);
+
+    if(view->priv->edit_ref != NULL)
+    {
+        gtk_tree_row_reference_free (view->priv->edit_ref);
+        view->priv->edit_ref = NULL;
+    }
+    view->priv->edit_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), path);
+
+    gtk_tree_path_free (path);
+
     return;
 }
 
 
-/* means: open trans for editing, unless we're editing a Split (split
-   != NULL) AND split doesn't belong to the trans (because it is the
-   blank split) */
+
+//FIXME I am not sure if we need the split here at all ???????
+/* Open Transaction for editing and set the default currency */
 static void
-begin_edit (GncTreeViewSplitReg *view, Split *split, Transaction *trans)
+gtv_begin_edit (GncTreeViewSplitReg *view, Split *split, Transaction *trans)
 {
-g_print("\n\nbegin_edit split %p and trans %p\n", split, trans);
+    ENTER("gtv_begin_edit split %p and trans %p", split, trans);
 
     if (split && trans != xaccSplitGetParent (split))
     {
-g_print("begin_edit - blank split, return\n");
+        LEAVE("gtv_begin_edit - blank split, return");
         return;
     }
 
@@ -1950,14 +2502,16 @@
         xaccTransBeginEdit (trans);
         view->priv->dirty_trans = trans;
 
-g_print("begin_edit - xaccTransBeginEdit trans %p\n", trans);
-
         if (!xaccTransGetCurrency (trans))
         {
-            if (view->priv->anchor)
+            if (gnc_commodity_is_currency (view->priv->reg_comm))
+            {
                 xaccTransSetCurrency (trans, view->priv->reg_comm);
+            }
             else
-                xaccTransSetCurrency (trans, xaccAccountGetCommodity (xaccSplitGetAccount (split)));
+            {
+                xaccTransSetCurrency (trans, gnc_default_currency());
+            }
         }
 
         if (ts.tv_sec == 0)
@@ -1967,12 +2521,14 @@
             //date on new transactions
 
             ts.tv_sec = gnc_time (NULL);
-            xaccTransSetDatePostedSecs(trans, ts.tv_sec);
+            xaccTransSetDatePostedSecs (trans, ts.tv_sec);
         }
     }
+    LEAVE(" ");
 }
 
 
+/* Call back to remove date widget */
 static void
 remove_edit_date (GtkCellEditable *ce, gpointer user_data)
 {
@@ -1984,41 +2540,47 @@
     char string[1024];
     time64 tt;
 
-    //These strings are used to determine if cell data was altered so that keynav works better
-g_print("\nremove edit date\n");
+    ENTER("remove edit date and temp cell rend %p", view->priv->temp_cr);
 
-    popup_entry = GNC_POPUP_ENTRY (g_object_get_data (G_OBJECT (view->priv->temp_cr), "cell-editable"));
+    if (view->priv->temp_cr != NULL)
+    {
+        //These strings are used to determine if cell data was altered so that keynav works better
+        popup_entry = GNC_POPUP_ENTRY (g_object_get_data (G_OBJECT (view->priv->temp_cr), "cell-editable"));
 
-    new_string = g_strdup (gtk_entry_get_text (GTK_ENTRY (popup_entry->entry)));
-//g_print("New String is '%s'\n", new_string);	
+        new_string = g_strdup (gtk_entry_get_text (GTK_ENTRY (popup_entry->entry)));
 
-    current_string = g_object_get_data (G_OBJECT (view->priv->temp_cr), "current-string");
-//g_print("Current String is '%s'\n", current_string);
+        current_string = g_object_get_data (G_OBJECT (view->priv->temp_cr), "current-string");
 
-    //If editing wasn't canceled and strings don't match then cell data was edited
-    if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view->priv->temp_cr), "edit-canceled")) 
+        DEBUG("New string is %s and Current_string is %s", new_string, current_string);
+
+        //If editing wasn't canceled and strings don't match then cell data was edited
+        if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view->priv->temp_cr), "edit-canceled"))
              && g_ascii_strcasecmp (new_string, current_string))
-    {
-        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (TRUE));
-    }
+        {
+            g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (TRUE));
+        }
 
-    /* Lets update the help text */
-    g_date_set_parse (&date, new_string);
-    if (g_date_valid (&date))
-    {
-	struct tm tm;
-	memset (&tm, 0, sizeof (tm));
-        g_date_to_struct_tm (&date, &tm);
-        qof_strftime (string, sizeof (string), "%A %d %B %Y", &tm);
+        /* Lets update the help text */
+        g_date_set_parse (&date, new_string);
+        if (g_date_valid (&date))
+        {
+            struct tm tm;
+            memset (&tm, 0, sizeof (tm));
+            g_date_to_struct_tm (&date, &tm);
+            qof_strftime (string, sizeof (string), "%A %d %B %Y", &tm);
+        }
+        view->help_text = g_strdup (string);
+        g_signal_emit_by_name (view, "help_signal", NULL);
+
+        g_object_set_data (G_OBJECT (view->priv->temp_cr), "cell-editable", NULL);
+        view->priv->temp_cr = NULL;
+        view->editing_now = FALSE;
     }
-    view->help_text = g_strdup (string);
-    g_signal_emit_by_name (view, "help_signal", NULL);
-
-    g_object_set_data (G_OBJECT (view->priv->temp_cr), "cell-editable", NULL);
-    view->priv->temp_cr = NULL;
+    LEAVE(" ");
 }
 
 
+/* Call back to remove combo widget */
 static void
 remove_edit_combo (GtkCellEditable *ce, gpointer user_data)
 {
@@ -2027,29 +2589,35 @@
     const gchar *new_string; 
     const gchar *current_string;
 
-    //These strings are used to determine if cell data was altered so that keynav works better
-g_print("\nremove edit combo\n");
+    ENTER("remove edit combo and temp cell rend %p", view->priv->temp_cr);
 
-    entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (g_object_get_data (G_OBJECT (view->priv->temp_cr), "cell-editable"))));
+    if (view->priv->temp_cr != NULL)
+    {
+        //These strings are used to determine if cell data was altered so that keynav works better
+        entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (g_object_get_data (G_OBJECT (view->priv->temp_cr), "cell-editable"))));
 
-    new_string = gtk_entry_get_text (GTK_ENTRY (entry));
-//g_print("New String is '%s'\n", new_string);	
+        new_string = gtk_entry_get_text (GTK_ENTRY (entry));
 
-    current_string = g_object_get_data (G_OBJECT (view->priv->temp_cr), "current-string");
-//g_print("Current String is '%s'\n", current_string);
+        current_string = g_object_get_data (G_OBJECT (view->priv->temp_cr), "current-string");
 
-    //If editing wasn't canceled and strings don't match then cell data was edited
-    if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view->priv->temp_cr), "edit-canceled"))
+        DEBUG("New string is %s and Current_string is %s", new_string, current_string);
+
+        //If editing wasn't canceled and strings don't match then cell data was edited
+        if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view->priv->temp_cr), "edit-canceled"))
              && g_ascii_strcasecmp (new_string, current_string))
-    {
-        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (TRUE));
+        {
+            g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (TRUE));
+        }
+
+        g_object_set_data (G_OBJECT (view->priv->temp_cr), "cell-editable", NULL);
+        view->priv->temp_cr = NULL;
+        view->editing_now = FALSE;
     }
-
-    g_object_set_data (G_OBJECT (view->priv->temp_cr), "cell-editable", NULL);
-    view->priv->temp_cr = NULL;
+    LEAVE(" ");
 }
 
 
+/* Call back to remove entry widget */
 static void
 remove_edit_entry (GtkCellEditable *ce, gpointer user_data)
 {
@@ -2057,28 +2625,32 @@
     const gchar *new_string; 
     const gchar *current_string; 
 
-g_print("\nremove edit entry\n");
+    ENTER("remove edit entry and temp cell rend %p", view->priv->temp_cr);
 
-    //These strings are used to determine if cell data was altered so that keynav works better
-    new_string = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (view->priv->temp_cr), "cell-editable")));
-//g_print("New String is '%s'\n", new_string);
+    if (view->priv->temp_cr != NULL)
+    {
+        //These strings are used to determine if cell data was altered so that keynav works better
+        new_string = gtk_entry_get_text (GTK_ENTRY (g_object_get_data (G_OBJECT (view->priv->temp_cr), "cell-editable")));
 
-    current_string = g_object_get_data (G_OBJECT (view->priv->temp_cr), "current-string");
-//g_print("Current String is '%s'\n", current_string);
+        current_string = g_object_get_data (G_OBJECT (view->priv->temp_cr), "current-string");
 
-    //If editing wasn't canceled and strings don't match then cell data was edited
-    if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view->priv->temp_cr), "edit-canceled")) 
+        DEBUG("New string is %s and Current_string is %s", new_string, current_string);
+
+        //If editing wasn't canceled and strings don't match then cell data was edited
+        if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view->priv->temp_cr), "edit-canceled"))
              && g_ascii_strcasecmp (new_string, current_string))
-    {
-        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (TRUE));
+        {
+            g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (TRUE));
+        }
+
+        g_object_set_data (G_OBJECT (view->priv->temp_cr), "cell-editable", NULL);
+        view->priv->temp_cr = NULL;
+        view->editing_now = FALSE;
     }
-
-    g_object_set_data (G_OBJECT (view->priv->temp_cr), "cell-editable", NULL);
-    view->priv->temp_cr = NULL;
+    LEAVE(" ");
 }
 
 
-
 /* Explain: GtkEntry has a cursor that blinks upon
    g_timeout_dispatch().  It complains if it blinks after the GtkEntry
    loses focus.  So, we can't pop up any dialogs while the blinking
@@ -2086,35 +2658,121 @@
    finished before raising the dialog.  That finalizes the
    gtkcelleditable. */
 static void
-finish_edit (GtkTreeViewColumn *col)
+gtv_finish_edit (GncTreeViewSplitReg *view)
 {
-    GList *renderers;
-    GtkCellRenderer *cr;
     GtkCellEditable *ce;
-g_print("\n\nfinish_edit\n");
 
-    if (!col)
+    if (view->priv->temp_cr == NULL)
         return;
-g_print("finish_edit column title is %s\n", gtk_tree_view_column_get_title (col));
-    renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col)); //FIXME I am only looking at one renderer per cell.
-    g_assert (g_list_length (renderers) == 1);
-    cr = g_list_nth_data (renderers, 0);
-    g_list_free (renderers);
 
-    if ((ce = GTK_CELL_EDITABLE (g_object_get_data (G_OBJECT (cr), "cell-editable"))))
+    DEBUG("gtv_finish_edit temp_cr is %p", view->priv->temp_cr);
+
+    if ((ce = GTK_CELL_EDITABLE (g_object_get_data (G_OBJECT (view->priv->temp_cr), "cell-editable"))))
     {
-g_print("finish_edit - editing_done\n");
+        DEBUG("gtv_finish_edit - editing_done");
         gtk_cell_editable_editing_done (ce);
         gtk_cell_editable_remove_widget (ce);
     }
 }
 
 
+/* This is used in g_idle_add to finish an edit */
+static gboolean
+gtv_idle_finish_edit (GncTreeViewSplitReg *view)
+{
+   gtv_finish_edit (view);
+   return FALSE;
+}
 
+
+/* Returns TRUE if dialog was canceled or discarded.
+   Does nothing if 'new_trans' is the dirty trans. */
+static gboolean
+transaction_changed_confirm (GncTreeViewSplitReg *view,
+                            Transaction *new_trans)
+{
+    GtkWidget *dialog, *window;
+    gint response;
+    const char *title = _("Save the changed transaction?");
+    const char *message = _(
+        "The current transaction has changed.  Would you like to "
+        "record the changes, or discard the changes?");
+
+    if (!view->priv->dirty_trans || view->priv->dirty_trans == new_trans)
+        return FALSE;
+
+    window = gnc_tree_view_split_reg_get_parent (view);
+    dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                    GTK_DIALOG_DESTROY_WITH_PARENT,
+                                    GTK_MESSAGE_QUESTION,
+                                    GTK_BUTTONS_NONE,
+                                    "%s", title);
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                             "%s", message);
+    gtk_dialog_add_buttons(
+        GTK_DIALOG(dialog),_("_Discard Changes"), GTK_RESPONSE_REJECT,
+        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+        _("_Record Changes"), GTK_RESPONSE_ACCEPT, NULL);
+    response = gnc_dialog_run (GTK_DIALOG (dialog), "transaction_changed");
+    gtk_widget_destroy (dialog);
+
+    switch (response)
+    {
+    case GTK_RESPONSE_ACCEPT:
+        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
+        xaccTransCommitEdit (view->priv->dirty_trans);
+        if(view->priv->edit_ref != NULL)
+        {
+            gtk_tree_row_reference_free (view->priv->edit_ref);
+            view->priv->edit_ref = NULL;
+        }
+        view->priv->dirty_trans = NULL;
+        view->change_allowed = FALSE;
+        return FALSE;
+        break;
+
+    case GTK_RESPONSE_REJECT:
+        if (view->priv->dirty_trans && xaccTransIsOpen (view->priv->dirty_trans))
+        {
+            GncTreeModelSplitReg *model;
+            Split                *split;
+
+            model = get_split_reg_model_from_view (view);
+
+            // Remove the split before rollback.
+            gnc_tree_model_split_reg_set_blank_split_parent (model, view->priv->dirty_trans, TRUE);
+
+            g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
+            xaccTransRollbackEdit (view->priv->dirty_trans);
+
+            // Add the split after rollback so it is last in list.
+            gnc_tree_model_split_reg_set_blank_split_parent (model, view->priv->dirty_trans, FALSE);
+            view->priv->dirty_trans = NULL;
+
+            split = gnc_tree_model_split_get_blank_split (model);
+            xaccSplitReinit (split); // Clear the blank split
+            view->change_allowed = FALSE;
+        }
+        return TRUE;
+        break;
+
+    case GTK_RESPONSE_CANCEL:
+        return TRUE;
+        break;
+
+    default:
+        return FALSE;
+    }
+
+    return FALSE;
+}
+
+
 /*####################################################################
           ^^^^^    edit function call backs      ^^^^^
           vvvvvv   gtv function call backs       vvvvv
 #####################################################################*/
+/* Set the column titles based on register type and depth */
 static void
 gtv_split_reg_titles (GncTreeViewSplitReg *view, RowDepth depth)
 {
@@ -2125,7 +2783,7 @@
     GList  *column;
     gint i;
 
-//g_print("title depth is %d\n", depth);
+    ENTER("title depth is %d and sort_depth %d, sort_col is %d", depth, view->sort_depth, view->sort_col);
 
     model = get_split_reg_model_from_view (view);
     columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (view));
@@ -2139,21 +2797,31 @@
 
         /*FIXME ## Do we need to look for multiple renderers ?
           We only have one renderer per cell now */
-        renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tvc)); //FIXME I am only looking at one renderer per cell.
+        renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tvc));
         g_assert (g_list_length (renderers) == 1);
         cr = g_list_nth_data (renderers, 0);
         g_list_free (renderers);
 
         viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(cr), "view_column"));
 
+        DEBUG("viewcol is %d", viewcol);
+
         switch(viewcol)
         {
         case COL_DATE:
             switch(model->type)
             {
             default: //FIXME These if statements may not be required
-                if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
-                    gtk_tree_view_column_set_title (tvc, _("Date"));
+                /* Display arrows if we are sorting on this row */
+                if (view->sort_depth == depth && view->sort_col == viewcol)
+                    gtk_tree_view_column_set_sort_indicator (tvc, TRUE);
+                else
+                    gtk_tree_view_column_set_sort_indicator (tvc, FALSE);
+
+                if(depth == TRANS1 || depth == SPLIT3)
+                    gtk_tree_view_column_set_title (tvc, _("Date Posted"));
+                else if(depth == TRANS2)
+                    gtk_tree_view_column_set_title (tvc, _("Date Entered"));
                 break;
             }
             break;
@@ -2173,7 +2841,7 @@
             {
             case RECEIVABLE_REGISTER2:
             case PAYABLE_REGISTER2:
-                if(depth == TRANS1)
+                if (depth == TRANS1)
                     gtk_tree_view_column_set_title (tvc, _("Reference"));
                 else if (depth == TRANS2)
                     gtk_tree_view_column_set_title (tvc, _("Action"));
@@ -2185,9 +2853,17 @@
 
 
             default:
-                if(depth == TRANS1)
+                /* Display arrows if we are sorting on this row */
+                if (view->sort_depth == depth && view->sort_col == viewcol)
+                    gtk_tree_view_column_set_sort_indicator (tvc, TRUE);
+                else
+                    gtk_tree_view_column_set_sort_indicator (tvc, FALSE);
+
+                if (depth == TRANS1)
                     gtk_tree_view_column_set_title (tvc, _("Number"));
-                else if (depth == TRANS2)
+                else if (depth == TRANS2 && (qof_book_use_split_action_for_num_field (gnc_get_current_book())))
+                    gtk_tree_view_column_set_title (tvc, _("T-Number"));
+                else if (depth == TRANS2 && (!qof_book_use_split_action_for_num_field (gnc_get_current_book())))
                     gtk_tree_view_column_set_title (tvc, _("Action"));
                 else if (depth == SPLIT3)
                     gtk_tree_view_column_set_title (tvc, _("Action"));
@@ -2208,7 +2884,7 @@
                 else if (depth == SPLIT3)
                     gtk_tree_view_column_set_title (tvc, _("Memo"));
                 else
-                    gtk_tree_view_column_set_title (tvc, _("Customer / Memo "));
+                    gtk_tree_view_column_set_title (tvc, _("Customer / Memo"));
                 break;
 
             case PAYABLE_REGISTER2:
@@ -2219,11 +2895,17 @@
                 else if (depth == SPLIT3)
                     gtk_tree_view_column_set_title (tvc, _("Memo"));
                 else
-                    gtk_tree_view_column_set_title (tvc, _("Vendor / Memo "));
+                    gtk_tree_view_column_set_title (tvc, _("Vendor / Memo"));
                 break;
 
 
             default:
+                /* Display arrows if we are sorting on this row */
+                if (view->sort_depth == depth && view->sort_col == viewcol)
+                    gtk_tree_view_column_set_sort_indicator (tvc, TRUE);
+                else
+                    gtk_tree_view_column_set_sort_indicator (tvc, FALSE);
+
                 if(depth == TRANS1)
                     gtk_tree_view_column_set_title (tvc, _("Description"));
                 else if (depth == TRANS2)
@@ -2318,6 +3000,16 @@
             }
             break;
 
+        case COL_COMM:
+            switch(model->type)
+            {
+            default: //FIXME These if statements may not be required
+                if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
+                    gtk_tree_view_column_set_title (tvc, _("Commodity"));
+                break;
+            }
+            break;
+
         case COL_RATE:
             switch(model->type)
             {
@@ -2498,10 +3190,12 @@
             break;
         }
     }
-g_list_free (columns);
+    LEAVE(" ");
+    g_list_free (columns);
 }
 
 
+/* Update the help text */
 static void
 gtv_split_reg_help (GncTreeViewSplitReg *view, GtkCellRenderer *cr, ViewCol viewcol, RowDepth depth)
 {
@@ -2509,7 +3203,7 @@
     const char *help = " ";
     const gchar *current_string;
 
-//g_print("Help Viewcol is %d and depth is %d\n", viewcol, depth);
+    ENTER("Help Viewcol is %d and depth is %d", viewcol, depth);
 
     model = get_split_reg_model_from_view (view);
 
@@ -2528,8 +3222,8 @@
                 g_date_set_parse (&date, current_string);
                 if (g_date_valid (&date))
                 {
-		    struct tm tm;
-		    memset (&tm, 0, sizeof (tm));
+                    struct tm tm;
+                    memset (&tm, 0, sizeof (tm));
                     g_date_to_struct_tm (&date, &tm);
                     qof_strftime (string, sizeof (string), "%A %d %B %Y", &tm);
                 }
@@ -2669,6 +3363,16 @@
         }
         break;
 
+    case COL_COMM:
+        switch(model->type)
+        {
+        default: //FIXME These if statements may not be required
+            if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
+                help = _("* Indicates the transaction Commodity.");
+            break;
+        }
+        break;
+
     case COL_RATE:
         switch(model->type)
         {
@@ -2714,10 +3418,44 @@
         break;
     }
 
+    LEAVE("Help text is - %s", help);
     view->help_text = g_strdup (help);
     g_signal_emit_by_name (view, "help_signal", NULL);
 }
 
+
+/* Move the selection to the blank split when expanded */
+static gboolean
+gtv_selection_to_blank (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    GtkTreePath *bpath, *spath;
+    Split *bsplit;
+
+    /* give gtk+ a chance to handle pending events */
+    while (gtk_events_pending ())
+        gtk_main_iteration ();
+
+    /* Make sure we have expanded splits */
+    if (view->priv->expanded == FALSE)
+        return FALSE;
+
+    model = get_split_reg_model_from_view (view);
+
+    bsplit = gnc_tree_model_split_get_blank_split (model);
+    bpath =  gnc_tree_model_split_reg_get_path_to_split_and_trans (model, bsplit, NULL);
+
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), bpath);
+
+    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
+
+    gtk_tree_path_free (bpath);
+    gtk_tree_path_free (spath);
+
+    return FALSE;
+}
+
+
 /* Callback for double click */
 void
 gtv_split_reg_double_click_cb (GtkTreeView *treeview, GtkTreePath *path,
@@ -2728,16 +3466,14 @@
 
     model = get_split_reg_model_from_view (view);
 
-//g_print("gtv_split_reg_double_click_cb\n\n");
+    /* this works on non editable cells like void, balance */
 
-    /* this does work on non editable cells like void, balance */
-
     if (model->style != REG2_STYLE_JOURNAL)
     {
-        if (gnc_tree_view_split_reg_current_trans_expanded (view))
-            gnc_tree_view_split_reg_expand_current_trans (view, FALSE);
+        if (view->priv->expanded)
+            gnc_tree_view_split_reg_collapse_trans (view, NULL);
         else
-            gnc_tree_view_split_reg_expand_current_trans (view, TRUE);
+            gnc_tree_view_split_reg_expand_trans (view, NULL);
 
         /* This updates the plugin page gui */
         if (view->moved_cb)
@@ -2746,6 +3482,35 @@
 }
 
 
+/* Call back for when a Transaction is deleted so we can move selection out of way */
+static void
+gtv_split_reg_trans_delete_cb (GncTreeModelSplitReg *model, gpointer item, gpointer user_data)
+{
+    GncTreeViewSplitReg *view = user_data;
+    Transaction *trans = item;
+
+    DEBUG("gtv_split_reg_trans_delete_cb view %p model %p trans %p ", view, model, trans);
+
+    DEBUG("gtv_split_reg_trans_delete_cb current_trans %p trans %p", view->priv->current_trans, trans);
+
+    /* if same, lets get out of the way so move */
+    if (trans == view->priv->current_trans)
+        gnc_tree_control_split_reg_goto_rel_trans_row (view, 1);
+}
+
+
+/* Call back for focus out evnt so we can finish edit */
+static gboolean
+gtv_split_reg_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+
+    gnc_tree_view_split_reg_finish_edit (view);
+
+    return FALSE;
+}
+
+
 /* For handling keynav */
 static gboolean
 gtv_split_reg_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
@@ -2762,7 +3527,8 @@
 
     gint editable = 0;
 
-g_print("\ngtvt_key_press_cb\n");
+//FIXME ????
+//g_print("\ngtvt_key_press_cb\n");
 
     if (event->type != GDK_KEY_PRESS)
         return TRUE;
@@ -2788,7 +3554,7 @@
     if (!path)
         return TRUE;
 
-    finish_edit (col);
+    gnc_tree_view_split_reg_finish_edit (view);
 
 
 
@@ -2816,8 +3582,8 @@
 
         g_object_get (G_OBJECT (cell), "editable", &editable, NULL);
 
-//g_print("key nav - Path is '%s' edit path is '%s' and viewcol is %d and editable is %d and cell pointer is %p\n", gtk_tree_path_to_string (path),
-//                  (view->priv->acct_edit_path == NULL) ? "NULL" : gtk_tree_path_to_string (view->priv->acct_edit_path), viewcol, editable, cell);
+//g_print("key nav - Path is '%s' and viewcol is %d and editable is %d and cell pointer is %p\n", gtk_tree_path_to_string (path),
+//                   viewcol, editable, cell);
 
 
 
@@ -2839,7 +3605,7 @@
         /* Set cursor to new column, open for editing */
         gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, col, TRUE);
 
-g_print( "end of key nav\n");
+//g_print( "end of key nav\n");
 
     gtk_tree_path_free (path);
 
@@ -2847,204 +3613,143 @@
 }
 
 
-void
-gnc_tree_view_split_reg_cancel_edit (GncTreeViewSplitReg *view)
-{
-    GncTreeModelSplitReg *model;
-    GtkTreePath       *path;
-    GtkTreeViewColumn *col_current;
-    Transaction *trans = view->priv->dirty_trans;
-    Split *split;
-
-    model = get_split_reg_model_from_view (view);
-
-    gtk_tree_view_get_cursor (GTK_TREE_VIEW (view), &path, &col_current);
-
-g_print("cancel column title is %s\n", gtk_tree_view_column_get_title (col_current));
-
-    /* Make sure we have stopped editing */
-    if (col_current != NULL)
-        finish_edit (col_current);
-
-    if (trans && xaccTransIsOpen (trans))
-    {
-        view->priv->acct_edit_path = NULL;
-        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
-        xaccTransRollbackEdit (view->priv->dirty_trans);
-        view->priv->dirty_trans = NULL;
-
-        split = gnc_tree_model_split_get_blank_split (model);
-        xaccSplitReinit (split);
-    }
-
-    /* this just refreshes the view */
-    gtk_tree_selection_unselect_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), path);
-    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), path);
-
-    gtk_tree_path_free (path);
-}
-
-
-/* Returns TRUE if dialog was canceled. Does nothing if 'new_trans'
-   is the dirty trans. */
-static gboolean
-transaction_changed_confirm (GncTreeViewSplitReg *view,
-                            Transaction *new_trans)
-{
-    GtkWidget *dialog;
-    gint response;
-    const char *title = _("Save the changed transaction?");
-    const char *message = _(
-        "The current transaction has changed.  Would you like to "
-        "record the changes, or discard the changes?");
-
-    if (!view->priv->dirty_trans || view->priv->dirty_trans == new_trans)
-        return FALSE;
-
-g_print(" ** transaction_changed_confirm **\n");
-    dialog = gtk_message_dialog_new(NULL,
-                                    GTK_DIALOG_DESTROY_WITH_PARENT,
-                                    GTK_MESSAGE_QUESTION,
-                                    GTK_BUTTONS_NONE,
-                                    "%s", title);
-    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
-                                             "%s", message);
-    gtk_dialog_add_buttons(
-        GTK_DIALOG(dialog),_("_Discard Changes"), GTK_RESPONSE_REJECT,
-        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-        _("_Record Changes"), GTK_RESPONSE_ACCEPT, NULL);
-    response = gnc_dialog_run (GTK_DIALOG (dialog), "transaction_changed");
-    gtk_widget_destroy (dialog);
-
-    switch (response)
-    {
-    case GTK_RESPONSE_ACCEPT:
-        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
-        xaccTransCommitEdit (view->priv->dirty_trans);
-        view->priv->acct_edit_path = NULL;
-        view->priv->dirty_trans = NULL;
-        break;
-
-    case GTK_RESPONSE_REJECT:
-        gnc_tree_view_split_reg_cancel_edit (view);
-        break;
-    case GTK_RESPONSE_CANCEL:
-    default:
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-
-
 /* Callback for selection move */
 static void
 gtv_split_reg_motion_cb (GtkTreeSelection *sel, gpointer user_data)
 {
-
-    GtkTreeIter iter;
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
-    GncTreeModelSplitReg *model; 
+    GncTreeModelSplitReg *model;
     Split *split = NULL;
     Transaction *trans = NULL;
+    Transaction *old_trans;
     gboolean is_trow1, is_trow2, is_split, is_blank;
     RowDepth depth = 0;
-    const gchar *path_string;
-    GtkTreePath *path;
-    gint *indices_old, *indices_now;
-    gint row_old, row_now;
+    GtkTreeIter iter;
+    GtkTreePath *mpath;
+    GtkTreePath *spath;
 
+//g_print ("\n** gtv_split_reg_motion_cb start\n");
+
     model = get_split_reg_model_from_view (view);
 
-g_print ("\ngtv_split_reg_motion_cb\n");
+//g_print("Motion - ** model is %p and view is %p dirty_trans is %p **\n", model, view, view->priv->dirty_trans);
+//g_print("Motion - ** o_trans is %p o_split is %p o_depth %d **\n", view->priv->current_trans, view->priv->current_split, view->priv->current_depth);
 
-g_print("Motion - dirty_trans is %p and dirty_split is %p\n", view->priv->dirty_trans, view->priv->dirty_split);
-
     /* Reset help text */
     view->help_text = " ";
     g_signal_emit_by_name (view, "help_signal", NULL);
 
-    mark_split_dirty (view, NULL, NULL);
-
     if (get_model_iter_from_selection (view, sel, &iter))
     {
+        mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
 
-        path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+        spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
-//g_print("Motion - Current Path is '%s' and edit path is '%s'\n", gtk_tree_path_to_string (view->priv->current_path),
-//                                                                 (view->priv->acct_edit_path == NULL) ? "NULL" :
-//                                                                  gtk_tree_path_to_string (view->priv->acct_edit_path));
+//g_print ("Motion - mpath is %s spath is %s\n\n", gtk_tree_path_to_string (mpath), gtk_tree_path_to_string (spath));
 
-        indices_old = gtk_tree_path_get_indices (view->priv->current_path);
-        indices_now = gtk_tree_path_get_indices (path);
+//g_print("Motion - current_ref is valid %d edit_ref is %d\n", gtk_tree_row_reference_valid (view->priv->current_ref),
+//                                                             gtk_tree_row_reference_valid (view->priv->edit_ref));
 
-        row_old = indices_old[0];
-        row_now = indices_now[0];
+//if(gtk_tree_row_reference_valid (view->priv->current_ref))
+    //g_print("Motion - Old Current Path is '%s'\n", gtk_tree_path_to_string (gtk_tree_row_reference_get_path (view->priv->current_ref)));
+//if(gtk_tree_row_reference_valid (view->priv->edit_ref))
+    //g_print("Motion - Old Edit path is '%s'\n", gtk_tree_path_to_string (gtk_tree_row_reference_get_path (view->priv->edit_ref)));
 
-g_print ("Motion - row old is %d and now %d\n", row_old, row_now);
-
-        view->priv->row_old = row_old;
-        view->priv->row_now = row_now;
-
         /* save the current path */
-        gtk_tree_path_free (view->priv->current_path);
-        view->priv->current_path = gtk_tree_path_copy (path);
+        if(view->priv->current_ref != NULL)
+        {
+            gtk_tree_row_reference_free (view->priv->current_ref);
+            view->priv->current_ref = NULL;
+        }
+        view->priv->current_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), mpath);
 
         /* Use depth to determine if it is a split or transaction */
-        depth = gtk_tree_path_get_depth (path);
+        depth = gtk_tree_path_get_depth (mpath);
 
         /* Update the tree view titles */
         gtv_split_reg_titles (view, depth);
 
-        gtk_tree_path_free (path);
+        gtk_tree_path_free (mpath);
 
-//g_print("Motion - New Current Path is '%s' and edit path is '%s'\n", gtk_tree_path_to_string (view->priv->current_path),
-//                                                                 (view->priv->acct_edit_path == NULL) ? "NULL" :
-//                                                                  gtk_tree_path_to_string (view->priv->acct_edit_path));
+//if(gtk_tree_row_reference_valid (view->priv->current_ref))
+    //g_print("Motion - Current Path is '%s'\n", gtk_tree_path_to_string (gtk_tree_row_reference_get_path (view->priv->current_ref)));
+//if(gtk_tree_row_reference_valid (view->priv->edit_ref))
+    //g_print("Motion - Edit path is '%s'\n", gtk_tree_path_to_string (gtk_tree_row_reference_get_path (view->priv->edit_ref)));
 
-
-        /*FIXME Not sure if will need this here, leave till end */
         gnc_tree_model_split_reg_get_split_and_trans (
                 GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
 
-g_print("Motion - row_now is %d, split %p, trans %p, is_split %d, is_blank %d\n", row_now, split, trans, is_split, is_blank);
+//g_print("Motion - get model split %p, trans %p, is_split %d, is_blank %d\n", split, trans, is_split, is_blank);
 
+
         //Ask for confirmation if data has been edited, transaction_changed_confirm return TRUE if canceled
         if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view), "data-edited")) && transaction_changed_confirm (view, trans))
         {
-            /* Restore position - Cancel */
-            gtk_tree_path_free (view->priv->current_path);
-            view->priv->current_path = gtk_tree_path_copy (view->priv->acct_edit_path);
+//g_print("Restore position - Cancel / Discard\n");
+            /* Restore position - Cancel / Discard */
+            if(view->priv->current_ref != NULL)
+            {
+                gtk_tree_row_reference_free (view->priv->current_ref);
+                view->priv->current_ref = NULL;
+            }
+            view->priv->current_ref = gtk_tree_row_reference_copy (view->priv->edit_ref);
 
             gnc_tree_view_split_reg_default_selection (view);
+            return;
         }
         else
         {
-            /* Discard, commit and skip */
+//g_print("Commit and skip\n");
+            /* Commit and skip */
 
             /* Move the blank split */ 
-            gnc_tree_model_split_reg_set_blank_split_parent (model, trans);
+            gnc_tree_model_split_reg_set_blank_split_parent (model, trans, FALSE);
         }
 
-g_print ("Motion - depth is %d row old is %d and now %d\n", depth, row_old, row_now);
+        old_trans = view->priv->current_trans;
+        view->priv->current_trans = trans;
+        view->priv->current_split = split;
+        view->priv->current_depth = depth;
 
-        /* Set the view format */
-        g_idle_add ((GSourceFunc)gnc_tree_view_split_reg_set_format, view);
+//g_print("Motion - ** view->priv-> c_trans is %p c_split is %p depth %d **\n\n", view->priv->current_trans, view->priv->current_split, view->priv->current_depth);
 
+        /* Auto expand transaction and collapse previous transaction */
+        if (old_trans != trans)
+        {
+            /* Reset allow changes for reconciled transctions */
+            view->change_allowed = FALSE;
+
+            if (model->style != REG2_STYLE_JOURNAL)
+            {
+                if (gnc_tree_view_split_reg_trans_expanded (view, old_trans))
+                    gnc_tree_view_split_reg_collapse_trans (view, old_trans);
+            }
+            else
+                gnc_tree_view_split_reg_expand_trans (view, NULL);
+
+            if (model->style == REG2_STYLE_AUTO_LEDGER)
+            {
+                gtk_tree_view_expand_row (GTK_TREE_VIEW (view), spath, TRUE);
+
+                view->priv->expanded = TRUE;
+
+                if (SELECTION_TO_BLANK_ON_EXPAND)
+                    gtv_selection_to_blank (view);
+            }
+        }
+        gtk_tree_path_free (spath);
     }
     else
     {
-g_print("Not valid selection\n");
+//g_print("Not valid selection\n");
         /* We do not have a valid iter */
         gtv_split_reg_titles (view, 0);
 
         /* Move the blank split to the last transaction */ 
-        gnc_tree_model_split_reg_set_blank_split_parent (model, NULL);
+        gnc_tree_model_split_reg_set_blank_split_parent (model, NULL, FALSE);
 
         /* Set the default selection start position */
         gnc_tree_view_split_reg_default_selection (view);
-
     }
 
     /* This updates the plugin page gui */
@@ -3061,6 +3766,7 @@
 {
     GncTreeViewSplitReg  *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
     GncTreeModelSplitReg *model;
+    GtkCellEditable      *editable;
     GtkTreeIter           iter;
     Split                *split;
     Transaction          *trans;
@@ -3069,8 +3775,18 @@
     char                 *error_loc = NULL;
     Account              *anchor = view->priv->anchor;
 
-g_print("\ngtv_split_reg_edited_cb\n");
+    editable = g_object_get_data (G_OBJECT (cell), "cell-editable");
 
+    DEBUG("cell is %p editable pointer is %p and id %lu", cell, editable, view->priv->fo_handler_id);
+
+    /* Remove the focus out cb if one exists */
+    if (view->priv->fo_handler_id != 0)
+    {
+        if (g_signal_handler_is_connected (G_OBJECT (editable), view->priv->fo_handler_id))
+            g_signal_handler_disconnect (G_OBJECT (editable), view->priv->fo_handler_id);
+    }
+    view->priv->fo_handler_id = 0;
+
     if (g_strcmp0 (g_object_get_data (G_OBJECT (cell), "current-string"), new_text) == 0) // No change, return
         return;
 
@@ -3084,8 +3800,6 @@
     gnc_tree_model_split_reg_get_split_and_trans (
         model, &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
 
-g_print("gtv_split_reg_edited_cb New Text is '%s'\n", new_text);
-
     switch (viewcol) {
     case COL_DATE:
         /* Column is DATE */
@@ -3095,7 +3809,7 @@
             g_date_set_parse (&date, new_text);
             if (g_date_valid (&date))
             {
-                begin_edit (view, split, trans);
+                gtv_begin_edit (view, NULL, trans);
                 xaccTransSetDate (trans, g_date_get_day (&date), g_date_get_month (&date), g_date_get_year (&date));
             }
             else
@@ -3107,7 +3821,7 @@
 
     case COL_NUMACT:
         /* Column is NUM / ACT */
-        begin_edit (view, split, trans);
+        gtv_begin_edit (view, NULL, trans);
         if (is_trow1)
         {
             /* set per book option */
@@ -3124,82 +3838,27 @@
         {
             /* Set split-action with gnc_set_num_action which is the same as
              * xaccSplitSetAction with these arguments */
-            gnc_set_num_action(NULL, split, NULL, new_text);
+            gnc_set_num_action (NULL, split, NULL, new_text);
         }
         break;
 
     case COL_DESCNOTES:
         /* Column is DESCRIPTION / NOTES / MEMO */
-        begin_edit (view, split, trans);
+        gtv_begin_edit (view, NULL, trans);
         if (is_trow1)
-        {
             xaccTransSetDescription (trans, new_text);
-        }
+
         if (is_trow2)
-        {
             xaccTransSetNotes (trans, new_text);
-        }
+
         if (is_split)
-        {
             xaccSplitSetMemo (split, new_text);
-        }
-        break;
 
-    case COL_TRANSVOID:
-        /* Column is TRANSFER / VOID (Only updated from menu.) */
-        {
-            Split         *osplit = NULL;
-            QofBook       *book; //do we have this
-            Account       *root; // do we have this
-            Account       *new_acct;
-            gint           num_of_splits;
-            gnc_numeric    num;
-
-            begin_edit (view, split, trans);
-
-            if (!is_split && anchor)
-            {
-                if (!get_split_pair (view, trans, &osplit, &split))
-                {
-                    PERR("couldn't get split pair");
-                    break;
-                }
-            }
-
-//FIXME Probably needs more work 
-
-            book = gnc_get_current_book();
-            root = gnc_book_get_root_account (book);
-
-            num_of_splits = xaccTransCountSplits (trans);
-
-g_print("num_of_splits is %d\n", num_of_splits);
-
-            if (view->priv->acct_short_names)
-                new_acct = gnc_account_lookup_by_name (root, new_text);
-            else
-                new_acct = gnc_account_lookup_by_full_name (root, new_text);
-
-            if (new_acct != NULL && is_split)
-                xaccSplitSetAccount (split, new_acct);
-            else
-                xaccSplitSetAccount (osplit, new_acct);
-
-            mark_split_dirty (view, trans, split);
-
-            num = get_value_for (view, trans, split, is_blank);
-
-g_print("number is %s\n", gnc_numeric_to_string (num));
-
-            if (!gnc_numeric_zero_p (num))
-                set_value_for (view, trans, split, num);
-
-        }
         break;
 
     case COL_RECN:
         /* Column is RECONCILE */
-        begin_edit (view, split, trans);
+        gtv_begin_edit (view, NULL, trans);
 
         if (new_text != NULL)
         {
@@ -3227,27 +3886,30 @@
 
         break;
 
-    case COL_VALUE:
-    case COL_AMOUNT:
-    case COL_RATE:
+    case COL_TRANSVOID:
     case COL_AMTVAL:
     case COL_PRICE:
     case COL_DEBIT:
     case COL_CREDIT:
         {
 
-            Account *acct;
-            gnc_numeric input;
-            Split *osplit = NULL;
+            Account       *acct, *old_acct;
+            gnc_numeric    input;
+            Split         *osplit = NULL;
+            QofBook       *book; //do we have this
+            Account       *root; // do we have this
+            gboolean       valid_input = FALSE;
+            gboolean       force = FALSE;
+            gboolean       input_used = FALSE;
 
-g_print("rest\n");
+            book = gnc_get_current_book();
+            root = gnc_book_get_root_account (book);
 
-            if (!gnc_exp_parser_parse (new_text, &input, &error_loc))
-                break;
+            gtv_begin_edit (view, NULL, trans);
 
+            /* Get the split pair if anchored to a register */
             if (!is_split && anchor)
             {
-g_print("rest1\n");
                 if (!get_split_pair (view, trans, &osplit, &split))
                 {
                     PERR("couldn't get split pair");
@@ -3255,16 +3917,43 @@
                 }
             }
 
-            begin_edit (view, NULL, trans); // open trans even if split not a child
-            mark_split_dirty (view, trans, split);
+            /* Setup the account field */
+            if (viewcol == COL_TRANSVOID)
+            {
+                if (view->priv->acct_short_names)
+                    acct = gnc_account_lookup_by_name (root, new_text);
+                else
+                    acct = gnc_account_lookup_by_full_name (root, new_text);
 
+                if (acct != NULL && is_split)
+                {
+                    old_acct = xaccSplitGetAccount (split);
+                    xaccSplitSetAccount (split, acct);
+                    if (!gnc_commodity_equiv (xaccAccountGetCommodity (old_acct), xaccAccountGetCommodity (acct)))
+                        force = TRUE;
+                }
+                else
+                {
+                    old_acct = xaccSplitGetAccount (osplit);
+                    xaccSplitSetAccount (osplit, acct);
+                    if (!gnc_commodity_equiv (xaccAccountGetCommodity (old_acct), xaccAccountGetCommodity (acct)))
+                        force = TRUE;
+                }
+            }
+            else
+            {
+                if (!gnc_exp_parser_parse (new_text, &input, &error_loc))
+                    break;
+                else
+                    valid_input = TRUE;
+            }
+
+            /* Get the account for this split */
             acct = xaccSplitGetAccount (split);
             if (!acct)
             {
-g_print("rest2\n");
                 if (anchor)
                 {
-g_print("rest3\n");
                     xaccSplitSetAccount (split, anchor);
                     acct = xaccSplitGetAccount (split);
                 }
@@ -3274,44 +3963,77 @@
                 }
             }
 
+            /* Set the transaction currency if not set or if this is a non currency register,
+                 this should be same as first currency split */
+            if (!xaccTransGetCurrency (trans) || !gnc_commodity_is_currency (view->priv->reg_comm))
+            {
+                gnc_commodity *split_commodity;
+                split_commodity = xaccAccountGetCommodity (xaccSplitGetAccount (split));
+
+                if (gnc_commodity_is_currency (split_commodity))
+                    xaccTransSetCurrency (trans, xaccAccountGetCommodity (xaccSplitGetAccount (split)));
+            }
+
+            /* This computes the value if we just commit the split after entering account */
+            if (!valid_input)
+                input = get_value_for (view, trans, split, is_blank);
+
+            // Negate the input if COL_CREDIT
             if (viewcol == COL_CREDIT)
                 input = gnc_numeric_neg (input);
 
-//FIXME 
-            if (viewcol == COL_AMOUNT)
+            // Set the split parent trans
+            xaccSplitSetParent (split, trans);
+
+            // If we are at trasaction level, column is value, split level is amount
+            if (viewcol == COL_AMTVAL)
             {
-                set_amount_for (view, trans, split, input);
-                break;
+                set_number_for_input (view, trans, split, input, COL_AMTVAL);
+                input_used = TRUE;
             }
 
-            if (viewcol == COL_RATE)
+            // The price of stock / shares
+            if (viewcol == COL_PRICE)
             {
-                set_rate_for (view, trans, split, input, is_blank);
-                break;
+                set_number_for_input (view, trans, split, input, COL_PRICE);
+                input_used = TRUE;
             }
-//FIXME
 
+            // Check if this is a stock / share amount
+            if (viewcol == COL_CREDIT || viewcol == COL_DEBIT)
+            {
+                if (!gnc_commodity_is_currency (xaccAccountGetCommodity (acct)))
+                {
+                    set_number_for_input (view, trans, split, input, viewcol);
+                    input_used = TRUE;
+                }
+            }
 
-            if ((viewcol == COL_AMTVAL) && is_split)
+            // This is used in transaction mode, two splits
+            if (input_used == FALSE)
             {
-                set_amount_for (view, trans, split, input);
-                break;
+                if (gnc_commodity_is_currency (xaccAccountGetCommodity (acct)))
+                    set_value_for (view, trans, split, input, force);
+                else
+                    set_value_for_amount (view, trans, split, input);
             }
 
-            if ((viewcol == COL_AMTVAL) && is_trow1)
+            // If this is the blank split, promote it.
+            if (is_blank)
             {
-                set_value_for (view, trans, split, input);
-                break;
+                /*FIXME May be this should be a signal - Promote the blank split to a real split */
+                g_idle_add ((GSourceFunc)gnc_tree_model_split_reg_commit_blank_split, get_split_reg_model_from_view (view));
             }
-//End FIXME
 
-            set_value_for (view, trans, split, input);
-
+            // In transaction mode, two splits only, set up the other split.
             if (osplit)
             {
-g_print("rest4\n");
                 xaccSplitSetParent (osplit, trans);
-                set_value_for (view, trans, osplit, gnc_numeric_neg (input));
+
+                if (gnc_commodity_is_currency (xaccAccountGetCommodity (acct)))
+                    set_value_for (view, trans, osplit, gnc_numeric_neg (input), force);
+                else
+                    set_value_for_amount (view, trans, osplit, gnc_numeric_neg (xaccSplitGetValue (split)));
             }
         }
         break;
@@ -3323,6 +4045,7 @@
 }
 
 
+/* Callback for changing reconcile setting with space bar */
 static void
 gtv_split_reg_recn_cb (GtkEntry    *entry,
                           const gchar *text,
@@ -3341,8 +4064,6 @@
 
 /*FIXME this works, but is there a simpler way ? */
 
-//g_print("gtv_split_reg_recn_cb '%s'\n", text);
-
     result = g_ascii_strdown (text, length);
 
     if (g_object_get_data (G_OBJECT (view->priv->temp_cr), "current-flag") != NULL)
@@ -3398,12 +4119,13 @@
 
 /* The main Start Editing Call back for the TEXT columns */
 static void
-get_editable_start_editing_cb (GtkCellRenderer *cr, GtkCellEditable *editable,
+gtv_get_editable_start_editing_cb (GtkCellRenderer *cr, GtkCellEditable *editable,
                               const gchar *path_string, gpointer user_data)
 {
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
     GncTreeModelSplitReg *model;
-    GtkTreePath *path;
+    GtkTreeModel     *smodel;
+    GtkTreePath *path, *mpath;
     ViewCol viewcol;
 
     GtkListStore *description_list;
@@ -3414,37 +4136,37 @@
     GtkEntryCompletion *completion = gtk_entry_completion_new();
     RowDepth depth;
 
-    ENTER(" ");
-g_print("\n\nget_editable_start_editing_cb\n");
+    ENTER("ngtv_get_editable_start_editing_cb Path string is '%s'\n", path_string);
 
     model = get_split_reg_model_from_view (view);
 
+    smodel = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+
     /* Description / Notes / Memo / Accounts Completion Lists */
     description_list = gnc_tree_model_split_reg_get_description_list (model);
     notes_list = gnc_tree_model_split_reg_get_notes_list (model);
     memo_list = gnc_tree_model_split_reg_get_memo_list (model);
     acct_list = gnc_tree_model_split_reg_get_acct_list (model);
 
-//g_print("editable Path string is '%s'\n", path_string);
-
-    //Use depth to determine if it is a split or transaction
+    // Use depth to determine if it is a split or transaction
     path = gtk_tree_path_new_from_string (path_string);
     depth = gtk_tree_path_get_depth (path);
 
     viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(cr), "view_column"));
 
-g_print("editable Depth is %u and ViewCol is %d\n", depth, viewcol);
+    DEBUG("editable Depth is %u and ViewCol is %d", depth, viewcol);
 
     /* DATE COLUMN */
     if (viewcol == COL_DATE)
     {
         g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
+
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (GTK_ENTRY (GNC_POPUP_ENTRY (editable)->entry))));
 
         g_signal_connect (G_OBJECT (editable), "remove-widget", (GCallback) remove_edit_date, view);
 
-//g_print("Current String date is '%s'\n", g_strdup (gtk_entry_get_text (GTK_ENTRY (GNC_POPUP_ENTRY (editable)->entry))));
+        DEBUG("Current String date is '%s'", g_strdup (gtk_entry_get_text (GTK_ENTRY (GNC_POPUP_ENTRY (editable)->entry))));
 
     }
 
@@ -3469,17 +4191,18 @@
         gtk_entry_completion_set_inline_selection (completion, TRUE);
         gtk_entry_completion_set_popup_set_width (completion, FALSE);
         gtk_entry_completion_set_minimum_key_length (completion, KEY_LENGTH);
-/*??        g_signal_connect(G_OBJECT(completion), "match-selected", (GCallback)gtv_split_reg_match_selected_cb, view); */
+//??        g_signal_connect(G_OBJECT(completion), "match-selected", (GCallback) gtv_split_reg_match_selected_cb, view);
         g_object_unref (completion);
 
         g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
+
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data(G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (entry)));
 
-        g_signal_connect (G_OBJECT (cr), "changed", (GCallback)gtv_split_reg_changed_cb, view);
+//??        g_signal_connect (G_OBJECT (cr), "changed", (GCallback) gtv_split_reg_changed_cb, view);
         g_signal_connect (G_OBJECT (editable), "remove-widget", (GCallback) remove_edit_combo, view);
 
-//g_print("Current String tv is '%s'\n", g_strdup(gtk_entry_get_text (entry)));
+        DEBUG("Current String tv is '%s'", g_strdup(gtk_entry_get_text (entry)));
     }
 
 
@@ -3502,13 +4225,14 @@
         entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (editable)));
 
         g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
+
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (entry)));
 
-/*??        g_signal_connect (G_OBJECT (cr), "changed", (GCallback)gtv_split_reg_changed_cb, view); */
+//??        g_signal_connect (G_OBJECT (cr), "changed", (GCallback) gtv_split_reg_changed_cb, view);
         g_signal_connect (G_OBJECT (editable), "remove-widget", (GCallback) remove_edit_combo, view);
 
-//g_print("Current String na is '%s'\n", g_strdup (gtk_entry_get_text (entry)));
+        DEBUG("Current String na is '%s'", g_strdup (gtk_entry_get_text (entry)));
     }
 
 
@@ -3540,16 +4264,20 @@
         gtk_entry_completion_set_popup_completion (completion, TRUE);
         gtk_entry_completion_set_inline_selection (completion, TRUE);
         gtk_entry_completion_set_minimum_key_length (completion, KEY_LENGTH);
-/*??        g_signal_connect (G_OBJECT (completion), "match-selected", (GCallback)gtv_split_reg_match_selected_cb, view); */
+//??        g_signal_connect (G_OBJECT (completion), "match-selected", (GCallback) gtv_split_reg_match_selected_cb, view);
 
         g_object_unref (completion);
 
         g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
+
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (GTK_ENTRY(editable))));
+
+        view->priv->fo_handler_id = g_signal_connect (G_OBJECT (editable), "focus-out-event", (GCallback) gtv_split_reg_focus_out_cb, view);
+
         g_signal_connect (G_OBJECT (editable), "remove-widget", (GCallback) remove_edit_entry, view);
 
-//g_print("Current String dnm is '%s'\n", g_strdup (gtk_entry_get_text (GTK_ENTRY(editable))));
+        DEBUG("Current String dnm is '%s'", g_strdup (gtk_entry_get_text (GTK_ENTRY(editable))));
     }
 
 
@@ -3560,14 +4288,19 @@
 
         entry = GTK_ENTRY (editable);
 
-        g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
+         g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
+
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (entry)));
+
         g_signal_connect (G_OBJECT (GTK_ENTRY (editable)), "insert_text", (GCallback)gtv_split_reg_recn_cb, view);
+
+        view->priv->fo_handler_id = g_signal_connect (G_OBJECT (editable), "focus-out-event", (GCallback) gtv_split_reg_focus_out_cb, view);
+
         g_signal_connect (G_OBJECT (editable), "remove-widget", (GCallback) remove_edit_entry, view);
 
-/*??        g_signal_connect (G_OBJECT (cr), "changed", (GCallback)gtv_split_reg_changed_cb, view); */
-//g_print("Current String recn is '%s'\n", g_strdup (gtk_entry_get_text (entry)));
+//??        g_signal_connect (G_OBJECT (cr), "changed", (GCallback) gtv_split_reg_changed_cb, view);
+        DEBUG("Current String recn is '%s'", g_strdup (gtk_entry_get_text (entry)));
     }
 
 
@@ -3579,73 +4312,125 @@
         entry = GTK_ENTRY (editable);
 
         g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
+
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (entry)));
-//        g_signal_connect (G_OBJECT (GTK_ENTRY (editable)), "insert_text", (GCallback)gtv_split_reg_recn_cb, view);
+
+        view->priv->fo_handler_id = g_signal_connect (G_OBJECT (editable), "focus-out-event", (GCallback) gtv_split_reg_focus_out_cb, view);
+
         g_signal_connect (G_OBJECT (editable), "remove-widget", (GCallback) remove_edit_entry, view);
 
-/*??        g_signal_connect (G_OBJECT (cr), "changed", (GCallback)gtv_split_reg_changed_cb, view); */
-//g_print("Current String rest is '%s'\n", g_strdup (gtk_entry_get_text (entry)));
+//??        g_signal_connect (G_OBJECT (cr), "changed", (GCallback)gtv_split_reg_changed_cb, view);
+        DEBUG("Current String rest is '%s'", g_strdup (gtk_entry_get_text (entry)));
     }
 
 
     gtv_split_reg_help (view, cr, viewcol, depth);
 
-    gtk_tree_path_free (view->priv->acct_edit_path);
-    view->priv->acct_edit_path = gtk_tree_path_copy (path);
-//g_print("edit_path is %s\n", gtk_tree_path_to_string (view->priv->acct_edit_path));
+    mpath = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (smodel), path);
+
+    if(view->priv->edit_ref != NULL)
+    {
+        gtk_tree_row_reference_free (view->priv->edit_ref);
+        view->priv->edit_ref = NULL;
+    }
+    view->priv->edit_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), mpath);
+
+    DEBUG("edit_path is %s", gtk_tree_path_to_string (gtk_tree_row_reference_get_path (view->priv->edit_ref)));
     gtk_tree_path_free (path);
+    gtk_tree_path_free (mpath);
+
     view->priv->temp_cr = cr;
+    view->editing_now = TRUE;
+
+    DEBUG("Temp Cell Rend %p", view->priv->temp_cr);
+
     //Add edit-canceled property to cr so we can distinguish between
     //cancelled and actual changes
     g_object_set_data (G_OBJECT (cr), "edit-canceled", GINT_TO_POINTER (FALSE));
 
+
+    /*******************************************************************/
+    /*            Test function before edit started                    */
+    /*******************************************************************/
+
+    /* Test for change of RECN COLUMN setting from reconciled */
+    if (viewcol == COL_RECN)
+    {
+       /* Are we trying to change the reconcile setting */
+        if (gnc_tree_control_split_reg_recn_change (view))
+        {
+            /* Make sure we have stopped editing */
+            g_idle_add( (GSourceFunc)gtv_idle_finish_edit, view ); //FIXME Not sure if this is ok.
+        }
+        else
+        {
+            /* Make sure we have stopped editing */
+            g_idle_add( (GSourceFunc)gtv_idle_finish_edit, view ); //FIXME Not sure if this is ok.
+        }
+    }
+
+    /* Ask, are we allowed to change reconciled values other than 'description / notes / memo'
+       which we can change always */
+    if (viewcol != COL_DESCNOTES && viewcol != COL_RECN)
+    {
+        if (gnc_tree_control_split_reg_recn_test (view))
+        {
+            ;
+        }
+        else
+        {
+            /* Make sure we have stopped editing */
+            g_idle_add( (GSourceFunc)gtv_idle_finish_edit, view ); //FIXME Not sure if this is ok.
+        }
+    }
+
     LEAVE(" ");
 }
 
 
-//Handle the "match-selected" signal
+// Handle the "match-selected" signal
 static void
 gtv_split_reg_match_selected_cb (GtkEntryCompletion *widget, GtkTreeModel *model,
                         GtkTreeIter *iter, gpointer user_data)
 {
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
 
-    gboolean is_trow1, is_trow2, is_split, is_blank;
+//FIXME g_print("gtv_split_reg_match_selected_cb\n\n");
 
-g_print("gtv_split_reg_match_selected_cb\n\n");
-
 /* Not sure what I am going to put in here yet */
 
 }
 
 
-//Handle the "changed" signal
+// Handle the "changed" signal
 static void
 gtv_split_reg_changed_cb (GtkCellRendererCombo *widget, gchar *path_string,
                         GtkTreeIter *iter, gpointer user_data)
 {
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
 
-    gboolean is_trow1, is_trow2, is_split, is_blank;
+//FIXME g_print("gtv_split_reg_changed_cb path string is '%s'\n\n", path_string);
 
-g_print("gtv_split_reg_changed_cb path string is '%s'\n\n", path_string);
-
-
 /* Not sure what I am going to put in here yet */
 
 }
 
 
-//Handle the "editing-canceled" signal
+// Handle the "editing-canceled" signal
 static void
 gtv_split_reg_editing_canceled_cb (GtkCellRenderer *cr, gpointer user_data)
 {
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
-g_print("gtv_split_reg_editing_canceled_cb\n\n");
 
-    if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view), "data-edited")) == FALSE) // None edited, reset edit path
-        view->priv->acct_edit_path = NULL;
+    if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view), "data-edited")) == FALSE) // Not edited, reset edit path
+    {
+        if(view->priv->edit_ref != NULL)
+        {
+            gtk_tree_row_reference_free (view->priv->edit_ref);
+            view->priv->edit_ref = NULL;
+        }
+    }
 
     /* Reset Help text */
     view->help_text = " ";
@@ -3655,207 +4440,168 @@
     g_object_set_data (G_OBJECT (cr), "edit-canceled", GINT_TO_POINTER (TRUE));	
 }
 
-/*####################################################################
-          ^^^^   gtv function call backs    ^^^^
-#####################################################################*/
 
-void
-gnc_tree_view_split_reg_void_current_trans (GncTreeViewSplitReg *view, const char *reason)
+/* Scroll the view to show selected row based on sort direction */
+static gboolean
+gtv_scroll_to_cell (GncTreeViewSplitReg *view)
 {
-    Transaction *trans;
-    Split *blank_split;
-    Split *split;
+    GncTreeModelSplitReg *model;
+    GtkTreePath *mpath, *spath;
 
-    if (!view) return;
+    model = get_split_reg_model_from_view (view);
 
-    blank_split = gnc_tree_view_split_reg_get_blank_split (view);
+    mpath = gnc_tree_view_split_reg_get_current_path (view);
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
-    /* get the current split based on cursor position */
-    split = gnc_tree_view_split_reg_get_current_split (view);
-    if (split == NULL)
-        return;
 
-    /* Bail if trying to void the blank split. */
-    if (split == blank_split)
-        return;
-
-    /* already voided. */
-    if (xaccSplitGetReconcile (split) == VREC)
-        return;
-
-    trans = xaccSplitGetParent (split);
-    xaccTransVoid (trans, reason);
-
-    if (xaccTransIsOpen (trans))
+    if (view->sort_direction == 1)
+        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 0.0, 0.0);
+    else
     {
-        PERR("We should not be voiding an open transaction.");
-        xaccTransCommitEdit (trans);
+        if (model->use_double_line)
+        {
+            gtk_tree_path_down (spath); // move to the second row of transaction
+            gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 1.0, 0.0);
+            gtk_tree_path_up (spath); // back to first row of transaction
+        }
+        else
+            gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 1.0, 0.0);
     }
+    gtk_tree_path_free (mpath);
+    gtk_tree_path_free (spath);
+    return (FALSE);
 }
 
 
-void
-gnc_tree_view_split_reg_unvoid_current_trans (GncTreeViewSplitReg *view)
+/*####################################################################
+          ^^^^   gtv function call backs    ^^^^
+#####################################################################*/
+
+/* Returns the Transaction at the current selected position */
+Transaction *
+gnc_tree_view_split_reg_get_current_trans (GncTreeViewSplitReg *view)
 {
-    Transaction *trans;
-    Split *blank_split;
-    Split *split;
+    return view->priv->current_trans;
+}
 
-    if (!view) return;
 
-    blank_split = gnc_tree_view_split_reg_get_blank_split (view);
+/* Returns the Split at the current selected position or NULL */
+Split *
+gnc_tree_view_split_reg_get_current_split (GncTreeViewSplitReg *view)
+{
+    return view->priv->current_split;
+}
 
-    /* get the current split based on cursor position */
-    split = gnc_tree_view_split_reg_get_current_split (view);
-    if (split == NULL)
-        return;
 
-    /* Bail if trying to unvoid the blank split. */
-    if (split == blank_split)
-        return;
+/* Returns the depth of the selected row */
+RowDepth
+gnc_tree_view_reg_get_selected_row_depth (GncTreeViewSplitReg *view)
+{
+    return view->priv->current_depth;
+}
 
-    /* not voided. */
-    if (xaccSplitGetReconcile (split) != VREC)
-        return;
 
-    trans = xaccSplitGetParent (split);
-
-    xaccTransUnvoid (trans);
+/* Returns the dirty_trans or NULL */
+Transaction *
+gnc_tree_view_split_reg_get_dirty_trans (GncTreeViewSplitReg *view)
+{
+    return view->priv->dirty_trans;
 }
 
 
-/* Reinit transaction / delete the splits */
+/* Sets dirty_trans to trans or NULL to clear */
 void
-gnc_tree_view_split_reg_reinit_trans (GncTreeViewSplitReg *view)
+gnc_tree_view_split_reg_set_dirty_trans (GncTreeViewSplitReg *view, Transaction *trans)
 {
     GncTreeModelSplitReg *model;
-    GtkTreeIter iter;
-    Split *split = NULL;
-    Transaction *trans = NULL;
-    gboolean is_trow1, is_trow2, is_split, is_blank;
 
-g_print("gnc_tree_view_split_reg_reinit_trans\n");
     model = get_split_reg_model_from_view (view);
 
-    /* Lets get out of the way, move the selection to the transaction */
-    gnc_tree_view_split_reg_goto_rel_trans_row (view, 0);
-
-    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, view->priv->current_path);
-
-    gnc_tree_model_split_reg_get_split_and_trans (
-            GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
-
-    if (trans && (is_trow1 || is_trow2))
+    if (trans == NULL)
     {
-        Split *s;
-        int i = 0;
-        
-        begin_edit (view, NULL, trans);        
-        while ((s = xaccTransGetSplit(trans, i)) != NULL)
+        if(view->priv->edit_ref != NULL)
         {
-            if (xaccTransGetRateForCommodity (trans, view->priv->reg_comm, s, NULL))
-                xaccSplitDestroy(s);
-            else i++;
+            gtk_tree_row_reference_free (view->priv->edit_ref);
+            view->priv->edit_ref = NULL;
         }
-    g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (TRUE));
-    view->priv->dirty_trans = trans;
+        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
+        view->priv->dirty_trans = NULL;
     }
+    else
+    {
+        if(view->priv->edit_ref != NULL)
+        {
+            gtk_tree_row_reference_free (view->priv->edit_ref);
+            view->priv->edit_ref = NULL;
+        }
+        view->priv->edit_ref = gtk_tree_row_reference_copy (view->priv->current_ref);
+        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (TRUE));
+        view->priv->dirty_trans = trans;
+    }
 }
 
 
-/* Jump to the Blank transaction, i.e. last in list */
-void
-gnc_tree_view_split_reg_jump_to_blank (GncTreeViewSplitReg *view)
+/* Returns the current path */
+GtkTreePath *
+gnc_tree_view_split_reg_get_current_path (GncTreeViewSplitReg *view)
 {
-    GncTreeModelSplitReg *model;
-    GtkTreePath *path;
-
-g_print("gnc_tree_view_split_reg_jump_to_blank\n");
-    model = get_split_reg_model_from_view (view);
-
-    path = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, NULL);
-
-    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), path);
-
-    /* Scroll the window to show selection */
-    if (model->use_double_line)
-       gtk_tree_path_down (path); // show the second row of transaction
-
-    /* scroll when view idle */
-    g_idle_add ((GSourceFunc)gtv_scroll_to_cell, view );
-
-    gtk_tree_path_free (path);
+    return gtk_tree_row_reference_get_path (view->priv->current_ref);
 }
 
 
-static gboolean
-gtv_scroll_to_cell (GncTreeViewSplitReg *view)
-{
-    GncTreeModelSplitReg *model;
-    GtkTreePath *path;
-
-    model = get_split_reg_model_from_view (view);
-
-    path = view->priv->current_path;
-   
-    gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), path, NULL, TRUE, 0.5, 0.0);
-
-   return (FALSE);
-}
-
-
-/* Jump to split */
+/* Set the Current path to path */
 void
-gnc_tree_view_split_reg_jump_to_split (GncTreeViewSplitReg *view, Split *split)
+gnc_tree_view_split_reg_set_current_path (GncTreeViewSplitReg *view, GtkTreePath *path)
 {
     GncTreeModelSplitReg *model;
-    GtkTreePath *path;
 
-g_print("gnc_tree_view_split_reg_jump_to_split and split is %p\n", split);
-
     model = get_split_reg_model_from_view (view);
 
-    path = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, split, NULL);
+    if(view->priv->current_ref != NULL)
+    {
+        gtk_tree_row_reference_free (view->priv->current_ref);
+        view->priv->current_ref = NULL;
+    }
+    view->priv->current_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), path);
 
-    gtk_tree_path_free (view->priv->current_path);
-
-    view->priv->current_path = gtk_tree_path_copy (path);
-
-    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), path);
-
-    gtk_tree_path_free (path);
-
-    /* scroll when view is idle */
-    g_idle_add ((GSourceFunc)gtv_scroll_to_cell, view );
+    view->priv->current_trans = gnc_tree_view_split_reg_get_current_trans (view);
+    view->priv->current_split = gnc_tree_view_split_reg_get_current_split (view);
+    view->priv->current_depth = gnc_tree_view_reg_get_selected_row_depth (view);
 }
 
 
-/* Move to the relative transaction */
+/* Reinit transaction / delete the splits */
 void
-gnc_tree_view_split_reg_goto_rel_trans_row (GncTreeViewSplitReg *view, gint relative)
+gnc_tree_view_split_reg_reinit_trans (GncTreeViewSplitReg *view)
 {
+    Transaction           *trans;
+    RowDepth               depth;
 
-    GncTreeModelSplitReg *model;
-    GtkTreePath *path;
-    gint *indices;
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
 
-g_print("gnc_tree_view_split_reg_goto_rel_trans_row\n");
+    trans = view->priv->current_trans;
 
-//FIXME Need to do some checks on relative -1,0,1
-    model = get_split_reg_model_from_view (view);
+    /* Lets get out of the way, move the selection to the transaction */
+    gnc_tree_control_split_reg_goto_rel_trans_row (view, 0);
 
-    indices = gtk_tree_path_get_indices (view->priv->current_path);
+    depth = view->priv->current_depth;
 
-    path = gtk_tree_path_new_from_indices (indices[0] + relative, -1);
+    if (trans && (depth != SPLIT3))
+    {
+        Split *s;
+        int i = 0;
 
-    gtk_tree_path_free (view->priv->current_path);
+        gtv_begin_edit (view, NULL, trans);
+        gnc_tree_view_split_reg_set_dirty_trans (view, trans);
 
-    view->priv->current_path = gtk_tree_path_copy (path);
-
-    gtk_tree_selection_unselect_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), path);
-    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), path);
-
-    gtk_tree_path_free (path);
+        while ((s = xaccTransGetSplit (trans, i)) != NULL)
+        {
+            if (xaccTransGetRateForCommodity (trans, view->priv->reg_comm, s, NULL))
+                xaccSplitDestroy (s);
+            else i++;
+        }
+    }
 }
 
 
@@ -3863,41 +4609,26 @@
 void
 gnc_tree_view_split_reg_delete_current_split (GncTreeViewSplitReg *view)
 {
-    GncTreeModelSplitReg  *model;
-    GtkTreeIter            iter;
-    GtkTreePath           *path;
-    GtkTreeViewColumn     *col_current;
-    Split                 *split = NULL;
-    Transaction           *trans = NULL;
-    gboolean               is_trow1, is_trow2, is_split, is_blank;
+    Transaction           *trans;
+    Split                 *split;
+    gboolean               was_open;
 
-g_print("gnc_tree_view_split_reg_delete_current_split\n");
-
-    model = get_split_reg_model_from_view (view);
-
-    gtk_tree_view_get_cursor (GTK_TREE_VIEW (view), &path, &col_current);
-
     /* Make sure we have stopped editing */
-    if (col_current != NULL)
-        finish_edit (col_current);
+    gnc_tree_view_split_reg_finish_edit (view);
 
-    gtk_tree_path_free (path);
+    trans = view->priv->current_trans;
+    split = view->priv->current_split;
 
-    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, view->priv->current_path);
+    gtv_begin_edit (view, NULL, trans);
 
-    gnc_tree_model_split_reg_get_split_and_trans (
-            GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+    gnc_tree_view_split_reg_set_dirty_trans (view, trans);
 
     /* Lets get out of the way, move the selection to the transaction */
-    gnc_tree_view_split_reg_goto_rel_trans_row (view, 0);
+    gnc_tree_control_split_reg_goto_rel_trans_row (view, 0);
 
-    begin_edit (view, split, trans);
-
-    if (is_split)
-    {
+    was_open = xaccTransIsOpen (trans);
+    if (was_open)
         xaccSplitDestroy (split);
-        xaccTransCommitEdit (trans);
-    }
 }
 
 
@@ -3906,35 +4637,22 @@
 gnc_tree_view_split_reg_delete_current_trans (GncTreeViewSplitReg *view)
 {
     GncTreeModelSplitReg  *model;
-    GtkTreeIter            iter;
-    GtkTreePath           *path;
-    GtkTreeViewColumn     *col_current;
-    Split                 *split = NULL;
-    Transaction           *trans = NULL;
-    gboolean               is_trow1, is_trow2, is_split, is_blank;
+    Transaction           *trans;
     gboolean               was_open;
 
-g_print("gnc_tree_view_split_reg_delete_current_trans\n");
-    model = get_split_reg_model_from_view (view);
+    /* We do not use the normal confirmation with this one as we have
+       all ready asked the user to confirm delete */
 
-    gtk_tree_view_get_cursor (GTK_TREE_VIEW (view), &path, &col_current);
-
     /* Make sure we have stopped editing */
-    if (col_current != NULL)
-        finish_edit (col_current);
+    gnc_tree_view_split_reg_finish_edit (view);
 
-    gtk_tree_path_free (path);
+    trans = view->priv->current_trans;
 
-    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, view->priv->current_path);
+    /* We need to go back one to select the next transaction */
+    gnc_tree_control_split_reg_goto_rel_trans_row (view, 1);
 
-    gnc_tree_model_split_reg_get_split_and_trans (
-            GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+    gtv_begin_edit (view, NULL, trans);
 
-    begin_edit (view, split, trans);
-
-    /* Lets get out of the way, move the selection to the next transaction */
-    gnc_tree_view_split_reg_goto_rel_trans_row (view, 1);
-
     was_open = xaccTransIsOpen (trans);
 
     xaccTransDestroy (trans);
@@ -3943,209 +4661,233 @@
         DEBUG("committing");
         xaccTransCommitEdit (trans);
     }
-
     view->priv->dirty_trans = NULL;
-
-    /* We need to go back one to select the next transaction */
-    gnc_tree_view_split_reg_goto_rel_trans_row (view, -1);
 }
 
 
-/* Returns whether the splits are revealed at the current position */ 
+/* Record changes */
 gboolean
-gnc_tree_view_split_reg_current_trans_expanded (GncTreeViewSplitReg *view)
+gnc_tree_view_split_reg_enter (GncTreeViewSplitReg *view)
 {
-    GtkTreePath *path;
-    gint *indices;
-    gboolean expanded = FALSE;
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
 
-    indices = gtk_tree_path_get_indices (view->priv->current_path);
+    /* Ask for confirmation if data has been edited, transaction_changed_confirm return TRUE if canceled */
+    if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view), "data-edited")) && transaction_changed_confirm (view, NULL))
+    {
+        return FALSE;
+    }
+    return TRUE;
+}
 
-    path = gtk_tree_path_new_from_indices (indices[0], 0, -1);
 
-    expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path);
+/* Cancel the edit and rollback changes */
+void
+gnc_tree_view_split_reg_cancel_edit (GncTreeViewSplitReg *view, gboolean reg_closing)
+{
+    GncTreeModelSplitReg *model;
+    Transaction          *trans = view->priv->dirty_trans;
+    Split                *split;
 
-    gtk_tree_path_free(path);
-    return expanded;
-}
+    ENTER("gnc_tree_view_split_reg_cancel_edit view is %p and reg_closing is %d", view, reg_closing);
 
+    model = get_split_reg_model_from_view (view);
 
-/* Returns the depth of the selected row */
-RowDepth
-gnc_tree_view_reg_get_selected_row_depth (GncTreeViewSplitReg *view)
-{
-    gint depth;
+    if (trans && xaccTransIsOpen (trans))
+    {
+        gnc_tree_control_split_reg_goto_rel_trans_row (view, 0);
 
-    depth = gtk_tree_path_get_depth (view->priv->current_path);
+        // Remove the split before rollback.
+        gnc_tree_model_split_reg_set_blank_split_parent (model, trans, TRUE);
 
-    return depth;
+        g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
+        xaccTransRollbackEdit (view->priv->dirty_trans);
+
+        // Add the split after rollback so it is last in list.
+        gnc_tree_model_split_reg_set_blank_split_parent (model, trans, FALSE);
+        view->priv->dirty_trans = NULL;
+
+        split = gnc_tree_model_split_get_blank_split (model);
+        xaccSplitReinit (split); // Clear the blank split
+
+        if (view->priv->edit_ref != NULL)
+        {
+            gtk_tree_row_reference_free (view->priv->edit_ref);
+            view->priv->edit_ref = NULL;
+        }
+    }
+    /* Reset allow changes for reconciled transctions */
+    view->change_allowed = FALSE;
+    LEAVE(" ");
 }
 
 
-/* Returns the Blank Split */
-Split * 
-gnc_tree_view_split_reg_get_blank_split (GncTreeViewSplitReg *view)
+/* Make sure we have stopped editing */
+void
+gnc_tree_view_split_reg_finish_edit (GncTreeViewSplitReg *view)
 {
-    GncTreeModelSplitReg *model;
+    gtv_finish_edit (view);
 
-//g_print("gnc_tree_view_split_reg_get_blank_split\n");
-    model = get_split_reg_model_from_view (view);
-
-    return gnc_tree_model_split_get_blank_split (model);
+    /* give gtk+ a chance to handle pending events */
+    while (gtk_events_pending ())
+       gtk_main_iteration ();
 }
 
 
-/* Return the Split for the current Transaction */
-Split *
-gnc_tree_view_reg_get_current_trans_split (GncTreeViewSplitReg *view)
+/* Returns whether the splits are revealed for the transaction or current position
+   if transaction is NULL */
+gboolean
+gnc_tree_view_split_reg_trans_expanded (GncTreeViewSplitReg *view, Transaction *trans)
 {
     GncTreeModelSplitReg *model;
-    GtkTreeIter iter;
-    Split *split = NULL;
-    Transaction *trans = NULL;
-    gboolean is_trow1, is_trow2, is_split, is_blank;
+    GtkTreePath  *mpath, *spath;
+    gboolean expanded;
 
-//g_print("gnc_tree_view_reg_get_current_trans_split\n");
-    model = get_split_reg_model_from_view (view);
+    /* if trans is NULL use priv->expanded */
+    if (trans == NULL)
+        expanded = view->priv->expanded;
+    else
+    {
+        model = get_split_reg_model_from_view (view);
 
-    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, view->priv->current_path);
+        mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, trans);
 
-    gnc_tree_model_split_reg_get_split_and_trans (
-            GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+        spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
-    split = get_this_split (view, trans);
+        gtk_tree_path_down (spath); /* Move the path down to trow2 */
+        expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), spath);
 
-//g_print("gnc_tree_view_reg_get_current_trans_split %p\n", split);
-
-    return split;
+        gtk_tree_path_free (mpath);
+        gtk_tree_path_free (spath);
+    }
+    return expanded;
 }
 
 
-/* Returns the Split at the current selected position */
-Split * 
-gnc_tree_view_split_reg_get_current_split (GncTreeViewSplitReg *view)
+/* Collapse the transaction, if trans is NULL,  use current_ref */
+void
+gnc_tree_view_split_reg_collapse_trans (GncTreeViewSplitReg *view, Transaction *trans)
 {
     GncTreeModelSplitReg *model;
-    GtkTreeIter iter;
-    Split *split = NULL;
-    Transaction *trans = NULL;
-    gboolean is_trow1, is_trow2, is_split, is_blank;
+    GtkTreePath *temp_spath, *mpath, *spath;
+    gint *indices;
+    RowDepth depth;
 
-//g_print("gnc_tree_view_split_reg_get_current_split\n");
+    ENTER("gnc_tree_view_split_reg_collapse_trans and trans is %p", trans);
+
     model = get_split_reg_model_from_view (view);
 
-    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, view->priv->current_path);
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
 
-    gnc_tree_model_split_reg_get_split_and_trans (
-            GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+    /* if trans is NULL use current_ref */
+    if (trans == NULL)
+        mpath = gtk_tree_row_reference_get_path (view->priv->current_ref);
+    else
+        mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, trans);
 
-//g_print("gnc_tree_view_split_reg_get_current_split %p\n", split);
-    return split;
-}
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
+    /* Collapse the view back to the transaction */
+    indices = gtk_tree_path_get_indices (spath);
+    depth = gtk_tree_path_get_depth (spath);
 
-/* Returns the Transaction at the current selected position */
-Transaction * 
-gnc_tree_view_split_reg_get_current_trans (GncTreeViewSplitReg *view)
-{
-    GncTreeModelSplitReg *model;
-    GtkTreeIter iter;
-    Split *split = NULL;
-    Transaction *trans = NULL;
-    gboolean is_trow1, is_trow2, is_split, is_blank;
+    if (model->use_double_line)
+        temp_spath = gtk_tree_path_new_from_indices (indices[0], 0, -1);
+    else
+        temp_spath = gtk_tree_path_new_from_indices (indices[0], -1);
 
-//g_print("gnc_tree_view_split_reg_get_current_trans\n");
-    model = get_split_reg_model_from_view (view);
+    /* if trans is NULL, collapse and update current_ref */
+    if (trans == NULL)
+    {
+        GtkTreePath *temp_mpath;
 
-    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, view->priv->current_path);
+        gnc_tree_view_split_reg_block_selection (view, TRUE);
 
-    gnc_tree_model_split_reg_get_split_and_trans (
-            GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+        /* Change the selection to last available row of transaction - double */
+        if ((model->use_double_line) && (depth == SPLIT3))
+            gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), temp_spath);
 
-//g_print("gnc_tree_view_split_reg_get_current_trans %p\n", trans);
+        /* Change the selection to last available row of transaction - single */
+        if ((!model->use_double_line) && (depth != TRANS1))
+            gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), temp_spath);
 
-    return trans;
-}
+        gtk_tree_view_collapse_row (GTK_TREE_VIEW (view), temp_spath);
 
+        if (view->priv->current_ref != NULL)
+        {
+            gtk_tree_row_reference_free (view->priv->current_ref);
+            view->priv->current_ref = NULL;
+        }
 
-/* Record changes */
-gboolean
-gnc_tree_view_split_reg_enter (GncTreeViewSplitReg *view)
-{
-    GtkTreePath       *path;
-    GtkTreeViewColumn *col_current;
+        temp_mpath = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), temp_spath);
 
-    gtk_tree_view_get_cursor (GTK_TREE_VIEW (view), &path, &col_current);
+        view->priv->current_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), temp_mpath);
 
-g_print("gnc_tree_view_split_reg_enter column title is %s\n", gtk_tree_view_column_get_title (col_current));
+        gnc_tree_view_split_reg_block_selection (view, FALSE);
 
-    /* Make sure we have stopped editing */
-    if (col_current != NULL)
-        finish_edit (col_current);
+        gtk_tree_path_free (temp_mpath);
+    }
+    else
+        gtk_tree_view_collapse_row (GTK_TREE_VIEW (view), temp_spath);
 
-    gtk_tree_path_free (path);
+    gtk_tree_path_free (temp_spath);
+    gtk_tree_path_free (mpath);
+    gtk_tree_path_free (spath);
 
-    //Ask for confirmation if data has been edited, transaction_changed_confirm return TRUE if canceled
-    if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view), "data-edited")) && transaction_changed_confirm (view, NULL))
-    {
-        return FALSE;
-    }
-    return TRUE;
+    view->priv->expanded = FALSE;
+    LEAVE(" ");
 }
 
 
-/* Expands or collapse the current transaction */
+/* Expands the transaction or the current transaction if NULL */
 void
-gnc_tree_view_split_reg_expand_current_trans (GncTreeViewSplitReg *view, gboolean expand)
+gnc_tree_view_split_reg_expand_trans (GncTreeViewSplitReg *view, Transaction *trans)
 {
     GncTreeModelSplitReg *model;
-    GtkTreePath *path;
-    gint *indices;
-    RowDepth depth;
+    GtkTreePath *mpath, *spath;
 
-g_print("\ngnc_tree_view_split_reg_expand_current_trans and expand is %d\n", expand);
+    ENTER("gnc_tree_view_split_reg_expand_trans and trans is %p", trans);
 
     model = get_split_reg_model_from_view (view);
 
-    if (expand)
-        gtk_tree_view_expand_row (GTK_TREE_VIEW (view), view->priv->current_path, TRUE);
+    /* Make sure we have stopped editing */
+    gnc_tree_view_split_reg_finish_edit (view);
+
+    if (trans == NULL)
+        mpath = gtk_tree_row_reference_get_path (view->priv->current_ref);
     else
-    {
-        /* Colapse the view back to the transaction */
-        indices = gtk_tree_path_get_indices (view->priv->current_path);
-        depth = gtk_tree_path_get_depth (view->priv->current_path);
+        mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, trans);
 
-        gnc_tree_view_split_reg_block_selection (view, TRUE);
+    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
-        if (model->use_double_line)
-            path =  gtk_tree_path_new_from_indices (indices[0], 0, -1);
-        else
-            path = gtk_tree_path_new_from_indices (indices[0], -1);
+    gtk_tree_view_expand_row (GTK_TREE_VIEW (view), spath, TRUE);
 
-        gtk_tree_view_collapse_row (GTK_TREE_VIEW (view), path);
+    view->priv->expanded = TRUE;
 
-        gtk_tree_path_free (path);
+    if (SELECTION_TO_BLANK_ON_EXPAND && (model->style != REG2_STYLE_JOURNAL))
+        gtv_selection_to_blank (view);
 
-        gnc_tree_view_split_reg_block_selection (view, FALSE);
+    gtk_tree_path_free (mpath);
+    gtk_tree_path_free (spath);
 
-        /* Change the selection to last available row of transaction */
-        if ((model->use_double_line) && (depth != TRANS1))
-            path =  gtk_tree_path_new_from_indices (indices[0], 0, -1);
-        else
-            path = gtk_tree_path_new_from_indices (indices[0], -1);
+    LEAVE(" ");
+}
 
-        gtk_tree_path_free (view->priv->current_path);
-        view->priv->current_path = gtk_tree_path_copy (path);
 
-        gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), path);
-
-        gtk_tree_path_free (path);
-    }
+/* Returns the parent Window */
+GtkWidget *
+gnc_tree_view_split_reg_get_parent (GncTreeViewSplitReg *view)
+{
+    GncTreeModelSplitReg *model;
+    model = get_split_reg_model_from_view (view);
+    return gnc_tree_model_split_reg_get_parent (model);
 }
 
 
 /* This sets up the page gui update from the tree view motion callback */
-void gnc_tree_view_split_reg_moved_cb (GncTreeViewSplitReg *view, GFunc cb, gpointer cb_data)
+void
+gnc_tree_view_split_reg_moved_cb (GncTreeViewSplitReg *view, GFunc cb, gpointer cb_data)
 {
     view->moved_cb = cb;
     view->moved_cb_data = cb_data;

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.h	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -2,8 +2,8 @@
  * gnc-tree-view-split-reg.h -- GtkTreeView implementation to       *
  *                     display registers   in a GtkTreeView.        *
  *                                                                  *
+ * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
  * Copyright (C) 2012 Robert Fewell                                 *
- * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker at cox.net>    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -48,14 +48,21 @@
 
 typedef struct
 {
-    GncTreeView gnc_tree_view;
+    GncTreeView                 gnc_tree_view;
     GncTreeViewSplitRegPrivate *priv;
-    int stamp;
+    int                         stamp;
 
-    GFunc moved_cb;
-    gpointer moved_cb_data;
+    GtkWidget                  *window;                   // Parent Window.
+    GFunc                       moved_cb;                 // Used for page gui update
+    gpointer                    moved_cb_data;            // Used for page gui update
 
-    gchar *help_text;
+    gchar                      *help_text;                // This is the help text to be displayed.
+    gint                        sort_depth;               // This is the row the sort direction is based on.
+    gint                        sort_col;                 // This is the column the sort direction is based on.
+    gint                        sort_direction;           // This is the direction of sort, 1 for ascending or -1 rest
+    gboolean                    reg_closing;              // This is set when closing the register.
+    gboolean                    change_allowed;           // This is set when we allow the reconciled split to change.
+    gboolean                    editing_now;              // This is set while editing of a cell.
 
 } GncTreeViewSplitReg;
 
@@ -78,6 +85,7 @@
     SPLIT3, //3
 }RowDepth;
 
+
 /* Standard g_object type */
 GType gnc_tree_view_split_reg_get_type (void);
 
@@ -89,44 +97,50 @@
 
 void gnc_tree_view_split_reg_set_read_only (GncTreeViewSplitReg *view, gboolean read_only);
 
-/*************************************************************************************/
+void gnc_tree_view_split_reg_set_value_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input, gboolean force);
 
+void gnc_tree_view_split_reg_set_dirty_trans (GncTreeViewSplitReg *view, Transaction *trans);
+
+Transaction * gnc_tree_view_split_reg_get_current_trans (GncTreeViewSplitReg *view);
+
 Split * gnc_tree_view_split_reg_get_current_split (GncTreeViewSplitReg *view);
 
-Split * gnc_tree_view_split_reg_get_blank_split (GncTreeViewSplitReg *view);
+Transaction * gnc_tree_view_split_reg_get_dirty_trans (GncTreeViewSplitReg *view);
 
-Split * gnc_tree_view_reg_get_current_trans_split (GncTreeViewSplitReg *view);
+void gnc_tree_view_split_reg_set_current_path (GncTreeViewSplitReg *view, GtkTreePath *path);
 
+GtkTreePath * gnc_tree_view_split_reg_get_current_path (GncTreeViewSplitReg *view);
+
 RowDepth gnc_tree_view_reg_get_selected_row_depth (GncTreeViewSplitReg *view);
 
-void gnc_tree_view_split_reg_delete_current_split (GncTreeViewSplitReg *view);
+void gnc_tree_view_split_reg_moved_cb (GncTreeViewSplitReg *view, GFunc cb, gpointer cb_data);
 
-void gnc_tree_view_split_reg_delete_current_trans (GncTreeViewSplitReg *view);
+void gnc_tree_view_split_reg_refresh_from_gconf (GncTreeViewSplitReg *view);
 
-void gnc_tree_view_split_reg_jump_to_blank (GncTreeViewSplitReg *view);
+GtkWidget * gnc_tree_view_split_reg_get_parent (GncTreeViewSplitReg *view);
 
-void gnc_tree_view_split_reg_jump_to_split (GncTreeViewSplitReg *view, Split *split);
+gboolean gnc_tree_view_split_reg_trans_expanded (GncTreeViewSplitReg *view, Transaction *trans);
 
-void gnc_tree_view_split_reg_reinit_trans (GncTreeViewSplitReg *view);
+void gnc_tree_view_split_reg_expand_trans (GncTreeViewSplitReg *view, Transaction *trans);
 
-void gnc_tree_view_split_reg_goto_rel_trans_row (GncTreeViewSplitReg *view, gint relative);
+void gnc_tree_view_split_reg_collapse_trans (GncTreeViewSplitReg *view, Transaction *trans);
 
-gboolean gnc_tree_view_split_reg_enter (GncTreeViewSplitReg *view);
 
-gboolean gnc_tree_view_split_reg_current_trans_expanded (GncTreeViewSplitReg *view);
+/*************************************************************************************/
 
-Transaction * gnc_tree_view_split_reg_get_current_trans (GncTreeViewSplitReg *view);
+void gnc_tree_view_split_reg_delete_current_split (GncTreeViewSplitReg *view);
 
-void gnc_tree_view_split_reg_cancel_edit (GncTreeViewSplitReg *view);
+void gnc_tree_view_split_reg_delete_current_trans (GncTreeViewSplitReg *view);
 
-void gnc_tree_view_split_reg_expand_current_trans (GncTreeViewSplitReg *view, gboolean expand);
+void gnc_tree_view_split_reg_reinit_trans (GncTreeViewSplitReg *view);
 
-void gnc_tree_view_split_reg_moved_cb (GncTreeViewSplitReg *view, GFunc cb, gpointer cb_data);
+gboolean gnc_tree_view_split_reg_enter (GncTreeViewSplitReg *view);
 
-void gnc_tree_view_split_reg_void_current_trans (GncTreeViewSplitReg *view, const char *reason);
+void gnc_tree_view_split_reg_cancel_edit (GncTreeViewSplitReg *view, gboolean reg_closing);
 
-void gnc_tree_view_split_reg_unvoid_current_trans (GncTreeViewSplitReg *view);
+void gnc_tree_view_split_reg_finish_edit (GncTreeViewSplitReg *view);
 
+
 G_END_DECLS
 
 #endif /* __GNC_TREE_VIEW_SPLIT_REG_H */

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -111,6 +111,9 @@
     GtkWidget         *column_menu;
     gboolean           show_column_menu;
 
+    /* Sort callback user_data */
+    gpointer           sort_user_data;
+
     /* Gconf related values */
     gchar             *gconf_section;
     gboolean           seen_gconf_visibility;
@@ -235,6 +238,7 @@
     priv = GNC_TREE_VIEW_GET_PRIVATE(view);
     priv->column_menu = NULL;
     priv->show_column_menu = FALSE;
+    priv->sort_user_data = NULL;
     priv->gconf_section = NULL;
     priv->seen_gconf_visibility = FALSE;
     priv->columns_changed_cb_id = 0;
@@ -954,6 +958,7 @@
     if (!gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(s_model),
             &current, &order))
         order = GTK_SORT_ASCENDING;
+
     g_signal_handler_block(s_model, priv->sort_column_changed_cb_id);
     gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
                                          model_column, order);
@@ -1053,6 +1058,7 @@
     priv = GNC_TREE_VIEW_GET_PRIVATE(view);
     key = gconf_entry_get_key(entry);
     value = gconf_entry_get_value(entry);
+
     if (!value)
     {
         /* Values can be unset */
@@ -1601,11 +1607,70 @@
     va_end (args);
 
     gtk_tree_view_column_set_visible (priv->spacer_column, !hide_spacer);
-    gtk_tree_view_column_set_visible (priv->selection_column, !hide_spacer);
 
     LEAVE(" ");
 }
 
+
+/* Links the cell backgrounds of the two control columns to the model or
+   cell data function */
+static void
+update_control_cell_renderers_background (GncTreeView *view, GtkTreeViewColumn *col, gint column, GtkTreeCellDataFunc func )
+{
+    GList *renderers;
+    GtkCellRenderer *cell;
+    GList *node;
+
+    renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col));
+
+    /* Update the cell background in the list of renderers */
+    for (node = renderers; node; node = node->next)
+    {
+        cell = node->data;
+        if (func == NULL)
+            gtk_tree_view_column_add_attribute (col, cell, "cell-background", column);
+        else
+            gtk_tree_view_column_set_cell_data_func (col, cell, func, view, NULL);
+    }
+    g_list_free (renderers);
+}
+
+
+/* This function links the cell backgrounds of the two control columns to a column
+   in the model that has color strings or a cell data function */
+void
+gnc_tree_view_set_control_column_background (GncTreeView *view, gint column, GtkTreeCellDataFunc func )
+{
+    GncTreeViewPrivate *priv;
+
+    g_return_if_fail (GNC_IS_TREE_VIEW (view));
+
+    ENTER("view %p, column %d, func %p", view, column, func);
+    priv = GNC_TREE_VIEW_GET_PRIVATE (view);
+
+    update_control_cell_renderers_background (view, priv->spacer_column, column, func);
+    update_control_cell_renderers_background (view, priv->selection_column, column, func);
+
+    LEAVE(" ");
+}
+
+
+/* This set the user_data value used in the sort callback */
+void
+gnc_tree_view_set_sort_user_data (GncTreeView *view, gpointer user_data)
+{
+    GncTreeViewPrivate *priv;
+
+    g_return_if_fail (GNC_IS_TREE_VIEW (view));
+
+    ENTER("view %p, user_data %p", view, user_data);
+    priv = GNC_TREE_VIEW_GET_PRIVATE (view);
+
+    priv->sort_user_data = user_data;
+    LEAVE(" ");
+}
+
+
 /** This function is called to set the "show-column-menu" property on
  *  this view.  This function has no visible effect if the
  *  "gconf-section" property has not been set.
@@ -1838,8 +1903,15 @@
         gtk_tree_view_column_set_sort_column_id (column, data_column);
         if (column_sort_fn)
         {
-            gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE(s_model),
+            priv = GNC_TREE_VIEW_GET_PRIVATE(view);
+            if (priv->sort_user_data != NULL)
+                gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE(s_model),
                                              data_column, column_sort_fn,
+                                             priv->sort_user_data,
+                                             NULL /* destroy fn */);
+            else
+                gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE(s_model),
+                                             data_column, column_sort_fn,
                                              GINT_TO_POINTER(data_column),
                                              NULL /* destroy fn */);
         }

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view.h	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -383,10 +383,41 @@
  */
 const gchar *gnc_tree_view_get_gconf_section (GncTreeView *view);
 
+/** This function set the columns that will be allocated the free space
+ *  in the view.
+ *
+ *  @param view The tree view.
+ *
+ *  @param list of column names.
+ */
 void gnc_tree_view_expand_columns (GncTreeView *view,
                                    gchar *first_column_name,
                                    ...);
 
+/** This function links the cell backgrounds of the two control columns
+ *  to a column in the model that has color strings or a cell data function
+ *  that sets the "cell-background" property.
+ *
+ *  @param view The tree view.
+ *
+ *  @param column The column in the model containg color strings.
+ *
+ *  @param func This is a cell data function that sets the "cell-background".
+ */
+void
+gnc_tree_view_set_control_column_background (GncTreeView *view, gint column,
+                                             GtkTreeCellDataFunc func);
+
+
+/** This function sets the user_data value used in the sort callback
+ *
+ *  @param view The tree view.
+ *
+ *  @param user_data pointer to the user_data to be used.
+ */
+void
+gnc_tree_view_set_sort_user_data (GncTreeView *view, gpointer user_data);
+
 /** This function is called to set the "show-column-menu" property on
  *  this view.  This function has no visible effect if the
  *  "gconf-section" property has not been set.

Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.c	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.c	2013-02-28 09:52:12 UTC (rev 22815)
@@ -4,6 +4,7 @@
  *                                                                  *
  * Copyright (C) 1997 Robin D. Clark                                *
  * Copyright (C) 1997, 1998 Linas Vepstas                           *
+ * Copyright (C) 2012 Robert Fewell                                 *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -614,7 +615,7 @@
      */
     splits = qof_query_run (ld->query);
 
-//    gnc_ledger_display2_set_watches (ld, splits);
+//FIXME Not Needed ?    gnc_ledger_display2_set_watches (ld, splits);
 
     gnc_ledger_display2_refresh_internal (ld, splits);
     LEAVE(" ");
@@ -625,9 +626,11 @@
 {
     GNCLedgerDisplay2 *ld = user_data;
 
+
+    ENTER(" ");
     if (!ld)
         return;
-//g_print("ledger close_handler\n");
+
     gnc_unregister_gui_component (ld->component_id);
 
     if (ld->destroy)
@@ -640,6 +643,7 @@
     qof_query_destroy (ld->query);
     ld->query = NULL;
 
+    LEAVE(" ");
     g_free (ld);
 }
 
@@ -822,12 +826,12 @@
 
     gnc_tree_model_split_reg_set_data (ld->model, ld, gnc_ledger_display2_parent);
 
-    g_signal_connect (G_OBJECT (ld->model), "refresh_signal",
-                      G_CALLBACK ( gnc_ledger_display2_refresh_cb ), ld );
+//FIXME Not Needed ?    g_signal_connect (G_OBJECT (ld->model), "refresh_signal",
+//                      G_CALLBACK ( gnc_ledger_display2_refresh_cb ), ld );
 
     splits = qof_query_run (ld->query);
 
-//    gnc_ledger_display2_set_watches (ld, splits);
+//FIXME Not Needed ?    gnc_ledger_display2_set_watches (ld, splits);
 
     gnc_ledger_display2_refresh_internal (ld, splits);
 
@@ -880,10 +884,6 @@
 static void
 gnc_ledger_display2_refresh_internal (GNCLedgerDisplay2 *ld, GList *splits)
 {
-    GtkTreeModel *smodel, *model;
-
-g_print("gnc_ledger_display2_refresh_internal ledger %p and splits %p\n", ld, splits);
-
     if (!ld || ld->loading)
         return;
 
@@ -896,32 +896,10 @@
     else
     {
         ld->loading = TRUE;
-/*FIXME All this may not be required !!!!! */
-        smodel =  gtk_tree_view_get_model (GTK_TREE_VIEW (ld->view)); // this is the sort model
 
-        model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (smodel)); // our model
-//g_print("view is %p model is %p and smodel is %p\n", ld->view, model, smodel);
-        g_object_ref (smodel);
-        g_object_ref (model);
-
-        gnc_tree_view_split_reg_block_selection (ld->view, TRUE); // This blocks the tree selection
-
-        gtk_tree_view_set_model (GTK_TREE_VIEW (ld->view), NULL); // Detach sort model from view
-
-        gnc_tree_model_split_reg_load (ld->model, splits, gnc_ledger_display2_leader (ld)); //reload splits
-
-//Not needed        smodel = gtk_tree_model_sort_new_with_model (model); // create new sort model
-
-        gtk_tree_view_set_model (GTK_TREE_VIEW(ld->view), GTK_TREE_MODEL (smodel)); // Re-attach sort model to view
-//g_print("view is %p model is %p and smodel is %p\n", ld->view, model, smodel);
-        gnc_tree_view_split_reg_block_selection (ld->view, FALSE); // This unblocks the tree selection
-
         /* Set the default selection start position */
         gnc_tree_view_split_reg_default_selection (ld->view);
 
-        g_object_unref (model);
-        g_object_unref (smodel);
-
         ld->loading = FALSE;
     }
 }
@@ -1001,7 +979,6 @@
 gnc_ledger_display2_refresh_cb (GncTreeModelSplitReg *model, gpointer user_data)
 {
     GNCLedgerDisplay2 *ld = user_data;
-//g_print("refresh model %p user_data %p\n", model,  user_data);
 
     /* Refresh the view when idle */
     g_idle_add ((GSourceFunc)gnc_ledger_display2_refresh, ld);
@@ -1013,6 +990,6 @@
 {
     if (!ld)
         return;
-//g_print("gnc_ledger_display2_close\n");
+
     gnc_close_gui_component (ld->component_id);
 }

Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.h	2013-02-27 23:31:35 UTC (rev 22814)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.h	2013-02-28 09:52:12 UTC (rev 22815)
@@ -5,6 +5,7 @@
  * Copyright (C) 1997 Robin D. Clark                                *
  * Copyright (C) 1997, 1998 Linas Vepstas                           *
  * Copyright (C) 2001 Linux Developers Group                        *
+ * Copyright (C) 2012 Robert Fewell                                 *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *



More information about the gnucash-changes mailing list