/**
- * modest_platform_get_application_name:
+ * modest_platform_get_app_name:
*
* this function returns the name of the application. Do not modify.
*/
/* Create and run the dialog */
dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
+ modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view));
result = gtk_dialog_run (GTK_DIALOG(dialog));
g_object_ref (tree_view);
{
gchar *key;
const gchar* account_id;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
/* Save the visible account */
key = _modest_widget_memory_get_keyname (name, "visible_server_account_id");
modest_conf_set_string (conf, key, account_id, NULL);
g_free (key);
- /* Save the last selected folder */
- key = _modest_widget_memory_get_keyname (name, "last_selected_path");
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_view));
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
- gchar *str;
- GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
- str = gtk_tree_path_to_string (path);
- modest_conf_set_string (conf, key, str, NULL);
- g_free (str);
- gtk_tree_path_free (path);
- }
- g_free (key);
-
return TRUE;
}
ModestFolderView *folder_view,
const gchar *name)
{
- gchar *key, *account_id, *str;
+ gchar *key, *account_id;
/* Restore the visible account */
key = _modest_widget_memory_get_keyname (name, "visible_server_account_id");
g_free (key);
- /* Restore the last selected folder. Check first that the model is not NULL */
- if (gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view))) {
- key = _modest_widget_memory_get_keyname (name, "last_selected_path");
- if (modest_conf_key_exists (conf, key, NULL)) {
- GtkTreePath *path;
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_view));
- str = modest_conf_get_string (conf, key, NULL);
- path = gtk_tree_path_new_from_string ((const gchar *) str);
- gtk_tree_view_expand_to_path (GTK_TREE_VIEW (folder_view), path);
- gtk_tree_selection_select_path (selection, path);
- g_free (str);
- gtk_tree_path_free (path);
- }
- g_free (key);
- }
+ /* Select the first INBOX folder */
+ modest_folder_view_select_first_inbox_or_local (folder_view);
return TRUE;
}
sorted = old_model;
model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sorted));
-
+
tny_folder_store_remove_observer (TNY_FOLDER_STORE (local_account),
TNY_FOLDER_STORE_OBSERVER (model));
}
g_signal_connect (G_OBJECT (mail_op), "progress-changed",
G_CALLBACK (on_progress_changed), helper);
- /* FIXME: I replaced this because the API changed, but D&D
- should be reviewed in order to allow multiple drags*/
headers = tny_simple_list_new ();
tny_list_append (headers, G_OBJECT (header));
- modest_mail_operation_xfer_msgs (mail_op, headers, folder, helper->delete_source, NULL, NULL);
+ modest_mail_operation_xfer_msgs (mail_op,
+ headers,
+ folder,
+ helper->delete_source,
+ NULL, NULL);
/* Frees */
g_object_unref (G_OBJECT (mail_op));
return (const gchar *) priv->visible_account_id;
}
+
+static gboolean
+find_inbox_iter (GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *inbox_iter)
+{
+ do {
+ GtkTreeIter child;
+ gint type;
+
+ gtk_tree_model_get (model, iter,
+ TNY_GTK_FOLDER_STORE_TREE_MODEL_TYPE_COLUMN,
+ &type, -1);
+
+ if (type == TNY_FOLDER_TYPE_INBOX) {
+ *inbox_iter = *iter;
+ return TRUE;
+ }
+
+ if (gtk_tree_model_iter_children (model, &child, iter)) {
+ if (find_inbox_iter (model, &child, inbox_iter))
+ return TRUE;
+ }
+
+ } while (gtk_tree_model_iter_next (model, iter));
+
+ return FALSE;
+}
+
+
+
+void
+modest_folder_view_select_first_inbox_or_local (ModestFolderView *self)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter, inbox_iter;
+ GtkTreeSelection *sel;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
+ if (!model)
+ return;
+
+ sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
+
+ gtk_tree_model_get_iter_first (model, &iter);
+ 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);
+ }
+}
**/
const gchar* modest_folder_view_get_account_id_of_visible_server_account (ModestFolderView *self);
+
+void modest_folder_view_select_first_inbox_or_local (ModestFolderView *self);
+
G_END_DECLS
#endif /* __MODEST_FOLDER_VIEW_H__ */