gnucash master: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Sun May 3 07:20:20 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/7483d501 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3d2974d9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9faba45f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/79501e58 (commit)
	from  https://github.com/Gnucash/gnucash/commit/624a2d80 (commit)



commit 7483d5014152e9b6868beea08e0caf2cf5aa0b34
Merge: 624a2d809 3d2974d97
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun May 3 12:11:57 2020 +0100

    Merge Chris Good's branch 'bug797236RecMas', PR #707 into master


commit 3d2974d97e1d20ad77389ebb835a546d3efad79c
Author: goodvibes2 <goodchris96 at gmail.com>
Date:   Sat May 2 11:51:04 2020 +1000

    Fix 2 comment typos in gnucash/gnome/window-reconcile.c

diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c
index 54185e846..f387bc69d 100644
--- a/gnucash/gnome/window-reconcile.c
+++ b/gnucash/gnome/window-reconcile.c
@@ -659,7 +659,7 @@ gnc_save_reconcile_interval(Account *account, time64 statement_date)
 
     /*
      * See if we need to remember days(weeks) or months.  The only trick
-     * value is 28 days which could be wither 4 weeks or 1 month.
+     * value is 28 days which could be either 4 weeks or 1 month.
      */
     if (days == 28)
     {
@@ -2120,7 +2120,7 @@ use Find Transactions to find them, unreconcile, and re-reconcile."));
 
 
 /********************************************************************\
- * gnc_ui_reconile_window_raise                                     *
+ * gnc_ui_reconcile_window_raise                                     *
  *   shows and raises an account editing window                     *
  *                                                                  *
  * Args:   editAccData - the edit window structure                  *

commit 9faba45fd5ec1a4f8db0d028e4cb0dea582492d5
Author: goodvibes2 <goodchris96 at gmail.com>
Date:   Sat May 2 11:41:29 2020 +1000

    Reconcile window - Retain position in split list after deletion
    
    The changes for Bug 797236 so that the last selected split is
    visible when the list is refreshed has no effect when the Delete
    button is used, as the selected split has been deleted.
    So preselect the next split after the split to be deleted.
    If no next split in the list, select the previous.
    The split preselected must have a different parent transaction to
    the split to be deleted, as all splits in the transaction will be
    deleted.

diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c
index 431c3f64c..54185e846 100644
--- a/gnucash/gnome/window-reconcile.c
+++ b/gnucash/gnome/window-reconcile.c
@@ -1320,12 +1320,93 @@ gnc_ui_reconcile_window_unrec_cb(GtkButton *button, gpointer data)
 }
 
 
+/** Get the debit or credit view that has at least 1 split selected.
+ *   gnc_reconcile_window_focus_cb() ensures only 1 view
+ *   has a selection.
+ * @param window The reconcile window.
+ */
+static GNCReconcileView *
+gnc_reconcile_window_get_selection_view (RecnWindow *recnData)
+{
+    if (gnc_reconcile_view_num_selected (GNC_RECONCILE_VIEW (recnData->debit)) > 0)
+        return GNC_RECONCILE_VIEW (recnData->debit);
+
+    if (gnc_reconcile_view_num_selected (GNC_RECONCILE_VIEW (recnData->credit)) > 0)
+        return GNC_RECONCILE_VIEW (recnData->credit);
+
+    return NULL;
+}
+
+
+/** Select the next split in the debit or credit view so that after the Delete
+ *   button is actioned, the working position in the list is still in view.
+ *  Unless this is done, the list will be scrolled to the top.
+ *  The new split selected must have a different parent transaction as all splits
+ *   for the transaction will be deleted.
+ */
+static void
+gnc_reconcile_window_delete_set_next_selection (RecnWindow *recnData, Split *split)
+{
+    GNCReconcileView *view = gnc_reconcile_window_get_selection_view (recnData);
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    Split *this_split = NULL;
+    GtkTreeIter iter;
+    GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+    GList *path_list, *node;
+    GtkTreePath *path, *save_del_path;
+    Transaction* trans = xaccSplitGetParent (split); // parent transaction of the split to delete
+
+    if (!view)
+        return; // no selected split
+
+    path_list = gtk_tree_selection_get_selected_rows (selection, &model);
+    // get path of the first split selected - there should be only 1 selected
+    node = g_list_first (path_list);
+    if (!node)
+        return;
+    path = node->data;
+    save_del_path = gtk_tree_path_copy (path);
+
+    gtk_tree_path_next (path);
+    if (gtk_tree_model_get_iter (model, &iter, path))
+    {
+        do
+        {
+            gtk_tree_model_get (model, &iter, REC_POINTER, &this_split, -1);
+        }
+        while (xaccSplitGetParent (this_split) == trans && gtk_tree_model_iter_next (model, &iter));
+    }
+
+    if ((!this_split) || xaccSplitGetParent (this_split) == trans)
+    {
+        // There aren't any splits for a different transaction after the split to be deleted,
+        //  so find the previous split having a different parent transaction
+        path = save_del_path; // split to be deleted
+        if (gtk_tree_path_prev (path) && gtk_tree_model_get_iter (model, &iter, path))
+        {
+            do
+            {
+                gtk_tree_model_get (model, &iter, REC_POINTER, &this_split, -1);
+            }
+            while (xaccSplitGetParent (this_split) == trans && gtk_tree_model_iter_previous (model, &iter));
+        }
+    }
+
+    gtk_tree_path_free (save_del_path);
+    g_list_free_full (path_list, (GDestroyNotify) gtk_tree_path_free);
+    if ((!this_split) || xaccSplitGetParent (this_split) == trans)
+        return;
+
+    gtk_tree_selection_select_iter (selection, &iter);
+}
+
+
 static void
 gnc_ui_reconcile_window_delete_cb(GtkButton *button, gpointer data)
 {
     RecnWindow *recnData = data;
     Transaction *trans;
-    Split *split;
+    Split *split, *next_split;
 
     split = gnc_reconcile_window_get_current_split(recnData);
     /* This should never be true, but be paranoid */
@@ -1343,6 +1424,9 @@ gnc_ui_reconcile_window_delete_cb(GtkButton *button, gpointer data)
             return;
     }
 
+    /* select the split that should be visible after the deletion */
+    gnc_reconcile_window_delete_set_next_selection(recnData, split);
+
     gnc_suspend_gui_refresh ();
 
     trans = xaccSplitGetParent(split);

commit 79501e58ddf70776b528e5ba7ae4d77485b61362
Author: goodvibes2 <goodchris96 at gmail.com>
Date:   Sat May 2 11:17:29 2020 +1000

    Bug 797236 - Reconciliation - Retain visibility of selected split.
    
    Ensure selected split (or last selected if multiples selected), is
    visible after all operations when the list is refreshed.

diff --git a/gnucash/gnome/reconcile-view.c b/gnucash/gnome/reconcile-view.c
index d600bca9c..61ddd07f4 100644
--- a/gnucash/gnome/reconcile-view.c
+++ b/gnucash/gnome/reconcile-view.c
@@ -901,6 +901,8 @@ void
 gnc_reconcile_view_refresh (GNCReconcileView *view)
 {
     GNCQueryView *qview;
+    GtkTreeSelection *selection;
+    GList *path_list, *node;
 
     g_return_if_fail (view != NULL);
     g_return_if_fail (GNC_IS_RECONCILE_VIEW (view));
@@ -908,6 +910,18 @@ gnc_reconcile_view_refresh (GNCReconcileView *view)
     qview = GNC_QUERY_VIEW (view);
     gnc_query_view_refresh (qview);
 
+    /* Ensure last selected split, if any, can be seen */
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (qview));
+    path_list = gtk_tree_selection_get_selected_rows (selection, NULL);
+    node = g_list_last (path_list);
+    if (node)
+    {
+        GtkTreePath *tree_path = node->data;
+        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (qview),
+                                      tree_path, NULL, FALSE, 0.0, 0.0);
+    }
+    g_list_free_full (path_list, (GDestroyNotify) gtk_tree_path_free);
+
     /* Now verify that everything in the reconcile hash is still in qview */
     if (view->reconciled)
         g_hash_table_foreach (view->reconciled, grv_refresh_helper, view);



Summary of changes:
 gnucash/gnome/reconcile-view.c   | 14 +++++++
 gnucash/gnome/window-reconcile.c | 90 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 101 insertions(+), 3 deletions(-)



More information about the gnucash-changes mailing list