[Gnucash-changes] r13741 - gnucash/trunk - Make the entire UI
(menus and toolbar) insensitive when the progress
David Hampton
hampton at cvs.gnucash.org
Wed Apr 5 23:44:51 EDT 2006
Author: hampton
Date: 2006-04-05 23:44:50 -0400 (Wed, 05 Apr 2006)
New Revision: 13741
Trac: http://svn.gnucash.org/trac/changeset/13741
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/gnome-utils/gnc-main-window.c
gnucash/trunk/src/gnome-utils/gnc-window.c
gnucash/trunk/src/gnome-utils/gnc-window.h
gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c
Log:
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.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-04-06 03:04:41 UTC (rev 13740)
+++ gnucash/trunk/ChangeLog 2006-04-06 03:44:50 UTC (rev 13741)
@@ -1,3 +1,14 @@
+2006-04-05 David Hampton <hampton at 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 at wilddev.net>
* NEWS: Added some text about the release.
Modified: gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c 2006-04-06 03:04:41 UTC (rev 13740)
+++ gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c 2006-04-06 03:44:50 UTC (rev 13741)
@@ -296,13 +296,6 @@
************************************************************/
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)
{
gnc_file_new ();
@@ -328,9 +321,7 @@
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 @@
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.) */
}
Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c 2006-04-06 03:04:41 UTC (rev 13740)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c 2006-04-06 03:44:50 UTC (rev 13741)
@@ -3356,6 +3356,27 @@
}
+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 @@
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;
}
Modified: gnucash/trunk/src/gnome-utils/gnc-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-window.c 2006-04-06 03:04:41 UTC (rev 13740)
+++ gnucash/trunk/src/gnome-utils/gnc-window.c 2006-04-06 03:44:50 UTC (rev 13741)
@@ -176,9 +176,14 @@
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 {
Modified: gnucash/trunk/src/gnome-utils/gnc-window.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-window.h 2006-04-06 03:04:41 UTC (rev 13740)
+++ gnucash/trunk/src/gnome-utils/gnc-window.h 2006-04-06 03:44:50 UTC (rev 13741)
@@ -62,6 +62,7 @@
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 */
More information about the gnucash-changes
mailing list