Set better the default max height for hildon2 dialogs
[modest] / src / widgets / modest-folder-view.c
index 29cc917..2a956e2 100644 (file)
@@ -500,7 +500,7 @@ convert_parent_folders_to_dots (gchar **item_name)
 }
 
 static void
-format_compact_style (gchar **item_name, 
+format_compact_style (gchar **item_name,
                      GObject *instance,
                      gboolean bold,
                      gboolean multiaccount,
@@ -604,17 +604,11 @@ text_cell_data  (GtkTreeViewColumn *column,
                        }
                }
 
-               if (type == TNY_FOLDER_TYPE_INBOX) {
-                       if (inbox_is_special (TNY_FOLDER_STORE (instance))) {
-                               g_free (fname);
-                               fname = g_strdup (_("mcen_me_folder_inbox"));
-                       }
-               }
-
-               /* note: we cannot reliably get the counts from the tree model, we need
-                * to use explicit calls on tny_folder for some reason.
-                */
-               /* Select the number to show: the unread or unsent messages. in case of outbox/drafts, show all */
+               /* note: we cannot reliably get the counts from the
+                * tree model, we need to use explicit calls on
+                * tny_folder for some reason. Select the number to
+                * show: the unread or unsent messages. in case of
+                * outbox/drafts, show all */
                if ((type == TNY_FOLDER_TYPE_DRAFTS) ||
                    (type == TNY_FOLDER_TYPE_OUTBOX) ||
                    (type == TNY_FOLDER_TYPE_MERGE)) { /* _OUTBOX actually returns _MERGE... */
@@ -887,6 +881,13 @@ get_folder_icons (TnyFolderType type, GObject *instance)
                type = modest_tny_folder_guess_folder_type (TNY_FOLDER (instance));
        }
 
+       /* It's not enough with check the folder type. We need to
+          ensure that we're not giving a special folder icon to a
+          normal folder with the same name than a special folder */
+       if (TNY_IS_FOLDER (instance) &&
+           get_cmp_pos (type, TNY_FOLDER (instance)) ==  4)
+               type = TNY_FOLDER_TYPE_NORMAL;
+
        /* Remote folders should not be treated as special folders */
        if (TNY_IS_FOLDER_STORE (instance) &&
            !TNY_IS_ACCOUNT (instance) &&
@@ -2138,6 +2139,8 @@ inbox_is_special (TnyFolderStore *folder_store)
                        last_inbox_bar = g_strrstr  (downcase, "inbox/");
                        if ((last_inbox_bar == NULL) || (last_inbox_bar + 5 != last_bar))
                                is_special = FALSE;
+               } else {
+                       is_special = FALSE;
                }
                g_free (downcase);
        }
@@ -2164,7 +2167,7 @@ get_cmp_pos (TnyFolderType t, TnyFolder *folder_store)
                 * inbox of the account, or if it's a submailbox inbox. To do
                 * this we'll apply an heuristic rule: Find last "/" and check
                 * if it's preceeded by another Inbox */
-               is_special = is_special && inbox_is_special (TNY_FOLDER_STORE (folder_store));
+               is_special = is_special && !inbox_is_special (TNY_FOLDER_STORE (folder_store));
                g_object_unref (account);
                return is_special?0:4;
        }
@@ -3573,17 +3576,19 @@ update_style (ModestFolderView *self)
        style = gtk_rc_get_style_by_paths (gtk_widget_get_settings
                                           (GTK_WIDGET(self)),
                                           "SmallSystemFont", NULL,
-                                          G_TYPE_NONE);  
-       attr = pango_attr_font_desc_new (pango_font_description_copy
-                                        (style->font_desc));
-       pango_attr_list_insert (attr_list, attr);
+                                          G_TYPE_NONE);
+       if (style) {
+               attr = pango_attr_font_desc_new (pango_font_description_copy
+                                                (style->font_desc));
+               pango_attr_list_insert (attr_list, attr);
 
-       g_object_set (G_OBJECT (priv->messages_renderer),
-                     "foreground-gdk", &style_color,
-                     "foreground-set", TRUE,
-                     "attributes", attr_list,
-                     NULL);
-       pango_attr_list_unref (attr_list);
+               g_object_set (G_OBJECT (priv->messages_renderer),
+                             "foreground-gdk", &style_color,
+                             "foreground-set", TRUE,
+                             "attributes", attr_list,
+                             NULL);
+               pango_attr_list_unref (attr_list);
+       }
 }
 
 static void 
@@ -3630,3 +3635,36 @@ modest_folder_view_unset_filter (ModestFolderView *self,
                gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model));  
        }
 }
+
+gboolean
+modest_folder_view_any_folder_fulfils_rules (ModestFolderView *self,
+                                            ModestTnyFolderRules rules)
+{
+       GtkTreeModel *filter_model;
+       GtkTreeIter iter;
+       gboolean fulfil = FALSE;
+
+       if (!get_inner_models (self, &filter_model, NULL, NULL))
+               return FALSE;
+
+       if (!gtk_tree_model_get_iter_first (filter_model, &iter))
+               return FALSE;
+
+       do {
+               TnyFolderStore *folder;
+
+               gtk_tree_model_get (filter_model, &iter, INSTANCE_COLUMN, &folder, -1);
+               if (folder) {
+                       if (TNY_IS_FOLDER (folder)) {
+                               ModestTnyFolderRules folder_rules = modest_tny_folder_get_rules (TNY_FOLDER (folder));
+                               /* Folder rules are negative: non_writable, non_deletable... */
+                               if (!(folder_rules & rules))
+                                       fulfil = TRUE;
+                       }
+                       g_object_unref (folder);
+               }
+
+       } while (gtk_tree_model_iter_next (filter_model, &iter) && !fulfil);
+
+       return fulfil;
+}