2007-05-07 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Mon, 7 May 2007 13:02:04 +0000 (13:02 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Mon, 7 May 2007 13:02:04 +0000 (13:02 +0000)
* 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.

pmo-trunk-r1769

ChangeLog2
src/gnome/modest-msg-edit-window.c
src/gnome/modest-msg-view-window.c
src/maemo/modest-main-window.c
src/maemo/modest-msg-edit-window.c
src/maemo/modest-msg-view-window.c
src/maemo/modest-osso-state-saving.c
src/widgets/modest-window-mgr.c
src/widgets/modest-window-mgr.h
src/widgets/modest-window.c
src/widgets/modest-window.h

index 2d2c166..2a7a69a 100644 (file)
@@ -1,5 +1,31 @@
 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
index 7a7a6ed..5fe035c 100644 (file)
@@ -100,6 +100,22 @@ modest_msg_edit_window_get_type (void)
        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)
 {
@@ -110,6 +126,8 @@ 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
@@ -128,22 +146,6 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
        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)
@@ -258,7 +260,7 @@ modest_msg_edit_window_finalize (GObject *obj)
 static gboolean
 on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgEditWindow *self)
 {
-       save_settings (self);
+       modest_window_save_state (MODEST_WINDOW(self));
        return FALSE;
 }
 
index 5ccd731..ffbb0e7 100644 (file)
@@ -123,6 +123,23 @@ modest_msg_view_window_get_type (void)
 }
 
 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;
@@ -132,6 +149,9 @@ modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
        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
@@ -145,23 +165,6 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj)
        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)
@@ -201,7 +204,7 @@ modest_msg_view_window_finalize (GObject *obj)
 static gboolean
 on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgViewWindow *self)
 {
-       save_settings (self);
+       modest_window_save_state (MODEST_WINDOW(self));
        return FALSE;
 }
 
index f0cae36..2ead14b 100644 (file)
@@ -71,8 +71,9 @@ static gboolean modest_main_window_window_state_event (GtkWidget *widget,
                                                           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);
@@ -208,16 +209,15 @@ modest_main_window_class_init (ModestMainWindowClass *klass)
 {
        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
@@ -286,7 +286,7 @@ modest_main_window_get_child_widget (ModestMainWindow *self,
 
 
 static void
-restore_sizes (ModestMainWindow *self)
+restore_settings (ModestMainWindow *self)
 {
        ModestConf *conf;
        ModestMainWindowPrivate *priv;
@@ -305,9 +305,10 @@ restore_sizes (ModestMainWindow *self)
 
 
 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);
@@ -336,7 +337,7 @@ wrap_in_scrolled_window (GtkWidget *win, GtkWidget *widget)
 static gboolean
 on_delete_event (GtkWidget *widget, GdkEvent  *event, ModestMainWindow *self)
 {
-       save_sizes (self);
+       modest_window_save_state (MODEST_WINDOW(self));
        return FALSE;
 }
 
@@ -583,7 +584,7 @@ modest_main_window_new (void)
        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);
index 45f2738..d142f35 100644 (file)
@@ -192,6 +192,22 @@ modest_msg_edit_window_get_type (void)
 }
 
 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;
@@ -209,6 +225,8 @@ modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass)
        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
@@ -236,23 +254,6 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
 }
 
 
-
-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)
@@ -455,8 +456,6 @@ modest_msg_edit_window_finalize (GObject *obj)
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
-
-
 static gboolean
 on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgEditWindow *self)
 {
@@ -465,7 +464,7 @@ 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));
index 5c4cfdf..57f6c0a 100644 (file)
@@ -178,6 +178,23 @@ modest_msg_view_window_get_type (void)
 }
 
 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;
@@ -195,6 +212,8 @@ modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
        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
@@ -211,23 +230,6 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj)
 
 }
 
-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, 
@@ -413,7 +415,7 @@ modest_msg_view_window_finalize (GObject *obj)
 static gboolean
 on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgViewWindow *self)
 {
-       save_settings (self);
+       modest_window_save_state (MODEST_WINDOW (self));
        return FALSE;
 }
 
index 076c78d..03a8f15 100644 (file)
@@ -29,6 +29,7 @@
 
 
 #include <maemo/modest-osso-state-saving.h>
+#include "modest-runtime.h"
 #include <libosso.h>
 
 void modest_osso_load_state()
@@ -40,7 +41,9 @@ 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 ());
 }
 
 
index 71de009..392524d 100644 (file)
@@ -475,3 +475,25 @@ gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self)
        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);
+       }
+}
+
+
index ba400fa..1a70a90 100644 (file)
@@ -152,7 +152,6 @@ ModestWindow*  modest_window_mgr_get_main_window       (ModestWindowMgr *self);
  * 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);
 
@@ -169,6 +168,15 @@ void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMg
  **/
 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__ */
index ee4553e..79aad9a 100644 (file)
@@ -232,3 +232,11 @@ modest_window_show_toolbar_default (ModestWindow *window,
 {
        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);
+}
index 90d6031..edc9b34 100644 (file)
@@ -90,6 +90,8 @@ struct _ModestWindowClass {
        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);
 };
 
 /**
@@ -174,6 +176,16 @@ gboolean modest_window_zoom_minus (ModestWindow *window);
  **/
 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