Build fix in wrap quote code
[modest] / src / widgets / modest-folder-view.c
index 1247138..55d53d2 100644 (file)
@@ -630,6 +630,52 @@ format_compact_style (gchar **item_name,
 }
 
 static void
+replace_special_folder_prefix (gchar **item_name)
+{
+       const gchar *separator;
+       gchar *prefix;
+
+       if (item_name == NULL || *item_name == NULL || **item_name == '\0')
+               return;
+       separator = g_strstr_len (*item_name, -1, MODEST_FOLDER_PATH_SEPARATOR);
+       if (separator == NULL)
+               return;
+
+       prefix = g_strndup (*item_name, separator - *item_name);
+       g_strstrip (prefix);
+
+       if (prefix && *prefix != '\0') {
+               TnyFolderType folder_type;
+               gchar *new_name;
+               gchar *downcase;
+
+               downcase = g_utf8_strdown (prefix, -1);
+               g_free (prefix);
+               prefix = downcase;
+
+               if (strcmp (downcase, "inbox") == 0) {
+                       folder_type = TNY_FOLDER_TYPE_INBOX;
+                       new_name = g_strconcat (_("mcen_me_folder_inbox"), separator, NULL);
+                       g_free (*item_name);
+                       *item_name = new_name;
+               } else {
+                       folder_type = modest_local_folder_info_get_type (prefix);
+                       switch (folder_type) {
+                       case TNY_FOLDER_TYPE_INBOX:
+                       case TNY_FOLDER_TYPE_ARCHIVE:
+                               new_name = g_strconcat (modest_local_folder_info_get_type_display_name (folder_type), separator, NULL);
+                               g_free (*item_name);
+                               *item_name = new_name;
+                               break;
+                       default:
+                               break;
+                       }
+               }
+       }
+       g_free (prefix);
+}
+
+static void
 text_cell_data  (GtkTreeViewColumn *column,
                 GtkCellRenderer *renderer,
                 GtkTreeModel *tree_model,
@@ -753,6 +799,8 @@ text_cell_data  (GtkTreeViewColumn *column,
                format_compact_style (&item_name, instance, priv->mailbox,
                                      item_weight == 800, 
                                      multiaccount, &use_markup);
+       } else {
+               replace_special_folder_prefix (&item_name);
        }
 
        if (item_name && item_weight) {
@@ -1374,10 +1422,6 @@ modest_folder_view_dispose (GObject *obj)
        get_inner_models (MODEST_FOLDER_VIEW (obj),
                          NULL, NULL, &model);
 
-       if (model && TNY_IS_GTK_FOLDER_LIST_STORE (model)) {
-               g_object_run_dispose (G_OBJECT (model));
-       }
-
 #ifdef MODEST_TOOLKIT_HILDON2
        if (priv->signal_handlers) {
                modest_signal_mgr_disconnect_all_and_destroy (priv->signal_handlers);
@@ -2362,10 +2406,48 @@ modest_folder_view_update_model (ModestFolderView *self,
                g_object_unref (account);
        }
 
-       /* Get the accounts: */
-       tny_account_store_get_accounts (TNY_ACCOUNT_STORE(account_store),
-                                       TNY_LIST (model),
-                                       TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+       if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ALL) {
+               /* Get the accounts */
+               tny_account_store_get_accounts (TNY_ACCOUNT_STORE(account_store),
+                                               TNY_LIST (model),
+                                               TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+       } else {
+               if (priv->visible_account_id) {
+                       TnyAccount *account;
+
+                       /* Add local folders account */
+                      account = modest_tny_account_store_get_local_folders_account ((ModestTnyAccountStore *) account_store);
+
+                       if (account) {
+                               tny_list_append (TNY_LIST (model), (GObject *) account);
+                               g_object_unref (account);
+                       }
+
+                      account = modest_tny_account_store_get_mmc_folders_account ((ModestTnyAccountStore *) account_store);
+
+                       if (account) {
+                               tny_list_append (TNY_LIST (model), (GObject *) account);
+                               g_object_unref (account);
+                       }
+
+                       /* Add visible account */
+                      account = modest_tny_account_store_get_tny_account_by ((ModestTnyAccountStore *) account_store,
+                                                                             MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
+                                                                              priv->visible_account_id);
+                       if (account) {
+                               tny_list_append (TNY_LIST (model), (GObject *) account);
+                               g_object_unref (account);
+                       } else {
+                               g_warning ("You need to set an account first");
+                               g_object_unref (model);
+                               return FALSE;
+                       }
+               } else {
+                       g_warning ("You need to set an account first");
+                       g_object_unref (model);
+                       return FALSE;
+               }
+       }
 
        sortable = gtk_tree_model_sort_new_with_model (model);
        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(sortable),
@@ -3611,6 +3693,9 @@ modest_folder_view_set_account_id_of_visible_server_account (ModestFolderView *s
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
        if (GTK_IS_TREE_MODEL_FILTER (model))
                gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
+       else
+               modest_folder_view_update_model(self,
+                                               (TnyAccountStore *) modest_runtime_get_account_store());
 
        /* Save settings to gconf */
        modest_widget_memory_save (modest_runtime_get_conf (), G_OBJECT(self),
@@ -4292,3 +4377,21 @@ on_activity_changed (TnyGtkFolderListStore *store,
                       activity);
 }
 #endif
+
+TnyList *
+modest_folder_view_get_model_tny_list (ModestFolderView *self)
+{
+       GtkTreeModel *model;
+       TnyList *ret_value;
+
+       ret_value = NULL;
+       model = NULL;
+
+       if (get_inner_models (MODEST_FOLDER_VIEW (self), NULL, NULL, (GtkTreeModel **) &model)) {
+               ret_value = TNY_LIST (model);
+               g_object_ref (ret_value);
+       }
+
+       return ret_value;
+
+}