* src/maemo/modest-main-window.c:
authorJose Dapena Paz <jdapena@igalia.com>
Fri, 18 Jan 2008 11:43:44 +0000 (11:43 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Fri, 18 Jan 2008 11:43:44 +0000 (11:43 +0000)
        * Improve saving/restoring paned size, taking into account
          better when the folder view is hidden or paned is not visible
          (fixes NB#79378).
* src/modest-widget-memory.c:
        * Don't restore the paned if it's not visible.

pmo-trunk-r4065

src/maemo/modest-main-window.c
src/modest-widget-memory.c

index 0e49e44..a39c31a 100644 (file)
@@ -214,6 +214,7 @@ struct _ModestMainWindowPrivate {
 
        ModestMainWindowStyle style;
        ModestMainWindowContentsStyle contents_style;
 
        ModestMainWindowStyle style;
        ModestMainWindowContentsStyle contents_style;
+       gboolean wait_for_settings;
 
        guint progress_bar_timeout;
        guint restore_paned_timeout;
 
        guint progress_bar_timeout;
        guint restore_paned_timeout;
@@ -345,6 +346,7 @@ modest_main_window_init (ModestMainWindow *obj)
        priv->progress_bar = NULL;
        priv->current_toolbar_mode = TOOLBAR_MODE_NORMAL;
        priv->style  = MODEST_MAIN_WINDOW_STYLE_SPLIT;
        priv->progress_bar = NULL;
        priv->current_toolbar_mode = TOOLBAR_MODE_NORMAL;
        priv->style  = MODEST_MAIN_WINDOW_STYLE_SPLIT;
+       priv->wait_for_settings = TRUE;
        priv->contents_style  = -1; /* invalid contents style. We need this to select it for the first time */
        priv->merge_ids = NULL;
        priv->optimized_view  = FALSE;
        priv->contents_style  = -1; /* invalid contents style. We need this to select it for the first time */
        priv->merge_ids = NULL;
        priv->optimized_view  = FALSE;
@@ -1081,7 +1083,9 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
        modest_osso_load_state ();
 
        /* Restore window & widget settings */  
        modest_osso_load_state ();
 
        /* Restore window & widget settings */  
+       priv->wait_for_settings = TRUE;
        restore_settings (MODEST_MAIN_WINDOW(self), TRUE);
        restore_settings (MODEST_MAIN_WINDOW(self), TRUE);
+       priv->wait_for_settings = FALSE;
 
        /* Check if accounts exist and show the account wizard if not */
        gboolean accounts_exist = 
 
        /* Check if accounts exist and show the account wizard if not */
        gboolean accounts_exist = 
@@ -1329,6 +1333,10 @@ modest_main_window_set_style (ModestMainWindow *self,
        priv->style = style;
        switch (style) {
        case MODEST_MAIN_WINDOW_STYLE_SIMPLE:
        priv->style = style;
        switch (style) {
        case MODEST_MAIN_WINDOW_STYLE_SIMPLE:
+
+               if (!priv->wait_for_settings)
+                       modest_widget_memory_save (modest_runtime_get_conf (), G_OBJECT (priv->main_paned),
+                                                  MODEST_CONF_MAIN_PANED_KEY);
                /* Remove main paned */
                g_object_ref (priv->main_paned);
                gtk_container_remove (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
                /* Remove main paned */
                g_object_ref (priv->main_paned);
                gtk_container_remove (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
@@ -1346,6 +1354,8 @@ modest_main_window_set_style (ModestMainWindow *self,
                gtk_paned_add2 (GTK_PANED (priv->main_paned), priv->contents_widget);
                gtk_container_add (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
 
                gtk_paned_add2 (GTK_PANED (priv->main_paned), priv->contents_widget);
                gtk_container_add (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
 
+               g_timeout_add (500, (GSourceFunc) restore_paned_timeout_handler, self);
+
                break;
        default:
                g_return_if_reached ();
                break;
        default:
                g_return_if_reached ();
index 97ac310..050d406 100644 (file)
@@ -245,8 +245,10 @@ restore_settings_paned (ModestConf *conf, GtkPaned *paned, const gchar *name)
        key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_POS); 
        percent = modest_conf_get_int (conf, key, NULL);
        
        key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_POS); 
        percent = modest_conf_get_int (conf, key, NULL);
        
-       pos = GTK_WIDGET (paned)->allocation.width * percent /100;
-       gtk_paned_set_position (paned, pos);
+       if (GTK_WIDGET_VISIBLE (GTK_WIDGET (paned)) && GTK_WIDGET_REALIZED (GTK_WIDGET (paned))) {
+               pos = GTK_WIDGET (paned)->allocation.width * percent /100;
+               gtk_paned_set_position (paned, pos);
+       }
 
        g_free (key);
        return TRUE;
 
        g_free (key);
        return TRUE;