Remove not used size_limit item in settings dialog
[modest] / src / widgets / modest-header-view.c
index 0d9fda6..5932522 100644 (file)
@@ -1028,7 +1028,7 @@ modest_header_view_on_expose_event(GtkTreeView *header_view,
                        gtk_tree_path_free (tree_iter_path);
                }
        } else {
-               if (priv->autoselect_reference != NULL) {
+               if (priv->autoselect_reference != NULL && gtk_tree_row_reference_valid (priv->autoselect_reference)) {
                        gboolean moved_selection = FALSE;
                        GtkTreePath * last_path;
                        if (gtk_tree_selection_count_selected_rows (sel) != 1) {
@@ -1119,7 +1119,9 @@ set_folder_intern_get_headers_async_cb (TnyFolder *folder,
 }
 
 static void
-modest_header_view_set_folder_intern (ModestHeaderView *self, TnyFolder *folder)
+modest_header_view_set_folder_intern (ModestHeaderView *self,
+                                     TnyFolder *folder,
+                                     gboolean refresh)
 {
        TnyFolderType type;
        TnyList *headers;
@@ -1146,7 +1148,7 @@ modest_header_view_set_folder_intern (ModestHeaderView *self, TnyFolder *folder)
           be added again by tny_gtk_header_list_model_set_folder, so
           we'd end up with duplicate headers. sergio */
        tny_gtk_header_list_model_set_folder (TNY_GTK_HEADER_LIST_MODEL(headers),
-                                             folder, FALSE,
+                                             folder, refresh,
                                              set_folder_intern_get_headers_async_cb,
                                              NULL, self);
 
@@ -1375,7 +1377,7 @@ modest_header_view_set_folder (ModestHeaderView *self,
                ModestMailOperation *mail_op = NULL;
 
                /* Set folder in the model */
-               modest_header_view_set_folder_intern (self, folder);
+               modest_header_view_set_folder_intern (self, folder, refresh);
 
                /* Pick my reference. Nothing to do with the mail operation */
                priv->folder = g_object_ref (folder);
@@ -1624,7 +1626,6 @@ cmp_subject_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *ite
        gint t1, t2;
        gchar *val1, *val2;
        gint cmp;
-/*     static int counter = 0; */
 
        g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN(user_data), 0);
 
@@ -1633,9 +1634,22 @@ cmp_subject_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *ite
        gtk_tree_model_get (tree_model, iter2, TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN, &val2,
                            TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN, &t2, -1);
 
-       cmp = modest_text_utils_utf8_strcmp (val1 + modest_text_utils_get_subject_prefix_len(val1),
-                                            val2 + modest_text_utils_get_subject_prefix_len(val2),
+       /* Do not use the prefixes for sorting. Consume all the blank
+          spaces for sorting */
+       cmp = modest_text_utils_utf8_strcmp (g_strchug (val1 + modest_text_utils_get_subject_prefix_len(val1)),
+                                            g_strchug (val2 + modest_text_utils_get_subject_prefix_len(val2)),
                                             TRUE);
+
+       /* If they're equal based on subject without prefix then just
+          sort them by length. This will show messages like this.
+          * Fw:
+          * Fw:Fw:
+          * Fw:Fw:
+          * Fw:Fw:Fw:
+          * */
+       if (cmp == 0)
+               cmp = (g_utf8_strlen (val1, -1) >= g_utf8_strlen (val2, -1)) ? 1 : -1;
+
        g_free (val1);
        g_free (val2);
        return cmp;
@@ -2384,8 +2398,8 @@ update_style (ModestHeaderView *self)
        /* Set color */
 
        attr_list = pango_attr_list_new ();
-       if (!gtk_style_lookup_color (GTK_WIDGET (self)->style, "SecondaryTextColor", &style_color)) {
-               gdk_color_parse ("grey", &style_color);
+       if (!gtk_style_lookup_color (gtk_widget_get_style (GTK_WIDGET (self)), "SecondaryTextColor", &style_color)) {
+               gdk_color_parse (MODEST_SECONDARY_COLOR, &style_color);
        }
        priv->secondary_color = style_color;
        attr = pango_attr_foreground_new (style_color.red, style_color.green, style_color.blue);
@@ -2427,7 +2441,7 @@ update_style (ModestHeaderView *self)
                              NULL);
        }
 
-       if (gtk_style_lookup_color (GTK_WIDGET (self)->style, "ActiveTextColor", &style_active_color)) {
+       if (gtk_style_lookup_color (gtk_widget_get_style (GTK_WIDGET (self)), "ActiveTextColor", &style_active_color)) {
                priv->active_color = style_active_color;
 #ifdef MODEST_TOOLKIT_HILDON2
                g_object_set_data (G_OBJECT (priv->renderer_subject), BOLD_IS_ACTIVE_COLOR, GINT_TO_POINTER (TRUE));