Read-only mode: Add "Revert file" menu item so that a file that might got changed from someone else can easily be reloaded.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21810 57a11ea4-9604-0410-9ed3-97b8803252fd
pull/1/head
Christian Stimming 15 years ago
parent 6f3b555946
commit e067a30f2d

@ -55,6 +55,7 @@
#include "gnc-window.h"
#include "gnc-session.h"
#include "gnc-plugin-page-sx-list.h"
#include "gnc-plugin-file-history.h"
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_GUI;
@ -70,6 +71,7 @@ static void gnc_main_window_cmd_file_new (GtkAction *action, GncMainWindowAction
static void gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data);
static void gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data);
static void gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *data);
static void gnc_main_window_cmd_file_revert (GtkAction *action, GncMainWindowActionData *data);
static void gnc_main_window_cmd_file_export_accounts (GtkAction *action, GncMainWindowActionData *data);
static void gnc_main_window_cmd_edit_tax_options (GtkAction *action, GncMainWindowActionData *data);
static void gnc_main_window_cmd_actions_mortgage_loan (GtkAction *action, GncMainWindowActionData *data);
@ -115,6 +117,11 @@ static GtkActionEntry gnc_plugin_actions [] =
N_("Save this file with a different name"),
G_CALLBACK (gnc_main_window_cmd_file_save_as)
},
{
"FileRevertAction", GTK_STOCK_REVERT_TO_SAVED, N_("Re_vert"), NULL,
N_("Reload the current database, reverting all unsaved changes"),
G_CALLBACK (gnc_main_window_cmd_file_revert)
},
{
"FileExportAccountsAction", GTK_STOCK_CONVERT,
N_("Export _Accounts"), NULL,
@ -422,6 +429,26 @@ gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *da
/* FIXME GNOME 2 Port (update the title etc.) */
}
static void
gnc_main_window_cmd_file_revert (GtkAction *action, GncMainWindowActionData *data)
{
g_return_if_fail (data != NULL);
if (!gnc_main_window_all_finish_pending())
return;
gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
{
gchar *filename = gnc_history_get_last();
// And actually open the current file again
gnc_file_open_file (filename, qof_book_is_readonly(gnc_get_current_book()));
g_free(filename);
}
gnc_window_set_progressbar_window (NULL);
}
static void
gnc_main_window_cmd_file_export_accounts (GtkAction *action, GncMainWindowActionData *data)
{

@ -10,6 +10,7 @@
<placeholder name="FileSavePlaceholder">
<menuitem name="FileSave" action="FileSaveAction"/>
<menuitem name="FileSaveAs" action="FileSaveAsAction"/>
<menuitem name="FileRevert" action="FileRevertAction"/>
</placeholder>
<menu name="FileExport" action="FileExportAction">
<menuitem name="FileExportAccounts" action="FileExportAccountsAction"/>

Loading…
Cancel
Save