X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=7dba80572a9507d5c8d996d992b7f181ebf5f928;hp=af3090120c948398724f90ab63b3f9ea4de8c89a;hb=152ee6945dc5142b5e63f2a6ac6efc2dbb94df0c;hpb=f6b3776cd90fca73f1dd7905bebe05526e841a6a diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index af30901..7dba805 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -140,15 +140,14 @@ static void _on_send_receive_progress_changed (ModestMailOperation *mail_op gpointer user_data); static gboolean -download_uncached_messages (TnyList *header_list, GtkWindow *win, - gboolean reply_fwd); +download_uncached_messages (TnyList *header_list, GtkWindow *win); -static gint +/*static gint msgs_move_to_confirmation (GtkWindow *win, TnyFolder *dest_folder, gboolean delete, - TnyList *headers); + TnyList *headers);*/ /* Show the account creation wizard dialog. @@ -165,9 +164,17 @@ modest_run_account_setup_wizard (ModestWindow *win) g_return_val_if_fail (MODEST_IS_WINDOW(win), FALSE); - wizard = modest_easysetup_wizard_dialog_new (); + wizard = modest_easysetup_wizard_dialog_new_or_present (); + + /* if wizard == NULL it means there is already a easy setup thingy running; + * in that case, don't do anything here; the call above will present it instead */ + if (!wizard) { + g_message ("%s: easysetup wizard already running", __FUNCTION__); + return FALSE; + } + gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win)); - + /* Don't make this a modal window, because secondary windows will then * be unusable, freezing the UI: */ /* gtk_window_set_modal (GTK_WINDOW (wizard), TRUE); */ @@ -396,7 +403,6 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win) tny_list_get_length(header_list)), desc); /* Confirmation dialog */ - printf("DEBUG: %s\n", __FUNCTION__); response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win), message); @@ -717,16 +723,17 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) goto cleanup; } - if (modest_account_mgr_get_bool (modest_runtime_get_account_mgr (), account_name, - MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) { - signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), account_name, - MODEST_ACCOUNT_SIGNATURE, FALSE); + gboolean use_signature = FALSE; + signature = modest_account_mgr_get_signature (modest_runtime_get_account_mgr (), account_name, &use_signature); + + if (use_signature) { blank_and_signature = g_strconcat ("\n", signature, NULL); - g_free (signature); } else { blank_and_signature = g_strdup (""); } + g_free (signature); + msg = modest_tny_msg_new ("", from_str, "", "", "", blank_and_signature, NULL); if (!msg) { g_printerr ("modest: failed to create new msg\n"); @@ -741,7 +748,7 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) /* Create and register edit window */ - /* This is destroyed by TOOD. */ + /* This is destroyed by TODO. */ msg_win = modest_msg_edit_window_new (msg, account_name, FALSE); mgr = modest_runtime_get_window_mgr (); modest_window_mgr_register_window (mgr, msg_win); @@ -855,17 +862,15 @@ open_msg_cb (ModestMailOperation *mail_op, g_list_foreach (sel_list, (GFunc) gtk_tree_path_free, NULL); g_list_free (sel_list); - win = modest_msg_view_window_new_with_header_model (msg, - account, - (const gchar*) uid, - model, - row_reference); + win = modest_msg_view_window_new_with_header_model ( + msg, account, (const gchar*) uid, + model, row_reference); gtk_tree_row_reference_free (row_reference); } else { - win = modest_msg_view_window_new (msg, account, (const gchar*) uid); + win = modest_msg_view_window_new_for_attachment (msg, account, (const gchar*) uid); } } else { - win = modest_msg_view_window_new (msg, account, (const gchar*) uid); + win = modest_msg_view_window_new_for_attachment (msg, account, (const gchar*) uid); } g_free (uid); } @@ -1174,8 +1179,7 @@ cleanup: */ static gboolean download_uncached_messages (TnyList *header_list, - GtkWindow *win, - gboolean reply_fwd) + GtkWindow *win) { TnyIterator *iter; gboolean retval; @@ -1199,21 +1203,20 @@ download_uncached_messages (TnyList *header_list, /* Ask for user permission to download the messages */ retval = TRUE; if (uncached_messages > 0) { - GtkResponseType response; - if (reply_fwd) - response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win), - _("emev_nc_include_original")); - else - response = + gboolean download = TRUE; + if (!tny_device_is_online (modest_runtime_get_device())) { + GtkResponseType response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win), ngettext("mcen_nc_get_msg", "mcen_nc_get_msgs", uncached_messages)); - if (response == GTK_RESPONSE_CANCEL) - retval = FALSE; - else { + if (response == GTK_RESPONSE_CANCEL) download = FALSE; + } + if (download) { /* If a download will be necessary, make sure that we have a connection: */ retval = modest_platform_connect_and_wait(win, NULL); + } else { + retval = FALSE; } } return retval; @@ -1254,7 +1257,7 @@ reply_forward (ReplyForwardAction action, ModestWindow *win) /* Check that the messages have been previously downloaded */ do_retrieve = (action == ACTION_FORWARD) || (reply_forward_type != MODEST_TNY_MSG_REPLY_TYPE_CITE); if (do_retrieve) - continue_download = download_uncached_messages (header_list, GTK_WINDOW (win), TRUE); + continue_download = download_uncached_messages (header_list, GTK_WINDOW (win)); if (!continue_download) { g_object_unref (header_list); return; @@ -1725,15 +1728,6 @@ modest_ui_actions_on_header_selected (ModestHeaderView *header_view, if (!gtk_widget_is_focus (GTK_WIDGET(header_view))) gtk_widget_grab_focus (GTK_WIDGET(header_view)); - /* Update Main window title */ - if (gtk_widget_is_focus (GTK_WIDGET(header_view))) { - const gchar *subject = tny_header_get_subject (header); - if (subject && strlen(subject) > 0) - gtk_window_set_title (GTK_WINDOW (main_window), subject); - else - gtk_window_set_title (GTK_WINDOW (main_window), _("mail_va_no_subject")); - } - /* Update toolbar dimming state */ modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window)); } @@ -1787,8 +1781,8 @@ folder_refreshed_cb (ModestMailOperation *mail_op, ModestMainWindow *win = NULL; GtkWidget *header_view; TnyFolder *current_folder; - gboolean folder_empty = TRUE; - gboolean all_marked_as_deleted = TRUE; + gboolean folder_empty = FALSE; + gboolean all_marked_as_deleted = FALSE; g_return_if_fail (TNY_IS_FOLDER (folder)); @@ -2094,34 +2088,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name); - /* mail content checks and dialogs */ - if (data->subject == NULL || data->subject[0] == '\0') { - GtkResponseType response; - response = modest_platform_run_confirmation_dialog (GTK_WINDOW (edit_window), - _("mcen_nc_subject_is_empty_send")); - if (response == GTK_RESPONSE_CANCEL) { - g_free (account_name); - return; - } - } - - if (data->plain_body == NULL || data->plain_body[0] == '\0') { - GtkResponseType response; - gchar *note_message; - gchar *note_subject = data->subject; - if (note_subject == NULL || note_subject[0] == '\0') - note_subject = _("mail_va_no_subject"); - note_message = g_strdup_printf (_("emev_ni_ui_smtp_message_null"), note_subject); - response = modest_platform_run_confirmation_dialog (GTK_WINDOW (edit_window), - note_message); - g_free (note_message); - if (response == GTK_RESPONSE_CANCEL) { - g_free (account_name); - return; - } - } - - modest_platform_information_banner (NULL, NULL, _("mcen_ib_outbox_waiting_to_be_sent")); +/* modest_platform_information_banner (NULL, NULL, _("mcen_ib_outbox_waiting_to_be_sent")); */ /* Create the mail operation */ ModestMailOperation *mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_SEND, G_OBJECT(edit_window)); @@ -2455,10 +2422,14 @@ modest_ui_actions_on_rename_folder (GtkAction *action, gchar *folder_name; gint response; const gchar *current_name; + TnyFolderStore *parent; current_name = tny_folder_get_name (TNY_FOLDER (folder)); - response = modest_platform_run_rename_folder_dialog (GTK_WINDOW (main_window), NULL, - current_name, &folder_name); + parent = tny_folder_get_folder_store (TNY_FOLDER (folder)); + response = modest_platform_run_rename_folder_dialog (GTK_WINDOW (main_window), + parent, current_name, + &folder_name); + g_object_unref (parent); if (response == GTK_RESPONSE_ACCEPT && strlen (folder_name) > 0) { ModestMailOperation *mail_op; @@ -2468,6 +2439,7 @@ modest_ui_actions_on_rename_folder (GtkAction *action, G_OBJECT(main_window), modest_ui_actions_rename_folder_error_handler, main_window); + modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); @@ -2858,7 +2830,7 @@ modest_ui_actions_on_copy (GtkAction *action, /* Check that the messages have been previously downloaded */ gboolean continue_download = TRUE; if (ask) - continue_download = download_uncached_messages (header_list, GTK_WINDOW (window), FALSE); + continue_download = download_uncached_messages (header_list, GTK_WINDOW (window)); if (continue_download) modest_header_view_copy_selection (MODEST_HEADER_VIEW (focused_widget)); g_object_unref (header_list); @@ -3447,6 +3419,7 @@ create_move_to_dialog (GtkWindow *win, /* Create folder view */ *tree_view = modest_platform_create_folder_view (NULL); +/* *tree_view = modest_folder_view_new (NULL); */ g_signal_connect (G_OBJECT (new_button), "clicked", G_CALLBACK(create_move_to_dialog_on_new_folder), *tree_view); @@ -3454,13 +3427,14 @@ create_move_to_dialog (GtkWindow *win, window (msg window for example) after the main window was closed, so we can not just get the model of the folder view */ - if (MODEST_IS_FOLDER_VIEW (folder_view)) - gtk_tree_view_set_model (GTK_TREE_VIEW (*tree_view), - gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view))); - else + if (MODEST_IS_FOLDER_VIEW (folder_view)) { + modest_folder_view_copy_model (MODEST_FOLDER_VIEW(folder_view), + MODEST_FOLDER_VIEW(*tree_view)); + } else modest_folder_view_update_model (MODEST_FOLDER_VIEW (*tree_view), TNY_ACCOUNT_STORE (modest_runtime_get_account_store ())); + /* Hide special folders */ modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (*tree_view), FALSE); gtk_container_add (GTK_CONTAINER (scroll), *tree_view); @@ -3479,6 +3453,7 @@ create_move_to_dialog (GtkWindow *win, * Returns TRUE if at least one of the headers of the list belongs to * a message that has been fully retrieved. */ +#if 0 /* no longer in use. delete in 2007.10 */ static gboolean has_retrieved_msgs (TnyList *list) { @@ -3507,6 +3482,8 @@ has_retrieved_msgs (TnyList *list) return found; } +#endif /* 0 */ + /* * Shows a confirmation dialog to the user when we're moving messages @@ -3514,7 +3491,7 @@ has_retrieved_msgs (TnyList *list) * response. If it's other kind of movement the it always returns * GTK_RESPONSE_OK */ -static gint +gint msgs_move_to_confirmation (GtkWindow *win, TnyFolder *dest_folder, gboolean delete, @@ -3524,11 +3501,24 @@ msgs_move_to_confirmation (GtkWindow *win, /* If the destination is a local folder (or MMC folder )*/ if (!modest_tny_folder_is_remote_folder (dest_folder)) { -/* if (modest_tny_folder_is_local_folder (dest_folder)) { */ + + gboolean is_online; + TnyDevice *device; + TnyFolder *src_folder = NULL; TnyIterator *iter = NULL; TnyHeader *header = NULL; + /* get the device */ + + device = modest_runtime_get_device (); + if (device) + is_online = tny_device_is_online (device); + else { + g_warning ("failed to get tny device"); /* should not happend */ + is_online = FALSE; + } + /* Get source folder */ iter = tny_list_create_iterator (headers); header = TNY_HEADER (tny_iterator_get_current (iter)); @@ -3544,23 +3534,15 @@ msgs_move_to_confirmation (GtkWindow *win, return GTK_RESPONSE_CANCEL; /* If the source is a remote folder */ -/* if (!modest_tny_folder_is_local_folder (src_folder)) { */ - if (modest_tny_folder_is_remote_folder (src_folder)) { + if (!is_online && modest_tny_folder_is_remote_folder (src_folder)) { + const gchar *message = NULL; - gboolean cached = has_retrieved_msgs (headers); - if (cached) - message = ngettext ("mcen_nc_move_retrieve", "mcen_nc_move_retrieves", - tny_list_get_length (headers)); - else - message = ngettext ("mcen_nc_move_header", "mcen_nc_move_headers", - tny_list_get_length (headers)); - - if (cached && !delete) - response = GTK_RESPONSE_OK; - else - response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win), - (const gchar *) message); - } + message = ngettext ("mcen_nc_get_msg", "mcen_nc_get_msgs", + tny_list_get_length (headers)); + response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win), + (const gchar *) message); + } else + response = GTK_RESPONSE_OK; g_object_unref (src_folder); } @@ -3798,8 +3780,12 @@ modest_ui_actions_xfer_messages_from_move_to (TnyFolderStore *dst_folder, dst_account = tny_folder_get_account (TNY_FOLDER (dst_folder)); proto_str = tny_account_get_proto (dst_account); - dst_is_pop = (modest_protocol_info_get_transport_store_protocol (proto_str) == - MODEST_PROTOCOL_STORE_POP); + + /* tinymail will return NULL for local folders it seems */ + dst_is_pop = proto_str && + (modest_protocol_info_get_transport_store_protocol (proto_str) == + MODEST_PROTOCOL_STORE_POP); + g_object_unref (dst_account); /* Get selected headers */ @@ -3843,7 +3829,6 @@ modest_ui_actions_xfer_messages_from_move_to (TnyFolderStore *dst_folder, g_object_unref (headers); } - /* * UI handler for the "Move to" action when invoked from the * ModestMainWindow