mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-23 01:16:43 -06:00
Bug388500 - Add option to remove deleted files from the history list
If a file is opened from the history list and does not exist the dialog advises of this and asks if it should be removed from the list. If a file is opened from the command line and does not exist, the normal dialog is used
This commit is contained in:
parent
954110c479
commit
a8ebc794ab
@ -605,7 +605,10 @@ 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
|
||||
@ -654,6 +657,7 @@ 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))
|
||||
|
@ -374,8 +374,17 @@ show_session_error (QofBackendError io_error,
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt = _("The file/URI %s could not be found.");
|
||||
gnc_error_dialog (parent, fmt, displayname);
|
||||
if (gnc_history_test_for_file (displayname))
|
||||
{
|
||||
fmt = _("The file/URI %s could not be found.\n\nThe file is in the history list, do you want to remove it?");
|
||||
if (gnc_verify_dialog (parent, FALSE, fmt, displayname))
|
||||
gnc_history_remove_file (displayname);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt = _("The file/URI %s could not be found.");
|
||||
gnc_error_dialog (parent, fmt, displayname);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -67,6 +67,7 @@ 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"
|
||||
@ -262,6 +263,38 @@ 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.
|
||||
*/
|
||||
gboolean gnc_history_test_for_file (const char *oldfile)
|
||||
{
|
||||
gchar *filename, *from;
|
||||
gint i;
|
||||
gboolean found = FALSE;
|
||||
|
||||
if (!oldfile)
|
||||
return FALSE;
|
||||
if (!g_utf8_validate(oldfile, -1, NULL))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < MAX_HISTORY_FILES; i++)
|
||||
{
|
||||
from = gnc_history_index_to_pref_name(i);
|
||||
filename = gnc_prefs_get_string(GNC_PREFS_GROUP_HISTORY, from);
|
||||
|
||||
if (filename && file_from_history)
|
||||
{
|
||||
if (g_utf8_collate(oldfile, filename) == 0)
|
||||
found = TRUE;
|
||||
}
|
||||
g_free(from);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the name of the file most recently accessed. This is the
|
||||
* name at the front of the list. Since the "list" is actually a
|
||||
* sequence of up to ten preference names, this is the value of the first preference.
|
||||
@ -279,6 +312,14 @@ 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 *
|
||||
************************************************************/
|
||||
@ -662,10 +703,12 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,11 @@ void gnc_history_add_file (const char *filename);
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
gboolean gnc_history_test_for_file (const char *oldfile);
|
||||
|
||||
/** Retrieve the name of the file most recently accessed. This is the
|
||||
* name at the front of the list.
|
||||
@ -107,6 +112,10 @@ void gnc_history_remove_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 */
|
||||
|
Loading…
Reference in New Issue
Block a user