X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=98d57c6682ef06b8fe1d0a46206f136559386087;hp=e177ba176855ab80fc1ab1413ad3ce58bc10a89e;hb=de8ac9aa1f0d03dffda84e55ad31c094923ad70f;hpb=dc6f85efbd256ef1e02449f075dd94b462dee791 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index e177ba1..98d57c6 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -122,8 +122,6 @@ static void reply_forward_cb (ModestMailOperation *mail_op, static void reply_forward (ReplyForwardAction action, ModestWindow *win); -static gchar* ask_for_folder_name (GtkWindow *parent_window, const gchar *title); - static void _on_send_receive_progress_changed (ModestMailOperation *mail_op, ModestMailOperationState *state, @@ -347,10 +345,11 @@ modest_ui_actions_on_delete (GtkAction *action, ModestWindow *win) void modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win) { - #ifdef MODEST_PLATFORM_MAEMO +#ifdef MODEST_PLATFORM_MAEMO modest_osso_save_state(); - #endif /* MODEST_PLATFORM_MAEMO */ - +#endif /* MODEST_PLATFORM_MAEMO */ + + g_message ("quiting..."); gtk_main_quit (); } @@ -726,11 +725,20 @@ _modest_ui_actions_open (TnyList *headers, ModestWindow *win) modest_ui_actions_get_msgs_full_error_handler, NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); - modest_mail_operation_get_msgs_full (mail_op, - not_opened_headers, - open_msg_cb, - NULL, - NULL); + if (tny_list_get_length (not_opened_headers) > 1) { + modest_mail_operation_get_msgs_full (mail_op, + not_opened_headers, + open_msg_cb, + NULL, + NULL); + } else { + TnyIterator *iter = tny_list_create_iterator (not_opened_headers); + TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter)); + modest_mail_operation_get_msg (mail_op, header, open_msg_cb, NULL); + g_object_unref (header); + g_object_unref (iter); + } + /* Clean */ g_object_unref (not_opened_headers); g_object_unref (iter); @@ -1072,6 +1080,17 @@ modest_ui_actions_on_sort (GtkAction *action, } } +static void +new_messages_arrived (ModestMailOperation *self, + gint new_messages, + gpointer user_data) +{ + if (new_messages == 0) + return; + + modest_platform_on_new_msg (); +} + /* * This function performs the send & receive required actions. The * window is used to create the mail operation. Typically it should @@ -1114,7 +1133,7 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win) internally, so the progress objects will receive the proper progress information */ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); - modest_mail_operation_update_account (mail_op, acc_name); + modest_mail_operation_update_account (mail_op, acc_name, new_messages_arrived, NULL); g_object_unref (G_OBJECT (mail_op)); /* Free */ @@ -1266,7 +1285,6 @@ folder_refreshed_cb (const GObject *obj, TnyFolder *folder, gpointer user_data) { -/* printf ("DEBUG: %s\n", __FUNCTION__); */ ModestMainWindow *win = NULL; GtkWidget *header_view; @@ -1348,8 +1366,11 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, } else { /* Update the active account */ modest_window_set_active_account (MODEST_WINDOW (main_window), NULL); - /* Do not show folder */ - modest_widget_memory_save (conf, G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY); + /* Save only if we're seeing headers */ + if (modest_main_window_get_contents_style (main_window) == + MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) + modest_widget_memory_save (conf, G_OBJECT (header_view), + MODEST_CONF_HEADER_VIEW_KEY); modest_header_view_clear (MODEST_HEADER_VIEW(header_view)); } } @@ -1452,6 +1473,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi MsgData *data; gchar *account_name, *from; ModestAccountMgr *account_mgr; + gchar *info_text = NULL; g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window)); @@ -1508,6 +1530,10 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi modest_msg_edit_window_free_msg_data (edit_window, data); + info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts")); + modest_platform_information_banner (NULL, NULL, info_text); + g_free (info_text); + /* Save settings and close the window */ gtk_widget_destroy (GTK_WIDGET (edit_window)); } @@ -1581,6 +1607,8 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) } } + 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)); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation); @@ -1755,46 +1783,6 @@ modest_ui_actions_on_remove_attachments (GtkAction *action, modest_msg_edit_window_remove_attachments (window, NULL); } -/* - * Shows a dialog with an entry that asks for some text. The returned - * value must be freed by the caller. The dialog window title will be - * set to @title. - */ -static gchar * -ask_for_folder_name (GtkWindow *parent_window, - const gchar *title) -{ - GtkWidget *dialog, *entry; - gchar *folder_name = NULL; - - /* Ask for folder name */ - dialog = gtk_dialog_new_with_buttons (_("New Folder Name"), - parent_window, - GTK_DIALOG_MODAL, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - NULL); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), - gtk_label_new(title), - FALSE, FALSE, 0); - - entry = gtk_entry_new_with_max_length (40); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), - entry, - TRUE, FALSE, 0); - - gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox)); - - if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) - folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); - - gtk_widget_destroy (dialog); - - return folder_name; -} - void modest_ui_actions_on_new_folder (GtkAction *action, ModestMainWindow *main_window) { @@ -1874,10 +1862,14 @@ modest_ui_actions_on_rename_folder (GtkAction *action, if (folder && TNY_IS_FOLDER (folder)) { gchar *folder_name; - folder_name = ask_for_folder_name (GTK_WINDOW (main_window), - _("Please enter a new name for the folder")); + gint response; + const gchar *current_name; - if (folder_name != NULL && strlen (folder_name) > 0) { + 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); + + if (response == GTK_RESPONSE_OK && strlen (folder_name) > 0) { ModestMailOperation *mail_op; mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(main_window)); @@ -2108,12 +2100,8 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, const gboolean username_was_changed = (strcmp (*username, initial_username) != 0); if (username_was_changed) { - /* To actually use a changed username, - * we must reset the connection, according to pvanhoof. - * This _might_ be a sensible way to do that: */ - TnyDevice *device = modest_runtime_get_device(); - tny_device_force_offline (device); - tny_device_force_online (device); + g_warning ("%s: tinymail does not yet support changing the " + "username in the get_password() callback.\n", __FUNCTION__); } } @@ -2337,6 +2325,10 @@ modest_ui_actions_on_select_all (GtkAction *action, /* Select all messages */ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(header_view)); gtk_tree_selection_select_all (selection); + + /* Set focuse on header view */ + gtk_widget_grab_focus (header_view); + } else if (GTK_IS_HTML (focused_widget)) { gtk_html_select_all (GTK_HTML (focused_widget)); } @@ -2531,16 +2523,20 @@ modest_ui_actions_on_details (GtkAction *action, folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win), MODEST_WIDGET_TYPE_FOLDER_VIEW); if (gtk_widget_is_focus (folder_view)) { - TnyFolder *folder; - - folder = (TnyFolder *) modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view)); - + TnyFolderStore *folder_store + = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view)); + if (!folder_store) { + g_warning ("%s: No item was selected.\n", __FUNCTION__); + return; + } /* Show only when it's a folder */ - if (!folder || !TNY_IS_FOLDER (folder)) - return; + /* This function should not be called for account items, + * because we dim the menu item for them. */ + if (TNY_IS_FOLDER (folder_store)) { + show_folder_details (TNY_FOLDER (folder_store), GTK_WINDOW (win)); + } - show_folder_details (folder, GTK_WINDOW (win)); - g_object_unref (folder); + g_object_unref (folder_store); } else { header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win), @@ -3051,7 +3047,7 @@ modest_ui_actions_remove_attachments (GtkAction *action, ModestWindow *window) { if (MODEST_IS_MSG_VIEW_WINDOW (window)) { - modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL); + modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (window)); } else { /* not supported window for this action */ g_return_if_reached ();