X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=959cc97fe9a26cf9d7e4d2bbb17179aace7bf9d5;hb=d8cb7ecc661787017912f164d52f6d7b39390446;hp=1b6ed49c720141828b825bfcdfd571a46cac7c37;hpb=af2f008361db970fccfb6993802787e938224dc7;p=modest diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 1b6ed49..959cc97 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -120,6 +120,13 @@ static void reply_forward (ReplyForwardAction action, ModestWindow static gchar* ask_for_folder_name (GtkWindow *parent_window, const gchar *title); + +static void _on_send_receive_progress_changed (ModestMailOperation *mail_op, + ModestMailOperationState *state, + gpointer user_data); + + + void modest_ui_actions_on_about (GtkAction *action, ModestWindow *win) { @@ -468,7 +475,7 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) /* GError *err = NULL; */ TnyAccount *account = NULL; ModestWindowMgr *mgr; - gchar *signature = NULL; + gchar *signature = NULL, *blank_and_signature = NULL; account_name = g_strdup(modest_window_get_active_account (win)); if (!account_name) @@ -496,11 +503,13 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) { signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), account_name, MODEST_ACCOUNT_SIGNATURE, FALSE); + blank_and_signature = g_strconcat ("\n", signature, NULL); + g_free (signature); } else { - signature = g_strdup (""); + blank_and_signature = g_strdup (""); } - msg = modest_tny_msg_new ("", from_str, "", "", "", signature, NULL); + msg = modest_tny_msg_new ("", from_str, "", "", "", blank_and_signature, NULL); if (!msg) { g_printerr ("modest: failed to create new msg\n"); goto cleanup; @@ -534,7 +543,7 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) cleanup: g_free (account_name); g_free (from_str); - g_free (signature); + g_free (blank_and_signature); if (account) g_object_unref (G_OBJECT(account)); if (msg) @@ -738,8 +747,6 @@ reply_forward_cb (ModestMailOperation *mail_op, ModestWindow *msg_win; ModestEditType edit_type; gchar *from; - GError *err = NULL; - TnyFolder *folder = NULL; TnyAccount *account = NULL; ModestWindowMgr *mgr; gchar *signature = NULL; @@ -796,20 +803,6 @@ reply_forward_cb (ModestMailOperation *mail_op, goto cleanup; } - folder = modest_tny_account_get_special_folder (account, TNY_FOLDER_TYPE_DRAFTS); - if (!folder) { - g_printerr ("modest: failed to find Drafts folder\n"); - goto cleanup; - } - - tny_folder_add_msg (folder, msg, &err); - if (err) { - g_printerr ("modest: error adding msg to Drafts folder: %s", - err->message); - g_error_free (err); - goto cleanup; - } - /* Create and register the windows */ msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account_name); mgr = modest_runtime_get_window_mgr (); @@ -828,8 +821,6 @@ reply_forward_cb (ModestMailOperation *mail_op, cleanup: if (new_msg) g_object_unref (G_OBJECT (new_msg)); - if (folder) - g_object_unref (G_OBJECT (folder)); if (account) g_object_unref (G_OBJECT (account)); g_object_unref (msg); @@ -934,7 +925,7 @@ reply_forward (ReplyForwardAction action, ModestWindow *win) reply_forward_cb must do it */ msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW(win)); header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW(win)); - if (!msg || !header) { + if (!msg || !header) { if (msg) g_object_unref (msg); if (header) @@ -1073,6 +1064,14 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win) acc_name = g_strdup (account_name); } + /* Set send/receive operation in progress */ + modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW(win)); + + mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win)); + g_signal_connect (G_OBJECT(mail_op), "progress-changed", + G_CALLBACK (_on_send_receive_progress_changed), + win); + /* Send & receive. */ /* TODO: The spec wants us to first do any pending deletions, before receiving. */ /* Receive and then send. The operation is tagged initially as @@ -1080,7 +1079,6 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win) receive and then a send. The operation changes its type internally, so the progress objects will receive the proper progress information */ - mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win)); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); modest_mail_operation_update_account (mail_op, acc_name); g_object_unref (G_OBJECT (mail_op)); @@ -1236,7 +1234,8 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, { ModestConf *conf; GtkWidget *header_view; - + gboolean folder_empty = FALSE; + g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window)); header_view = modest_main_window_get_child_widget(main_window, @@ -1251,26 +1250,33 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, set_active_account_from_tny_account (TNY_ACCOUNT (folder_store), MODEST_WINDOW (main_window)); /* Show account details */ modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS); - } else if (modest_tny_folder_store_is_virtual_local_folders (folder_store )) { - //TODO: Set the virtual folder store as the "active account" somehow: - modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS); } else { if (TNY_IS_FOLDER (folder_store) && selected) { if (!TNY_IS_MERGE_FOLDER (folder_store)) { /* TnyMergeFolder can have no get_account() implementation. */ /* Update the active account */ - TnyAccount *account = tny_folder_get_account (TNY_FOLDER (folder_store)); + TnyAccount *account = modest_tny_folder_get_account (TNY_FOLDER (folder_store)); set_active_account_from_tny_account (account, MODEST_WINDOW (main_window)); g_object_unref (account); } + /* Set folder on header view */ - modest_main_window_set_contents_style (main_window, - MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS); modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view), - TNY_FOLDER (folder_store)); - modest_widget_memory_restore (conf, G_OBJECT(header_view), - MODEST_CONF_HEADER_VIEW_KEY); + TNY_FOLDER (folder_store)); + + /* Set main view style */ + folder_empty = tny_folder_get_all_count (TNY_FOLDER (folder_store)) == 0; + if (folder_empty) { + modest_main_window_set_contents_style (main_window, + MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY); + } + else { + modest_main_window_set_contents_style (main_window, + MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS); + modest_widget_memory_restore (conf, G_OBJECT(header_view), + MODEST_CONF_HEADER_VIEW_KEY); + } } else { /* Update the active account */ modest_window_set_active_account (MODEST_WINDOW (main_window), NULL); @@ -1392,6 +1398,11 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi modest_msg_edit_window_free_msg_data (edit_window, data); return; } + + if (!strcmp (account_name, MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID)) { + account_name = g_strdup (data->account_name); + } + transport_account = TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_tny_account_by_account (modest_runtime_get_account_store(), @@ -1411,6 +1422,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi modest_mail_operation_save_to_drafts (mail_operation, transport_account, + data->draft_msg, from, data->to, data->cc, @@ -1453,6 +1465,11 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) g_printerr ("modest: no account found\n"); return; } + MsgData *data = modest_msg_edit_window_get_msg_data (edit_window); + + if (!strcmp (account_name, MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID)) { + account_name = g_strdup (data->account_name); + } /* Get the currently-active transport account for this modest account: */ TnyTransportAccount *transport_account = @@ -1462,13 +1479,12 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) if (!transport_account) { g_printerr ("modest: no transport account found for '%s'\n", account_name); g_free (account_name); + modest_msg_edit_window_free_msg_data (edit_window, data); return; } gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name); - MsgData *data = modest_msg_edit_window_get_msg_data (edit_window); - /* mail content checks and dialogs */ if (data->subject == NULL || data->subject[0] == '\0') { GtkResponseType response; @@ -1502,6 +1518,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) modest_mail_operation_send_new_mail (mail_operation, transport_account, + data->draft_msg, from, data->to, data->cc, @@ -3013,3 +3030,25 @@ modest_ui_actions_check_toolbar_dimming_rules (ModestWindow *window) /* Update dimmed */ modest_window_check_dimming_rules_group (window, "ModestToolbarDimmingRules"); } + +void +modest_ui_actions_on_search_messages (GtkAction *action, ModestWindow *window) +{ + g_return_if_fail (MODEST_IS_WINDOW (window)); + + modest_platform_show_search_messages (GTK_WINDOW (window)); +} + + +static void +_on_send_receive_progress_changed (ModestMailOperation *mail_op, + ModestMailOperationState *state, + gpointer user_data) +{ + g_return_if_fail (MODEST_IS_MAIN_WINDOW(user_data)); + + /* Set send/receive operation finished */ + if (state->status != MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS) + modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW(user_data)); + +}