gnucash maint: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Sun Sep 9 14:25:05 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/ef56e7cc (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6e023755 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/74f285d7 (commit)
	from  https://github.com/Gnucash/gnucash/commit/f8a9be2c (commit)



commit ef56e7cc76cb5504e1a67eb34d7c9f3afb0c5254
Merge: f8a9be2 6e02375
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Sep 9 11:19:38 2018 -0700

    Merge Bob Fewell's 'Bug796839' into maint.


commit 6e023755dd5653031ddbc247c1736ac50167844f
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 7 20:05:16 2018 +0100

    Reduce the number of times the register loads - Update
    
    In the previous update the changes to 'double_line mode' and 'register
    style' were not catered for so this commit fixes that by using a stored
    value 'enable_refresh' in the GncPluginPageRegister. This value is used
    to enable/disable the triggering of gnc_ledger_display_refresh command
    instead of passing a parameter as these settings are triggered by call
    backs. The value is set to FALSE in ...recreate_page before restoring
    all settings and subsequently set to TRUE after so normal refreshing
    can occur. This reduces the potential number of refreshes on load from
    7 to 2.

diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c
index a3d040c..229894a 100644
--- a/gnucash/gnome/gnc-plugin-page-register.c
+++ b/gnucash/gnome/gnc-plugin-page-register.c
@@ -139,8 +139,8 @@ static gchar *gnc_plugin_page_register_get_filter (GncPluginPage *plugin_page);
 void gnc_plugin_page_register_set_filter (GncPluginPage *plugin_page, const gchar *filter);
 static void gnc_plugin_page_register_set_filter_tooltip (GncPluginPageRegister *page);
 
-static void gnc_ppr_update_status_query (GncPluginPageRegister *page, gboolean refresh);
-static void gnc_ppr_update_date_query (GncPluginPageRegister *page, gboolean refresh);
+static void gnc_ppr_update_status_query (GncPluginPageRegister *page);
+static void gnc_ppr_update_date_query (GncPluginPageRegister *page);
 
 /* Command callbacks */
 static void gnc_plugin_page_register_cmd_print_check (GtkAction *action, GncPluginPageRegister *plugin_page);
@@ -548,6 +548,7 @@ typedef struct GncPluginPageRegisterPrivate
 
     gint lines_default;
     gboolean read_only;
+    gboolean enable_refresh; // used to reduce ledger display refreshes
     Query *search_query;     // saved search query for comparison
     Query *filter_query;     // saved filter query for comparison
 
@@ -808,6 +809,7 @@ gnc_plugin_page_register_init (GncPluginPageRegister *plugin_page)
     priv->read_only         = FALSE;
     priv->fd.cleared_match  = CLEARED_ALL;
     priv->fd.days           = 0;
+    priv->enable_refresh    = TRUE;
     priv->search_query      = NULL;
     priv->filter_query      = NULL;
 }
@@ -1119,6 +1121,7 @@ gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page)
     gchar **filter;
     gchar *order;
     int filter_changed = 0;
+    gboolean create_new_page = FALSE;
 
     ENTER("page %p", plugin_page);
     page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
@@ -1263,12 +1266,24 @@ gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page)
         priv->fd.end_time = end_time;
     }
 
+    // if enable_refresh is TRUE, default, come from creating
+    // new page instead of restoring
+    if (priv->enable_refresh == TRUE)
+    {
+        create_new_page = TRUE;
+        priv->enable_refresh = FALSE; // disable refresh
+    }
+
     /* Update Query with Filter Status and Dates */
-    gnc_ppr_update_status_query (page, FALSE);
-    gnc_ppr_update_date_query(page, FALSE);
+    gnc_ppr_update_status_query (page);
+    gnc_ppr_update_date_query (page);
 
-    /* Now do the refresh */
-    gnc_ledger_display_refresh(priv->ledger);
+    /* Now do the refresh if this is a new page instaed of restore */
+    if (create_new_page)
+    {
+        priv->enable_refresh = TRUE;
+        gnc_ledger_display_refresh (priv->ledger);
+    }
 
     // Set filter tooltip for summary bar
     gnc_plugin_page_register_set_filter_tooltip (page);
@@ -1558,6 +1573,7 @@ gnc_plugin_page_register_recreate_page (GtkWidget *window,
                                         GKeyFile *key_file,
                                         const gchar *group_name)
 {
+    GncPluginPageRegisterPrivate *priv;
     GncPluginPage *page;
     GError *error = NULL;
     gchar *reg_type, *acct_guid;
@@ -1615,6 +1631,11 @@ gnc_plugin_page_register_recreate_page (GtkWidget *window,
     }
     g_free(reg_type);
 
+    /* disable the refresh of the display ledger, this is for
+     * sort/filter updates and double line/style changes */
+    priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
+    priv->enable_refresh = FALSE;
+
     /* Recreate page in given window */
     gnc_plugin_page_set_use_new_window(page, FALSE);
 
@@ -1623,6 +1644,10 @@ gnc_plugin_page_register_recreate_page (GtkWidget *window,
 
     /* Now update the page to the last state it was in */
     gnc_plugin_page_register_restore_edit_menu(page, key_file, group_name);
+
+    /* enable the refresh */
+    priv->enable_refresh = TRUE;
+    gnc_ledger_display_refresh (priv->ledger);
     LEAVE(" ");
     return page;
 }
@@ -2420,7 +2445,7 @@ gnc_ppr_update_for_search_query (GncPluginPageRegister *page)
  *  associated with this filter dialog.
  */
 static void
-gnc_ppr_update_status_query (GncPluginPageRegister *page, gboolean refresh)
+gnc_ppr_update_status_query (GncPluginPageRegister *page)
 {
     GncPluginPageRegisterPrivate *priv;
     GSList *param_list;
@@ -2465,7 +2490,7 @@ gnc_ppr_update_status_query (GncPluginPageRegister *page, gboolean refresh)
     qof_query_destroy (priv->filter_query);
     priv->filter_query = qof_query_copy (query);
 
-    if (refresh)
+    if (priv->enable_refresh)
         gnc_ledger_display_refresh (priv->ledger);
     LEAVE(" ");
 }
@@ -2484,7 +2509,7 @@ gnc_ppr_update_status_query (GncPluginPageRegister *page, gboolean refresh)
  *  associated with this filter dialog.
  */
 static void
-gnc_ppr_update_date_query (GncPluginPageRegister *page, gboolean refresh)
+gnc_ppr_update_date_query (GncPluginPageRegister *page)
 {
     GncPluginPageRegisterPrivate *priv;
     GSList *param_list;
@@ -2543,12 +2568,11 @@ gnc_ppr_update_date_query (GncPluginPageRegister *page, gboolean refresh)
     // Set filter tooltip for summary bar
     gnc_plugin_page_register_set_filter_tooltip (page);
 
-
     // clear previous filter query and save current
     qof_query_destroy (priv->filter_query);
     priv->filter_query = qof_query_copy (query);
 
-    if (refresh)
+    if (priv->enable_refresh)
         gnc_ledger_display_refresh (priv->ledger);
     LEAVE(" ");
 }
@@ -2630,7 +2654,7 @@ gnc_plugin_page_register_filter_status_one_cb (GtkToggleButton *button,
         priv->fd.cleared_match |= value;
     else
         priv->fd.cleared_match &= ~value;
-    gnc_ppr_update_status_query(page, TRUE);
+    gnc_ppr_update_status_query(page);
     LEAVE(" ");
 }
 
@@ -2669,7 +2693,7 @@ gnc_plugin_page_register_filter_status_all_cb (GtkButton *button,
     /* Set the requested status */
     priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
     priv->fd.cleared_match = CLEARED_ALL;
-    gnc_ppr_update_status_query(page, TRUE);
+    gnc_ppr_update_status_query(page);
     LEAVE(" ");
 }
 
@@ -2777,7 +2801,7 @@ gnc_plugin_page_register_filter_select_range_cb (GtkRadioButton *button,
         priv->fd.start_time = 0;
         priv->fd.end_time = 0;
     }
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_query(page);
     LEAVE(" ");
 }
 
@@ -2805,7 +2829,7 @@ gnc_plugin_page_register_filter_days_changed_cb (GtkSpinButton *button,
     priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
 
     priv->fd.days = gtk_spin_button_get_value(GTK_SPIN_BUTTON(button));
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_query(page);
     LEAVE(" ");
 }
 
@@ -2828,7 +2852,7 @@ gnc_plugin_page_register_filter_gde_changed_cb (GtkWidget *unused,
 
     ENTER("(widget %s(%p), page %p)", gtk_buildable_get_name(GTK_BUILDABLE(unused)), unused, page);
     get_filter_times(page);
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_query(page);
     LEAVE(" ");
 }
 
@@ -2875,7 +2899,7 @@ gnc_plugin_page_register_filter_start_cb (GtkWidget *radio,
     active = ( g_strcmp0(name, g_strdup("start_date_choose")) == 0 ? 1 : 0 );
     gtk_widget_set_sensitive(priv->fd.start_date, active);
     get_filter_times(page);
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_query(page);
     LEAVE(" ");
 }
 
@@ -2922,7 +2946,7 @@ gnc_plugin_page_register_filter_end_cb (GtkWidget *radio,
     active = ( g_strcmp0(name, g_strdup("end_date_choose")) == 0 ? 1 : 0 );
     gtk_widget_set_sensitive(priv->fd.end_date, active);
     get_filter_times(page);
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_query(page);
     LEAVE(" ");
 }
 
@@ -2986,12 +3010,14 @@ gnc_plugin_page_register_filter_response_cb (GtkDialog *dialog,
     {
         /* Remove the old status match */
         priv->fd.cleared_match = priv->fd.original_cleared_match;
-        gnc_ppr_update_status_query(page, FALSE);
+        priv->enable_refresh = FALSE;
+        gnc_ppr_update_status_query(page);
+        priv->enable_refresh = TRUE;
         priv->fd.start_time = priv->fd.original_start_time;
         priv->fd.end_time = priv->fd.original_end_time;
         priv->fd.days = priv->fd.original_days;
         priv->fd.save_filter = priv->fd.original_save_filter;
-        gnc_ppr_update_date_query(page, TRUE);
+        gnc_ppr_update_date_query(page);
     }
     else
     {
@@ -4026,7 +4052,7 @@ gnc_plugin_page_register_cmd_style_changed (GtkAction *action,
 
     priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(plugin_page);
     value = gtk_radio_action_get_current_value(current);
-    gnc_split_reg_change_style(priv->gsr, value);
+    gnc_split_reg_change_style(priv->gsr, value, priv->enable_refresh);
 
     gnc_plugin_page_register_ui_update (NULL, plugin_page);
     LEAVE(" ");
@@ -4052,7 +4078,8 @@ gnc_plugin_page_register_cmd_style_double_line (GtkToggleAction *action,
     if (use_double_line != reg->use_double_line)
     {
         gnc_split_register_config(reg, reg->type, reg->style, use_double_line);
-        gnc_ledger_display_refresh(priv->ledger);
+        if (priv->enable_refresh)
+            gnc_ledger_display_refresh(priv->ledger);
     }
     LEAVE(" ");
 }
diff --git a/gnucash/gnome/gnc-split-reg.c b/gnucash/gnome/gnc-split-reg.c
index a82c603..d42e518 100644
--- a/gnucash/gnome/gnc-split-reg.c
+++ b/gnucash/gnome/gnc-split-reg.c
@@ -1749,7 +1749,7 @@ gnc_split_reg_jump_cb( GtkWidget *widget, gpointer data )
 }
 
 void
-gnc_split_reg_change_style (GNCSplitReg *gsr, SplitRegisterStyle style)
+gnc_split_reg_change_style (GNCSplitReg *gsr, SplitRegisterStyle style, gboolean refresh)
 {
     SplitRegister *reg = gnc_ledger_display_get_split_register (gsr->ledger);
 
@@ -1757,7 +1757,8 @@ gnc_split_reg_change_style (GNCSplitReg *gsr, SplitRegisterStyle style)
         return;
 
     gnc_split_register_config (reg, reg->type, style, reg->use_double_line);
-    gnc_ledger_display_refresh (gsr->ledger);
+    if (refresh)
+        gnc_ledger_display_refresh (gsr->ledger);
 }
 
 void
@@ -1768,7 +1769,7 @@ gnc_split_reg_style_ledger_cb (GtkWidget *w, gpointer data)
     if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(w)))
         return;
 
-    gnc_split_reg_change_style (gsr, REG_STYLE_LEDGER);
+    gnc_split_reg_change_style (gsr, REG_STYLE_LEDGER, TRUE);
 }
 
 void
@@ -1779,7 +1780,7 @@ gnc_split_reg_style_auto_ledger_cb (GtkWidget *w, gpointer data)
     if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(w)))
         return;
 
-    gnc_split_reg_change_style (gsr, REG_STYLE_AUTO_LEDGER);
+    gnc_split_reg_change_style (gsr, REG_STYLE_AUTO_LEDGER, TRUE);
 }
 
 void
@@ -1790,7 +1791,7 @@ gnc_split_reg_style_journal_cb (GtkWidget *w, gpointer data)
     if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(w)))
         return;
 
-    gnc_split_reg_change_style (gsr, REG_STYLE_JOURNAL);
+    gnc_split_reg_change_style (gsr, REG_STYLE_JOURNAL, TRUE);
 }
 
 void
diff --git a/gnucash/gnome/gnc-split-reg.h b/gnucash/gnome/gnc-split-reg.h
index 09ffc73..af22ef4 100644
--- a/gnucash/gnome/gnc-split-reg.h
+++ b/gnucash/gnome/gnc-split-reg.h
@@ -206,13 +206,15 @@ void gnc_split_reg_set_sort_type_force( GNCSplitReg *gsr, SortType t, gboolean f
 /**
  * Set/get sort order of register
  **/
-void gnc_split_reg_set_sort_reversed(GNCSplitReg *gsr, gboolean rev, gboolean refresh);
+void gnc_split_reg_set_sort_reversed(GNCSplitReg *gsr,
+                                     gboolean rev, gboolean refresh);
 
 
 /**
  * Gets/sets the style of the GNCSplitReg.
  **/
-void gnc_split_reg_change_style (GNCSplitReg *gsr, SplitRegisterStyle style);
+void gnc_split_reg_change_style (GNCSplitReg *gsr,
+                                 SplitRegisterStyle style, gboolean refresh);
 
 /**
  * Can return NULL if the indicated subwidget was not created.

commit 74f285d78c0849420dda814679359c0c054db28c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Sep 7 19:32:43 2018 +0100

    Bug 796839 - Find transaction won't filter on Date Posted
    
    The results of the find are displayed in a search_ledger but with reset
    filter settings. As part of the initial setup of the filter, the
    SPLIT_RECONCILE and TRANS_DATE_POSTED parameters are purged from the
    query and so if 'Date Posted' was used, all transactions were displayed
    so this commit tests for a search_ledger and stops the purge along with
    saving the query for subsequent use in the filter dialogue.

diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c
index 8ec8752..a3d040c 100644
--- a/gnucash/gnome/gnc-plugin-page-register.c
+++ b/gnucash/gnome/gnc-plugin-page-register.c
@@ -548,6 +548,8 @@ typedef struct GncPluginPageRegisterPrivate
 
     gint lines_default;
     gboolean read_only;
+    Query *search_query;     // saved search query for comparison
+    Query *filter_query;     // saved filter query for comparison
 
     struct
     {
@@ -806,6 +808,8 @@ gnc_plugin_page_register_init (GncPluginPageRegister *plugin_page)
     priv->read_only         = FALSE;
     priv->fd.cleared_match  = CLEARED_ALL;
     priv->fd.days           = 0;
+    priv->search_query      = NULL;
+    priv->filter_query      = NULL;
 }
 
 static void
@@ -1359,6 +1363,9 @@ gnc_plugin_page_register_destroy_widget (GncPluginPage *plugin_page)
         memset(&priv->fd, 0, sizeof(priv->fd));
     }
 
+    qof_query_destroy (priv->search_query);
+    qof_query_destroy (priv->filter_query);
+
     gtk_widget_hide(priv->widget);
     gnc_ledger_display_close (priv->ledger);
     priv->ledger = NULL;
@@ -2373,6 +2380,33 @@ gnc_plugin_page_register_sort_order_reverse_cb (GtkToggleButton *button,
 /*                    "Filter By" Dialog                    */
 /************************************************************/
 
+static void
+gnc_ppr_update_for_search_query (GncPluginPageRegister *page)
+{
+    GncPluginPageRegisterPrivate *priv;
+    SplitRegister *reg;
+
+    priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
+    reg = gnc_ledger_display_get_split_register (priv->ledger);
+
+    if (reg->type == SEARCH_LEDGER)
+    {
+        Query *query_tmp = gnc_ledger_display_get_query (priv->ledger);
+
+        // if filter_query is NULL, then the dialogue find has been run
+        // before coming here. if query_tmp does not equal filter_query
+        // then the dialogue find has been run again before coming here
+        if ((priv->filter_query == NULL) ||
+           (!qof_query_equal (query_tmp, priv->filter_query)))
+        {
+            qof_query_destroy (priv->search_query);
+            priv->search_query = qof_query_copy (query_tmp);
+        }
+        gnc_ledger_display_set_query (priv->ledger, priv->search_query);
+    }
+}
+
+
 /** This function updates the "cleared match" term of the register
  *  query.  It unconditionally removes any old "cleared match" query
  *  term, then adds back a new query term if needed.  There seems to
@@ -2391,9 +2425,18 @@ gnc_ppr_update_status_query (GncPluginPageRegister *page, gboolean refresh)
     GncPluginPageRegisterPrivate *priv;
     GSList *param_list;
     Query *query;
+    SplitRegister *reg;
 
     ENTER(" ");
     priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
+    if (!priv->ledger)
+    {
+        LEAVE("no ledger");
+        return;
+    }
+    // check if this a search register and save query
+    gnc_ppr_update_for_search_query (page);
+
     query = gnc_ledger_display_get_query( priv->ledger );
     if (!query)
     {
@@ -2401,9 +2444,11 @@ gnc_ppr_update_status_query (GncPluginPageRegister *page, gboolean refresh)
         return;
     }
 
+    reg = gnc_ledger_display_get_split_register (priv->ledger);
+
     /* Remove the old status match */
     param_list = qof_query_build_param_list (SPLIT_RECONCILE, NULL);
-    if (param_list)
+    if (param_list && (reg->type != SEARCH_LEDGER))
     {
         qof_query_purge_terms (query, param_list);
         g_slist_free(param_list);
@@ -2416,6 +2461,10 @@ gnc_ppr_update_status_query (GncPluginPageRegister *page, gboolean refresh)
     // Set filter tooltip for summary bar
     gnc_plugin_page_register_set_filter_tooltip (page);
 
+    // clear previous filter query and save current
+    qof_query_destroy (priv->filter_query);
+    priv->filter_query = qof_query_copy (query);
+
     if (refresh)
         gnc_ledger_display_refresh (priv->ledger);
     LEAVE(" ");
@@ -2440,6 +2489,7 @@ gnc_ppr_update_date_query (GncPluginPageRegister *page, gboolean refresh)
     GncPluginPageRegisterPrivate *priv;
     GSList *param_list;
     Query *query;
+    SplitRegister *reg;
 
     ENTER(" ");
     priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
@@ -2448,17 +2498,22 @@ gnc_ppr_update_date_query (GncPluginPageRegister *page, gboolean refresh)
         LEAVE("no ledger");
         return;
     }
+    // check if this a search register and save query
+    gnc_ppr_update_for_search_query (page);
+
+    query = gnc_ledger_display_get_query (priv->ledger);
 
-    query = gnc_ledger_display_get_query( priv->ledger );
     if (!query)
     {
         LEAVE("no query");
         return;
     }
 
+    reg = gnc_ledger_display_get_split_register (priv->ledger);
+
     /* Delete any existing old date spec. */
     param_list = qof_query_build_param_list(SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
-    if (param_list)
+    if (param_list && (reg->type != SEARCH_LEDGER))
     {
         qof_query_purge_terms (query, param_list);
         g_slist_free(param_list);
@@ -2488,6 +2543,11 @@ gnc_ppr_update_date_query (GncPluginPageRegister *page, gboolean refresh)
     // Set filter tooltip for summary bar
     gnc_plugin_page_register_set_filter_tooltip (page);
 
+
+    // clear previous filter query and save current
+    qof_query_destroy (priv->filter_query);
+    priv->filter_query = qof_query_copy (query);
+
     if (refresh)
         gnc_ledger_display_refresh (priv->ledger);
     LEAVE(" ");



Summary of changes:
 gnucash/gnome/gnc-plugin-page-register.c | 135 +++++++++++++++++++++++++------
 gnucash/gnome/gnc-split-reg.c            |  11 +--
 gnucash/gnome/gnc-split-reg.h            |   6 +-
 3 files changed, 121 insertions(+), 31 deletions(-)



More information about the gnucash-changes mailing list