* Fixes NB#94467, do not show special icons for remote folders
[modest] / src / widgets / modest-folder-view.c
index 80846fc..97c5805 100644 (file)
@@ -62,6 +62,7 @@
 #include <modest-widget-memory.h>
 #include <modest-ui-actions.h>
 #include "modest-dnd.h"
+#include <modest-ui-constants.h>
 #include "widgets/modest-window.h"
 
 /* Folder view drag types */
@@ -190,6 +191,7 @@ static void         on_display_name_changed (ModestAccountMgr *self,
                                             gpointer user_data);
 static void         update_style (ModestFolderView *self);
 static void         on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata);
+static gint         get_cmp_pos (TnyFolderType t, TnyFolder *folder_store);
 
 enum {
        FOLDER_SELECTION_CHANGED_SIGNAL,
@@ -421,6 +423,60 @@ on_get_mmc_account_name (TnyStoreAccount* account, gpointer user_data)
 }
 
 static void
+format_compact_style (gchar **item_name, 
+                     GObject *instance,
+                     gboolean bold,
+                     gboolean *use_markup)
+{
+       TnyFolder *folder;
+       gboolean is_special;
+       TnyFolderType folder_type;
+
+       if (!TNY_IS_FOLDER (instance))
+               return;
+
+       folder = (TnyFolder *) instance;
+
+       folder_type = tny_folder_get_folder_type (folder);
+       is_special = (get_cmp_pos (folder_type, folder)!= 4);
+
+       if (!is_special) {
+               TnyAccount *account = tny_folder_get_account (folder);
+               const gchar *folder_name;
+               gboolean concat_folder_name = FALSE;
+               GString *buffer;
+
+               /* Should not happen */
+               if (account == NULL)
+                       return;
+
+               folder_name = tny_folder_get_name (folder);
+               if (g_str_has_suffix (*item_name, folder_name)) {
+                       gchar *offset = g_strrstr (*item_name, folder_name);
+                       *offset = '\0';
+                       concat_folder_name = TRUE;
+               }
+
+               buffer = g_string_new ("");
+               buffer = g_string_append (buffer, tny_account_get_name (account));
+               buffer = g_string_append (buffer, MODEST_FOLDER_PATH_SEPARATOR);
+               buffer = g_string_append (buffer, *item_name);
+               if (concat_folder_name) {
+                       if (bold) buffer = g_string_append (buffer, "<span weight='bold'>");
+                       buffer = g_string_append (buffer, folder_name);
+                       if (bold) buffer = g_string_append (buffer, "</span>");
+               }
+               g_free (*item_name);
+               g_object_unref (account);
+
+               *item_name = g_string_free (buffer, FALSE);
+               *use_markup = bold;
+       } else {
+               *use_markup = FALSE;
+       }
+}
+
+static void
 text_cell_data  (GtkTreeViewColumn *column,
                 GtkCellRenderer *renderer,
                 GtkTreeModel *tree_model,
@@ -432,6 +488,7 @@ text_cell_data  (GtkTreeViewColumn *column,
        gchar *fname = NULL;
        TnyFolderType type = TNY_FOLDER_TYPE_UNKNOWN;
        GObject *instance = NULL;
+       gboolean use_markup = FALSE;
 
        gtk_tree_model_get (tree_model, iter,
                            NAME_COLUMN, &fname,
@@ -525,9 +582,17 @@ text_cell_data  (GtkTreeViewColumn *column,
        if (!item_name)
                item_name = g_strdup ("unknown");
 
+       if (priv->cell_style == MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT) {
+               /* Convert item_name to markup */
+               format_compact_style (&item_name, instance, item_weight == 800, &use_markup);
+       }
+
        if (item_name && item_weight) {
                /* Set the name in the treeview cell: */
-               g_object_set (rendobj, "text", item_name, "weight", item_weight, NULL);
+               if (use_markup)
+                       g_object_set (rendobj, "markup", item_name, NULL);
+               else
+                       g_object_set (rendobj, "text", item_name, "weight", item_weight, NULL);
 
                /* Notify display name observers */
                /* TODO: What listens for this signal, and how can it use only the new name? */
@@ -735,6 +800,16 @@ get_folder_icons (TnyFolderType type, GObject *instance)
                type = modest_tny_folder_guess_folder_type (TNY_FOLDER (instance));
        }
 
+       /* Remote folders should not be treated as special folders */
+       if (TNY_IS_FOLDER_STORE (instance) &&
+           type != TNY_FOLDER_TYPE_INBOX &&
+           modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (instance))) {
+               return get_composite_icons (MODEST_FOLDER_ICON_NORMAL,
+                                           &normal_pixbuf,
+                                           &normal_pixbuf_open,
+                                           &normal_pixbuf_close);
+       }
+
        switch (type) {
        case TNY_FOLDER_TYPE_INVALID:
                g_warning ("%s: BUG: TNY_FOLDER_TYPE_INVALID", __FUNCTION__);
@@ -1514,10 +1589,7 @@ filter_row (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
                        retval = FALSE;
 #endif
        } else {
-               GtkTreeIter parent;
-
-               if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE &&
-                   !gtk_tree_model_iter_parent (model, iter, &parent)) {
+               if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE) {
                        /* Only show special folders for current account if needed */
                        if (TNY_IS_FOLDER (instance) && !TNY_IS_MERGE_FOLDER (instance)) {
                                TnyAccount *account;
@@ -1614,6 +1686,8 @@ modest_folder_view_update_model (ModestFolderView *self,
 #ifdef MODEST_TOOLKIT_HILDON2
        model = tny_gtk_folder_list_store_new_with_flags (NULL, 
                                                          TNY_GTK_FOLDER_LIST_STORE_FLAG_SHOW_PATH);
+       tny_gtk_folder_list_store_set_path_separator (TNY_GTK_FOLDER_LIST_STORE (model),
+                                                     MODEST_FOLDER_PATH_SEPARATOR);
 #else
        model = tny_gtk_folder_store_tree_model_new (NULL);
 #endif