static void setup_drag_and_drop (GtkTreeView *self);
-static gboolean _clipboard_set_selected_data (ModestFolderView *folder_view, gboolean delete);
+static gboolean _clipboard_set_selected_data (ModestFolderView *folder_view,
+ gboolean delete);
static void _clear_hidding_filter (ModestFolderView *folder_view);
-static void on_row_changed_maybe_select_folder (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter,
+static void on_row_changed_maybe_select_folder (GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
ModestFolderView *self);
enum {
/* printf ("DEBU1G: %s: account name=%s\n", __FUNCTION__, tny_account_get_name (TNY_ACCOUNT(account))); */
GetMmcAccountNameData *data = (GetMmcAccountNameData*)user_data;
-
+
if (!strings_are_equal (
tny_account_get_name(TNY_ACCOUNT(account)),
data->previous_name)) {
if (type != TNY_FOLDER_TYPE_ROOT) {
gint number = 0;
- if (modest_tny_folder_is_local_folder (TNY_FOLDER (instance))) {
- type = modest_tny_folder_get_local_folder_type (TNY_FOLDER (instance));
+ if (modest_tny_folder_is_local_folder (TNY_FOLDER (instance)) ||
+ modest_tny_folder_is_memory_card_folder (TNY_FOLDER (instance))) {
+ type = modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (instance));
if (type != TNY_FOLDER_TYPE_UNKNOWN) {
g_free (fname);
fname = g_strdup(modest_local_folder_info_get_type_display_name (type));
signals[FOLDER_DISPLAY_NAME_CHANGED_SIGNAL], 0,
item_name);
}
-
g_free (item_name);
}
g_free (fname);
}
-
-
static void
icon_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
/* If the removed account is the currently viewed one then
clear the configuration value. The new visible account will be the default account */
- if (!strcmp (priv->visible_account_id, tny_account_get_id (account))) {
+ if (priv->visible_account_id &&
+ !strcmp (priv->visible_account_id, tny_account_get_id (account))) {
+
+ /* Clear the current visible account_id */
modest_folder_view_set_account_id_of_visible_server_account (self, NULL);
+
+ /* Call the restore method, this will set the new visible account */
+ modest_widget_memory_restore (modest_runtime_get_conf(), G_OBJECT(self),
+ MODEST_CONF_FOLDER_VIEW_KEY);
+
+ /* Select the INBOX */
+ modest_folder_view_select_first_inbox_or_local (self);
}
}
self = MODEST_FOLDER_VIEW (user_data);
priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
- if (!priv->visible_account_id)
+ /* If we're adding a new account, and there is no previous
+ one, we need to select the visible server account */
+ if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE &&
+ !priv->visible_account_id)
modest_widget_memory_restore (modest_runtime_get_conf(), G_OBJECT(self),
MODEST_CONF_FOLDER_VIEW_KEY);
be a bug, because the INBOX is not selected, but we
need to rewrite some parts of Modest to avoid the
deathlock situation */
-/* modest_folder_view_select_first_inbox_or_local (self); */
+ /* TODO: check if this is still the case */
priv->reselect = FALSE;
+ modest_folder_view_select_first_inbox_or_local (self);
+ /* Notify the display name observers */
+ g_signal_emit (G_OBJECT(self),
+ signals[FOLDER_DISPLAY_NAME_CHANGED_SIGNAL], 0,
+ NULL);
}
return FALSE;
}
guint i;
gboolean found = FALSE;
gboolean cleared = FALSE;
-
+
g_return_val_if_fail (MODEST_IS_FOLDER_VIEW (data), FALSE);
priv = MODEST_FOLDER_VIEW_GET_PRIVATE (data);
/* If it isn't a special folder,
* don't show it unless it is the visible account: */
- if (!modest_tny_account_is_virtual_local_folders (acc) &&
- strcmp (account_id, MODEST_MMC_ACCOUNT_ID)) {
+ if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE &&
+ !modest_tny_account_is_virtual_local_folders (acc) &&
+ strcmp (account_id, MODEST_MMC_ACCOUNT_ID)) {
+
/* Show only the visible account id */
- if (priv->visible_account_id && strcmp (account_id, priv->visible_account_id))
+ if (priv->visible_account_id) {
+ if (strcmp (account_id, priv->visible_account_id))
+ retval = FALSE;
+ } else {
retval = FALSE;
+ }
}
/* Never show these to the user. They are merged into one folder
retval = FALSE;
}
}
-
- /* The virtual local-folders folder store is also shown by default. */
/* Check hiding (if necessary) */
cleared = modest_email_clipboard_cleared (priv->clipboard);
retval = !found;
}
+
+ /* If this is a move to dialog, hide Sent, Outbox and Drafts
+ folder as no message can be move there according to UI specs */
if (!priv->show_non_move)
{
switch (type)
{
case TNY_FOLDER_TYPE_OUTBOX:
case TNY_FOLDER_TYPE_SENT:
+ case TNY_FOLDER_TYPE_DRAFTS:
retval = FALSE;
break;
+ case TNY_FOLDER_TYPE_UNKNOWN:
+ case TNY_FOLDER_TYPE_NORMAL:
+ type = modest_tny_folder_guess_folder_type(TNY_FOLDER(instance));
+ if (type == TNY_FOLDER_TYPE_OUTBOX || type == TNY_FOLDER_TYPE_SENT
+ || type == TNY_FOLDER_TYPE_DRAFTS)
+ {
+ retval = FALSE;
+ }
+ break;
default:
break;
}
GTK_SORT_ASCENDING);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (sortable),
TNY_GTK_FOLDER_STORE_TREE_MODEL_NAME_COLUMN,
- cmp_rows, NULL, NULL);
+ cmp_rows, NULL, NULL);
/* Create filter model */
filter_model = gtk_tree_model_filter_new (sortable, NULL);
filter_row,
self,
NULL);
-/* if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE) { */
-/* filter_model = gtk_tree_model_filter_new (sortable, NULL); */
-/* gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter_model), */
-/* filter_row, */
-/* self, */
-/* NULL); */
-/* } */
/* Set new model */
gtk_tree_view_set_model (GTK_TREE_VIEW(self), filter_model);
g_signal_connect (G_OBJECT(filter_model), "row-inserted",
(GCallback)on_row_changed_maybe_select_folder, self);
-
-
-/* gtk_tree_view_set_model (GTK_TREE_VIEW(self), */
-/* (filter_model) ? filter_model : sortable); */
g_object_unref (model);
- g_object_unref (filter_model);
-/* if (filter_model) */
-/* g_object_unref (filter_model); */
-
+ g_object_unref (filter_model);
g_object_unref (sortable);
/* Force a reselection of the INBOX next time the widget is shown */
/* Current folder was unselected */
if (priv->cur_folder_store) {
+ g_signal_emit (G_OBJECT(tree_view), signals[FOLDER_SELECTION_CHANGED_SIGNAL], 0,
+ priv->cur_folder_store, FALSE);
+
if (TNY_IS_FOLDER(priv->cur_folder_store))
- tny_folder_sync_async (TNY_FOLDER(priv->cur_folder_store),
+ tny_folder_sync_async (TNY_FOLDER(priv->cur_folder_store),
FALSE, NULL, NULL, NULL);
/* FALSE --> don't expunge the messages */
- g_signal_emit (G_OBJECT(tree_view), signals[FOLDER_SELECTION_CHANGED_SIGNAL], 0,
- priv->cur_folder_store, FALSE);
g_object_unref (priv->cur_folder_store);
priv->cur_folder_store = NULL;
}
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)));
+ cmp1 = get_cmp_subfolder_type_pos (modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (folder1)));
+ cmp2 = get_cmp_subfolder_type_pos (modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (folder2)));
}
g_object_unref (parent_folder);
}
helper->delete_source,
NULL,
NULL);
+
+ g_object_unref (G_OBJECT (mail_op));
}
/* Frees */
g_object_unref (G_OBJECT (parent_folder));
g_object_unref (G_OBJECT (folder));
- g_object_unref (G_OBJECT (mail_op));
}
/*
do {
GtkTreeIter child;
TnyFolderType type = TNY_FOLDER_TYPE_UNKNOWN;
- gchar *name = NULL;
gtk_tree_model_get (model, iter,
- TNY_GTK_FOLDER_STORE_TREE_MODEL_NAME_COLUMN, &name,
TNY_GTK_FOLDER_STORE_TREE_MODEL_TYPE_COLUMN,
&type, -1);
-
- /*
- printf ("DEBUG: %s: name=%s, type=%d, TNY_FOLDER_TYPE_INBOX=%d\n",
- __FUNCTION__, name, type, TNY_FOLDER_TYPE_INBOX);
- */
gboolean result = FALSE;
if (type == TNY_FOLDER_TYPE_INBOX) {
result = TRUE;
- } else if (type == TNY_FOLDER_TYPE_NORMAL) {
- /* tinymail's camel implementation only provides TNY_FOLDER_TYPE_NORMAL
- * when getting folders from the cache, before connectin, so we do
- * an extra check. We could fix this in tinymail, but it's easier
- * to do here.
- */
- if (strcmp (name, "Inbox") == 0)
- result = TRUE;
- }
-
- g_free (name);
-
+ }
if (result) {
*inbox_iter = *iter;
return TRUE;
GtkTreeModel *model;
GtkTreeIter iter, inbox_iter;
GtkTreeSelection *sel;
-
-/* /\* Do not set it if the folder view was not painted *\/ */
-/* if (!GTK_WIDGET_MAPPED (self)) */
-/* return; */
+ GtkTreePath *path = NULL;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
if (!model)
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
gtk_tree_model_get_iter_first (model, &iter);
- gtk_tree_selection_unselect_all (sel);
- if (find_inbox_iter (model, &iter, &inbox_iter)) {
- gtk_tree_selection_select_iter (sel, &inbox_iter);
- }
- else {
- gtk_tree_model_get_iter_first (model, &iter);
- gtk_tree_selection_select_iter (sel, &iter);
- }
+ if (find_inbox_iter (model, &iter, &inbox_iter))
+ path = gtk_tree_model_get_path (model, &inbox_iter);
+ else
+ path = gtk_tree_path_new_first ();
+
+ /* Select the row and free */
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (self), path, NULL, FALSE);
+ gtk_tree_path_free (path);
}
if (!MODEST_IS_FOLDER_VIEW(self))
return;
- g_return_if_fail (MODEST_IS_FOLDER_VIEW (self));
priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
-
if (priv->folder_to_select) {
if (!modest_folder_view_select_folder (self, priv->folder_to_select,
gtk_tree_path_free (path);
- }
+ }
g_object_unref (priv->folder_to_select);
priv->folder_to_select = NULL;
- }
+ }
}
priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
if (after_change) {
+
+ sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
+ gtk_tree_selection_unselect_all (sel);
+
if (priv->folder_to_select)
g_object_unref(priv->folder_to_select);
priv->folder_to_select = TNY_FOLDER(g_object_ref(folder));