1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #endif /*HAVE_CONFIG_H*/
34 #include <glib/gi18n.h>
35 #include <glib/gprintf.h>
37 #include <modest-runtime.h>
38 #include <modest-tny-folder.h>
39 #include <modest-tny-msg.h>
40 #include <modest-tny-account.h>
41 #include <modest-address-book.h>
42 #include "modest-error.h"
43 #include "modest-ui-actions.h"
45 #include "modest-tny-platform-factory.h"
46 #include "modest-platform.h"
48 #ifdef MODEST_PLATFORM_MAEMO
49 #include "maemo/modest-osso-state-saving.h"
50 #endif /* MODEST_PLATFORM_MAEMO */
52 #include "widgets/modest-ui-constants.h"
53 #include <widgets/modest-main-window.h>
54 #include <widgets/modest-msg-view-window.h>
55 #include <widgets/modest-account-view-window.h>
56 #include <widgets/modest-details-dialog.h>
57 #include <widgets/modest-attachments-view.h>
58 #include "widgets/modest-folder-view.h"
59 #include "widgets/modest-global-settings-dialog.h"
60 #include "modest-connection-specific-smtp-window.h"
61 #include "modest-account-mgr-helpers.h"
62 #include "modest-mail-operation.h"
63 #include "modest-text-utils.h"
65 #ifdef MODEST_HAVE_EASYSETUP
66 #include "easysetup/modest-easysetup-wizard.h"
67 #endif /* MODEST_HAVE_EASYSETUP */
69 #include <modest-widget-memory.h>
70 #include <tny-error.h>
71 #include <tny-simple-list.h>
72 #include <tny-msg-view.h>
73 #include <tny-device.h>
74 #include <tny-merge-folder.h>
76 #include <gtkhtml/gtkhtml.h>
78 typedef struct _GetMsgAsyncHelper {
80 ModestMailOperation *mail_op;
87 typedef enum _ReplyForwardAction {
93 typedef struct _ReplyForwardHelper {
94 guint reply_forward_type;
95 ReplyForwardAction action;
97 GtkWidget *parent_window;
101 * The do_headers_action uses this kind of functions to perform some
102 * action to each member of a list of headers
104 typedef void (*HeadersFunc) (TnyHeader *header, ModestWindow *win, gpointer user_data);
107 do_headers_action (ModestWindow *win,
112 static void open_msg_cb (ModestMailOperation *mail_op,
117 static void reply_forward_cb (ModestMailOperation *mail_op,
122 static void reply_forward (ReplyForwardAction action, ModestWindow *win);
124 static gchar* ask_for_folder_name (GtkWindow *parent_window, const gchar *title);
127 static void _on_send_receive_progress_changed (ModestMailOperation *mail_op,
128 ModestMailOperationState *state,
134 run_account_setup_wizard (ModestWindow *win)
136 ModestEasysetupWizardDialog *wizard;
138 g_return_if_fail (MODEST_IS_WINDOW(win));
140 wizard = modest_easysetup_wizard_dialog_new ();
141 gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
142 gtk_dialog_run (GTK_DIALOG (wizard));
143 gtk_widget_destroy (GTK_WIDGET (wizard));
148 modest_ui_actions_on_about (GtkAction *action, ModestWindow *win)
151 const gchar *authors[] = {
152 "Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>",
155 about = gtk_about_dialog_new ();
156 gtk_about_dialog_set_name (GTK_ABOUT_DIALOG(about), PACKAGE_NAME);
157 gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(about),PACKAGE_VERSION);
158 gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about),
159 _("Copyright (c) 2006, Nokia Corporation\n"
160 "All rights reserved."));
161 gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(about),
162 _("a modest e-mail client\n\n"
163 "design and implementation: Dirk-Jan C. Binnema\n"
164 "contributions from the fine people at KC and Ig\n"
165 "uses the tinymail email framework written by Philip van Hoof"));
166 gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(about), authors);
167 gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(about), "http://modest.garage.maemo.org");
169 gtk_dialog_run (GTK_DIALOG (about));
170 gtk_widget_destroy(about);
174 * Gets the list of currently selected messages. If the win is the
175 * main window, then it returns a newly allocated list of the headers
176 * selected in the header view. If win is the msg view window, then
177 * the value returned is a list with just a single header.
179 * The caller of this funcion must free the list.
182 get_selected_headers (ModestWindow *win)
184 if (MODEST_IS_MAIN_WINDOW(win)) {
185 GtkWidget *header_view;
187 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
188 MODEST_WIDGET_TYPE_HEADER_VIEW);
189 return modest_header_view_get_selected_headers (MODEST_HEADER_VIEW(header_view));
191 } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
192 /* for MsgViewWindows, we simply return a list with one element */
194 TnyList *list = NULL;
196 header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
197 if (header != NULL) {
198 list = tny_simple_list_new ();
199 tny_list_prepend (list, G_OBJECT(header));
200 g_object_unref (G_OBJECT(header));
210 headers_action_mark_as_read (TnyHeader *header,
214 TnyHeaderFlags flags;
216 g_return_if_fail (TNY_IS_HEADER(header));
218 flags = tny_header_get_flags (header);
219 if (flags & TNY_HEADER_FLAG_SEEN) return;
220 tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
224 headers_action_mark_as_unread (TnyHeader *header,
228 TnyHeaderFlags flags;
230 g_return_if_fail (TNY_IS_HEADER(header));
232 flags = tny_header_get_flags (header);
233 if (flags & TNY_HEADER_FLAG_SEEN) {
234 tny_header_unset_flags (header, TNY_HEADER_FLAG_SEEN);
240 headers_action_delete (TnyHeader *header,
244 ModestMailOperation *mail_op = NULL;
246 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_DELETE, G_OBJECT(win));
247 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
250 /* Always delete. TODO: Move to trash still not supported */
251 modest_mail_operation_remove_msg (mail_op, header, FALSE);
252 g_object_unref (G_OBJECT (mail_op));
256 modest_ui_actions_on_delete (GtkAction *action, ModestWindow *win)
258 TnyList *header_list = NULL;
259 TnyIterator *iter = NULL;
260 TnyHeader *header = NULL;
261 gchar *message = NULL;
265 ModestWindowMgr *mgr;
267 g_return_if_fail (MODEST_IS_WINDOW(win));
269 header_list = get_selected_headers (win);
270 if (!header_list) return;
272 /* Check if any of the headers is already opened */
273 iter = tny_list_create_iterator (header_list);
275 mgr = modest_runtime_get_window_mgr ();
276 while (!tny_iterator_is_done (iter) && !found) {
277 header = TNY_HEADER (tny_iterator_get_current (iter));
278 if (modest_window_mgr_find_window_by_header (mgr, header))
280 g_object_unref (header);
281 tny_iterator_next (iter);
283 g_object_unref (iter);
288 num = g_strdup_printf ("%d", tny_list_get_length (header_list));
289 msg = g_strdup_printf (_("mcen_nc_unable_to_delete_n_messages"), num);
291 modest_platform_run_information_dialog (GTK_WINDOW (win), (const gchar *) msg);
295 g_object_unref (header_list);
300 if (tny_list_get_length(header_list) > 1)
301 message = g_strdup(_("emev_nc_delete_messages"));
303 iter = tny_list_create_iterator (header_list);
304 header = TNY_HEADER (tny_iterator_get_current (iter));
305 desc = g_strdup_printf ("%s", tny_header_get_subject (header));
306 message = g_strdup_printf(_("emev_nc_delete_message"), desc);
307 g_object_unref (header);
308 g_object_unref (iter);
311 /* Confirmation dialog */
312 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
316 if (response == GTK_RESPONSE_OK) {
317 if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
319 g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value);
323 /* Remove each header */
324 do_headers_action (win, headers_action_delete, NULL);
326 if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
327 gtk_widget_destroy (GTK_WIDGET(win));
334 g_object_unref (header_list);
339 modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win)
341 #ifdef MODEST_PLATFORM_MAEMO
342 modest_osso_save_state();
343 #endif /* MODEST_PLATFORM_MAEMO */
349 modest_ui_actions_on_close_window (GtkAction *action, ModestWindow *win)
351 if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
352 gtk_widget_destroy (GTK_WIDGET (win));
353 } else if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
355 g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value);
356 } else if (MODEST_IS_WINDOW (win)) {
357 gtk_widget_destroy (GTK_WIDGET (win));
359 g_return_if_reached ();
364 modest_ui_actions_on_add_to_contacts (GtkAction *action, ModestWindow *win)
366 GtkClipboard *clipboard = NULL;
367 gchar *selection = NULL;
369 clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
370 selection = gtk_clipboard_wait_for_text (clipboard);
372 /* Question: why is the clipboard being used here?
373 * It doesn't really make a lot of sense. */
377 modest_address_book_add_address (selection);
383 modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
385 /* This is currently only implemented for Maemo */
386 #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
387 if (!modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE)) {
388 run_account_setup_wizard (win);
391 /* Show the list of accounts: */
392 GtkDialog *account_win = GTK_DIALOG(modest_account_view_window_new ());
393 gtk_window_set_transient_for (GTK_WINDOW (account_win), GTK_WINDOW(win));
394 gtk_dialog_run (account_win);
395 gtk_widget_destroy (GTK_WIDGET(account_win));
398 GtkWidget *dialog, *label;
400 /* Create the widgets */
402 dialog = gtk_dialog_new_with_buttons ("Message",
404 GTK_DIALOG_DESTROY_WITH_PARENT,
408 label = gtk_label_new ("Hello World!");
410 /* Ensure that the dialog box is destroyed when the user responds. */
412 g_signal_connect_swapped (dialog, "response",
413 G_CALLBACK (gtk_widget_destroy),
416 /* Add the label, and show everything we've added to the dialog. */
418 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
420 gtk_widget_show_all (dialog);
421 #endif /* MODEST_PLATFORM_MAEMO */
425 on_smtp_servers_window_hide (GtkWindow* window, gpointer user_data)
427 ModestWindow *main_window = MODEST_WINDOW (user_data);
429 /* Save any changes. */
430 modest_connection_specific_smtp_window_save_server_accounts (
431 MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (window),
432 modest_window_get_active_account (main_window));
433 gtk_widget_destroy (GTK_WIDGET (window));
439 modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win)
441 /* This is currently only implemented for Maemo,
442 * because it requires an API (libconic) to detect different connection
445 #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
447 /* Create the window if necessary: */
448 const gchar *active_account_name = modest_window_get_active_account (win);
450 /* TODO: Dim the menu item (not in the UI spec)? or show a warning,
451 * or show the default account?
452 * If we show the default account then the account name should be shown in
453 * the window when we show it. */
454 if (!active_account_name) {
455 g_warning ("%s: No account is active.", __FUNCTION__);
459 GtkWidget *specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
460 modest_connection_specific_smtp_window_fill_with_connections (
461 MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window),
462 modest_runtime_get_account_mgr(),
463 active_account_name);
465 /* Show the window: */
466 gtk_window_set_transient_for (GTK_WINDOW (specific_window), GTK_WINDOW (win));
467 gtk_window_set_modal (GTK_WINDOW (specific_window), TRUE);
468 gtk_widget_show (specific_window);
470 /* Save changes when the window is hidden: */
471 g_signal_connect (specific_window, "hide",
472 G_CALLBACK (on_smtp_servers_window_hide), win);
473 #endif /* MODEST_PLATFORM_MAEMO */
477 modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win)
479 ModestWindow *msg_win;
481 TnyFolder *folder = NULL;
482 gchar *account_name = NULL;
483 gchar *from_str = NULL;
484 /* GError *err = NULL; */
485 TnyAccount *account = NULL;
486 ModestWindowMgr *mgr;
487 gchar *signature = NULL, *blank_and_signature = NULL;
489 /* if there are no accounts yet, just show the wizard */
490 if (!modest_account_mgr_has_accounts (modest_runtime_get_account_mgr(), TRUE)) {
491 run_account_setup_wizard (win);
495 account_name = g_strdup(modest_window_get_active_account (win));
497 account_name = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
499 g_printerr ("modest: no account found\n");
503 account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store(),
505 TNY_ACCOUNT_TYPE_STORE);
507 g_printerr ("modest: failed to get tnyaccount for '%s'\n", account_name);
511 from_str = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(), account_name);
513 g_printerr ("modest: failed get from string for '%s'\n", account_name);
517 if (modest_account_mgr_get_bool (modest_runtime_get_account_mgr (), account_name,
518 MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) {
519 signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), account_name,
520 MODEST_ACCOUNT_SIGNATURE, FALSE);
521 blank_and_signature = g_strconcat ("\n", signature, NULL);
524 blank_and_signature = g_strdup ("");
527 msg = modest_tny_msg_new ("", from_str, "", "", "", blank_and_signature, NULL);
529 g_printerr ("modest: failed to create new msg\n");
533 folder = modest_tny_account_get_special_folder (account, TNY_FOLDER_TYPE_DRAFTS);
535 g_printerr ("modest: failed to find Drafts folder\n");
540 /* Create and register edit window */
541 /* This is destroyed by TOOD. */
542 msg_win = modest_msg_edit_window_new (msg, account_name);
543 mgr = modest_runtime_get_window_mgr ();
544 modest_window_mgr_register_window (mgr, msg_win);
547 gtk_window_set_transient_for (GTK_WINDOW (msg_win),
549 gtk_widget_show_all (GTK_WIDGET (msg_win));
552 g_free (account_name);
554 g_free (blank_and_signature);
556 g_object_unref (G_OBJECT(account));
558 g_object_unref (G_OBJECT(msg));
560 g_object_unref (G_OBJECT(folder));
564 open_msg_cb (ModestMailOperation *mail_op,
569 ModestWindowMgr *mgr = NULL;
570 ModestWindow *parent_win = NULL;
571 ModestWindow *win = NULL;
572 TnyFolderType folder_type = TNY_FOLDER_TYPE_UNKNOWN;
573 gchar *account = NULL;
576 /* TODO: Show an error? (review the specs) */
580 parent_win = (ModestWindow *) modest_mail_operation_get_source (mail_op);
581 folder = tny_header_get_folder (header);
583 /* Mark header as read */
584 headers_action_mark_as_read (header, MODEST_WINDOW(parent_win), NULL);
587 account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (parent_win)));
589 account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
591 /* Gets folder type (OUTBOX headers will be opened in edit window */
592 if (modest_tny_folder_is_local_folder (folder))
593 folder_type = modest_tny_folder_get_local_folder_type (folder);
595 /* If the header is in the drafts folder then open the editor,
596 else the message view window */
597 if (folder_type == TNY_FOLDER_TYPE_DRAFTS) {
598 /* we cannot edit without a valid account... */
599 if (!modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE)) {
600 run_account_setup_wizard(parent_win);
603 win = modest_msg_edit_window_new (msg, account);
605 gchar *uid = modest_tny_folder_get_header_unique_id (header);
607 if (MODEST_IS_MAIN_WINDOW (parent_win)) {
608 GtkWidget *header_view;
609 GtkTreeSelection *sel;
610 GList *sel_list = NULL;
613 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(parent_win),
614 MODEST_WIDGET_TYPE_HEADER_VIEW);
616 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view));
617 sel_list = gtk_tree_selection_get_selected_rows (sel, &model);
619 if (sel_list != NULL) {
620 GtkTreeRowReference *row_reference;
622 row_reference = gtk_tree_row_reference_new (model, (GtkTreePath *) sel_list->data);
623 g_list_foreach (sel_list, (GFunc) gtk_tree_path_free, NULL);
624 g_list_free (sel_list);
626 win = modest_msg_view_window_new_with_header_model (msg,
631 gtk_tree_row_reference_free (row_reference);
633 win = modest_msg_view_window_new (msg, account, (const gchar*) uid);
636 win = modest_msg_view_window_new (msg, account, (const gchar*) uid);
641 /* Register and show new window */
643 mgr = modest_runtime_get_window_mgr ();
644 modest_window_mgr_register_window (mgr, win);
645 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (parent_win));
646 gtk_widget_show_all (GTK_WIDGET(win));
652 g_object_unref (msg);
653 g_object_unref (folder);
654 g_object_unref (header);
658 * This function is the error handler of the
659 * modest_mail_operation_get_msgs_full operation
662 modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op,
667 error = modest_mail_operation_get_error (mail_op);
668 if (error->code == MODEST_MAIL_OPERATION_ERROR_MESSAGE_SIZE_LIMIT) {
669 GObject *win = modest_mail_operation_get_source (mail_op);
671 modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
677 * This function is used by both modest_ui_actions_on_open and
678 * modest_ui_actions_on_header_activated. This way we always do the
679 * same when trying to open messages.
682 _modest_ui_actions_open (TnyList *headers, ModestWindow *win)
684 ModestWindowMgr *mgr;
686 ModestMailOperation *mail_op;
687 TnyList *not_opened_headers;
689 /* Look if we already have a message view for each header. If
690 true, then remove the header from the list of headers to
692 mgr = modest_runtime_get_window_mgr ();
693 iter = tny_list_create_iterator (headers);
694 not_opened_headers = tny_simple_list_new ();
695 while (!tny_iterator_is_done (iter)) {
696 ModestWindow *window;
699 header = TNY_HEADER (tny_iterator_get_current (iter));
700 window = modest_window_mgr_find_window_by_header (mgr, header);
701 /* Do not open again the message and present the
702 window to the user */
704 gtk_window_present (GTK_WINDOW (window));
706 tny_list_append (not_opened_headers, G_OBJECT (header));
708 g_object_unref (header);
709 tny_iterator_next (iter);
712 /* Open each message */
713 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
715 modest_ui_actions_get_msgs_full_error_handler,
717 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
718 modest_mail_operation_get_msgs_full (mail_op,
724 g_object_unref (not_opened_headers);
725 g_object_unref (iter);
726 g_object_unref (mail_op);
730 modest_ui_actions_on_open (GtkAction *action, ModestWindow *win)
735 headers = get_selected_headers (win);
740 _modest_ui_actions_open (headers, win);
742 g_object_unref(headers);
747 free_reply_forward_helper (gpointer data)
749 ReplyForwardHelper *helper;
751 helper = (ReplyForwardHelper *) data;
752 g_free (helper->account_name);
753 g_slice_free (ReplyForwardHelper, helper);
757 reply_forward_cb (ModestMailOperation *mail_op,
763 ReplyForwardHelper *rf_helper;
764 ModestWindow *msg_win;
765 ModestEditType edit_type;
767 TnyAccount *account = NULL;
768 ModestWindowMgr *mgr;
769 gchar *signature = NULL;
771 g_return_if_fail (user_data != NULL);
772 rf_helper = (ReplyForwardHelper *) user_data;
774 from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
775 rf_helper->account_name);
776 if (modest_account_mgr_get_bool (modest_runtime_get_account_mgr(),
777 rf_helper->account_name,
778 MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) {
779 signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (),
780 rf_helper->account_name,
781 MODEST_ACCOUNT_SIGNATURE, FALSE);
784 /* Create reply mail */
785 switch (rf_helper->action) {
788 modest_tny_msg_create_reply_msg (msg, from, signature,
789 rf_helper->reply_forward_type,
790 MODEST_TNY_MSG_REPLY_MODE_SENDER);
792 case ACTION_REPLY_TO_ALL:
794 modest_tny_msg_create_reply_msg (msg, from, signature, rf_helper->reply_forward_type,
795 MODEST_TNY_MSG_REPLY_MODE_ALL);
796 edit_type = MODEST_EDIT_TYPE_REPLY;
800 modest_tny_msg_create_forward_msg (msg, from, signature, rf_helper->reply_forward_type);
801 edit_type = MODEST_EDIT_TYPE_FORWARD;
804 g_return_if_reached ();
811 g_printerr ("modest: failed to create message\n");
815 account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store(),
816 rf_helper->account_name,
817 TNY_ACCOUNT_TYPE_STORE);
819 g_printerr ("modest: failed to get tnyaccount for '%s'\n", rf_helper->account_name);
823 /* Create and register the windows */
824 msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account_name);
825 mgr = modest_runtime_get_window_mgr ();
826 modest_window_mgr_register_window (mgr, msg_win);
828 if (rf_helper->parent_window != NULL) {
831 parent_zoom = modest_window_get_zoom (MODEST_WINDOW (rf_helper->parent_window));
832 modest_window_set_zoom (msg_win, parent_zoom);
835 /* Show edit window */
836 gtk_widget_show_all (GTK_WIDGET (msg_win));
840 g_object_unref (G_OBJECT (new_msg));
842 g_object_unref (G_OBJECT (account));
843 g_object_unref (msg);
844 g_object_unref (header);
848 * Checks a list of headers. If any of them are not currently
849 * downloaded (CACHED) then it asks the user for permission to
852 * Returns FALSE if the user does not want to download the
853 * messages. Returns TRUE if the user allowed the download or if all
854 * of them are currently downloaded
857 download_uncached_messages (TnyList *header_list, GtkWindow *win)
860 gboolean found, retval;
862 iter = tny_list_create_iterator (header_list);
864 while (!tny_iterator_is_done (iter) && !found) {
866 TnyHeaderFlags flags;
868 header = TNY_HEADER (tny_iterator_get_current (iter));
869 flags = tny_header_get_flags (header);
870 /* TODO: is this the right flag?, it seems that some
871 headers that have been previously downloaded do not
873 found = !(flags & TNY_HEADER_FLAG_CACHED);
874 g_object_unref (header);
875 tny_iterator_next (iter);
877 g_object_unref (iter);
879 /* Ask for user permission to download the messages */
882 GtkResponseType response;
884 modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
885 _("mcen_nc_get_multi_msg_txt"));
886 if (response == GTK_RESPONSE_CANCEL)
894 * Common code for the reply and forward actions
897 reply_forward (ReplyForwardAction action, ModestWindow *win)
899 ModestMailOperation *mail_op = NULL;
900 TnyList *header_list = NULL;
901 ReplyForwardHelper *rf_helper = NULL;
902 guint reply_forward_type;
903 gboolean continue_download;
905 g_return_if_fail (MODEST_IS_WINDOW(win));
907 /* we need an account when editing */
908 if (!modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE)) {
909 run_account_setup_wizard (win);
913 header_list = get_selected_headers (win);
917 /* Check that the messages have been previously downloaded */
918 continue_download = download_uncached_messages (header_list, GTK_WINDOW (win));
919 if (!continue_download) {
920 g_object_unref (header_list);
925 modest_conf_get_int (modest_runtime_get_conf (),
926 (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE,
928 /* We assume that we can only select messages of the
929 same folder and that we reply all of them from the
930 same account. In fact the interface currently only
931 allows single selection */
934 rf_helper = g_slice_new0 (ReplyForwardHelper);
935 rf_helper->reply_forward_type = reply_forward_type;
936 rf_helper->action = action;
937 rf_helper->account_name = g_strdup (modest_window_get_active_account (win));
938 if ((win != NULL) && (MODEST_IS_WINDOW (win)))
939 rf_helper->parent_window = GTK_WIDGET (win);
940 if (!rf_helper->account_name)
941 rf_helper->account_name =
942 modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
944 if (MODEST_IS_MSG_VIEW_WINDOW(win)) {
947 /* Get header and message. Do not free them here, the
948 reply_forward_cb must do it */
949 msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW(win));
950 header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW(win));
951 if (!msg || !header) {
953 g_object_unref (msg);
955 g_object_unref (header);
956 g_printerr ("modest: no message found\n");
959 reply_forward_cb (NULL, header, msg, rf_helper);
961 /* Retrieve messages */
962 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
964 modest_ui_actions_get_msgs_full_error_handler,
966 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
967 modest_mail_operation_get_msgs_full (mail_op,
971 free_reply_forward_helper);
974 g_object_unref(mail_op);
978 g_object_unref (header_list);
982 modest_ui_actions_on_reply (GtkAction *action, ModestWindow *win)
984 g_return_if_fail (MODEST_IS_WINDOW(win));
986 reply_forward (ACTION_REPLY, win);
990 modest_ui_actions_on_forward (GtkAction *action, ModestWindow *win)
992 g_return_if_fail (MODEST_IS_WINDOW(win));
994 reply_forward (ACTION_FORWARD, win);
998 modest_ui_actions_on_reply_all (GtkAction *action, ModestWindow *win)
1000 g_return_if_fail (MODEST_IS_WINDOW(win));
1002 reply_forward (ACTION_REPLY_TO_ALL, win);
1006 modest_ui_actions_on_next (GtkAction *action,
1007 ModestWindow *window)
1009 if (MODEST_IS_MAIN_WINDOW (window)) {
1010 GtkWidget *header_view;
1012 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
1013 MODEST_WIDGET_TYPE_HEADER_VIEW);
1017 modest_header_view_select_next (MODEST_HEADER_VIEW(header_view));
1018 } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
1019 modest_msg_view_window_select_next_message (MODEST_MSG_VIEW_WINDOW (window));
1021 g_return_if_reached ();
1026 modest_ui_actions_on_prev (GtkAction *action,
1027 ModestWindow *window)
1029 g_return_if_fail (MODEST_IS_WINDOW(window));
1031 if (MODEST_IS_MAIN_WINDOW (window)) {
1032 GtkWidget *header_view;
1033 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
1034 MODEST_WIDGET_TYPE_HEADER_VIEW);
1038 modest_header_view_select_prev (MODEST_HEADER_VIEW(header_view));
1039 } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
1040 modest_msg_view_window_select_previous_message (MODEST_MSG_VIEW_WINDOW (window));
1042 g_return_if_reached ();
1047 modest_ui_actions_on_sort (GtkAction *action,
1048 ModestWindow *window)
1050 g_return_if_fail (MODEST_IS_WINDOW(window));
1052 if (MODEST_IS_MAIN_WINDOW (window)) {
1053 GtkWidget *header_view;
1054 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
1055 MODEST_WIDGET_TYPE_HEADER_VIEW);
1059 /* Show sorting dialog */
1060 modest_platform_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);
1065 * This function performs the send & receive required actions. The
1066 * window is used to create the mail operation. Typically it should
1067 * always be the main window, but we pass it as argument in order to
1071 modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win)
1073 gchar *acc_name = NULL;
1074 ModestMailOperation *mail_op;
1076 /* If no account name was provided then get the current account, and if
1077 there is no current account then pick the default one: */
1078 if (!account_name) {
1079 acc_name = g_strdup (modest_window_get_active_account(win));
1081 acc_name = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
1083 g_printerr ("modest: cannot get default account\n");
1087 acc_name = g_strdup (account_name);
1090 /* Set send/receive operation in progress */
1091 modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW(win));
1093 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
1094 g_signal_connect (G_OBJECT(mail_op), "progress-changed",
1095 G_CALLBACK (_on_send_receive_progress_changed),
1098 /* Send & receive. */
1099 /* TODO: The spec wants us to first do any pending deletions, before receiving. */
1100 /* Receive and then send. The operation is tagged initially as
1101 a receive operation because the account update performs a
1102 receive and then a send. The operation changes its type
1103 internally, so the progress objects will receive the proper
1104 progress information */
1105 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
1106 modest_mail_operation_update_account (mail_op, acc_name);
1107 g_object_unref (G_OBJECT (mail_op));
1114 * Refreshes all accounts. This function will be used by automatic
1118 modest_ui_actions_do_send_receive_all (ModestWindow *win)
1120 GSList *account_names, *iter;
1122 account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr(),
1125 iter = account_names;
1127 modest_ui_actions_do_send_receive ((const char*) iter->data, win);
1128 iter = g_slist_next (iter);
1131 g_slist_foreach (account_names, (GFunc) g_free, NULL);
1132 g_slist_free (account_names);
1136 * Handler of the click on Send&Receive button in the main toolbar
1139 modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
1141 /* Check if accounts exist */
1142 gboolean accounts_exist =
1143 modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE);
1145 /* If not, allow the user to create an account before trying to send/receive. */
1146 if (!accounts_exist)
1147 modest_ui_actions_on_accounts (NULL, win);
1149 /* Refresh the active account */
1150 modest_ui_actions_do_send_receive (NULL, win);
1155 modest_ui_actions_toggle_header_list_view (GtkAction *action, ModestMainWindow *main_window)
1158 GtkWidget *header_view;
1160 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1162 header_view = modest_main_window_get_child_widget (main_window,
1163 MODEST_WIDGET_TYPE_HEADER_VIEW);
1167 conf = modest_runtime_get_conf ();
1169 /* what is saved/restored is depending on the style; thus; we save with
1170 * old style, then update the style, and restore for this new style
1172 modest_widget_memory_save (conf, G_OBJECT(header_view), MODEST_CONF_HEADER_VIEW_KEY);
1174 if (modest_header_view_get_style
1175 (MODEST_HEADER_VIEW(header_view)) == MODEST_HEADER_VIEW_STYLE_DETAILS)
1176 modest_header_view_set_style (MODEST_HEADER_VIEW(header_view),
1177 MODEST_HEADER_VIEW_STYLE_TWOLINES);
1179 modest_header_view_set_style (MODEST_HEADER_VIEW(header_view),
1180 MODEST_HEADER_VIEW_STYLE_DETAILS);
1182 modest_widget_memory_restore (conf, G_OBJECT(header_view),
1183 MODEST_CONF_HEADER_VIEW_KEY);
1188 modest_ui_actions_on_header_selected (ModestHeaderView *header_view,
1190 ModestMainWindow *main_window)
1192 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1193 g_return_if_fail (MODEST_IS_HEADER_VIEW (header_view));
1195 /* If no header has been selected then exit */
1199 /* Update Main window title */
1200 if (GTK_WIDGET_HAS_FOCUS (header_view)) {
1201 const gchar *subject = tny_header_get_subject (header);
1202 if (subject && strlen(subject) > 0)
1203 gtk_window_set_title (GTK_WINDOW (main_window), subject);
1205 gtk_window_set_title (GTK_WINDOW (main_window), _("mail_va_no_subject"));
1208 /* Update toolbar dimming state */
1209 modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
1213 modest_ui_actions_on_header_activated (ModestHeaderView *header_view,
1215 ModestMainWindow *main_window)
1219 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1224 headers = tny_simple_list_new ();
1225 tny_list_prepend (headers, G_OBJECT (header));
1227 _modest_ui_actions_open (headers, MODEST_WINDOW (main_window));
1229 g_object_unref (headers);
1233 set_active_account_from_tny_account (TnyAccount *account,
1234 ModestWindow *window)
1236 const gchar *server_acc_name = tny_account_get_id (account);
1238 /* We need the TnyAccount provided by the
1239 account store because that is the one that
1240 knows the name of the Modest account */
1241 TnyAccount *modest_server_account = modest_server_account =
1242 modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store (),
1243 MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
1246 const gchar *modest_acc_name =
1247 modest_tny_account_get_parent_modest_account_name_for_server_account (modest_server_account);
1248 modest_window_set_active_account (window, modest_acc_name);
1249 g_object_unref (modest_server_account);
1254 folder_refreshed_cb (const GObject *obj,
1258 printf ("DEBUG: %s\n", __FUNCTION__);
1259 ModestMainWindow *win = NULL;
1260 GtkWidget *header_view;
1262 g_return_if_fail (TNY_IS_FOLDER (folder));
1264 win = MODEST_MAIN_WINDOW (user_data);
1266 modest_main_window_get_child_widget(win, MODEST_WIDGET_TYPE_HEADER_VIEW);
1268 /* Check if folder is empty and set headers view contents style */
1269 if (tny_folder_get_all_count (folder) == 0) {
1270 printf ("DEBUG: %s: tny_folder_get_all_count() returned 0.\n", __FUNCTION__);
1271 modest_main_window_set_contents_style (win,
1272 MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY);
1274 printf ("DEBUG: %s: tny_folder_get_all_count() returned >0.\n", __FUNCTION__);
1275 /* Restore configuration. There is no need to set the
1276 contents style to headers because it was already
1277 being done in folder_selection_changed */
1278 modest_widget_memory_restore (modest_runtime_get_conf (),
1279 G_OBJECT(header_view),
1280 MODEST_CONF_HEADER_VIEW_KEY);
1285 modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
1286 TnyFolderStore *folder_store,
1288 ModestMainWindow *main_window)
1291 GtkWidget *header_view;
1293 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1295 header_view = modest_main_window_get_child_widget(main_window,
1296 MODEST_WIDGET_TYPE_HEADER_VIEW);
1300 conf = modest_runtime_get_conf ();
1302 if (TNY_IS_ACCOUNT (folder_store)) {
1303 /* Update active account */
1304 set_active_account_from_tny_account (TNY_ACCOUNT (folder_store), MODEST_WINDOW (main_window));
1305 /* Show account details */
1306 modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS);
1308 if (TNY_IS_FOLDER (folder_store) && selected) {
1310 if (!TNY_IS_MERGE_FOLDER (folder_store)) { /* TnyMergeFolder can have no get_account() implementation. */
1311 /* Update the active account */
1312 TnyAccount *account = modest_tny_folder_get_account (TNY_FOLDER (folder_store));
1313 set_active_account_from_tny_account (account, MODEST_WINDOW (main_window));
1314 g_object_unref (account);
1317 /* Set the header view, we could change it to
1318 the empty view after the refresh */
1319 modest_main_window_set_contents_style (main_window,
1320 MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS);
1322 modest_widget_memory_save (modest_runtime_get_conf(),
1323 G_OBJECT(header_view),
1324 MODEST_CONF_HEADER_VIEW_KEY);
1326 /* Set folder on header view. This function
1327 will call tny_folder_refresh_async so we
1328 pass a callback that will be called when
1329 finished. We use that callback to set the
1330 empty view if there are no messages */
1331 modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view),
1332 TNY_FOLDER (folder_store),
1333 folder_refreshed_cb,
1336 /* Update the active account */
1337 modest_window_set_active_account (MODEST_WINDOW (main_window), NULL);
1338 /* Do not show folder */
1339 modest_widget_memory_save (conf, G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY);
1340 modest_header_view_clear (MODEST_HEADER_VIEW(header_view));
1344 /* Update toolbar dimming state */
1345 modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
1349 modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,ModestItemType type,
1356 item = (type == MODEST_ITEM_TYPE_FOLDER) ? "folder" : "message";
1358 if (g_main_depth > 0)
1359 gdk_threads_enter ();
1360 online = tny_device_is_online (modest_runtime_get_device());
1363 /* already online -- the item is simply not there... */
1364 dialog = gtk_message_dialog_new (GTK_WINDOW (win),
1366 GTK_MESSAGE_WARNING,
1368 _("The %s you selected cannot be found"),
1370 gtk_dialog_run (GTK_DIALOG(dialog));
1372 dialog = gtk_dialog_new_with_buttons (_("Connection requested"),
1376 GTK_RESPONSE_REJECT,
1378 GTK_RESPONSE_ACCEPT,
1380 txt = g_strdup_printf (_("This %s is not available in offline mode.\n"
1381 "Do you want to get online?"), item);
1382 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1383 gtk_label_new (txt), FALSE, FALSE, 0);
1384 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
1387 gtk_window_set_default_size (GTK_WINDOW(dialog), 300, 300);
1388 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
1389 // modest_platform_connect_and_wait ();
1392 gtk_widget_destroy (dialog);
1393 if (g_main_depth > 0)
1394 gdk_threads_leave ();
1398 modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, const gchar* link,
1401 /* g_message ("%s %s", __FUNCTION__, link); */
1406 modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview, const gchar* link,
1409 modest_platform_activate_uri (link);
1413 modest_ui_actions_on_msg_link_contextual (ModestMsgView *msgview, const gchar* link,
1416 modest_platform_show_uri_popup (link);
1420 modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, TnyMimePart *mime_part,
1423 modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (win), mime_part);
1427 modest_ui_actions_on_msg_recpt_activated (ModestMsgView *msgview,
1428 const gchar *address,
1431 /* g_message ("%s %s", __FUNCTION__, address); */
1435 modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edit_window)
1437 TnyTransportAccount *transport_account;
1438 ModestMailOperation *mail_operation;
1440 gchar *account_name, *from;
1441 ModestAccountMgr *account_mgr;
1443 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
1445 data = modest_msg_edit_window_get_msg_data (edit_window);
1447 account_mgr = modest_runtime_get_account_mgr();
1448 account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window)));
1450 account_name = modest_account_mgr_get_default_account (account_mgr);
1451 if (!account_name) {
1452 g_printerr ("modest: no account found\n");
1453 modest_msg_edit_window_free_msg_data (edit_window, data);
1457 if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
1458 account_name = g_strdup (data->account_name);
1462 TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_server_account
1463 (modest_runtime_get_account_store(),
1465 TNY_ACCOUNT_TYPE_TRANSPORT));
1466 if (!transport_account) {
1467 g_printerr ("modest: no transport account found for '%s'\n", account_name);
1468 g_free (account_name);
1469 modest_msg_edit_window_free_msg_data (edit_window, data);
1472 from = modest_account_mgr_get_from_string (account_mgr, account_name);
1474 /* Create the mail operation */
1475 mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(edit_window));
1476 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
1478 modest_mail_operation_save_to_drafts (mail_operation,
1489 data->priority_flags);
1492 g_free (account_name);
1493 g_object_unref (G_OBJECT (transport_account));
1494 g_object_unref (G_OBJECT (mail_operation));
1496 modest_msg_edit_window_free_msg_data (edit_window, data);
1498 /* Save settings and close the window */
1499 gtk_widget_destroy (GTK_WIDGET (edit_window));
1502 /* For instance, when clicking the Send toolbar button when editing a message: */
1504 modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
1506 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
1508 if (!modest_msg_edit_window_check_names (edit_window))
1511 /* FIXME: Code added just for testing. The final version will
1512 use the send queue provided by tinymail and some
1514 ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
1515 gchar *account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window)));
1517 account_name = modest_account_mgr_get_default_account (account_mgr);
1519 if (!account_name) {
1520 g_printerr ("modest: no account found\n");
1524 MsgData *data = modest_msg_edit_window_get_msg_data (edit_window);
1526 if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
1527 account_name = g_strdup (data->account_name);
1530 /* Get the currently-active transport account for this modest account: */
1531 TnyTransportAccount *transport_account =
1532 TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_transport_account_for_open_connection
1533 (modest_runtime_get_account_store(),
1535 if (!transport_account) {
1536 g_printerr ("modest: no transport account found for '%s'\n", account_name);
1537 g_free (account_name);
1538 modest_msg_edit_window_free_msg_data (edit_window, data);
1542 gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name);
1544 /* mail content checks and dialogs */
1545 if (data->subject == NULL || data->subject[0] == '\0') {
1546 GtkResponseType response;
1547 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (edit_window),
1548 _("mcen_nc_subject_is_empty_send"));
1549 if (response == GTK_RESPONSE_CANCEL) {
1550 g_free (account_name);
1555 if (data->plain_body == NULL || data->plain_body[0] == '\0') {
1556 GtkResponseType response;
1557 gchar *note_message;
1558 gchar *note_subject = data->subject;
1559 if (note_subject == NULL || note_subject[0] == '\0')
1560 note_subject = _("mail_va_no_subject");
1561 note_message = g_strdup_printf (_("emev_ni_ui_smtp_message_null"), note_subject);
1562 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (edit_window),
1564 g_free (note_message);
1565 if (response == GTK_RESPONSE_CANCEL) {
1566 g_free (account_name);
1571 /* Create the mail operation */
1572 ModestMailOperation *mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_SEND, G_OBJECT(edit_window));
1573 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
1575 modest_mail_operation_send_new_mail (mail_operation,
1586 data->priority_flags);
1590 g_free (account_name);
1591 g_object_unref (G_OBJECT (transport_account));
1592 g_object_unref (G_OBJECT (mail_operation));
1594 modest_msg_edit_window_free_msg_data (edit_window, data);
1596 /* Save settings and close the window: */
1597 gtk_widget_destroy (GTK_WIDGET (edit_window));
1601 modest_ui_actions_on_toggle_bold (GtkToggleAction *action,
1602 ModestMsgEditWindow *window)
1604 ModestMsgEditFormatState *format_state = NULL;
1606 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1607 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1609 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW (window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1612 format_state = modest_msg_edit_window_get_format_state (window);
1613 g_return_if_fail (format_state != NULL);
1615 format_state->bold = gtk_toggle_action_get_active (action);
1616 modest_msg_edit_window_set_format_state (window, format_state);
1617 g_free (format_state);
1622 modest_ui_actions_on_toggle_italics (GtkToggleAction *action,
1623 ModestMsgEditWindow *window)
1625 ModestMsgEditFormatState *format_state = NULL;
1627 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1628 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1630 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1633 format_state = modest_msg_edit_window_get_format_state (window);
1634 g_return_if_fail (format_state != NULL);
1636 format_state->italics = gtk_toggle_action_get_active (action);
1637 modest_msg_edit_window_set_format_state (window, format_state);
1638 g_free (format_state);
1643 modest_ui_actions_on_toggle_bullets (GtkToggleAction *action,
1644 ModestMsgEditWindow *window)
1646 ModestMsgEditFormatState *format_state = NULL;
1648 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1649 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1651 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW (window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1654 format_state = modest_msg_edit_window_get_format_state (window);
1655 g_return_if_fail (format_state != NULL);
1657 format_state->bullet = gtk_toggle_action_get_active (action);
1658 modest_msg_edit_window_set_format_state (window, format_state);
1659 g_free (format_state);
1664 modest_ui_actions_on_change_justify (GtkRadioAction *action,
1665 GtkRadioAction *selected,
1666 ModestMsgEditWindow *window)
1668 ModestMsgEditFormatState *format_state = NULL;
1669 GtkJustification value;
1671 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1673 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1676 value = gtk_radio_action_get_current_value (selected);
1678 format_state = modest_msg_edit_window_get_format_state (window);
1679 g_return_if_fail (format_state != NULL);
1681 format_state->justification = value;
1682 modest_msg_edit_window_set_format_state (window, format_state);
1683 g_free (format_state);
1687 modest_ui_actions_on_select_editor_color (GtkAction *action,
1688 ModestMsgEditWindow *window)
1690 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1691 g_return_if_fail (GTK_IS_ACTION (action));
1693 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1696 modest_msg_edit_window_select_color (window);
1700 modest_ui_actions_on_select_editor_background_color (GtkAction *action,
1701 ModestMsgEditWindow *window)
1703 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1704 g_return_if_fail (GTK_IS_ACTION (action));
1706 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1709 modest_msg_edit_window_select_background_color (window);
1713 modest_ui_actions_on_insert_image (GtkAction *action,
1714 ModestMsgEditWindow *window)
1716 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1717 g_return_if_fail (GTK_IS_ACTION (action));
1719 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1722 modest_msg_edit_window_insert_image (window);
1726 modest_ui_actions_on_attach_file (GtkAction *action,
1727 ModestMsgEditWindow *window)
1729 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1730 g_return_if_fail (GTK_IS_ACTION (action));
1732 modest_msg_edit_window_attach_file (window);
1736 modest_ui_actions_on_remove_attachments (GtkAction *action,
1737 ModestMsgEditWindow *window)
1739 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1740 g_return_if_fail (GTK_IS_ACTION (action));
1742 modest_msg_edit_window_remove_attachments (window, NULL);
1746 * Shows a dialog with an entry that asks for some text. The returned
1747 * value must be freed by the caller. The dialog window title will be
1751 ask_for_folder_name (GtkWindow *parent_window,
1754 GtkWidget *dialog, *entry;
1755 gchar *folder_name = NULL;
1757 /* Ask for folder name */
1758 dialog = gtk_dialog_new_with_buttons (_("New Folder Name"),
1762 GTK_RESPONSE_REJECT,
1764 GTK_RESPONSE_ACCEPT,
1766 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1767 gtk_label_new(title),
1770 entry = gtk_entry_new_with_max_length (40);
1771 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1775 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
1777 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
1778 folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
1780 gtk_widget_destroy (dialog);
1786 modest_ui_actions_on_new_folder (GtkAction *action, ModestMainWindow *main_window)
1788 TnyFolderStore *parent_folder;
1789 GtkWidget *folder_view;
1791 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1793 folder_view = modest_main_window_get_child_widget (main_window,
1794 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1798 parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
1800 if (parent_folder) {
1801 gboolean finished = FALSE;
1803 gchar *folder_name = NULL, *suggested_name = NULL;
1805 /* Run the new folder dialog */
1807 result = modest_platform_run_new_folder_dialog (GTK_WINDOW (main_window),
1812 if (result == GTK_RESPONSE_REJECT) {
1815 ModestMailOperation *mail_op;
1816 TnyFolder *new_folder = NULL;
1818 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO,
1819 G_OBJECT(main_window));
1820 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1822 new_folder = modest_mail_operation_create_folder (mail_op,
1824 (const gchar *) folder_name);
1826 g_object_unref (new_folder);
1829 g_object_unref (mail_op);
1831 g_free (folder_name);
1835 g_object_unref (parent_folder);
1840 modest_ui_actions_on_rename_folder (GtkAction *action,
1841 ModestMainWindow *main_window)
1843 TnyFolderStore *folder;
1844 GtkWidget *folder_view;
1845 GtkWidget *header_view;
1847 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1849 folder_view = modest_main_window_get_child_widget (main_window,
1850 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1854 header_view = modest_main_window_get_child_widget (main_window,
1855 MODEST_WIDGET_TYPE_HEADER_VIEW);
1860 folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
1862 if (folder && TNY_IS_FOLDER (folder)) {
1864 folder_name = ask_for_folder_name (GTK_WINDOW (main_window),
1865 _("Please enter a new name for the folder"));
1867 if (folder_name != NULL && strlen (folder_name) > 0) {
1868 ModestMailOperation *mail_op;
1870 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(main_window));
1871 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1874 modest_header_view_clear (MODEST_HEADER_VIEW (header_view));
1876 modest_mail_operation_rename_folder (mail_op,
1877 TNY_FOLDER (folder),
1878 (const gchar *) folder_name);
1880 g_object_unref (mail_op);
1881 g_free (folder_name);
1883 g_object_unref (folder);
1888 modest_ui_actions_delete_folder_error_handler (ModestMailOperation *mail_op,
1891 GObject *win = modest_mail_operation_get_source (mail_op);
1893 modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
1894 _("mail_in_ui_folder_delete_error"));
1898 delete_folder (ModestMainWindow *main_window, gboolean move_to_trash)
1900 TnyFolderStore *folder;
1901 GtkWidget *folder_view;
1905 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1907 folder_view = modest_main_window_get_child_widget (main_window,
1908 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1912 folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
1914 /* Show an error if it's an account */
1915 if (!TNY_IS_FOLDER (folder)) {
1916 modest_platform_run_information_dialog (GTK_WINDOW (main_window),
1917 _("mail_in_ui_folder_delete_error"));
1922 message = g_strdup_printf (_("mcen_nc_delete_folder_text"),
1923 tny_folder_get_name (TNY_FOLDER (folder)));
1924 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (main_window),
1925 (const gchar *) message);
1928 if (response == GTK_RESPONSE_OK) {
1929 ModestMailOperation *mail_op =
1930 modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_DELETE,
1931 G_OBJECT(main_window),
1932 modest_ui_actions_delete_folder_error_handler,
1935 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1937 modest_mail_operation_remove_folder (mail_op, TNY_FOLDER (folder), move_to_trash);
1938 g_object_unref (G_OBJECT (mail_op));
1941 g_object_unref (G_OBJECT (folder));
1945 modest_ui_actions_on_delete_folder (GtkAction *action,
1946 ModestMainWindow *main_window)
1948 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1950 delete_folder (main_window, FALSE);
1954 modest_ui_actions_on_move_folder_to_trash_folder (GtkAction *action, ModestMainWindow *main_window)
1956 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1958 delete_folder (main_window, TRUE);
1962 modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
1963 const gchar* server_account_name,
1968 ModestMainWindow *main_window)
1970 g_return_if_fail(server_account_name);
1971 /* printf("DEBUG: %s: server_account_name=%s\n", __FUNCTION__, server_account_name); */
1973 /* Initalize output parameters: */
1980 #ifdef MODEST_PLATFORM_MAEMO
1981 /* Maemo uses a different (awkward) button order,
1982 * It should probably just use gtk_alternative_dialog_button_order ().
1984 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
1988 GTK_RESPONSE_ACCEPT,
1990 GTK_RESPONSE_REJECT,
1993 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
1997 GTK_RESPONSE_REJECT,
1999 GTK_RESPONSE_ACCEPT,
2001 #endif /* MODEST_PLATFORM_MAEMO */
2003 gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(main_window));
2005 gchar *server_name = modest_server_account_get_hostname (
2006 modest_runtime_get_account_mgr(), server_account_name);
2007 if (!server_name) {/* This happened once, though I don't know why. murrayc. */
2008 g_warning("%s: Could not get server name for server account '%s'", __FUNCTION__, server_account_name);
2013 /* This causes a warning because the logical ID has no %s in it,
2014 * though the translation does, but there is not much we can do about that: */
2015 gchar *txt = g_strdup_printf (_("mail_ia_password_info"), server_name);
2016 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt),
2019 g_free (server_name);
2023 gchar *initial_username = modest_server_account_get_username (
2024 modest_runtime_get_account_mgr(), server_account_name);
2026 GtkWidget *entry_username = gtk_entry_new ();
2027 if (initial_username)
2028 gtk_entry_set_text (GTK_ENTRY (entry_username), initial_username);
2029 /* Dim this if a connection has ever succeeded with this username,
2030 * as per the UI spec: */
2031 const gboolean username_known =
2032 modest_server_account_get_username_has_succeeded(
2033 modest_runtime_get_account_mgr(), server_account_name);
2034 gtk_widget_set_sensitive (entry_username, !username_known);
2036 #ifdef MODEST_PLATFORM_MAEMO
2037 /* Auto-capitalization is the default, so let's turn it off: */
2038 hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_username), HILDON_GTK_INPUT_MODE_FULL);
2040 /* Create a size group to be used by all captions.
2041 * Note that HildonCaption does not create a default size group if we do not specify one.
2042 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
2043 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2045 GtkWidget *caption = hildon_caption_new (sizegroup,
2046 _("mail_fi_username"), entry_username, NULL, HILDON_CAPTION_MANDATORY);
2047 gtk_widget_show (entry_username);
2048 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption,
2049 FALSE, FALSE, MODEST_MARGIN_HALF);
2050 gtk_widget_show (caption);
2052 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_username,
2054 #endif /* MODEST_PLATFORM_MAEMO */
2057 GtkWidget *entry_password = gtk_entry_new ();
2058 gtk_entry_set_visibility (GTK_ENTRY(entry_password), FALSE);
2059 /* gtk_entry_set_invisible_char (GTK_ENTRY(entry_password), "*"); */
2061 #ifdef MODEST_PLATFORM_MAEMO
2062 /* Auto-capitalization is the default, so let's turn it off: */
2063 hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_password),
2064 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
2066 caption = hildon_caption_new (sizegroup,
2067 _("mail_fi_password"), entry_password, NULL, HILDON_CAPTION_MANDATORY);
2068 gtk_widget_show (entry_password);
2069 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption,
2070 FALSE, FALSE, MODEST_MARGIN_HALF);
2071 gtk_widget_show (caption);
2072 g_object_unref (sizegroup);
2074 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_password,
2076 #endif /* MODEST_PLATFORM_MAEMO */
2078 /* This is not in the Maemo UI spec:
2079 remember_pass_check = gtk_check_button_new_with_label (_("Remember password"));
2080 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), remember_pass_check,
2084 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
2086 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
2088 *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username)));
2090 modest_server_account_set_username (
2091 modest_runtime_get_account_mgr(), server_account_name,
2094 const gboolean username_was_changed =
2095 (strcmp (*username, initial_username) != 0);
2096 if (username_was_changed) {
2097 /* To actually use a changed username,
2098 * we must reset the connection, according to pvanhoof.
2099 * This _might_ be a sensible way to do that: */
2100 TnyDevice *device = modest_runtime_get_device();
2101 tny_device_force_offline (device);
2102 tny_device_force_online (device);
2107 *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password)));
2109 /* We do not save the password in the configuration,
2110 * because this function is only called for passwords that should
2111 * not be remembered:
2112 modest_server_account_set_password (
2113 modest_runtime_get_account_mgr(), server_account_name,
2132 /* This is not in the Maemo UI spec:
2133 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pass_check)))
2139 gtk_widget_destroy (dialog);
2141 /* printf ("DEBUG: %s: cancel=%d\n", __FUNCTION__, *cancel); */
2145 modest_ui_actions_on_cut (GtkAction *action,
2146 ModestWindow *window)
2148 GtkWidget *focused_widget;
2150 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2151 if (GTK_IS_EDITABLE (focused_widget)) {
2152 gtk_editable_cut_clipboard (GTK_EDITABLE(focused_widget));
2153 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2154 GtkTextBuffer *buffer;
2155 GtkClipboard *clipboard;
2157 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2158 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2159 gtk_text_buffer_cut_clipboard (buffer, clipboard, TRUE);
2164 modest_ui_actions_on_copy (GtkAction *action,
2165 ModestWindow *window)
2167 GtkClipboard *clipboard;
2168 GtkWidget *focused_widget;
2170 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2171 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2172 if (GTK_IS_LABEL (focused_widget)) {
2173 gtk_clipboard_set_text (clipboard, gtk_label_get_text (GTK_LABEL (focused_widget)), -1);
2174 } else if (GTK_IS_EDITABLE (focused_widget)) {
2175 gtk_editable_copy_clipboard (GTK_EDITABLE(focused_widget));
2176 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2177 GtkTextBuffer *buffer;
2179 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2180 gtk_text_buffer_copy_clipboard (buffer, clipboard);
2185 modest_ui_actions_on_undo (GtkAction *action,
2186 ModestWindow *window)
2188 if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
2189 modest_msg_edit_window_undo (MODEST_MSG_EDIT_WINDOW (window));
2191 g_return_if_reached ();
2196 modest_ui_actions_on_paste (GtkAction *action,
2197 ModestWindow *window)
2199 GtkWidget *focused_widget;
2201 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2202 if (GTK_IS_EDITABLE (focused_widget)) {
2203 gtk_editable_paste_clipboard (GTK_EDITABLE(focused_widget));
2204 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2205 GtkTextBuffer *buffer;
2206 GtkClipboard *clipboard;
2208 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2209 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2210 gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE);
2215 modest_ui_actions_on_select_all (GtkAction *action,
2216 ModestWindow *window)
2218 GtkWidget *focused_widget;
2220 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2221 if (MODEST_IS_ATTACHMENTS_VIEW (focused_widget)) {
2222 modest_attachments_view_select_all (MODEST_ATTACHMENTS_VIEW (focused_widget));
2223 } else if (GTK_IS_LABEL (focused_widget)) {
2224 gtk_label_select_region (GTK_LABEL (focused_widget), 0, -1);
2225 } else if (GTK_IS_EDITABLE (focused_widget)) {
2226 gtk_editable_select_region (GTK_EDITABLE(focused_widget), 0, -1);
2227 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2228 GtkTextBuffer *buffer;
2229 GtkTextIter start, end;
2231 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2232 gtk_text_buffer_get_start_iter (buffer, &start);
2233 gtk_text_buffer_get_end_iter (buffer, &end);
2234 gtk_text_buffer_select_range (buffer, &start, &end);
2236 else if ((MODEST_IS_FOLDER_VIEW (focused_widget)) ||
2237 (MODEST_IS_HEADER_VIEW (focused_widget))) {
2239 GtkTreeSelection *selection = NULL;
2241 /* Get header view */
2242 GtkWidget *header_view = focused_widget;
2243 if (MODEST_IS_FOLDER_VIEW (focused_widget))
2244 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
2245 MODEST_WIDGET_TYPE_HEADER_VIEW);
2247 /* Select all messages */
2248 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(header_view));
2249 gtk_tree_selection_select_all (selection);
2250 } else if (GTK_IS_HTML (focused_widget)) {
2251 gtk_html_select_all (GTK_HTML (focused_widget));
2256 modest_ui_actions_on_mark_as_read (GtkAction *action,
2257 ModestWindow *window)
2259 g_return_if_fail (MODEST_IS_WINDOW(window));
2261 /* Mark each header as read */
2262 do_headers_action (window, headers_action_mark_as_read, NULL);
2266 modest_ui_actions_on_mark_as_unread (GtkAction *action,
2267 ModestWindow *window)
2269 g_return_if_fail (MODEST_IS_WINDOW(window));
2271 /* Mark each header as read */
2272 do_headers_action (window, headers_action_mark_as_unread, NULL);
2276 modest_ui_actions_on_change_zoom (GtkRadioAction *action,
2277 GtkRadioAction *selected,
2278 ModestWindow *window)
2282 value = gtk_radio_action_get_current_value (selected);
2283 if (MODEST_IS_WINDOW (window)) {
2284 modest_window_set_zoom (MODEST_WINDOW (window), ((gdouble)value)/100);
2288 void modest_ui_actions_msg_edit_on_change_priority (GtkRadioAction *action,
2289 GtkRadioAction *selected,
2290 ModestWindow *window)
2292 TnyHeaderFlags flags;
2293 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2295 flags = gtk_radio_action_get_current_value (selected);
2296 modest_msg_edit_window_set_priority_flags (MODEST_MSG_EDIT_WINDOW (window), flags);
2299 void modest_ui_actions_msg_edit_on_change_file_format (GtkRadioAction *action,
2300 GtkRadioAction *selected,
2301 ModestWindow *window)
2305 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2307 file_format = gtk_radio_action_get_current_value (selected);
2308 modest_msg_edit_window_set_file_format (MODEST_MSG_EDIT_WINDOW (window), file_format);
2313 modest_ui_actions_on_zoom_plus (GtkAction *action,
2314 ModestWindow *window)
2316 g_return_if_fail (MODEST_IS_WINDOW (window));
2318 modest_window_zoom_plus (MODEST_WINDOW (window));
2322 modest_ui_actions_on_zoom_minus (GtkAction *action,
2323 ModestWindow *window)
2325 g_return_if_fail (MODEST_IS_WINDOW (window));
2327 modest_window_zoom_minus (MODEST_WINDOW (window));
2331 modest_ui_actions_on_toggle_fullscreen (GtkToggleAction *toggle,
2332 ModestWindow *window)
2334 ModestWindowMgr *mgr;
2335 gboolean fullscreen, active;
2336 g_return_if_fail (MODEST_IS_WINDOW (window));
2338 mgr = modest_runtime_get_window_mgr ();
2340 active = (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle)))?1:0;
2341 fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
2343 if (active != fullscreen) {
2344 modest_window_mgr_set_fullscreen_mode (mgr, active);
2345 gtk_window_present (GTK_WINDOW (window));
2350 modest_ui_actions_on_change_fullscreen (GtkAction *action,
2351 ModestWindow *window)
2353 ModestWindowMgr *mgr;
2354 gboolean fullscreen;
2356 g_return_if_fail (MODEST_IS_WINDOW (window));
2358 mgr = modest_runtime_get_window_mgr ();
2359 fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
2360 modest_window_mgr_set_fullscreen_mode (mgr, !fullscreen);
2362 gtk_window_present (GTK_WINDOW (window));
2366 * Used by modest_ui_actions_on_details to call do_headers_action
2369 headers_action_show_details (TnyHeader *header,
2370 ModestWindow *window,
2377 dialog = modest_details_dialog_new_with_header (GTK_WINDOW (window), header);
2380 gtk_widget_show_all (dialog);
2381 gtk_dialog_run (GTK_DIALOG (dialog));
2383 gtk_widget_destroy (dialog);
2387 * Show the folder details in a ModestDetailsDialog widget
2390 show_folder_details (TnyFolder *folder,
2396 dialog = modest_details_dialog_new_with_folder (window, folder);
2399 gtk_widget_show_all (dialog);
2400 gtk_dialog_run (GTK_DIALOG (dialog));
2402 gtk_widget_destroy (dialog);
2406 * Show the header details in a ModestDetailsDialog widget
2409 modest_ui_actions_on_details (GtkAction *action,
2412 TnyList * headers_list;
2416 if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
2419 msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win));
2422 g_object_unref (msg);
2424 headers_list = get_selected_headers (win);
2428 iter = tny_list_create_iterator (headers_list);
2430 header = TNY_HEADER (tny_iterator_get_current (iter));
2431 headers_action_show_details (header, win, NULL);
2432 g_object_unref (header);
2434 g_object_unref (iter);
2435 g_object_unref (headers_list);
2437 } else if (MODEST_IS_MAIN_WINDOW (win)) {
2438 GtkWidget *folder_view, *header_view;
2440 /* Check which widget has the focus */
2441 folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
2442 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2443 if (gtk_widget_is_focus (folder_view)) {
2446 folder = (TnyFolder *) modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
2448 /* Show only when it's a folder */
2449 if (!folder || !TNY_IS_FOLDER (folder))
2452 show_folder_details (folder, GTK_WINDOW (win));
2455 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
2456 MODEST_WIDGET_TYPE_HEADER_VIEW);
2457 /* Show details of each header */
2458 do_headers_action (win, headers_action_show_details, header_view);
2464 modest_ui_actions_on_toggle_show_cc (GtkToggleAction *toggle,
2465 ModestMsgEditWindow *window)
2467 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2469 modest_msg_edit_window_show_cc (window, gtk_toggle_action_get_active (toggle));
2473 modest_ui_actions_on_toggle_show_bcc (GtkToggleAction *toggle,
2474 ModestMsgEditWindow *window)
2476 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2478 modest_msg_edit_window_show_bcc (window, gtk_toggle_action_get_active (toggle));
2482 modest_ui_actions_toggle_folders_view (GtkAction *action,
2483 ModestMainWindow *main_window)
2487 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
2489 conf = modest_runtime_get_conf ();
2491 if (modest_main_window_get_style (main_window) == MODEST_MAIN_WINDOW_STYLE_SPLIT)
2492 modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SIMPLE);
2494 modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SPLIT);
2498 modest_ui_actions_on_toggle_toolbar (GtkToggleAction *toggle,
2499 ModestWindow *window)
2501 gboolean active, fullscreen = FALSE;
2502 ModestWindowMgr *mgr;
2504 active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle));
2506 /* Check if we want to toggle the toolbar vuew in fullscreen
2508 if (!strcmp (gtk_action_get_name (GTK_ACTION (toggle)),
2509 "ViewShowToolbarFullScreen")) {
2513 /* Toggle toolbar */
2514 mgr = modest_runtime_get_window_mgr ();
2515 modest_window_mgr_show_toolbars (mgr, active, fullscreen);
2519 modest_ui_actions_msg_edit_on_select_font (GtkAction *action,
2520 ModestMsgEditWindow *window)
2522 modest_msg_edit_window_select_font (window);
2526 modest_ui_actions_on_folder_display_name_changed (ModestFolderView *folder_view,
2527 const gchar *display_name,
2530 /* Do not change the application name if the widget has not
2531 the focus. This callback could be called even if the folder
2532 view has not the focus, because the handled signal could be
2533 emitted when the folder view is redrawn */
2534 if (gtk_widget_is_focus (GTK_WIDGET (folder_view))) {
2536 gtk_window_set_title (window, display_name);
2538 gtk_window_set_title (window, " ");
2543 modest_ui_actions_on_select_contacts (GtkAction *action, ModestMsgEditWindow *window)
2545 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2546 modest_msg_edit_window_select_contacts (window);
2550 modest_ui_actions_on_check_names (GtkAction *action, ModestMsgEditWindow *window)
2552 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2553 modest_msg_edit_window_check_names (window);
2558 create_move_to_dialog (ModestWindow *win,
2559 GtkWidget *folder_view,
2560 GtkWidget **tree_view)
2562 GtkWidget *dialog, *scroll;
2564 dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"),
2566 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT,
2568 GTK_RESPONSE_ACCEPT,
2570 GTK_RESPONSE_REJECT,
2573 /* Create scrolled window */
2574 scroll = gtk_scrolled_window_new (NULL, NULL);
2575 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
2576 GTK_POLICY_AUTOMATIC,
2577 GTK_POLICY_AUTOMATIC);
2579 /* Create folder view */
2580 *tree_view = modest_platform_create_folder_view (NULL);
2582 /* It could happen that we're trying to move a message from a
2583 window (msg window for example) after the main window was
2584 closed, so we can not just get the model of the folder
2586 if (MODEST_IS_FOLDER_VIEW (folder_view))
2587 gtk_tree_view_set_model (GTK_TREE_VIEW (*tree_view),
2588 gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view)));
2590 modest_folder_view_update_model (MODEST_FOLDER_VIEW (*tree_view),
2591 TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
2593 gtk_container_add (GTK_CONTAINER (scroll), *tree_view);
2595 /* Add scroll to dialog */
2596 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
2597 scroll, FALSE, FALSE, 0);
2599 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
2601 /* Select INBOX or local account */
2602 modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (*tree_view));
2608 * Returns TRUE if at least one of the headers of the list belongs to
2609 * a message that has been fully retrieved.
2612 has_retrieved_msgs (TnyList *list)
2615 gboolean found = FALSE;
2617 iter = tny_list_create_iterator (list);
2618 while (tny_iterator_is_done (iter) && !found) {
2620 TnyHeaderFlags flags;
2622 header = TNY_HEADER (tny_iterator_get_current (iter));
2623 flags = tny_header_get_flags (header);
2624 if (!(flags & TNY_HEADER_FLAG_PARTIAL))
2628 tny_iterator_next (iter);
2630 g_object_unref (iter);
2636 * Shows a confirmation dialog to the user when we're moving messages
2637 * from a remote server to the local storage. Returns the dialog
2638 * response. If it's other kind of movement the it always returns
2642 msgs_move_to_confirmation (GtkWindow *win,
2643 TnyFolder *dest_folder,
2646 gint response = GTK_RESPONSE_OK;
2648 /* If the destination is a local folder */
2649 if (modest_tny_folder_is_local_folder (dest_folder)) {
2650 TnyFolder *src_folder;
2654 /* Get source folder */
2655 iter = tny_list_create_iterator (headers);
2656 header = TNY_HEADER (tny_iterator_get_current (iter));
2657 src_folder = tny_header_get_folder (header);
2658 g_object_unref (header);
2659 g_object_unref (iter);
2661 /* If the source is a remote folder */
2662 if (!modest_tny_folder_is_local_folder (src_folder)) {
2663 const gchar *message;
2665 if (tny_list_get_length (headers) == 1)
2666 if (has_retrieved_msgs (headers))
2667 message = _("mcen_nc_move_retrieve");
2669 message = _("mcen_nc_move_header");
2671 if (has_retrieved_msgs (headers))
2672 message = _("mcen_nc_move_retrieves");
2674 message = _("mcen_nc_move_headers");
2676 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
2677 (const gchar *) message);
2679 g_object_unref (src_folder);
2686 transfer_msgs_from_viewer_cb (const GObject *object, gpointer user_data)
2688 ModestMsgViewWindow *self = NULL;
2690 g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (object));
2691 self = MODEST_MSG_VIEW_WINDOW (object);
2693 /* If there are not more messages don't do anything. The
2694 viewer will show the same message */
2695 if (!modest_msg_view_window_select_first_message (self))
2700 modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
2703 GObject *win = modest_mail_operation_get_source (mail_op);
2705 /* TODO: show error message */
2706 modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
2707 _("mail_in_ui_folder_move_target_error"));
2711 * UI handler for the "Move to" action when invoked from the
2715 modest_ui_actions_on_main_window_move_to (GtkAction *action,
2716 ModestMainWindow *win)
2718 GtkWidget *dialog = NULL, *folder_view = NULL, *tree_view = NULL;
2719 GtkWidget *header_view = NULL;
2721 TnyFolderStore *folder_store = NULL;
2722 ModestMailOperation *mail_op = NULL;
2724 g_return_if_fail (MODEST_IS_MAIN_WINDOW (win));
2726 /* Get the folder view */
2727 folder_view = modest_main_window_get_child_widget (win,
2728 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2730 /* Get header view */
2731 header_view = modest_main_window_get_child_widget (win,
2732 MODEST_WIDGET_TYPE_HEADER_VIEW);
2734 /* Create and run the dialog */
2735 dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
2736 modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view));
2737 result = gtk_dialog_run (GTK_DIALOG(dialog));
2738 g_object_ref (tree_view);
2740 /* We do this to save an indentation level ;-) */
2741 if (result != GTK_RESPONSE_ACCEPT)
2744 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (tree_view));
2746 if (TNY_IS_ACCOUNT (folder_store))
2749 /* Get folder or messages to transfer */
2750 if (gtk_widget_is_focus (folder_view)) {
2751 TnyFolderStore *src_folder;
2752 src_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
2754 /* Clean folder on header view before moving it */
2755 modest_header_view_clear (MODEST_HEADER_VIEW (header_view));
2757 if (TNY_IS_FOLDER (src_folder)) {
2759 modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
2761 modest_ui_actions_move_folder_error_handler,
2763 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
2765 modest_mail_operation_xfer_folder (mail_op,
2766 TNY_FOLDER (src_folder),
2769 /* Unref mail operation */
2770 g_object_unref (G_OBJECT (mail_op));
2774 g_object_unref (G_OBJECT (src_folder));
2776 if (gtk_widget_is_focus (header_view)) {
2780 headers = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (header_view));
2782 /* Ask for user confirmation */
2783 response = msgs_move_to_confirmation (GTK_WINDOW (win),
2784 TNY_FOLDER (folder_store),
2787 /* Transfer messages */
2788 if (response == GTK_RESPONSE_OK) {
2789 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
2790 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
2793 modest_mail_operation_xfer_msgs (mail_op,
2795 TNY_FOLDER (folder_store),
2800 g_object_unref (G_OBJECT (mail_op));
2802 g_object_unref (headers);
2805 g_object_unref (folder_store);
2807 gtk_widget_destroy (dialog);
2812 * UI handler for the "Move to" action when invoked from the
2813 * ModestMsgViewWindow
2816 modest_ui_actions_on_msg_view_window_move_to (GtkAction *action,
2817 ModestMsgViewWindow *win)
2819 GtkWidget *dialog, *folder_view, *tree_view = NULL;
2821 ModestMainWindow *main_window;
2825 /* Get the folder view */
2826 main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()));
2828 folder_view = modest_main_window_get_child_widget (main_window,
2829 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2833 /* Create and run the dialog */
2834 dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
2835 result = gtk_dialog_run (GTK_DIALOG(dialog));
2836 g_object_ref (tree_view);
2838 if (result == GTK_RESPONSE_ACCEPT) {
2839 TnyFolderStore *folder_store;
2842 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (tree_view));
2844 /* Create header list */
2845 header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
2846 headers = tny_simple_list_new ();
2847 tny_list_prepend (headers, G_OBJECT (header));
2848 g_object_unref (header);
2850 /* Ask user for confirmation. MSG-NOT404 */
2851 response = msgs_move_to_confirmation (GTK_WINDOW (win),
2852 TNY_FOLDER (folder_store),
2855 /* Transfer current msg */
2856 if (response == GTK_RESPONSE_OK) {
2857 ModestMailOperation *mail_op;
2859 /* Create mail op */
2860 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
2861 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
2864 /* Transfer messages */
2865 modest_mail_operation_xfer_msgs (mail_op,
2867 TNY_FOLDER (folder_store),
2869 transfer_msgs_from_viewer_cb,
2871 g_object_unref (G_OBJECT (mail_op));
2873 g_object_unref (headers);
2874 g_object_unref (folder_store);
2876 gtk_widget_destroy (dialog);
2880 modest_ui_actions_on_move_to (GtkAction *action,
2883 g_return_if_fail (MODEST_IS_MAIN_WINDOW (win) ||
2884 MODEST_IS_MSG_VIEW_WINDOW (win));
2886 if (MODEST_IS_MAIN_WINDOW (win))
2887 modest_ui_actions_on_main_window_move_to (action,
2888 MODEST_MAIN_WINDOW (win));
2890 modest_ui_actions_on_msg_view_window_move_to (action,
2891 MODEST_MSG_VIEW_WINDOW (win));
2895 * Calls #HeadersFunc for each header already selected in the main
2896 * window or the message currently being shown in the msg view window
2899 do_headers_action (ModestWindow *win,
2903 TnyList *headers_list;
2909 headers_list = get_selected_headers (win);
2913 /* Get the folder */
2914 iter = tny_list_create_iterator (headers_list);
2915 header = TNY_HEADER (tny_iterator_get_current (iter));
2916 folder = tny_header_get_folder (header);
2917 g_object_unref (header);
2919 /* Call the function for each header */
2920 while (!tny_iterator_is_done (iter)) {
2921 header = TNY_HEADER (tny_iterator_get_current (iter));
2922 func (header, win, user_data);
2923 g_object_unref (header);
2924 tny_iterator_next (iter);
2927 /* Trick: do a poke status in order to speed up the signaling
2929 tny_folder_poke_status (folder);
2932 g_object_unref (folder);
2933 g_object_unref (iter);
2934 g_object_unref (headers_list);
2938 modest_ui_actions_view_attachment (GtkAction *action,
2939 ModestWindow *window)
2941 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2942 modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (window), NULL);
2944 /* not supported window for this action */
2945 g_return_if_reached ();
2950 modest_ui_actions_save_attachments (GtkAction *action,
2951 ModestWindow *window)
2953 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2954 modest_msg_view_window_save_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
2956 /* not supported window for this action */
2957 g_return_if_reached ();
2962 modest_ui_actions_remove_attachments (GtkAction *action,
2963 ModestWindow *window)
2965 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2966 modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
2968 /* not supported window for this action */
2969 g_return_if_reached ();
2974 modest_ui_actions_on_settings (GtkAction *action,
2979 dialog = modest_platform_get_global_settings_dialog ();
2980 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (win));
2981 gtk_widget_show (dialog);
2983 gtk_dialog_run (GTK_DIALOG (dialog));
2985 gtk_widget_destroy (dialog);
2989 modest_ui_actions_on_help (GtkAction *action,
2992 const gchar *help_id = NULL;
2994 if (MODEST_IS_MAIN_WINDOW (win)) {
2995 const gchar *action_name;
2996 action_name = gtk_action_get_name (action);
2998 if (!strcmp (action_name, "FolderViewCSMHelp") ||
2999 !strcmp (action_name, "HeaderViewCSMHelp")) {
3000 GtkWidget *folder_view;
3001 TnyFolderStore *folder_store;
3002 /* Get selected folder */
3003 folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
3004 MODEST_WIDGET_TYPE_FOLDER_VIEW);
3005 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
3007 /* Switch help_id */
3008 if (TNY_IS_FOLDER (folder_store)) {
3009 switch (tny_folder_get_folder_type (TNY_FOLDER (folder_store))) {
3010 case TNY_FOLDER_TYPE_NORMAL:
3011 help_id = "applications_email_userfolder";
3013 case TNY_FOLDER_TYPE_INBOX:
3014 help_id = "applications_email_inbox";
3016 case TNY_FOLDER_TYPE_OUTBOX:
3017 help_id = "applications_email_outbox";
3019 case TNY_FOLDER_TYPE_SENT:
3020 help_id = "applications_email_sent";
3022 case TNY_FOLDER_TYPE_DRAFTS:
3023 help_id = "applications_email_drafts";
3025 case TNY_FOLDER_TYPE_ARCHIVE:
3026 help_id = "applications_email_archive";
3033 help_id = "applications_email_mainview";
3035 } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
3036 help_id = "applications_email_viewer";
3037 } else if (MODEST_IS_MSG_EDIT_WINDOW (win))
3038 help_id = "applications_email_editor";
3040 modest_platform_show_help (GTK_WINDOW (win), help_id);
3044 modest_ui_actions_on_retrieve_msg_contents (GtkAction *action,
3045 ModestWindow *window)
3047 ModestMailOperation *mail_op;
3051 headers = get_selected_headers (window);
3055 /* Create mail operation */
3056 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
3058 modest_ui_actions_get_msgs_full_error_handler,
3060 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
3061 modest_mail_operation_get_msgs_full (mail_op, headers, NULL, NULL, NULL);
3064 g_object_unref (headers);
3065 g_object_unref (mail_op);
3069 modest_ui_actions_on_email_menu_activated (GtkAction *action,
3070 ModestWindow *window)
3072 g_return_if_fail (MODEST_IS_WINDOW (window));
3075 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3079 modest_ui_actions_on_edit_menu_activated (GtkAction *action,
3080 ModestWindow *window)
3082 g_return_if_fail (MODEST_IS_WINDOW (window));
3085 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3089 modest_ui_actions_on_view_menu_activated (GtkAction *action,
3090 ModestWindow *window)
3092 g_return_if_fail (MODEST_IS_WINDOW (window));
3095 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3099 modest_ui_actions_on_tools_menu_activated (GtkAction *action,
3100 ModestWindow *window)
3102 g_return_if_fail (MODEST_IS_WINDOW (window));
3105 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3109 modest_ui_actions_on_attachment_menu_activated (GtkAction *action,
3110 ModestWindow *window)
3112 g_return_if_fail (MODEST_IS_WINDOW (window));
3115 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3119 modest_ui_actions_on_toolbar_csm_menu_activated (GtkAction *action,
3120 ModestWindow *window)
3122 g_return_if_fail (MODEST_IS_WINDOW (window));
3125 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3129 modest_ui_actions_on_folder_view_csm_menu_activated (GtkAction *action,
3130 ModestWindow *window)
3132 g_return_if_fail (MODEST_IS_WINDOW (window));
3135 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3139 modest_ui_actions_on_header_view_csm_menu_activated (GtkAction *action,
3140 ModestWindow *window)
3142 g_return_if_fail (MODEST_IS_WINDOW (window));
3145 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3149 modest_ui_actions_check_toolbar_dimming_rules (ModestWindow *window)
3151 g_return_if_fail (MODEST_IS_WINDOW (window));
3154 modest_window_check_dimming_rules_group (window, "ModestToolbarDimmingRules");
3158 modest_ui_actions_on_search_messages (GtkAction *action, ModestWindow *window)
3160 g_return_if_fail (MODEST_IS_WINDOW (window));
3162 modest_platform_show_search_messages (GTK_WINDOW (window));
3166 modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *win)
3168 g_return_if_fail (MODEST_IS_WINDOW (win));
3169 modest_platform_show_addressbook (GTK_WINDOW (win));
3174 modest_ui_actions_on_toggle_find_in_page (GtkToggleAction *action,
3175 ModestWindow *window)
3177 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
3179 modest_msg_edit_window_toggle_find_toolbar (MODEST_MSG_EDIT_WINDOW (window), gtk_toggle_action_get_active (action));
3183 _on_send_receive_progress_changed (ModestMailOperation *mail_op,
3184 ModestMailOperationState *state,
3187 g_return_if_fail (MODEST_IS_MAIN_WINDOW(user_data));
3189 /* Set send/receive operation finished */
3190 if (state->status != MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
3191 modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW(user_data));