X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=6c8fdde3a87b0e48281231d5bb62542c8f4d63fc;hp=9c7e9c6aff0e6ec6aa3f903889dae264457c93d6;hb=60e5848997afb38e747c6750f2fc0d6639adaef4;hpb=1b2e91130576f60b2a35a03ffba6553249c1b7f0 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 9c7e9c6..6c8fdde 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -66,8 +66,8 @@ #include "maemo/modest-hildon-includes.h" #include "maemo/modest-connection-specific-smtp-window.h" #endif /* !MODEST_TOOLKIT_GTK */ -#include +#include #include "widgets/modest-ui-constants.h" #include #include @@ -639,7 +639,7 @@ modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win) ModestWindowMgr *mgr = NULL; #ifdef MODEST_PLATFORM_MAEMO - modest_osso_save_state(); + modest_window_mgr_save_state_for_all_windows (modest_runtime_get_window_mgr ()); #endif /* MODEST_PLATFORM_MAEMO */ g_debug ("closing down, clearing %d item(s) from operation queue", @@ -1544,7 +1544,7 @@ open_msg_from_header (TnyHeader *header, GtkTreeRowReference *rowref, ModestWind OpenMsgHelper *helper; ModestWindow *window; - g_return_if_fail (header != NULL && rowref != NULL); + g_return_if_fail (header != NULL && rowref != NULL && gtk_tree_row_reference_valid (rowref)); mgr = modest_runtime_get_window_mgr (); @@ -2048,7 +2048,7 @@ reply_forward (ReplyForwardAction action, ModestWindow *win) if (folder) g_object_unref (folder); } else { - reply_forward_cb (NULL, header, FALSE, NULL, NULL, rf_helper); + reply_forward_cb (NULL, header, FALSE, NULL, NULL, NULL); } /* Frees */ g_object_unref (header_list); @@ -2152,17 +2152,70 @@ modest_ui_actions_on_sort (GtkAction *action, } static void -new_messages_arrived (ModestMailOperation *self, - TnyList *new_headers, - gpointer user_data) +sync_folder_cb (ModestMailOperation *mail_op, + TnyFolder *folder, + gpointer user_data) +{ + ModestHeaderView *header_view = (ModestHeaderView *) user_data; + + if (modest_mail_operation_get_status (mail_op) == MODEST_MAIL_OPERATION_STATUS_SUCCESS) { + ModestWindow *parent = (ModestWindow *) modest_mail_operation_get_source (mail_op); + + /* We must clear first, because otherwise set_folder will ignore */ + /* the change as the folders are the same */ + modest_header_view_clear (header_view); + modest_header_view_set_folder (header_view, folder, TRUE, parent, NULL, NULL); + + g_object_unref (parent); + } + + g_object_unref (header_view); +} + +static gboolean +idle_refresh_folder (gpointer source) +{ + ModestHeaderView *header_view = NULL; + + /* If the window still exists */ + if (!GTK_IS_WIDGET (source) || + !GTK_WIDGET_VISIBLE (source)) + return FALSE; + + /* Refresh the current view */ +#ifdef MODEST_TOOLKIT_HILDON2 + if (MODEST_IS_HEADER_WINDOW (source)) + header_view = modest_header_window_get_header_view ((ModestHeaderWindow *) source); +#else + if (MODEST_IS_MAIN_WINDOW (source)) + header_view = MODEST_HEADER_VIEW (modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (source), + MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW)); +#endif + if (header_view) { + TnyFolder *folder = modest_header_view_get_folder (header_view); + if (folder) { + /* Sync the folder status */ + ModestMailOperation *mail_op = modest_mail_operation_new (source); + modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); + modest_mail_operation_sync_folder (mail_op, folder, FALSE, sync_folder_cb, g_object_ref (header_view)); + g_object_unref (folder); + g_object_unref (mail_op); + } + } + + return FALSE; +} + +static void +update_account_cb (ModestMailOperation *self, + TnyList *new_headers, + gpointer user_data) { - GObject *source; + ModestWindow *top; gboolean show_visual_notifications; - source = modest_mail_operation_get_source (self); - show_visual_notifications = (source) ? FALSE : TRUE; - if (source) - g_object_unref (source); + top = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ()); + show_visual_notifications = (top) ? FALSE : TRUE; /* Notify new messages have been downloaded. If the send&receive was invoked by the user then do not show any @@ -2210,29 +2263,15 @@ new_messages_arrived (ModestMailOperation *self, g_object_unref (actually_new_list); } -} - -gboolean -retrieve_all_messages_cb (GObject *source, - guint num_msgs, - guint retrieve_limit) -{ - GtkWindow *window; - gchar *msg; - gint response; - - window = GTK_WINDOW (source); - msg = g_strdup_printf (_("mail_nc_msg_count_limit_exceeded"), - num_msgs, retrieve_limit); - - /* Ask the user if they want to retrieve all the messages */ - response = - modest_platform_run_confirmation_dialog_with_buttons (window, msg, - _("mcen_bd_get_all"), - _("mcen_bd_newest_only")); - /* Free and return */ - g_free (msg); - return (response == GTK_RESPONSE_ACCEPT) ? TRUE : FALSE; + if (top) { + /* Refresh the current folder in an idle. We do this + in order to avoid refresh cancelations if the + currently viewed folder is the inbox */ + g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, + idle_refresh_folder, + g_object_ref (top), + g_object_unref); + } } typedef struct { @@ -2280,8 +2319,7 @@ do_send_receive_performer (gboolean canceled, /* Send & receive. */ modest_mail_operation_update_account (info->mail_op, info->account_name, info->poke_status, info->interactive, - (info->win) ? retrieve_all_messages_cb : NULL, - new_messages_arrived, info->win); + update_account_cb, info->win); clean: /* Frees */ @@ -3122,17 +3160,12 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), TRUE); - if (!modest_msg_edit_window_check_names (edit_window, TRUE)) + /* Check names but do not automatically add them to addressbook */ + if (!modest_msg_edit_window_check_names (edit_window, FALSE)) return TRUE; data = modest_msg_edit_window_get_msg_data (edit_window); - if (data->subject == NULL || data->subject[0] == '\0') { - /* Empty subject -> no send */ - modest_msg_edit_window_free_msg_data (edit_window, data); - return FALSE; - } - recipients = g_strconcat (data->to?data->to:"", data->cc?data->cc:"", data->bcc?data->bcc:"", @@ -3168,7 +3201,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) } /* Get the currently-active transport account for this modest account: */ - if (strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) != 0) { + if (account_name && strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) != 0) { transport_account = TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_server_account (modest_runtime_get_account_store (), @@ -3471,7 +3504,7 @@ do_create_folder_performer (gboolean canceled, /* This happens if we have selected the outbox folder as the parent */ - if (err->code == TNY_SERVICE_ERROR_UNKNOWN && + if (err && err->code == TNY_SERVICE_ERROR_UNKNOWN && TNY_IS_MERGE_FOLDER (helper->parent)) { /* Show an error and retry */ modest_platform_information_banner ((GtkWidget *) parent_window, @@ -3846,8 +3879,8 @@ on_delete_folder_cb (gboolean canceled, modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (folder_view)); - g_object_unref (G_OBJECT (mail_op)); - g_object_unref (G_OBJECT (info->folder)); + g_object_unref (mail_op); + g_object_unref (info->folder); g_free (info); } @@ -3897,22 +3930,23 @@ delete_folder (ModestWindow *window, gboolean move_to_trash) g_free (message); if (response == GTK_RESPONSE_OK) { - DeleteFolderInfo *info; + TnyAccount *account = NULL; + DeleteFolderInfo *info = NULL; info = g_new0(DeleteFolderInfo, 1); - info->folder = folder; + info->folder = g_object_ref (folder); info->move_to_trash = move_to_trash; - g_object_ref (G_OBJECT (info->folder)); - TnyAccount *account = tny_folder_get_account (TNY_FOLDER (folder)); + + account = tny_folder_get_account (TNY_FOLDER (folder)); modest_platform_connect_if_remote_and_perform (GTK_WINDOW (window), TRUE, TNY_FOLDER_STORE (account), on_delete_folder_cb, info); g_object_unref (account); + g_object_unref (folder); return TRUE; } else { return FALSE; } - g_object_unref (G_OBJECT (folder)); } void @@ -5091,7 +5125,6 @@ on_move_to_dialog_response (GtkDialog *dialog, parent_win = (GtkWidget *) helper->win; folder_view = MODEST_FOLDER_VIEW (g_object_get_data (G_OBJECT (dialog), MODEST_MOVE_TO_DIALOG_FOLDER_VIEW)); - switch (response) { TnyFolderStore *dst_folder; TnyFolderStore *selected; @@ -5209,8 +5242,8 @@ create_move_to_dialog (GtkWindow *win, modest_folder_view_set_style (MODEST_FOLDER_VIEW (tree_view), MODEST_FOLDER_VIEW_STYLE_SHOW_ALL); - modest_folder_view_update_model (MODEST_FOLDER_VIEW (tree_view), - TNY_ACCOUNT_STORE (modest_runtime_get_account_store ())); + /* modest_folder_view_update_model (MODEST_FOLDER_VIEW (tree_view), */ + /* TNY_ACCOUNT_STORE (modest_runtime_get_account_store ())); */ active_account_name = modest_window_get_active_account (MODEST_WINDOW (win)); mgr = modest_runtime_get_account_mgr ();