X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=e1dc2ff244876d51815acef97ab05530bce59ce9;hp=95b920a2b36b854c16d203eea8ca45fa843331b6;hb=82416b4e16ccb7f40304192ae58c0469781c63fe;hpb=09f875751e898932c6bafbea7efe692f6aa70f9c diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 95b920a..e1dc2ff 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -223,14 +223,38 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win) wizard = GTK_WINDOW (modest_platform_get_account_settings_wizard ()); modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), GTK_WINDOW (wizard), (GtkWindow *) win); +#ifndef MODEST_TOOLKIT_HILDON2 /* always present a main window in the background * we do it here, so we cannot end up with two wizards (as this * function might be called in modest_window_mgr_get_main_window as well */ - if (!win) + if (!win) win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), TRUE); /* create if not existent */ +#else + if (!win) { + GList *window_list; + ModestWindowMgr *mgr; + + mgr = modest_runtime_get_window_mgr (); + + window_list = modest_window_mgr_get_window_list (mgr); + if (window_list == NULL) { + win = MODEST_WINDOW (modest_accounts_window_new ()); + modest_window_mgr_register_window (mgr, win, NULL); + gtk_widget_show_all (GTK_WIDGET (win)); + + win = MODEST_WINDOW (modest_folder_window_new (NULL)); + modest_window_mgr_register_window (mgr, win, NULL); - gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win)); + gtk_widget_show_all (GTK_WIDGET (win)); + } else { + g_list_free (window_list); + } + } +#endif + + if (win) + gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win)); /* make sure the mainwindow is visible. We need to present the wizard again to give it the focus back. show_all are needed @@ -881,14 +905,30 @@ modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op, if (error && ((error->code == TNY_SERVICE_ERROR_NO_SUCH_MESSAGE) || error->code == TNY_SERVICE_ERROR_MESSAGE_NOT_AVAILABLE)) { - gchar *subject, *msg; + gchar *subject, *msg, *format = NULL; + TnyAccount *account; subject = tny_header_dup_subject (header); if (!subject) - subject = g_strdup (_("mail_va_no_subject"));; - msg = g_strdup_printf (_("emev_ni_ui_imap_message_not_available_in_server"), - subject); + subject = g_strdup (_("mail_va_no_subject")); + + account = modest_mail_operation_get_account (mail_op); + if (account) { + ModestProtocol *protocol; + ModestProtocolType proto; + proto = modest_tny_account_get_protocol_type (account); + protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (), proto); + if (protocol) + format = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE, subject); + g_object_unref (account); + } + + if (!format) + format = g_strdup (_("emev_ni_ui_imap_message_not_available_in_server")); + + msg = g_strdup_printf (format, subject); modest_platform_run_information_dialog (NULL, msg, FALSE); g_free (msg); + g_free (format); g_free (subject); } @@ -995,7 +1035,6 @@ get_info_from_header (TnyHeader *header, gboolean *is_draft, gboolean *can_open) outbox which is not in failed state */ *can_open = FALSE; - g_object_unref(traccount); } #endif } @@ -1156,7 +1195,7 @@ check_memory_full_error (GtkWidget *parent_window, GError *err) else if (err->code == TNY_SYSTEM_ERROR_MEMORY) /* If the account was created in memory full conditions then tinymail won't be able to - connect so it'll return this error code */ + connect so it'll return this error code */ modest_platform_information_banner (parent_window, NULL, _("emev_ui_imap_inbox_select_error")); else @@ -1434,7 +1473,7 @@ open_msg_from_header (TnyHeader *header, GtkTreeRowReference *rowref, ModestWind GtkWidget *header_view = NULL; OpenMsgHelper *helper; ModestWindow *window; - + g_return_if_fail (header != NULL && rowref != NULL); mgr = modest_runtime_get_window_mgr (); @@ -1451,7 +1490,7 @@ open_msg_from_header (TnyHeader *header, GtkTreeRowReference *rowref, ModestWind window = NULL; found = modest_window_mgr_find_registered_header (mgr, header, &window); - + /* Do not open again the message and present the window to the user */ if (found) { @@ -3419,7 +3458,7 @@ modest_ui_actions_rename_folder_error_handler (ModestMailOperation *mail_op, message is opened for example */ message = _("emev_ni_internal_error"); } else { - message = _("emev_ib_ui_imap_unable_to_rename"); + message = _CS("ckdg_ib_unable_to_remove"); } /* We don't set a parent for the dialog because the dialog @@ -3664,6 +3703,9 @@ delete_folder (ModestWindow *window, gboolean move_to_trash) folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view)); + if (!folder) + return FALSE; + /* Show an error if it's an account */ if (!TNY_IS_FOLDER (folder)) { modest_platform_run_information_dialog (GTK_WINDOW (window), @@ -3673,7 +3715,7 @@ delete_folder (ModestWindow *window, gboolean move_to_trash) return FALSE; } - /* Ask the user */ + /* Ask the user */ message = g_strdup_printf (_("mcen_nc_delete_folder_text"), tny_folder_get_name (TNY_FOLDER (folder))); response = modest_platform_run_confirmation_dialog (GTK_WINDOW (window), @@ -5283,7 +5325,7 @@ modest_ui_actions_on_main_window_remove_attachments (GtkAction *action, * Checks if we need a connection to do the transfer and if the user * wants to connect to complete it */ -void +static void modest_ui_actions_xfer_messages_check (GtkWindow *parent_window, TnyFolderStore *src_folder, TnyList *headers, @@ -5295,8 +5337,6 @@ modest_ui_actions_xfer_messages_check (GtkWindow *parent_window, TnyAccount *src_account; gint uncached_msgs = 0; - uncached_msgs = header_list_count_uncached_msgs (headers); - /* We don't need any further check if * * 1- the source folder is local OR @@ -5318,6 +5358,7 @@ modest_ui_actions_xfer_messages_check (GtkWindow *parent_window, * offline, it'll take place the next time we get a * connection) */ + uncached_msgs = header_list_count_uncached_msgs (headers); src_account = get_account_from_folder_store (src_folder); if (uncached_msgs > 0) { guint num_headers; @@ -5340,11 +5381,11 @@ modest_ui_actions_xfer_messages_check (GtkWindow *parent_window, if (remote_folder_has_leave_on_server (src_folder) && delete_originals) { const gchar *account_name; gboolean leave_on_server; - + account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (src_account); leave_on_server = modest_account_mgr_get_leave_on_server (modest_runtime_get_account_mgr (), account_name); - + if (leave_on_server == TRUE) { *need_connection = FALSE; } else { @@ -5363,10 +5404,19 @@ static void xfer_messages_error_handler (ModestMailOperation *mail_op, gpointer user_data) { - GObject *win = modest_mail_operation_get_source (mail_op); - modest_platform_run_information_dialog ((GtkWindow *) win, - _("mail_in_ui_folder_move_target_error"), - FALSE); + GObject *win; + const GError *error; + + win = modest_mail_operation_get_source (mail_op); + error = modest_mail_operation_get_error (mail_op); + + if (error && is_memory_full_error ((GError *) error)) + modest_platform_information_banner ((GtkWidget *) win, + NULL, _KR("cerm_device_memory_full")); + else + modest_platform_run_information_dialog ((GtkWindow *) win, + _("mail_in_ui_folder_move_target_error"), + FALSE); if (win) g_object_unref (win); } @@ -5644,6 +5694,10 @@ modest_ui_actions_on_folder_window_move_to (GtkWidget *folder_view, !MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (dst_folder) && !modest_tny_account_is_memory_card_account (TNY_ACCOUNT (dst_folder))) { do_xfer = FALSE; + /* Show an error */ + modest_platform_run_information_dialog (win, + _("mail_in_ui_folder_move_target_error"), + FALSE); } else if (!TNY_IS_FOLDER (src_folder)) { g_warning ("%s: src_folder is not a TnyFolder.\n", __FUNCTION__); do_xfer = FALSE; @@ -5652,7 +5706,7 @@ modest_ui_actions_on_folder_window_move_to (GtkWidget *folder_view, if (do_xfer) { MoveFolderInfo *info = g_new0 (MoveFolderInfo, 1); DoubleConnectionInfo *connect_info = g_slice_new (DoubleConnectionInfo); - + info->src_folder = g_object_ref (src_folder); info->dst_folder = g_object_ref (dst_folder); info->delete_original = TRUE; @@ -5666,6 +5720,7 @@ modest_ui_actions_on_folder_window_move_to (GtkWidget *folder_view, TNY_FOLDER_STORE (src_folder), connect_info); } + /* Frees */ g_object_unref (src_folder); } @@ -5761,27 +5816,22 @@ modest_ui_actions_on_move_to (GtkAction *action, gboolean modest_ui_actions_on_edit_mode_move_to (ModestWindow *win) { - GtkWidget *dialog = NULL, *folder_view = NULL; - ModestMainWindow *main_window; + GtkWidget *dialog = NULL; MoveToInfo *helper = NULL; TnyList *list_to_move; g_return_val_if_fail (MODEST_IS_WINDOW (win), FALSE); +#ifndef MODEST_TOOLKIT_HILDON2 /* Get the main window if exists */ + ModestMainWindow *main_window; if (MODEST_IS_MAIN_WINDOW (win)) main_window = MODEST_MAIN_WINDOW (win); else main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE)); /* don't create */ - - /* Get the folder view widget if exists */ - if (main_window) - folder_view = modest_main_window_get_child_widget (main_window, - MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW); - else - folder_view = NULL; +#endif list_to_move = modest_platform_get_list_to_move (MODEST_WINDOW (win)); @@ -5794,14 +5844,14 @@ modest_ui_actions_on_edit_mode_move_to (ModestWindow *win) } /* Create and run the dialog */ - dialog = create_move_to_dialog (GTK_WINDOW (win), folder_view); + dialog = create_move_to_dialog (GTK_WINDOW (win), NULL); modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), (GtkWindow *) win); /* Create helper */ helper = g_slice_new0 (MoveToInfo); - helper->list = modest_platform_get_list_to_move (MODEST_WINDOW (win)); + helper->list = list_to_move; helper->win = win; /* Listen to response signal */ @@ -5850,10 +5900,12 @@ do_headers_action (ModestWindow *win, /* Trick: do a poke status in order to speed up the signaling of observers */ - tny_folder_poke_status (folder); + if (folder) { + tny_folder_poke_status (folder); + g_object_unref (folder); + } /* Frees */ - g_object_unref (folder); g_object_unref (iter); g_object_unref (headers_list); } @@ -6309,63 +6361,70 @@ modest_ui_actions_on_send_queue_status_changed (ModestTnySendQueue *send_queue, guint status, gpointer user_data) { - ModestMainWindow *main_window = NULL; + ModestWindow *top_window = NULL; ModestWindowMgr *mgr = NULL; - GtkWidget *folder_view = NULL, *header_view = NULL; - TnyFolderStore *selected_folder = NULL; + GtkWidget *header_view = NULL; + TnyFolder *selected_folder = NULL; TnyFolderType folder_type; mgr = modest_runtime_get_window_mgr (); - main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (mgr, - FALSE));/* don't create */ - if (!main_window) + top_window = modest_window_mgr_get_current_top (mgr); + + if (!top_window) return; - /* Check if selected folder is OUTBOX */ - folder_view = modest_main_window_get_child_widget (main_window, - MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW); - header_view = modest_main_window_get_child_widget (main_window, - MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW); +#ifndef MODEST_TOOLKIT_HILDON2 + if (MODEST_IS_MAIN_WINDOW (top_window)) { + header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (top_window), + MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW); + } +#else + if (MODEST_IS_HEADER_WINDOW (top_window)) { + header_view = (GtkWidget *) + modest_header_window_get_header_view (MODEST_HEADER_WINDOW (top_window)); + } +#endif - selected_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view)); - if (!TNY_IS_FOLDER (selected_folder)) - goto frees; + /* Get selected folder */ + selected_folder = modest_header_view_get_folder (MODEST_HEADER_VIEW (header_view)); + if (!selected_folder) + return; /* gtk_tree_view_column_queue_resize is only available in GTK+ 2.8 */ -#if GTK_CHECK_VERSION(2, 8, 0) - folder_type = modest_tny_folder_guess_folder_type (TNY_FOLDER (selected_folder)); - if (folder_type == TNY_FOLDER_TYPE_OUTBOX) { +#if GTK_CHECK_VERSION(2, 8, 0) + folder_type = modest_tny_folder_guess_folder_type (selected_folder); + if (folder_type == TNY_FOLDER_TYPE_OUTBOX) { GtkTreeViewColumn *tree_column; - tree_column = gtk_tree_view_get_column (GTK_TREE_VIEW (header_view), + tree_column = gtk_tree_view_get_column (GTK_TREE_VIEW (header_view), TNY_GTK_HEADER_LIST_MODEL_FROM_COLUMN); if (tree_column) gtk_tree_view_column_queue_resize (tree_column); - } -#else + } +#else /* #if GTK_CHECK_VERSION(2, 8, 0) */ gtk_widget_queue_draw (header_view); -#endif +#endif +#ifndef MODEST_TOOLKIT_HILDON2 /* Rerun dimming rules, because the message could become deletable for example */ - modest_window_check_dimming_rules_group (MODEST_WINDOW (main_window), + modest_window_check_dimming_rules_group (MODEST_WINDOW (top_window), MODEST_DIMMING_RULES_TOOLBAR); - modest_window_check_dimming_rules_group (MODEST_WINDOW (main_window), + modest_window_check_dimming_rules_group (MODEST_WINDOW (top_window), MODEST_DIMMING_RULES_MENU); - +#endif + /* Free */ - frees: - if (selected_folder != NULL) - g_object_unref (selected_folder); + g_object_unref (selected_folder); } -void +void modest_ui_actions_on_account_connection_error (GtkWindow *parent_window, TnyAccount *account) { ModestProtocolType protocol_type; ModestProtocol *protocol; gchar *error_note = NULL; - + protocol_type = modest_tny_account_get_protocol_type (account); protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (), protocol_type);