+2007-05-07 Murray Cumming <murrayc@murrayc.com>
+
+ * src/widgets/modest-window-mgr.c:
+ * src/widgets/modest-window-mgr.h:
+ Added modest_window_mgr_prevent_hibernation_while_window_is_shown() and
+ modest_window_mgr_get_hibernation_is_prevented().
+
+ * src/maemo/modest-main-window.c:
+ (on_hildon_program_is_topmost_notify): Prevent hibernation
+ (possible when the application goes to the background in the WM),
+ if modest_window_mgr_get_hibernation_is_prevented() is TRUE.
+
+ * src/maemo/easysetup/modest-easysetup-wizard.c:
+ (modest_easysetup_wizard_dialog_init):
+ * src/maemo/modest-account-settings-dialog.c:
+ (modest_account_settings_dialog_init):
+ * src/maemo/modest-connection-specific-smtp-edit-window.c:
+ (modest_connection_specific_smtp_edit_window_init):
+ * src/maemo/modest-connection-specific-smtp-window.c:
+ (modest_connection_specific_smtp_window_init):
+ * src/maemo/modest-signature-editor-dialog.c:
+ (modest_signature_editor_dialog_init):
+ Call modest_window_mgr_prevent_hibernation_while_window_is_shown() to
+ prevent hibernation while any of these account settings dialogs are open.
+
2007-05-04 Murray Cumming <murrayc@murrayc.com>
* src/maemo/Makefile.am:
* then gtk_notebook_get_current_page() would return an incorrect value.)
*/
g_signal_connect_after (G_OBJECT (self), "response",
- G_CALLBACK (on_response), self);
+ G_CALLBACK (on_response), self);
+
+ /* When this window is shown, hibernation should not be possible,
+ * because there is no sensible way to save the state: */
+ modest_window_mgr_prevent_hibernation_while_window_is_shown (
+ modest_runtime_get_window_mgr (), GTK_WINDOW (self));
}
ModestEasysetupWizardDialog*
g_signal_connect (G_OBJECT (self), "response",
G_CALLBACK (on_response), self);
- self->modified = FALSE;
+ self->modified = FALSE;
+
+ /* When this window is shown, hibernation should not be possible,
+ * because there is no sensible way to save the state: */
+ modest_window_mgr_prevent_hibernation_while_window_is_shown (
+ modest_runtime_get_window_mgr (), GTK_WINDOW (self));
}
ModestAccountSettingsDialog*
#include "modest-connection-specific-smtp-edit-window.h"
#include "maemo/modest-maemo-ui-constants.h"
#include "modest-hildon-includes.h"
+#include "modest-runtime.h"
+
#include "widgets/modest-serversecurity-combo-box.h"
#include "widgets/modest-secureauth-combo-box.h"
#include "widgets/modest-validating-entry.h"
gtk_widget_show (box);
+
+
+ /* When this window is shown, hibernation should not be possible,
+ * because there is no sensible way to save the state: */
+ modest_window_mgr_prevent_hibernation_while_window_is_shown (
+ modest_runtime_get_window_mgr (), GTK_WINDOW (self));
}
ModestConnectionSpecificSmtpEditWindow*
g_signal_connect (sel, "changed",
G_CALLBACK(on_selection_changed), self);
on_selection_changed (sel, self);
+
+ /* When this window is shown, hibernation should not be possible,
+ * because there is no sensible way to save the state: */
+ modest_window_mgr_prevent_hibernation_while_window_is_shown (
+ modest_runtime_get_window_mgr (), GTK_WINDOW (self));
}
ModestConnectionSpecificSmtpWindow*
/* Allow hibernation if the program has gone to the background: */
/* However, prevent hibernation while the settings are being changed: */
- gboolean settings_dialog_is_open = FALSE;
-
- if (settings_dialog_is_open)
+ const gboolean hibernation_prevented =
+ modest_window_mgr_get_hibernation_is_prevented (
+ modest_runtime_get_window_mgr ());
+
+ if (hibernation_prevented)
hildon_program_set_can_hibernate (app, FALSE);
else {
-
/* Allow hibernation, after saving the state: */
modest_osso_save_state();
hildon_program_set_can_hibernate (app, TRUE);
#include "widgets/modest-serversecurity-combo-box.h"
#include "widgets/modest-secureauth-combo-box.h"
#include "widgets/modest-validating-entry.h"
+#include "modest-runtime.h"
#include <modest-account-mgr-helpers.h>
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkhbox.h>
gtk_widget_show (box);
+
+ /* When this window is shown, hibernation should not be possible,
+ * because there is no sensible way to save the state: */
+ modest_window_mgr_prevent_hibernation_while_window_is_shown (
+ modest_runtime_get_window_mgr (), GTK_WINDOW (self));
}
ModestSignatureEditorDialog*
gboolean fullscreen_mode;
gboolean show_toolbars;
gboolean show_toolbars_fullscreen;
+
+ GSList* windows_that_prevent_hibernation;
};
#define MODEST_WINDOW_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_WINDOW_MGR, \
return priv->main_window;
}
+
+static void
+on_nonhibernating_window_hide(GtkWidget *widget, gpointer user_data)
+{
+ ModestWindowMgr *self = MODEST_WINDOW_MGR (user_data);
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+
+ /* Forget this window,
+ * so hibernation will be allowed again if no windows are remembered: */
+ g_slist_remove (priv->windows_that_prevent_hibernation, GTK_WINDOW(widget));
+}
+
+static void
+on_nonhibernating_window_show(GtkWidget *widget, gpointer user_data)
+{
+ ModestWindowMgr *self = MODEST_WINDOW_MGR (user_data);
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+
+ GtkWindow *window = GTK_WINDOW (widget);
+
+ priv->windows_that_prevent_hibernation =
+ g_slist_append (priv->windows_that_prevent_hibernation, window);
+
+ /* Allow hibernation again when the window has been hidden: */
+ g_signal_connect (window, "hide",
+ G_CALLBACK (on_nonhibernating_window_hide), self);
+}
+
+void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self, GtkWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW_MGR (self));
+
+ if (GTK_WIDGET_VISIBLE(window)) {
+ on_nonhibernating_window_show (GTK_WIDGET (window), self);
+ }
+ else
+ {
+ /* Wait for it to be shown: */
+ g_signal_connect (window, "show",
+ G_CALLBACK (on_nonhibernating_window_show), self);
+ }
+}
+
+gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self)
+{
+ g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), FALSE);
+
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+
+ /* Prevent hibernation if any open windows are currently
+ * preventing hibernation: */
+ return (g_slist_length (priv->windows_that_prevent_hibernation) > 0);
+}
+
ModestWindow* modest_window_mgr_get_main_window (ModestWindowMgr *self);
+/**
+ * modest_window_mgr_prevent_hibernation_while_window_is_shown:
+ * @self: a #ModestWindowMgr
+ * @window: The window that should prevent hibernation while it is shown.
+ *
+ * Call this if hibernation should not be allowed because
+ * windows are open whose state cannot sensible be saved, such as Account
+ * Settings dialogs.
+ * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE
+ * until all such windows have been closed. That means, until the windows have
+ * been hidden - window destruction or other memory management is not relevant.
+ **/
+
+void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self,
+ GtkWindow *window);
+
+/**
+ * modest_window_mgr_get_hibernation_is_prevented:
+ * @self: a #ModestWindowMgr
+ * @result: Whether any windows are currently preventing hibernation.
+ *
+ * Use this to discover whether hibernation should not be allowed because
+ * windows are open whose state cannot sensible be saved, such as Account
+ * Settings dialogs. This function will return true after someone has called
+ * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before
+ * that window has been closed.
+ **/
+gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
+
G_END_DECLS
#endif /* __MODEST_WINDOW_MGR_H__ */