diff --git a/ChangeLog b/ChangeLog index 23fd00862a..11383681dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-04-03 David Hampton + * src/gnome-utils/gnc-main-window.[ch]: + * src/gnome/gnc-plugin-basic-commands.c: Serialize access to the + "Save" and "Save As" commands. Fixes 148905. + * src/backend/file/sixtp-dom-generators.c: * src/backend/file/gnc-commodity-xml-v2.c: * src/gnome-utils/dialog-commodity.c: diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c index f7dbd98e6f..6961c67a42 100644 --- a/src/gnome-utils/gnc-main-window.c +++ b/src/gnome-utils/gnc-main-window.c @@ -3509,5 +3509,18 @@ gnc_gtk_action_group_set_translation_domain (GtkActionGroup *action_group, } /* CS: End of code copied from gtk/gtkactiongroup.c */ +void +gnc_main_window_all_action_set_sensitive (const gchar *action_name, + gboolean sensitive) +{ + GList *tmp; + GtkAction *action; + + for (tmp = active_windows; tmp; tmp = g_list_next(tmp)) { + action = gnc_main_window_find_action (tmp->data, action_name); + gtk_action_set_sensitive (action, sensitive); + } +} + /** @} */ /** @} */ diff --git a/src/gnome-utils/gnc-main-window.h b/src/gnome-utils/gnc-main-window.h index a684abdc5f..652a952780 100644 --- a/src/gnome-utils/gnc-main-window.h +++ b/src/gnome-utils/gnc-main-window.h @@ -340,6 +340,16 @@ gboolean gnc_main_window_finish_pending (GncMainWindow *window); * should cancel the pending operation. TRUE otherwise */ gboolean gnc_main_window_all_finish_pending (void); +/** Change the sensitivity of a command in all windows. This can be + * used to serialize access to a command so that in cannot be + * reinvoked until the current invocation is finished. + * + * @param action_name The name of the command to modity. + * + * @param sensitive Whether or not the user should be able to invoke + * this action. */ +void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolean sensitive); + G_END_DECLS #endif /* __GNC_MAIN_WINDOW_H */ diff --git a/src/gnome/gnc-plugin-basic-commands.c b/src/gnome/gnc-plugin-basic-commands.c index febd23be9b..a5222c8125 100644 --- a/src/gnome/gnc-plugin-basic-commands.c +++ b/src/gnome/gnc-plugin-basic-commands.c @@ -295,6 +295,13 @@ gnc_plugin_basic_commands_finalize (GObject *object) * Command Callbacks * ************************************************************/ +static void +save_allowed (gboolean allowed) +{ + gnc_main_window_all_action_set_sensitive("FileSaveAction", allowed); + gnc_main_window_all_action_set_sensitive("FileSaveAsAction", allowed); +} + static void gnc_main_window_cmd_file_new (GtkAction *action, GncMainWindowActionData *data) { @@ -321,7 +328,9 @@ gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data) return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); + save_allowed(FALSE); gnc_file_save (); + save_allowed(TRUE); gnc_window_set_progressbar_window (NULL); /* FIXME GNOME 2 Port (update the title etc.) */ } @@ -335,7 +344,9 @@ gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *da return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); + save_allowed(FALSE); gnc_file_save_as (); + save_allowed(TRUE); gnc_window_set_progressbar_window (NULL); /* FIXME GNOME 2 Port (update the title etc.) */ }