gchar *local_account_name;
gchar *visible_account_id;
ModestFolderViewStyle style;
+
+ gboolean reselect; /* we use this to force a reselection of the INBOX */
};
#define MODEST_FOLDER_VIEW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), \
priv->clipboard = modest_runtime_get_email_clipboard ();
priv->hidding_ids = NULL;
priv->n_selected = 0;
+ priv->reselect = FALSE;
/* Build treeview */
add_columns (GTK_WIDGET (obj));
g_signal_connect (G_OBJECT(account_store), "accounts_reloaded",
G_CALLBACK (on_accounts_reloaded), self);
+ g_signal_connect (G_OBJECT(account_store), "connecting_finished",
+ G_CALLBACK (on_accounts_reloaded), self);
+
on_accounts_reloaded (account_store, (gpointer ) self);
g_object_unref (G_OBJECT (device));
title != NULL);
}
+static gboolean
+modest_folder_view_on_map (ModestFolderView *self,
+ GdkEventExpose *event,
+ gpointer data)
+{
+ ModestFolderViewPrivate *priv;
+
+ priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
+
+ /* This won't happen often */
+ if (G_UNLIKELY (priv->reselect)) {
+ /* Select the first inbox or the local account if not found */
+ modest_folder_view_select_first_inbox_or_local (self);
+ priv->reselect = FALSE;
+ }
+ return FALSE;
+}
+
GtkWidget*
modest_folder_view_new (TnyFolderStoreQuery *query)
{
priv->changed_signal = g_signal_connect (sel, "changed",
G_CALLBACK (on_selection_changed), self);
+ g_signal_connect (self, "expose-event", G_CALLBACK (modest_folder_view_on_map), NULL);
+
return GTK_WIDGET(self);
}
return FALSE;
if (type == TNY_FOLDER_TYPE_ROOT) {
- /* TNY_FOLDER_TYPE_ROOT means that the instance is an account instead of a folder. */
+ /* TNY_FOLDER_TYPE_ROOT means that the instance is an
+ account instead of a folder. */
if (TNY_IS_ACCOUNT (instance)) {
TnyAccount *acc = TNY_ACCOUNT (instance);
const gchar *account_id = tny_account_get_id (acc);
gtk_tree_view_set_model (GTK_TREE_VIEW(self), filter_model);
/* gtk_tree_view_set_model (GTK_TREE_VIEW(self), */
/* (filter_model) ? filter_model : sortable); */
- expand_root_items (self); /* expand all account folders */
-
+
g_object_unref (model);
-
g_object_unref (filter_model);
/* if (filter_model) */
/* g_object_unref (filter_model); */
g_object_unref (sortable);
- /* Select the first inbox or the local account if not found */
- modest_folder_view_select_first_inbox_or_local (self);
+ /* Force a reselection of the INBOX next time the widget is shown */
+ priv->reselect = TRUE;
return TRUE;
}
}
}
+static gint
+get_cmp_subfolder_type_pos (TnyFolderType t)
+{
+ /* Outbox, Drafts, Sent, User */
+ /* 0, 1, 2, 3 */
+
+ switch (t) {
+ case TNY_FOLDER_TYPE_OUTBOX:
+ return 0;
+ break;
+ case TNY_FOLDER_TYPE_DRAFTS:
+ return 1;
+ break;
+ case TNY_FOLDER_TYPE_SENT:
+ return 2;
+ break;
+ default:
+ return 3;
+ }
+}
+
/*
* This function orders the mail accounts according to these rules:
* 1st - remote accounts
gchar *name1 = NULL;
gchar *name2 = NULL;
TnyFolderType type = TNY_FOLDER_TYPE_UNKNOWN;
+ TnyFolderType type2 = TNY_FOLDER_TYPE_UNKNOWN;
GObject *folder1 = NULL;
GObject *folder2 = NULL;
-1);
gtk_tree_model_get (tree_model, iter2,
TNY_GTK_FOLDER_STORE_TREE_MODEL_NAME_COLUMN, &name2,
+ TNY_GTK_FOLDER_STORE_TREE_MODEL_TYPE_COLUMN, &type2,
TNY_GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN, &folder2,
-1);
cmp = modest_text_utils_utf8_strcmp (name1, name2, TRUE);
}
} else {
- cmp = modest_text_utils_utf8_strcmp (name1, name2, TRUE);
+ GtkTreeIter parent;
+ gboolean has_parent;
+ gint cmp1 = 0, cmp2 = 0;
+ /* get the parent to know if it's a local folder */
+ has_parent = gtk_tree_model_iter_parent (tree_model, &parent, iter1);
+ if (has_parent) {
+ GObject *parent_folder;
+ TnyFolderType parent_type = TNY_FOLDER_TYPE_UNKNOWN;
+ gtk_tree_model_get (tree_model, &parent,
+ TNY_GTK_FOLDER_STORE_TREE_MODEL_TYPE_COLUMN, &parent_type,
+ TNY_GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN, &parent_folder,
+ -1);
+ if ((parent_type == TNY_FOLDER_TYPE_ROOT) &&
+ TNY_IS_ACCOUNT (parent_folder) &&
+ modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (parent_folder))) {
+ cmp1 = get_cmp_subfolder_type_pos (modest_tny_folder_get_local_folder_type (TNY_FOLDER (folder1)));
+ cmp2 = get_cmp_subfolder_type_pos (modest_tny_folder_get_local_folder_type (TNY_FOLDER (folder2)));
+ }
+ g_object_unref (parent_folder);
+ }
+ if (cmp1 == cmp2)
+ cmp = modest_text_utils_utf8_strcmp (name1, name2, TRUE);
+ else
+ cmp = (cmp1 - cmp2);
}
if (folder1)