Make the entire UI (menus and toolbar) insensitive when the progress

bar is showing.  Replaces the code to make the Save/Save As menus
insensitive while saving.  Should prevent a whole class of bugs caused
by gtk commands sneaking in and causing non-recursive code to be
entered recursively.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13741 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2006-04-06 03:44:50 +00:00
parent 7f6ca4d36c
commit f31638e1cd
5 changed files with 39 additions and 11 deletions

View File

@ -1,3 +1,14 @@
2006-04-05 David Hampton <hampton@employees.org>
* src/gnome-utils/gnc-main-window.c:
* src/gnome-utils/gnc-window.[ch]:
* src/gnome/gnc-plugin-basic-commands.c: Make the entire UI (menus
and toolbar) insensitive when the progress bar is showing.
Replaces the code to make the Save/Save As menus insensitive while
saving. Should prevent a whole class of bugs caused by gtk
commands sneaking in and causing non-recursive code to be entered
recursively.
2006-04-05 Chris Lyttle <chris@wilddev.net>
* NEWS: Added some text about the release.

View File

@ -3356,6 +3356,27 @@ gnc_main_window_get_progressbar (GncWindow *window_in)
}
static void
gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive)
{
GncMainWindow *window;
GList *winp;
GSList *widgetp, *toplevels;
for (winp = active_windows; winp; winp = g_list_next(winp)) {
window = winp->data;
toplevels = gtk_ui_manager_get_toplevels(window->ui_merge,
GTK_UI_MANAGER_MENUBAR |
GTK_UI_MANAGER_TOOLBAR |
GTK_UI_MANAGER_POPUP);
for (widgetp = toplevels; widgetp; widgetp = g_slist_next(widgetp)) {
gtk_widget_set_sensitive (widgetp->data, sensitive);
}
g_slist_free(toplevels);
}
}
/** Initialize the generic window interface for a main window.
*
* @param iface A pointer to the interface data structure to
@ -3366,6 +3387,7 @@ gnc_window_main_window_init (GncWindowIface *iface)
iface->get_gtk_window = gnc_main_window_get_gtk_window;
iface->get_statusbar = gnc_main_window_get_statusbar;
iface->get_progressbar = gnc_main_window_get_progressbar;
iface->ui_set_sensitive = gnc_main_window_all_ui_set_sensitive;
}

View File

@ -176,9 +176,14 @@ gnc_window_show_progress (const char *message, double percentage)
if (percentage < 0) {
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbar), NULL);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), 0.0);
if (GNC_WINDOW_GET_IFACE(window)->ui_set_sensitive != NULL)
GNC_WINDOW_GET_IFACE(window)->ui_set_sensitive(window, TRUE);
} else {
if (message)
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbar), message);
if ((percentage == 0) &&
(GNC_WINDOW_GET_IFACE(window)->ui_set_sensitive != NULL))
GNC_WINDOW_GET_IFACE(window)->ui_set_sensitive(window, FALSE);
if (percentage <= 100) {
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), percentage/100);
} else {

View File

@ -62,6 +62,7 @@ typedef struct {
GtkWindow * (* get_gtk_window) (GncWindow *window);
GtkWidget * (* get_statusbar) (GncWindow *window);
GtkWidget * (* get_progressbar) (GncWindow *window);
void (* ui_set_sensitive) (GncWindow *window, gboolean sensitive);
} GncWindowIface;
/* function prototypes */

View File

@ -295,13 +295,6 @@ 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)
{
@ -328,9 +321,7 @@ 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.) */
}
@ -344,9 +335,7 @@ 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.) */
}