* Prevents the Expunged messages from appear
[modest] / src / maemo / modest-main-window.c
index 0e49e44..7bde64d 100644 (file)
@@ -59,7 +59,7 @@
 #include "modest-tny-msg.h"
 #include "modest-mail-operation.h"
 #include "modest-icon-names.h"
-#include "modest-progress-bar-widget.h"
+#include "modest-progress-bar.h"
 #include "modest-text-utils.h"
 #include "modest-ui-dimming-manager.h"
 #include "maemo/modest-osso-state-saving.h"
@@ -214,6 +214,7 @@ struct _ModestMainWindowPrivate {
 
        ModestMainWindowStyle style;
        ModestMainWindowContentsStyle contents_style;
+       gboolean wait_for_settings;
 
        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->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;
@@ -1081,7 +1083,9 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
        modest_osso_load_state ();
 
        /* Restore window & widget settings */  
+       priv->wait_for_settings = 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 = 
@@ -1329,6 +1333,10 @@ modest_main_window_set_style (ModestMainWindow *self,
        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);
@@ -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);
 
+               g_timeout_add (500, (GSourceFunc) restore_paned_timeout_handler, self);
+
                break;
        default:
                g_return_if_reached ();
@@ -1481,7 +1491,7 @@ modest_main_window_show_toolbar (ModestWindow *self,
                toolbar_resize (MODEST_MAIN_WINDOW (self));
                
                /* Add ProgressBar (Transfer toolbar) */ 
-               priv->progress_bar = modest_progress_bar_widget_new ();
+               priv->progress_bar = modest_progress_bar_new ();
                gtk_widget_set_no_show_all (priv->progress_bar, TRUE);
                placeholder = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ProgressBarView");
                insert_index = gtk_toolbar_get_item_index(GTK_TOOLBAR (parent_priv->toolbar), GTK_TOOL_ITEM(placeholder));
@@ -1893,6 +1903,7 @@ on_msg_count_changed (ModestHeaderView *header_view,
                      TnyFolderChange *change,
                      ModestMainWindow *main_window)
 {
+       gboolean refilter = FALSE;
        gboolean folder_empty = FALSE;
        gboolean all_marked_as_deleted = FALSE;
        ModestMainWindowPrivate *priv;
@@ -1913,8 +1924,11 @@ on_msg_count_changed (ModestHeaderView *header_view,
 
                /* Play a sound (if configured) and make the LED blink  */
                if (changed & TNY_FOLDER_CHANGE_CHANGED_ADDED_HEADERS) {
-                       modest_platform_on_new_headers_received (NULL, FALSE);
+                       modest_platform_push_email_notification ();
                }
+
+               if ((changed) & TNY_FOLDER_CHANGE_CHANGED_EXPUNGED_HEADERS)
+                       refilter = TRUE;
        }
 
        /* Check if all messages are marked to be deleted */
@@ -1930,6 +1944,9 @@ on_msg_count_changed (ModestHeaderView *header_view,
                modest_main_window_set_contents_style (main_window,
                                                       MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS);
        }
+
+       if (refilter)
+               modest_header_view_refilter (header_view);
 }
 
 
@@ -2223,6 +2240,7 @@ get_toolbar_mode_from_mail_operation (ModestMainWindow *self,
 
        /* Get toolbar mode from operation id*/
        switch (modest_mail_operation_get_type_operation (mail_op)) {
+       case MODEST_MAIL_OPERATION_TYPE_SEND_AND_RECEIVE:
        case MODEST_MAIL_OPERATION_TYPE_RECEIVE:
        case MODEST_MAIL_OPERATION_TYPE_OPEN:
                mode = TOOLBAR_MODE_TRANSFER;
@@ -2684,6 +2702,8 @@ modest_main_window_screen_is_on (ModestMainWindow *self)
 {
        ModestMainWindowPrivate *priv = NULL;
 
+       g_return_val_if_fail (MODEST_IS_MAIN_WINDOW(self), FALSE);
+
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE (self);
        
        return (priv->display_state == OSSO_DISPLAY_ON) ? TRUE : FALSE;