X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=3af2dd553849e15543e52e0b4ed275d6ca0b4ff2;hp=739638f4b7aef5c920306da62ec2f7b3006922d4;hb=311f7e1be00b2a22bbd3b759f06f39d2adc23865;hpb=3aa82e8145fa08ff404f3a55eee70a0c4763cf31 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 739638f..3af2dd5 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ #include #include #include +#include #endif #ifdef MODEST_PLATFORM_MAEMO @@ -239,14 +241,23 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win) window_list = modest_window_mgr_get_window_list (mgr); if (window_list == NULL) { + ModestWindow *old_win; win = MODEST_WINDOW (modest_accounts_window_new ()); - modest_window_mgr_register_window (mgr, win, NULL); - gtk_widget_show_all (GTK_WIDGET (win)); + if (modest_window_mgr_register_window (mgr, win, NULL)) { + gtk_widget_show_all (GTK_WIDGET (win)); + } else { + gtk_widget_destroy (GTK_WIDGET (win)); + win = NULL; + } + old_win = win; win = MODEST_WINDOW (modest_folder_window_new (NULL)); - modest_window_mgr_register_window (mgr, win, NULL); - - gtk_widget_show_all (GTK_WIDGET (win)); + if (modest_window_mgr_register_window (mgr, win, NULL)) { + gtk_widget_show_all (GTK_WIDGET (win)); + } else { + gtk_widget_destroy (GTK_WIDGET (win)); + win = old_win; + } } else { g_list_free (window_list); } @@ -918,7 +929,7 @@ modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op, 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); + format = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE, subject); g_object_unref (account); } @@ -1195,7 +1206,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 @@ -2058,12 +2069,12 @@ modest_ui_actions_on_sort (GtkAction *action, if (!header_view) { modest_platform_information_banner (NULL, NULL, _CS("ckdg_ib_nothing_to_sort")); - + return; } /* Show sorting dialog */ - modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS); + modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS); } static void @@ -3372,7 +3383,7 @@ do_create_folder (GtkWindow *parent_window, &parent_folder); if (result == GTK_RESPONSE_ACCEPT && parent_folder) { - CreateFolderConnect *helper = (CreateFolderConnect *) g_slice_new0 (CreateFolderHelper); + CreateFolderConnect *helper = (CreateFolderConnect *) g_slice_new0 (CreateFolderConnect); helper->folder_name = g_strdup (folder_name); helper->parent = g_object_ref (parent_folder); @@ -3406,8 +3417,10 @@ modest_ui_actions_create_folder(GtkWidget *parent_window, parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view)); #endif - if (parent_folder) + if (parent_folder) { do_create_folder (GTK_WINDOW (parent_window), parent_folder, NULL); + g_object_unref (parent_folder); + } } void @@ -3458,7 +3471,7 @@ modest_ui_actions_rename_folder_error_handler (ModestMailOperation *mail_op, message is opened for example */ message = _("emev_ni_internal_error"); } else { - message = _CS("ckdg_ib_unable_to_remove"); + message = _CS("ckdg_ib_unable_to_rename"); } /* We don't set a parent for the dialog because the dialog @@ -3490,7 +3503,7 @@ on_rename_folder_cb (ModestMailOperation *mail_op, } else { modest_folder_view_select_first_inbox_or_local (folder_view); } - gtk_widget_grab_focus (GTK_WIDGET (folder_view)); + gtk_widget_grab_focus (GTK_WIDGET (folder_view)); } static void @@ -3510,7 +3523,7 @@ on_rename_folder_performer (gboolean canceled, check_memory_full_error ((GtkWidget *) parent_window, err); } else { - mail_op = + mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(parent_window), modest_ui_actions_rename_folder_error_handler, parent_window, NULL); @@ -3523,13 +3536,17 @@ on_rename_folder_performer (gboolean canceled, folder_view = modest_main_window_get_child_widget ( MODEST_MAIN_WINDOW (parent_window), MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW); - - /* Clear the headers view */ - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_view)); - gtk_tree_selection_unselect_all (sel); - } else { - folder_view = NULL; + } +#ifdef MODEST_TOOLKIT_HILDON2 + else if (MODEST_IS_FOLDER_WINDOW (parent_window)) { + ModestFolderWindow *folder_window = (ModestFolderWindow *) parent_window; + folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (folder_window)); } +#endif + + /* Clear the folders view */ + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_view)); + gtk_tree_selection_unselect_all (sel); /* Actually rename the folder */ modest_mail_operation_rename_folder (mail_op, @@ -3537,10 +3554,10 @@ on_rename_folder_performer (gboolean canceled, (const gchar *) (data->new_name), on_rename_folder_cb, folder_view); - g_object_unref (data->folder); g_object_unref (mail_op); } + g_object_unref (data->folder); g_free (data->new_name); g_free (data); } @@ -3778,11 +3795,19 @@ password_dialog_check_field (GtkEditable *editable, const gchar *value; gboolean any_value_empty = FALSE; +#ifdef MODEST_TOOLKIT_HILDON2 + value = hildon_entry_get_text (HILDON_ENTRY (fields->username)); +#else value = gtk_entry_get_text (GTK_ENTRY (fields->username)); +#endif if ((value == NULL) || value[0] == '\0') { any_value_empty = TRUE; } +#ifdef MODEST_TOOLKIT_HILDON2 + value = hildon_entry_get_text (HILDON_ENTRY (fields->password)); +#else value = gtk_entry_get_text (GTK_ENTRY (fields->password)); +#endif if ((value == NULL) || value[0] == '\0') { any_value_empty = TRUE; } @@ -3821,6 +3846,8 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, _HL("wdgt_bd_done"), GTK_RESPONSE_ACCEPT, NULL); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), + HILDON_MARGIN_DOUBLE); #else GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"), @@ -3857,19 +3884,27 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, } gchar *txt = g_strdup_printf (_("mail_ia_password_info"), server_name); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt), - FALSE, FALSE, 0); + GtkWidget *label = gtk_label_new (txt); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); g_free (txt); g_free (server_name); + gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), label, + FALSE, FALSE, 0); server_name = NULL; /* username: */ gchar *initial_username = modest_account_mgr_get_server_account_username ( modest_runtime_get_account_mgr(), server_account_name); +#ifdef MODEST_TOOLKIT_HILDON2 + GtkWidget *entry_username = hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH); + if (initial_username) + hildon_entry_set_text (HILDON_ENTRY (entry_username), initial_username); +#else GtkWidget *entry_username = gtk_entry_new (); if (initial_username) gtk_entry_set_text (GTK_ENTRY (entry_username), initial_username); +#endif /* Dim this if a connection has ever succeeded with this username, * as per the UI spec: */ /* const gboolean username_known = */ @@ -3891,8 +3926,14 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */ GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); +#ifdef MODEST_TOOLKIT_HILDON2 + GtkWidget *caption = modest_maemo_utils_create_captioned (sizegroup, NULL, + _("mail_fi_username"), FALSE, + entry_username); +#else GtkWidget *caption = hildon_caption_new (sizegroup, _("mail_fi_username"), entry_username, NULL, HILDON_CAPTION_MANDATORY); +#endif gtk_widget_show (entry_username); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption, FALSE, FALSE, MODEST_MARGIN_HALF); @@ -3903,7 +3944,11 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, #endif /* !MODEST_TOOLKIT_GTK */ /* password: */ +#ifdef MODEST_TOOLKIT_HILDON2 + GtkWidget *entry_password = hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH); +#else GtkWidget *entry_password = gtk_entry_new (); +#endif gtk_entry_set_visibility (GTK_ENTRY(entry_password), FALSE); /* gtk_entry_set_invisible_char (GTK_ENTRY(entry_password), "*"); */ @@ -3912,8 +3957,14 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_password), HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE); +#ifdef MODEST_TOOLKIT_HILDON2 + caption = modest_maemo_utils_create_captioned (sizegroup, NULL, + _("mail_fi_password"), FALSE, + entry_password); +#else caption = hildon_caption_new (sizegroup, _("mail_fi_password"), entry_password, NULL, HILDON_CAPTION_MANDATORY); +#endif gtk_widget_show (entry_password); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption, FALSE, FALSE, MODEST_MARGIN_HALF); @@ -3948,7 +3999,11 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { if (username) { +#ifdef MODEST_TOOLKIT_HILDON2 + *username = g_strdup (hildon_entry_get_text (HILDON_ENTRY(entry_username))); +#else *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username))); +#endif /* Note that an empty field becomes the "" string */ if (*username && strlen (*username) > 0) { @@ -3974,7 +4029,11 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, } if (password) { +#ifdef MODEST_TOOLKIT_HILDON2 + *password = g_strdup (hildon_entry_get_text (HILDON_ENTRY(entry_password))); +#else *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password))); +#endif /* We do not save the password in the configuration, * because this function is only called for passwords that should @@ -4522,7 +4581,7 @@ modest_ui_actions_on_change_fullscreen (GtkAction *action, * Used by modest_ui_actions_on_details to call do_headers_action */ static void -headers_action_show_details (TnyHeader *header, +headers_action_show_details (TnyHeader *header, ModestWindow *window, gpointer user_data) @@ -4533,36 +4592,24 @@ headers_action_show_details (TnyHeader *header, /* * Show the header details in a ModestDetailsDialog widget */ -void -modest_ui_actions_on_details (GtkAction *action, +void +modest_ui_actions_on_details (GtkAction *action, ModestWindow *win) { - TnyList * headers_list; - TnyIterator *iter; - TnyHeader *header; - if (MODEST_IS_MSG_VIEW_WINDOW (win)) { TnyMsg *msg; + TnyHeader *header; msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win)); if (!msg) return; - g_object_unref (msg); - - headers_list = get_selected_headers (win); - if (!headers_list) - return; - iter = tny_list_create_iterator (headers_list); - - header = TNY_HEADER (tny_iterator_get_current (iter)); + header = tny_msg_get_header (msg); if (header) { headers_action_show_details (header, win, NULL); g_object_unref (header); } - - g_object_unref (iter); - g_object_unref (headers_list); + g_object_unref (msg); } else if (MODEST_IS_MAIN_WINDOW (win)) { GtkWidget *folder_view, *header_view; @@ -4856,41 +4903,58 @@ on_move_to_dialog_response (GtkDialog *dialog, gint response, gpointer user_data) { - GtkWidget *parent_win, *folder_view; + GtkWidget *parent_win; MoveToInfo *helper = NULL; + ModestFolderView *folder_view; helper = (MoveToInfo *) user_data; parent_win = (GtkWidget *) helper->win; - folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), - MODEST_MOVE_TO_DIALOG_FOLDER_VIEW)); + folder_view = MODEST_FOLDER_VIEW (g_object_get_data (G_OBJECT (dialog), + MODEST_MOVE_TO_DIALOG_FOLDER_VIEW)); switch (response) { TnyFolderStore *dst_folder; case MODEST_GTK_RESPONSE_NEW_FOLDER: - modest_ui_actions_create_folder (GTK_WIDGET (parent_win), folder_view); + modest_ui_actions_create_folder (GTK_WIDGET (dialog), GTK_WIDGET (folder_view)); return; case GTK_RESPONSE_NONE: case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: break; case GTK_RESPONSE_OK: - dst_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view)); - /* Do window specific stuff */ + dst_folder = modest_folder_view_get_selected (folder_view); + if (MODEST_IS_MAIN_WINDOW (parent_win)) { + /* Clean list to move used for filtering */ + modest_folder_view_set_list_to_move (folder_view, NULL); + modest_ui_actions_on_main_window_move_to (NULL, - folder_view, + GTK_WIDGET (folder_view), dst_folder, MODEST_MAIN_WINDOW (parent_win)); #ifdef MODEST_TOOLKIT_HILDON2 } else if (MODEST_IS_FOLDER_WINDOW (parent_win)) { - modest_ui_actions_on_folder_window_move_to (folder_view, + /* Clean list to move used for filtering */ + modest_folder_view_set_list_to_move (folder_view, NULL); + + modest_ui_actions_on_folder_window_move_to (GTK_WIDGET (folder_view), dst_folder, helper->list, GTK_WINDOW (parent_win)); #endif } else { + /* if the user selected a root folder + (account) then do not perform any action */ + if (TNY_IS_ACCOUNT (dst_folder)) { + g_signal_stop_emission_by_name (dialog, "response"); + return; + } + + /* Clean list to move used for filtering */ + modest_folder_view_set_list_to_move (folder_view, NULL); + /* Moving from headers window in edit mode */ modest_ui_actions_on_window_move_to (NULL, helper->list, dst_folder, @@ -4914,7 +4978,8 @@ on_move_to_dialog_response (GtkDialog *dialog, static GtkWidget* create_move_to_dialog (GtkWindow *win, - GtkWidget *folder_view) + GtkWidget *folder_view, + TnyList *list_to_move) { GtkWidget *dialog, *tree_view = NULL; @@ -4983,6 +5048,8 @@ create_move_to_dialog (GtkWindow *win, /* Hide special folders */ modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (tree_view), FALSE); + if (list_to_move) + modest_folder_view_set_list_to_move (MODEST_FOLDER_VIEW (tree_view), list_to_move); #ifndef MODEST_TOOLKIT_HILDON2 modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view)); #endif @@ -5325,7 +5392,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, @@ -5337,8 +5404,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 @@ -5360,6 +5425,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; @@ -5382,11 +5448,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 { @@ -5405,10 +5471,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); } @@ -5823,13 +5898,6 @@ modest_ui_actions_on_edit_mode_move_to (ModestWindow *win) 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)); @@ -5843,7 +5911,7 @@ modest_ui_actions_on_edit_mode_move_to (ModestWindow *win) } /* Create and run the dialog */ - dialog = create_move_to_dialog (GTK_WINDOW (win), NULL); + dialog = create_move_to_dialog (GTK_WINDOW (win), NULL, list_to_move); modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), (GtkWindow *) win); @@ -6302,7 +6370,7 @@ on_send_receive_finished (ModestMailOperation *mail_op, } -void +void modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, @@ -6324,10 +6392,10 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, /* Get the server name: */ - server_account = + server_account = TNY_TRANSPORT_ACCOUNT (tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (self))); if (server_account) - server_name = tny_account_get_hostname (TNY_ACCOUNT (server_account)); + server_name = tny_account_get_hostname (TNY_ACCOUNT (server_account)); else g_return_if_reached (); @@ -6346,7 +6414,7 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, g_warning ("%s: unexpected ERROR %d", __FUNCTION__, err->code); message = g_strdup (_CS("sfil_ib_unable_to_send")); - break; + break; } modest_platform_run_information_dialog (NULL, message, FALSE);