* Fixes NB#84551, allow changes in the outbox server authentication methods while...
[modest] / src / widgets / modest-header-view.c
index 4499008..cee8ad6 100644 (file)
@@ -32,6 +32,7 @@
 #include <tny-simple-list.h>
 #include <tny-folder-monitor.h>
 #include <tny-folder-change.h>
+#include <tny-error.h>
 #include <string.h>
 
 #include <modest-header-view.h>
@@ -154,6 +155,7 @@ struct _ModestHeaderViewPrivate {
 
        HeaderViewStatus status;
        guint status_timeout;
+       gboolean notify_status; /* whether or not the filter_row should notify about changes in the filtering */
 };
 
 typedef struct _HeadersCountChangedHelper HeadersCountChangedHelper;
@@ -284,7 +286,7 @@ modest_header_view_class_init (ModestHeaderViewClass *klass)
 static void
 tny_folder_observer_init (TnyFolderObserverIface *klass)
 {
-       klass->update_func = folder_monitor_update;
+       klass->update = folder_monitor_update;
 }
 
 static GtkTreeViewColumn*
@@ -388,12 +390,15 @@ modest_header_view_set_columns (ModestHeaderView *self, const GList *columns, Tn
        g_object_set (G_OBJECT (renderer_subject),
                      "ellipsize", PANGO_ELLIPSIZE_END, "yalign", 1.0,
                      NULL);
+       gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer_subject), 1);
        g_object_set (G_OBJECT (renderer_recpt),
                      "ellipsize", PANGO_ELLIPSIZE_END, "yalign", 0.0,
                      NULL);
+       gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer_recpt), 1);
        g_object_set(G_OBJECT(renderer_compact_date_or_status),
                     "xalign", 1.0, "yalign", 0.0,
                     NULL);
+       gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer_compact_date_or_status), 1);
        g_object_set (G_OBJECT (renderer_priority),
                      "yalign", 1.0, NULL);
        g_object_set (G_OBJECT (renderer_attach),
@@ -561,6 +566,7 @@ modest_header_view_init (ModestHeaderView *obj)
 
        priv->status  = HEADER_VIEW_INIT;
        priv->status_timeout = 0;
+       priv->notify_status = TRUE;
 
        priv->observer_list_lock = g_mutex_new();
        priv->observer_list = NULL;
@@ -1179,11 +1185,37 @@ folder_refreshed_cb (ModestMailOperation *mail_op,
        g_signal_emit (G_OBJECT (info->header_view), 
                       signals[UPDATING_MSG_LIST_SIGNAL], 0, FALSE, NULL);
 
+       /* Allow filtering notifications from now on if the current
+          folder is still the same (if not then the user has selected
+          another one to refresh, we should wait until that refresh
+          finishes) */
+       if (priv->folder == folder)
+               priv->notify_status = TRUE;
+
        /* Frees */
        g_object_unref (info->header_view);
        g_free (info);
 }
 
+static void
+refresh_folder_error_handler (ModestMailOperation *mail_op, 
+                             gpointer user_data)
+{
+       const GError *error = modest_mail_operation_get_error (mail_op);
+
+       if (error->code == TNY_SYSTEM_ERROR_MEMORY ||
+           error->code == TNY_IO_ERROR_WRITE ||
+           error->code == TNY_IO_ERROR_READ) {
+               ModestMailOperationStatus st = modest_mail_operation_get_status (mail_op);
+               /* If the mail op has been cancelled then it's not an error: don't show any message */
+               if (st != MODEST_MAIL_OPERATION_STATUS_CANCELED) {
+                       modest_platform_information_banner (NULL, NULL,
+                                                           dgettext("ke-recv",
+                                                                    "cerm_device_memory_full"));
+               }
+       }
+}
+
 void
 modest_header_view_set_folder (ModestHeaderView *self, 
                               TnyFolder *folder,
@@ -1226,6 +1258,9 @@ modest_header_view_set_folder (ModestHeaderView *self,
                /* Pick my reference. Nothing to do with the mail operation */
                priv->folder = g_object_ref (folder);
 
+               /* Do not notify about filterings until the refresh finishes */
+               priv->notify_status = FALSE;
+
                /* Clear the selection if exists */
                selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self));
                gtk_tree_selection_unselect_all(selection);
@@ -1242,7 +1277,9 @@ modest_header_view_set_folder (ModestHeaderView *self,
                info->user_data = user_data;
 
                /* Create the mail operation (source will be the parent widget) */
-               mail_op = modest_mail_operation_new (G_OBJECT(main_win));
+               mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(main_win),
+                                                                        refresh_folder_error_handler,
+                                                                        NULL, NULL);
                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                                 mail_op);
 
@@ -1957,7 +1994,7 @@ filter_row (GtkTreeModel *model,
        
        /* Check hiding */
        if (priv->hidding_ids != NULL) {
-               id = g_strdup(tny_header_get_message_id (header));
+               id = tny_header_dup_message_id (header);
                for (i=0; i < priv->n_selected && !found; i++)
                        if (priv->hidding_ids[i] != NULL && id != NULL)
                                found = (!strcmp (priv->hidding_ids[i], id));
@@ -1969,7 +2006,7 @@ filter_row (GtkTreeModel *model,
  frees:
        old_status = priv->status;
        priv->status = ((gboolean) priv->status) && !visible;
-       if (priv->status != old_status) {
+       if ((priv->notify_status) && (priv->status != old_status)) {
                NotifyFilterInfo *info;
 
                if (priv->status_timeout)
@@ -2043,7 +2080,7 @@ on_account_removed (TnyAccountStore *self,
                my_account = tny_folder_get_account (priv->folder);
                if (my_account == account)
                        modest_header_view_clear (MODEST_HEADER_VIEW (user_data));
-               g_object_unref (account);
+               g_object_unref (my_account);
        }
 }