+ g_object_unref (headers_list);
+}
+
+void
+modest_ui_actions_view_attachment (GtkAction *action,
+ ModestWindow *window)
+{
+ if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+ modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (window), NULL);
+ } else {
+ /* not supported window for this action */
+ g_return_if_reached ();
+ }
+}
+
+void
+modest_ui_actions_save_attachments (GtkAction *action,
+ ModestWindow *window)
+{
+ if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+ modest_msg_view_window_save_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
+ } else {
+ /* not supported window for this action */
+ g_return_if_reached ();
+ }
+}
+
+void
+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);
+ } else {
+ /* not supported window for this action */
+ g_return_if_reached ();
+ }
+}
+
+void
+modest_ui_actions_on_settings (GtkAction *action,
+ ModestWindow *win)
+{
+ GtkWidget *dialog;
+
+ dialog = modest_platform_get_global_settings_dialog ();
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (win));
+ gtk_widget_show (dialog);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+}
+
+void
+modest_ui_actions_on_help (GtkAction *action,
+ ModestWindow *win)
+{
+ const gchar *help_id = NULL;
+
+ if (MODEST_IS_MAIN_WINDOW (win)) {
+ const gchar *action_name;
+ action_name = gtk_action_get_name (action);
+
+ if (!strcmp (action_name, "FolderViewCSMHelp") ||
+ !strcmp (action_name, "HeaderViewCSMHelp")) {
+ GtkWidget *folder_view;
+ TnyFolderStore *folder_store;
+ /* Get selected folder */
+ folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+ MODEST_WIDGET_TYPE_FOLDER_VIEW);
+ folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+
+ /* Switch help_id */
+ if (TNY_IS_FOLDER (folder_store)) {
+ switch (tny_folder_get_folder_type (TNY_FOLDER (folder_store))) {
+ case TNY_FOLDER_TYPE_NORMAL:
+ help_id = "applications_email_userfolder";
+ break;
+ case TNY_FOLDER_TYPE_INBOX:
+ help_id = "applications_email_inbox";
+ break;
+ case TNY_FOLDER_TYPE_OUTBOX:
+ help_id = "applications_email_outbox";
+ break;
+ case TNY_FOLDER_TYPE_SENT:
+ help_id = "applications_email_sent";
+ break;
+ case TNY_FOLDER_TYPE_DRAFTS:
+ help_id = "applications_email_drafts";
+ break;
+ case TNY_FOLDER_TYPE_ARCHIVE:
+ help_id = "applications_email_archive";
+ break;
+ default:
+ help_id = NULL;
+ }
+ }
+ } else {
+ help_id = "applications_email_mainview";
+ }
+ } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
+ help_id = "applications_email_viewer";
+ } else if (MODEST_IS_MSG_EDIT_WINDOW (win))
+ help_id = "applications_email_editor";
+
+ modest_platform_show_help (GTK_WINDOW (win), help_id);
+}
+
+void
+modest_ui_actions_on_retrieve_msg_contents (GtkAction *action,
+ ModestWindow *window)
+{
+ ModestMailOperation *mail_op;
+ TnyList *headers;
+
+ /* Get headers */
+ headers = get_selected_headers (window);
+ if (!headers)
+ return;
+
+ /* Create mail operation */
+ mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT (window),
+ 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, headers, NULL, NULL, NULL);
+
+ /* Frees */
+ g_object_unref (headers);
+ g_object_unref (mail_op);
+}
+
+void
+modest_ui_actions_on_email_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
+}
+
+void
+modest_ui_actions_on_edit_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
+}
+
+void
+modest_ui_actions_on_toolbar_csm_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
+}
+
+void
+modest_ui_actions_on_folder_view_csm_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
+}
+
+void
+modest_ui_actions_on_header_view_csm_menu_activated (GtkAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (window));
+
+ /* Update dimmed */
+ modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
+}
+
+void
+modest_ui_actions_check_toolbar_dimming_rules (ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (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));
+}
+
+void
+modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *win)
+{
+ g_return_if_fail (MODEST_IS_WINDOW (win));
+ modest_platform_show_addressbook (GTK_WINDOW (win));
+}
+
+
+void
+modest_ui_actions_on_toggle_find_in_page (GtkToggleAction *action,
+ ModestWindow *window)
+{
+ g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
+
+ modest_msg_edit_window_toggle_find_toolbar (MODEST_MSG_EDIT_WINDOW (window), gtk_toggle_action_get_active (action));
+}
+
+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));
+