#include <tny-gnome-device.h>
#include <tny-camel-imap-store-account.h>
#include <tny-camel-pop-store-account.h>
-
+#include <tny-simple-list.h>
+#include <tny-error.h>
+#include <tny-merge-folder.h>
#include "modest-platform.h"
#include "modest-mail-operation-queue.h"
#include "modest-runtime.h"
-
#include "gnome/modest-gnome-global-settings-dialog.h"
-#include "widgets/modest-account-settings-dialog.h"
+#include "widgets/modest-default-account-settings-dialog.h"
#include "gnome/modest-account-assistant.h"
#include "gnome/modest-gnome-sort-dialog.h"
#include "widgets/modest-details-dialog.h"
+#include "widgets/modest-main-window.h"
gboolean
modest_platform_init (int argc, char *argv[])
gint
modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
- TnyFolderStore *parent_folder,
+ TnyFolderStore *suggested_parent,
gchar *suggested_name,
- gchar **folder_name)
+ gchar **folder_name,
+ TnyFolderStore **parent_folder)
{
GtkWidget *dialog, *entry;
gint result;
gtk_widget_destroy (dialog);
+ if (parent_folder != NULL) {
+ parent_folder = suggested_parent?g_object_ref (suggested_parent): NULL;
+ }
+
return result;
}
gpointer user_data)
{
TnyAccount *account = NULL;
-
- if (!folder_store) {
+
+ if (!folder_store ||
+ (TNY_IS_MERGE_FOLDER (folder_store) &&
+ (tny_folder_get_folder_type (TNY_FOLDER(folder_store)) == TNY_FOLDER_TYPE_OUTBOX))) {
+
/* We promise to instantly perform the callback, so ... */
if (callback) {
- callback (FALSE, NULL, parent_window, NULL, user_data);
- }
- return;
-
- /* Original comment: Maybe it is something local. */
- /* PVH's comment: maybe we should KNOW this in stead of assuming? */
-
+ GError *error = NULL;
+ g_set_error (&error, TNY_ERROR_DOMAIN, TNY_SERVICE_ERROR_UNKNOWN,
+ "Unable to move or not found folder");
+ callback (FALSE, error, parent_window, NULL, user_data);
+ g_error_free (error);
+ }
+ return;
+
} else if (TNY_IS_FOLDER (folder_store)) {
/* Get the folder's parent account: */
account = tny_folder_get_account(TNY_FOLDER (folder_store));
if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) {
if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) &&
!TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) {
-
+
/* This IS a local account like a maildir account, which does not require
* a connection. (original comment had a vague assumption in its language
* usage. There's no assuming needed, this IS what it IS: a local account), */
GtkWidget *
modest_platform_get_account_settings_dialog (ModestAccountSettings *settings)
{
- ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
+ ModestAccountSettingsDialog *dialog = modest_default_account_settings_dialog_new ();
- modest_account_settings_dialog_set_account (dialog, settings);
+ modest_account_settings_dialog_load_settings (dialog, settings);
return GTK_WIDGET (dialog);
}
/* Create pannable and add it to the dialog */
folder_view_container = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (*folder_view_container),
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (folder_view_container),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container);
return dialog;
}
+
+TnyList *
+modest_platform_get_list_to_move (ModestWindow *window)
+{
+ TnyList *list = NULL;
+
+ /* If it's a main window then it could be that we're moving a
+ folder or a set of messages */
+ if (MODEST_IS_MAIN_WINDOW (window)) {
+ ModestHeaderView *header_view = NULL;
+ ModestFolderView *folder_view = NULL;
+
+ folder_view = (ModestFolderView *)
+ modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
+ header_view = (ModestHeaderView *)
+ modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
+
+ /* Get folder or messages to transfer */
+ if (gtk_widget_is_focus (GTK_WIDGET (folder_view))) {
+ TnyFolderStore *src_folder;
+
+ src_folder = modest_folder_view_get_selected (folder_view);
+ if (src_folder) {
+ list = tny_simple_list_new ();
+ tny_list_prepend (list, G_OBJECT (src_folder));
+ g_object_unref (src_folder);
+ }
+ } else if (gtk_widget_is_focus (GTK_WIDGET(header_view))) {
+ list = modest_header_view_get_selected_headers(header_view);
+ }
+ } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+ TnyHeader *header = NULL;
+
+ /* We simply return the currently viewed message */
+ header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (window));
+ if (header) {
+ list = tny_simple_list_new ();
+ tny_list_prepend (list, G_OBJECT (header));
+ g_object_unref (header);
+ }
+ } else {
+ g_return_val_if_reached (NULL);
+ }
+
+ return list;
+}