gnucash master: Bug388500 - Add option to remove deleted files from the history list

Geert Janssens gjanssens at code.gnucash.org
Thu Mar 23 14:55:47 EDT 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/4f5658fc (commit)
	from  https://github.com/Gnucash/gnucash/commit/66e81040 (commit)



commit 4f5658fc7a3ed81bbd5b30238e535fa19f60af42
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Mar 23 14:33:27 2017 +0000

    Bug388500 - Add option to remove deleted files from the history list
    
    This patch simplifies the previous patch so it does not care where the
    file is opened from. If it is in the history list and does not exist,
    the dialog advises of this and asks if it should be removed from the
    list other wise the dialog displays file not found.

diff --git a/src/bin/gnucash-bin.c b/src/bin/gnucash-bin.c
index f9c8d5a..bfba5f3 100644
--- a/src/bin/gnucash-bin.c
+++ b/src/bin/gnucash-bin.c
@@ -605,10 +605,7 @@ get_file_to_load()
     if (file_to_load)
         return g_strdup(file_to_load);
     else
-    {
-        gnc_history_set_file_from_history(TRUE);
         return gnc_history_get_last();
-    }
 }
 
 static void
@@ -657,7 +654,6 @@ inner_main (void *closure, int argc, char **argv)
     {
         gnc_update_splash_screen(_("Loading data..."), GNC_SPLASH_PERCENTAGE_UNKNOWN);
         gnc_file_open_file(fn, /*open_readonly*/ FALSE);
-        gnc_history_set_file_from_history(FALSE);
         g_free(fn);
     }
     else if (gnc_prefs_get_bool(GNC_PREFS_GROUP_NEW_USER, GNC_PREF_FIRST_STARTUP))
diff --git a/src/gnome-utils/gnc-plugin-file-history.c b/src/gnome-utils/gnc-plugin-file-history.c
index 3f27dbe..d4f051c 100644
--- a/src/gnome-utils/gnc-plugin-file-history.c
+++ b/src/gnome-utils/gnc-plugin-file-history.c
@@ -67,8 +67,6 @@ static QofLogModule log_module = GNC_MOD_GUI;
 /* Command callbacks */
 static void gnc_plugin_file_history_cmd_open_file (GtkAction *action, GncMainWindowActionData *data);
 
-static gboolean file_from_history = FALSE;
-
 /** The label given to the main window for this plugin. */
 #define PLUGIN_ACTIONS_NAME "gnc-plugin-file-history-actions"
 /** The name of the UI description file for this plugin. */
@@ -266,7 +264,7 @@ gnc_history_remove_file (const char *oldfile)
 
 /** Test for a file name existing in the history list.
  *
- *  @param oldfile The name of the file to remove from the list.
+ *  @param oldfile The name of the file to test for in the list.
  */
 gboolean gnc_history_test_for_file (const char *oldfile)
 {
@@ -283,13 +281,13 @@ gboolean gnc_history_test_for_file (const char *oldfile)
     {
         from = gnc_history_index_to_pref_name(i);
         filename = gnc_prefs_get_string(GNC_PREFS_GROUP_HISTORY, from);
+        g_free(from);
 
-        if (filename && file_from_history)
+        if (filename && (g_utf8_collate(oldfile, filename) == 0))
         {
-            if (g_utf8_collate(oldfile, filename) == 0)
-                found = TRUE;
+            found = TRUE;
+            break;
         }
-        g_free(from);
     }
     return found;
 }
@@ -312,14 +310,6 @@ gnc_history_get_last (void)
 }
 
 
-/* Set the source of the open file, True for History.
- */
-void
-gnc_history_set_file_from_history (gboolean set)
-{
-    file_from_history = set;
-}
-
 /************************************************************
  *                     Other Functions                      *
  ************************************************************/
@@ -703,12 +693,10 @@ gnc_plugin_file_history_cmd_open_file (GtkAction *action,
      * Which progress bar should we be using? One in a window, or
      * in a new "file loading" dialog???
      */
-    file_from_history = TRUE;
     filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING);
     gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
     /* also opens new account page */
     gnc_file_open_file (filename, /*open_readonly*/ FALSE);
-    file_from_history = FALSE;
     gnc_window_set_progressbar_window (NULL);
 }
 
diff --git a/src/gnome-utils/gnc-plugin-file-history.h b/src/gnome-utils/gnc-plugin-file-history.h
index 022fbb4..24a30a5 100644
--- a/src/gnome-utils/gnc-plugin-file-history.h
+++ b/src/gnome-utils/gnc-plugin-file-history.h
@@ -99,7 +99,7 @@ void gnc_history_remove_file (const char *oldfile);
 
 /** Test for a file name existing in the history list.
  *
- *  @param oldfile The name of the file to remove from the list.
+ *  @param oldfile The name of the file to test in the list.
  */
 gboolean gnc_history_test_for_file (const char *oldfile);
 
@@ -112,10 +112,6 @@ gboolean gnc_history_test_for_file (const char *oldfile);
  */
 char * gnc_history_get_last (void);
 
-/** Set the source of the open file, True for History.
- */
-void gnc_history_set_file_from_history (gboolean set);
-
 G_END_DECLS
 
 #endif /* __GNC_PLUGIN_FILE_HISTORY_H */



Summary of changes:
 src/bin/gnucash-bin.c                     |  4 ----
 src/gnome-utils/gnc-plugin-file-history.c | 22 +++++-----------------
 src/gnome-utils/gnc-plugin-file-history.h |  6 +-----
 3 files changed, 6 insertions(+), 26 deletions(-)



More information about the gnucash-changes mailing list