2007-05-07 Murray Cumming <murrayc@murrayc.com>
+ * src/widgets/modest-window.h:
+ * src/widgets/modest-window.c: Added a save_state_func vfunc,
+ and modest_window_save_state(), which invokes it.
+
+ * src/widgets/modest-window-mgr.h:
+ * src/widgets/modest-window-mgr.c:
+ Added modest_window_mgr_save_state_for_all_windows(), which calls
+ the save_state vfunc on all registered windows, if implemented.
+
+ * src/gnome/modest-msg-edit-window.c:
+ * src/gnome/modest-msg-view-window.c:
+ * src/maemo/modest-msg-edit-window.c:
+ * src/maemo/modest-msg-view-window.c:
+ * src/maemo/modest-main-window.c:
+ Specify the existing save_settings functions as implementations of
+ ModestWindow::save_state_func().
+
+ * src/maemo/modest-osso-state-saving.c: modest_osso_save_state():
+ Call modest_window_mgr_save_state_for_all_windows(). This happens before
+ enabling hibernation, for instance.
+
+ We may need to do the same thing for restoring settings.
+
+
+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
return my_type;
}
+
+static void
+save_state (ModestWindow *self)
+{
+ modest_widget_memory_save (modest_runtime_get_conf (),
+ G_OBJECT(self), "modest-edit-msg-window");
+}
+
+
+static void
+restore_settings (ModestMsgEditWindow *self)
+{
+ modest_widget_memory_restore (modest_runtime_get_conf (),
+ G_OBJECT(self), "modest-edit-msg-window");
+}
+
static void
modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass)
{
gobject_class->finalize = modest_msg_edit_window_finalize;
g_type_class_add_private (gobject_class, sizeof(ModestMsgEditWindowPrivate));
+
+ modest_window_class->save_state_func = save_state;
}
static void
priv->subject_field = NULL;
}
-static void
-save_settings (ModestMsgEditWindow *self)
-{
- modest_widget_memory_save (modest_runtime_get_conf (),
- G_OBJECT(self), "modest-edit-msg-window");
-}
-
-
-static void
-restore_settings (ModestMsgEditWindow *self)
-{
- modest_widget_memory_restore (modest_runtime_get_conf (),
- G_OBJECT(self), "modest-edit-msg-window");
-}
-
-
static ModestPairList*
get_transports (void)
static gboolean
on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgEditWindow *self)
{
- save_settings (self);
+ modest_window_save_state (MODEST_WINDOW(self));
return FALSE;
}
}
static void
+save_state (ModestWindow *self)
+{
+ modest_widget_memory_save (modest_runtime_get_conf (),
+ G_OBJECT(self),
+ MODEST_CONF_MSG_VIEW_WINDOW_KEY);
+}
+
+
+static void
+restore_settings (ModestWindow *self)
+{
+ modest_widget_memory_restore (modest_runtime_get_conf (),
+ G_OBJECT(self),
+ MODEST_CONF_MSG_VIEW_WINDOW_KEY);
+}
+
+static void
modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
{
GObjectClass *gobject_class;
gobject_class->finalize = modest_msg_view_window_finalize;
g_type_class_add_private (gobject_class, sizeof(ModestMsgViewWindowPrivate));
+
+ ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
+ modest_window_class->save_state_func = save_state;
}
static void
priv->msg_view = NULL;
}
-static void
-save_settings (ModestMsgViewWindow *self)
-{
- modest_widget_memory_save (modest_runtime_get_conf (),
- G_OBJECT(self),
- MODEST_CONF_MSG_VIEW_WINDOW_KEY);
-}
-
-
-static void
-restore_settings (ModestMsgViewWindow *self)
-{
- modest_widget_memory_restore (modest_runtime_get_conf (),
- G_OBJECT(self),
- MODEST_CONF_MSG_VIEW_WINDOW_KEY);
-}
-
static void
init_window (ModestMsgViewWindow *obj, TnyMsg *msg)
static gboolean
on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgViewWindow *self)
{
- save_settings (self);
+ modest_window_save_state (MODEST_WINDOW(self));
return FALSE;
}
gpointer userdata);
static void connect_signals (ModestMainWindow *self);
-static void restore_sizes (ModestMainWindow *self);
-static void save_sizes (ModestMainWindow *self);
+
+static void restore_settings (ModestMainWindow *self);
+static void save_state (ModestWindow *self);
static void modest_main_window_show_toolbar (ModestWindow *window,
gboolean show_toolbar);
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass*) klass;
- ModestWindowClass *modest_window_class;
-
- modest_window_class = (ModestWindowClass *) klass;
+ ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = modest_main_window_finalize;
- modest_window_class->show_toolbar_func = modest_main_window_show_toolbar;
-
g_type_class_add_private (gobject_class, sizeof(ModestMainWindowPrivate));
+
+ modest_window_class->show_toolbar_func = modest_main_window_show_toolbar;
+ modest_window_class->save_state_func = save_state;
}
static void
static void
-restore_sizes (ModestMainWindow *self)
+restore_settings (ModestMainWindow *self)
{
ModestConf *conf;
ModestMainWindowPrivate *priv;
static void
-save_sizes (ModestMainWindow *self)
+save_state (ModestWindow *window)
{
ModestConf *conf;
+ ModestMainWindow* self = MODEST_MAIN_WINDOW(window);
ModestMainWindowPrivate *priv;
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
static gboolean
on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMainWindow *self)
{
- save_sizes (self);
+ modest_window_save_state (MODEST_WINDOW(self));
return FALSE;
}
gtk_box_pack_start (GTK_BOX(priv->main_vbox), priv->main_paned, TRUE, TRUE,0);
gtk_container_add (GTK_CONTAINER(self), priv->main_vbox);
- restore_sizes (MODEST_MAIN_WINDOW(self));
+ restore_settings (MODEST_MAIN_WINDOW(self));
/* Set window icon */
window_icon = modest_platform_get_icon (MODEST_APP_ICON);
}
static void
+save_state (ModestWindow *self)
+{
+ modest_widget_memory_save (modest_runtime_get_conf(),
+ G_OBJECT(self), MODEST_CONF_EDIT_WINDOW_KEY);
+}
+
+
+static void
+restore_settings (ModestMsgEditWindow *self)
+{
+ modest_widget_memory_restore (modest_runtime_get_conf(),
+ G_OBJECT(self), MODEST_CONF_EDIT_WINDOW_KEY);
+}
+
+
+static void
modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass)
{
GObjectClass *gobject_class;
modest_window_class->show_toolbar_func = modest_msg_edit_window_show_toolbar;
g_type_class_add_private (gobject_class, sizeof(ModestMsgEditWindowPrivate));
+
+ modest_window_class->save_state_func = save_state;
}
static void
}
-
-static void
-save_settings (ModestMsgEditWindow *self)
-{
- modest_widget_memory_save (modest_runtime_get_conf(),
- G_OBJECT(self), MODEST_CONF_EDIT_WINDOW_KEY);
-}
-
-
-static void
-restore_settings (ModestMsgEditWindow *self)
-{
- modest_widget_memory_restore (modest_runtime_get_conf(),
- G_OBJECT(self), MODEST_CONF_EDIT_WINDOW_KEY);
-}
-
-
/* FIXME: this is a dup from the one in gtk/ */
static ModestPairList*
get_transports (void)
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
-
-
static gboolean
on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgEditWindow *self)
{
gint response;
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
- save_settings (self);
+ modest_window_save_state (MODEST_WINDOW (self));
if (is_modified (self)) {
close_dialog = hildon_note_new_confirmation (GTK_WINDOW (self), _("mcen_nc_no_email_message_modified_save_changes"));
response = gtk_dialog_run (GTK_DIALOG (close_dialog));
}
static void
+save_state (ModestWindow *self)
+{
+ modest_widget_memory_save (modest_runtime_get_conf (),
+ G_OBJECT(self),
+ MODEST_CONF_MSG_VIEW_WINDOW_KEY);
+}
+
+
+static void
+restore_settings (ModestMsgViewWindow *self)
+{
+ modest_widget_memory_restore (modest_runtime_get_conf (),
+ G_OBJECT(self),
+ MODEST_CONF_MSG_VIEW_WINDOW_KEY);
+}
+
+static void
modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
{
GObjectClass *gobject_class;
modest_window_class->show_toolbar_func = modest_msg_view_window_show_toolbar;
g_type_class_add_private (gobject_class, sizeof(ModestMsgViewWindowPrivate));
+
+ modest_window_class->save_state_func = save_state;
}
static void
}
-static void
-save_settings (ModestMsgViewWindow *self)
-{
- modest_widget_memory_save (modest_runtime_get_conf (),
- G_OBJECT(self),
- MODEST_CONF_MSG_VIEW_WINDOW_KEY);
-}
-
-
-static void
-restore_settings (ModestMsgViewWindow *self)
-{
- modest_widget_memory_restore (modest_runtime_get_conf (),
- G_OBJECT(self),
- MODEST_CONF_MSG_VIEW_WINDOW_KEY);
-}
-
static void
set_toolbar_mode (ModestMsgViewWindow *self,
static gboolean
on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgViewWindow *self)
{
- save_settings (self);
+ modest_window_save_state (MODEST_WINDOW (self));
return FALSE;
}
#include <maemo/modest-osso-state-saving.h>
+#include "modest-runtime.h"
#include <libosso.h>
void modest_osso_load_state()
void modest_osso_save_state()
{
/* We don't need to call osso_state_write()
- * - we use our general widget-state-saving technique instead. */
+ * - we use our general widget-state-saving technique instead: */
+ modest_window_mgr_save_state_for_all_windows(
+ modest_runtime_get_window_mgr ());
}
return (g_slist_length (priv->windows_that_prevent_hibernation) > 0);
}
+
+void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self)
+{
+ g_return_if_fail (MODEST_IS_WINDOW_MGR (self));
+
+ ModestWindowMgrPrivate *priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+
+ /* Iterate over all windows */
+ GList *win = priv->window_list;
+ while (win) {
+ ModestWindow *window = MODEST_WINDOW (win->data);
+ if (window) {
+ /* This calls the vfunc,
+ * so each window can do its own thing: */
+ modest_window_save_state (window);
+ }
+
+ win = g_list_next (win);
+ }
+}
+
+
* 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);
**/
gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
+/**
+ * modest_window_mgr_save_state_for_all_windows:
+ * @self: a #ModestWindowMgr
+ *
+ * Save any state for all windows. For instance, call this before allowing
+ * application hibernation.
+ **/
+void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
+
G_END_DECLS
#endif /* __MODEST_WINDOW_MGR_H__ */
{
g_warning ("modest: You should implement %s", __FUNCTION__);
}
+
+void
+modest_window_save_state (ModestWindow *window)
+{
+ ModestWindowClass *klass = MODEST_WINDOW_GET_CLASS (window);
+ if (klass->save_state_func)
+ klass->save_state_func (window);
+}
gboolean (*zoom_plus_func) (ModestWindow *self);
gboolean (*zoom_minus_func) (ModestWindow *self);
void (*show_toolbar_func) (ModestWindow *self, gboolean show_toolbar);
+
+ void (*save_state_func) (ModestWindow *self);
};
/**
**/
void modest_window_show_toolbar (ModestWindow *window,
gboolean show_toolbar);
+
+/**
+ * modest_window_save_state:
+ * @window:
+ *
+ * Ask the window to save its settings for loading again later.
+ * This actually invokes the save_setting_func vfunc, which
+ * derived windows should implement.
+ **/
+void modest_window_save_state (ModestWindow *window);
G_END_DECLS