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 typedef struct _GetMsgAsyncHelper {
78 ModestMailOperation *mail_op;
85 typedef enum _ReplyForwardAction {
91 typedef struct _ReplyForwardHelper {
92 guint reply_forward_type;
93 ReplyForwardAction action;
95 GtkWidget *parent_window;
99 * The do_headers_action uses this kind of functions to perform some
100 * action to each member of a list of headers
102 typedef void (*HeadersFunc) (TnyHeader *header, ModestWindow *win, gpointer user_data);
105 do_headers_action (ModestWindow *win,
110 static void open_msg_cb (ModestMailOperation *mail_op,
115 static void reply_forward_cb (ModestMailOperation *mail_op,
120 static void reply_forward (ReplyForwardAction action, ModestWindow *win);
122 static gchar* ask_for_folder_name (GtkWindow *parent_window, const gchar *title);
125 static void _on_send_receive_progress_changed (ModestMailOperation *mail_op,
126 ModestMailOperationState *state,
132 modest_ui_actions_on_about (GtkAction *action, ModestWindow *win)
135 const gchar *authors[] = {
136 "Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>",
139 about = gtk_about_dialog_new ();
140 gtk_about_dialog_set_name (GTK_ABOUT_DIALOG(about), PACKAGE_NAME);
141 gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(about),PACKAGE_VERSION);
142 gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about),
143 _("Copyright (c) 2006, Nokia Corporation\n"
144 "All rights reserved."));
145 gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(about),
146 _("a modest e-mail client\n\n"
147 "design and implementation: Dirk-Jan C. Binnema\n"
148 "contributions from the fine people at KC and Ig\n"
149 "uses the tinymail email framework written by Philip van Hoof"));
150 gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(about), authors);
151 gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(about), "http://modest.garage.maemo.org");
153 gtk_dialog_run (GTK_DIALOG (about));
154 gtk_widget_destroy(about);
158 * Gets the list of currently selected messages. If the win is the
159 * main window, then it returns a newly allocated list of the headers
160 * selected in the header view. If win is the msg view window, then
161 * the value returned is a list with just a single header.
163 * The caller of this funcion must free the list.
166 get_selected_headers (ModestWindow *win)
168 if (MODEST_IS_MAIN_WINDOW(win)) {
169 GtkWidget *header_view;
171 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
172 MODEST_WIDGET_TYPE_HEADER_VIEW);
173 return modest_header_view_get_selected_headers (MODEST_HEADER_VIEW(header_view));
175 } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
176 /* for MsgViewWindows, we simply return a list with one element */
178 TnyList *list = NULL;
180 header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
181 if (header != NULL) {
182 list = tny_simple_list_new ();
183 tny_list_prepend (list, G_OBJECT(header));
184 g_object_unref (G_OBJECT(header));
194 headers_action_mark_as_read (TnyHeader *header,
198 TnyHeaderFlags flags;
200 g_return_if_fail (TNY_IS_HEADER(header));
202 flags = tny_header_get_flags (header);
203 if (flags & TNY_HEADER_FLAG_SEEN) return;
204 tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
208 headers_action_mark_as_unread (TnyHeader *header,
212 TnyHeaderFlags flags;
214 g_return_if_fail (TNY_IS_HEADER(header));
216 flags = tny_header_get_flags (header);
217 if (flags & TNY_HEADER_FLAG_SEEN) {
218 tny_header_unset_flags (header, TNY_HEADER_FLAG_SEEN);
224 headers_action_delete (TnyHeader *header,
228 ModestMailOperation *mail_op = NULL;
230 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_DELETE, G_OBJECT(win));
231 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
234 /* Always delete. TODO: Move to trash still not supported */
235 modest_mail_operation_remove_msg (mail_op, header, FALSE);
236 g_object_unref (G_OBJECT (mail_op));
240 modest_ui_actions_on_delete (GtkAction *action, ModestWindow *win)
242 TnyList *header_list = NULL;
243 TnyIterator *iter = NULL;
244 TnyHeader *header = NULL;
245 gchar *message = NULL;
249 ModestWindowMgr *mgr;
251 g_return_if_fail (MODEST_IS_WINDOW(win));
253 header_list = get_selected_headers (win);
254 if (!header_list) return;
256 /* Check if any of the headers is already opened */
257 iter = tny_list_create_iterator (header_list);
259 mgr = modest_runtime_get_window_mgr ();
260 while (!tny_iterator_is_done (iter) && !found) {
261 header = TNY_HEADER (tny_iterator_get_current (iter));
262 if (modest_window_mgr_find_window_by_header (mgr, header))
264 g_object_unref (header);
265 tny_iterator_next (iter);
267 g_object_unref (iter);
272 num = g_strdup_printf ("%d", tny_list_get_length (header_list));
273 msg = g_strdup_printf (_("mcen_nc_unable_to_delete_n_messages"), num);
275 modest_platform_run_information_dialog (GTK_WINDOW (win), (const gchar *) msg);
279 g_object_unref (header_list);
284 if (tny_list_get_length(header_list) > 1)
285 message = g_strdup(_("emev_nc_delete_messages"));
287 iter = tny_list_create_iterator (header_list);
288 header = TNY_HEADER (tny_iterator_get_current (iter));
289 desc = g_strdup_printf ("%s", tny_header_get_subject (header));
290 message = g_strdup_printf(_("emev_nc_delete_message"), desc);
291 g_object_unref (header);
292 g_object_unref (iter);
295 /* Confirmation dialog */
296 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
300 if (response == GTK_RESPONSE_OK) {
301 if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
303 g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value);
307 /* Remove each header */
308 do_headers_action (win, headers_action_delete, NULL);
310 if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
311 gtk_widget_destroy (GTK_WIDGET(win));
318 g_object_unref (header_list);
323 modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win)
325 #ifdef MODEST_PLATFORM_MAEMO
326 modest_osso_save_state();
327 #endif /* MODEST_PLATFORM_MAEMO */
333 modest_ui_actions_on_close_window (GtkAction *action, ModestWindow *win)
335 if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
336 gtk_widget_destroy (GTK_WIDGET (win));
337 } else if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
339 g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value);
340 } else if (MODEST_IS_WINDOW (win)) {
341 gtk_widget_destroy (GTK_WIDGET (win));
343 g_return_if_reached ();
348 modest_ui_actions_on_add_to_contacts (GtkAction *action, ModestWindow *win)
350 GtkClipboard *clipboard = NULL;
351 gchar *selection = NULL;
353 clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
354 selection = gtk_clipboard_wait_for_text (clipboard);
356 /* Question: why is the clipboard being used here?
357 * It doesn't really make a lot of sense. */
361 modest_address_book_add_address (selection);
367 modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
369 /* This is currently only implemented for Maemo,
370 * because it requires a providers preset file which is not publically available.
372 #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
373 gboolean accounts_exist = modest_account_mgr_has_accounts(
374 modest_runtime_get_account_mgr(), TRUE);
376 if (!accounts_exist) {
377 /* If there are no accounts yet, just show the easy-setup wizard, as per the UI spec: */
378 ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new ();
379 gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
380 gtk_dialog_run (GTK_DIALOG (wizard));
381 gtk_widget_destroy (GTK_WIDGET (wizard));
383 /* Show the list of accounts: */
384 GtkDialog *account_win = GTK_DIALOG(modest_account_view_window_new ());
385 gtk_window_set_transient_for (GTK_WINDOW (account_win), GTK_WINDOW(win));
386 gtk_dialog_run (account_win);
387 gtk_widget_destroy (GTK_WIDGET(account_win));
390 GtkWidget *dialog, *label;
392 /* Create the widgets */
394 dialog = gtk_dialog_new_with_buttons ("Message",
396 GTK_DIALOG_DESTROY_WITH_PARENT,
400 label = gtk_label_new ("Hello World!");
402 /* Ensure that the dialog box is destroyed when the user responds. */
404 g_signal_connect_swapped (dialog, "response",
405 G_CALLBACK (gtk_widget_destroy),
408 /* Add the label, and show everything we've added to the dialog. */
410 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
412 gtk_widget_show_all (dialog);
413 #endif /* MODEST_PLATFORM_MAEMO */
417 on_smtp_servers_window_hide (GtkWindow* window, gpointer user_data)
419 ModestWindow *main_window = MODEST_WINDOW (user_data);
421 /* Save any changes. */
422 modest_connection_specific_smtp_window_save_server_accounts (
423 MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (window),
424 modest_window_get_active_account (main_window));
425 gtk_widget_destroy (GTK_WIDGET (window));
429 modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win)
431 /* This is currently only implemented for Maemo,
432 * because it requires an API (libconic) to detect different connection
435 #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
437 /* Create the window if necessary: */
438 const gchar *active_account_name = modest_window_get_active_account (win);
440 /* TODO: Dim the menu item (not in the UI spec)? or show a warning,
441 * or show the default account?
442 * If we show the default account then the account name should be shown in
443 * the window when we show it. */
444 if (!active_account_name) {
445 g_warning ("%s: No account is active.", __FUNCTION__);
449 GtkWidget *specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
450 modest_connection_specific_smtp_window_fill_with_connections (
451 MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window),
452 modest_runtime_get_account_mgr(),
453 active_account_name);
455 /* Show the window: */
456 gtk_window_set_transient_for (GTK_WINDOW (specific_window), GTK_WINDOW (win));
457 gtk_window_set_modal (GTK_WINDOW (specific_window), TRUE);
458 gtk_widget_show (specific_window);
460 /* Save changes when the window is hidden: */
461 g_signal_connect (specific_window, "hide",
462 G_CALLBACK (on_smtp_servers_window_hide), win);
463 #endif /* MODEST_PLATFORM_MAEMO */
467 modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win)
469 ModestWindow *msg_win;
471 TnyFolder *folder = NULL;
472 gchar *account_name = NULL;
473 gchar *from_str = NULL;
474 /* GError *err = NULL; */
475 TnyAccount *account = NULL;
476 ModestWindowMgr *mgr;
477 gchar *signature = NULL, *blank_and_signature = NULL;
479 account_name = g_strdup(modest_window_get_active_account (win));
481 account_name = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
483 g_printerr ("modest: no account found\n");
487 account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store(),
489 TNY_ACCOUNT_TYPE_STORE);
491 g_printerr ("modest: failed to get tnyaccount for '%s'\n", account_name);
495 from_str = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(), account_name);
497 g_printerr ("modest: failed get from string for '%s'\n", account_name);
501 if (modest_account_mgr_get_bool (modest_runtime_get_account_mgr (), account_name,
502 MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) {
503 signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), account_name,
504 MODEST_ACCOUNT_SIGNATURE, FALSE);
505 blank_and_signature = g_strconcat ("\n", signature, NULL);
508 blank_and_signature = g_strdup ("");
511 msg = modest_tny_msg_new ("", from_str, "", "", "", blank_and_signature, NULL);
513 g_printerr ("modest: failed to create new msg\n");
517 folder = modest_tny_account_get_special_folder (account, TNY_FOLDER_TYPE_DRAFTS);
519 g_printerr ("modest: failed to find Drafts folder\n");
523 /* tny_folder_add_msg (folder, msg, &err); */
525 /* g_printerr ("modest: error adding msg to Drafts folder: %s", */
527 /* g_error_free (err); */
531 /* Create and register edit window */
532 /* This is destroyed by TOOD. */
533 msg_win = modest_msg_edit_window_new (msg, account_name);
534 mgr = modest_runtime_get_window_mgr ();
535 modest_window_mgr_register_window (mgr, msg_win);
538 gtk_window_set_transient_for (GTK_WINDOW (msg_win),
540 gtk_widget_show_all (GTK_WIDGET (msg_win));
543 g_free (account_name);
545 g_free (blank_and_signature);
547 g_object_unref (G_OBJECT(account));
549 g_object_unref (G_OBJECT(msg));
551 g_object_unref (G_OBJECT(folder));
555 open_msg_cb (ModestMailOperation *mail_op,
560 ModestWindowMgr *mgr = NULL;
561 ModestWindow *parent_win = NULL;
562 ModestWindow *win = NULL;
563 TnyFolderType folder_type = TNY_FOLDER_TYPE_UNKNOWN;
564 gchar *account = NULL;
567 /* TODO: Show an error? (review the specs) */
571 parent_win = (ModestWindow *) modest_mail_operation_get_source (mail_op);
572 folder = tny_header_get_folder (header);
574 /* Mark header as read */
575 headers_action_mark_as_read (header, MODEST_WINDOW(parent_win), NULL);
578 account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (parent_win)));
580 account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
582 /* Gets folder type (OUTBOX headers will be opened in edit window */
583 if (modest_tny_folder_is_local_folder (folder))
584 folder_type = modest_tny_folder_get_local_folder_type (folder);
586 /* If the header is in the drafts folder then open the editor,
587 else the message view window */
588 if (folder_type == TNY_FOLDER_TYPE_DRAFTS) {
589 win = modest_msg_edit_window_new (msg, account);
591 gchar *uid = modest_tny_folder_get_header_unique_id (header);
593 if (MODEST_IS_MAIN_WINDOW (parent_win)) {
594 GtkWidget *header_view;
595 GtkTreeSelection *sel;
596 GList *sel_list = NULL;
599 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(parent_win),
600 MODEST_WIDGET_TYPE_HEADER_VIEW);
602 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view));
603 sel_list = gtk_tree_selection_get_selected_rows (sel, &model);
605 if (sel_list != NULL) {
606 GtkTreeRowReference *row_reference;
608 row_reference = gtk_tree_row_reference_new (model, (GtkTreePath *) sel_list->data);
609 g_list_foreach (sel_list, (GFunc) gtk_tree_path_free, NULL);
610 g_list_free (sel_list);
612 win = modest_msg_view_window_new_with_header_model (msg,
617 gtk_tree_row_reference_free (row_reference);
619 win = modest_msg_view_window_new (msg, account, (const gchar*) uid);
622 win = modest_msg_view_window_new (msg, account, (const gchar*) uid);
627 /* Register and show new window */
629 mgr = modest_runtime_get_window_mgr ();
630 modest_window_mgr_register_window (mgr, win);
631 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (parent_win));
632 gtk_widget_show_all (GTK_WIDGET(win));
637 g_object_unref (msg);
638 g_object_unref (folder);
639 g_object_unref (header);
643 * This function is the error handler of the
644 * modest_mail_operation_get_msgs_full operation
647 modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op,
652 error = modest_mail_operation_get_error (mail_op);
653 if (error->code == MODEST_MAIL_OPERATION_ERROR_MESSAGE_SIZE_LIMIT) {
654 GObject *win = modest_mail_operation_get_source (mail_op);
656 modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
662 * This function is used by both modest_ui_actions_on_open and
663 * modest_ui_actions_on_header_activated. This way we always do the
664 * same when trying to open messages.
667 _modest_ui_actions_open (TnyList *headers, ModestWindow *win)
669 ModestWindowMgr *mgr;
671 ModestMailOperation *mail_op;
673 /* Look if we already have a message view for each header. If
674 true, then remove the header from the list of headers to
676 mgr = modest_runtime_get_window_mgr ();
677 iter = tny_list_create_iterator (headers);
678 while (!tny_iterator_is_done (iter)) {
679 ModestWindow *window;
682 header = TNY_HEADER (tny_iterator_get_current (iter));
683 window = modest_window_mgr_find_window_by_header (mgr, header);
685 /* Do not open again the message and present
686 the window to the user */
687 tny_list_remove (headers, G_OBJECT (header));
688 gtk_window_present (GTK_WINDOW (window));
691 g_object_unref (header);
692 tny_iterator_next (iter);
696 /* Open each message */
697 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
699 modest_ui_actions_get_msgs_full_error_handler,
701 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
702 modest_mail_operation_get_msgs_full (mail_op,
708 g_object_unref (iter);
709 g_object_unref(mail_op);
713 modest_ui_actions_on_open (GtkAction *action, ModestWindow *win)
718 headers = get_selected_headers (win);
723 _modest_ui_actions_open (headers, win);
725 g_object_unref(headers);
730 free_reply_forward_helper (gpointer data)
732 ReplyForwardHelper *helper;
734 helper = (ReplyForwardHelper *) data;
735 g_free (helper->account_name);
736 g_slice_free (ReplyForwardHelper, helper);
740 reply_forward_cb (ModestMailOperation *mail_op,
746 ReplyForwardHelper *rf_helper;
747 ModestWindow *msg_win;
748 ModestEditType edit_type;
750 TnyAccount *account = NULL;
751 ModestWindowMgr *mgr;
752 gchar *signature = NULL;
754 g_return_if_fail (user_data != NULL);
755 rf_helper = (ReplyForwardHelper *) user_data;
757 from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
758 rf_helper->account_name);
759 if (modest_account_mgr_get_bool (modest_runtime_get_account_mgr(),
760 rf_helper->account_name,
761 MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) {
762 signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (),
763 rf_helper->account_name,
764 MODEST_ACCOUNT_SIGNATURE, FALSE);
767 /* Create reply mail */
768 switch (rf_helper->action) {
771 modest_tny_msg_create_reply_msg (msg, from, signature,
772 rf_helper->reply_forward_type,
773 MODEST_TNY_MSG_REPLY_MODE_SENDER);
775 case ACTION_REPLY_TO_ALL:
777 modest_tny_msg_create_reply_msg (msg, from, signature, rf_helper->reply_forward_type,
778 MODEST_TNY_MSG_REPLY_MODE_ALL);
779 edit_type = MODEST_EDIT_TYPE_REPLY;
783 modest_tny_msg_create_forward_msg (msg, from, signature, rf_helper->reply_forward_type);
784 edit_type = MODEST_EDIT_TYPE_FORWARD;
787 g_return_if_reached ();
794 g_printerr ("modest: failed to create message\n");
798 account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store(),
799 rf_helper->account_name,
800 TNY_ACCOUNT_TYPE_STORE);
802 g_printerr ("modest: failed to get tnyaccount for '%s'\n", rf_helper->account_name);
806 /* Create and register the windows */
807 msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account_name);
808 mgr = modest_runtime_get_window_mgr ();
809 modest_window_mgr_register_window (mgr, msg_win);
811 if (rf_helper->parent_window != NULL) {
814 parent_zoom = modest_window_get_zoom (MODEST_WINDOW (rf_helper->parent_window));
815 modest_window_set_zoom (msg_win, parent_zoom);
818 /* Show edit window */
819 gtk_widget_show_all (GTK_WIDGET (msg_win));
823 g_object_unref (G_OBJECT (new_msg));
825 g_object_unref (G_OBJECT (account));
826 g_object_unref (msg);
827 g_object_unref (header);
831 * Checks a list of headers. If any of them are not currently
832 * downloaded (CACHED) then it asks the user for permission to
835 * Returns FALSE if the user does not want to download the
836 * messages. Returns TRUE if the user allowed the download or if all
837 * of them are currently downloaded
840 download_uncached_messages (TnyList *header_list, GtkWindow *win)
843 gboolean found, retval;
845 iter = tny_list_create_iterator (header_list);
847 while (!tny_iterator_is_done (iter) && !found) {
849 TnyHeaderFlags flags;
851 header = TNY_HEADER (tny_iterator_get_current (iter));
852 flags = tny_header_get_flags (header);
853 /* TODO: is this the right flag?, it seems that some
854 headers that have been previously downloaded do not
856 found = !(flags & TNY_HEADER_FLAG_CACHED);
857 g_object_unref (header);
858 tny_iterator_next (iter);
860 g_object_unref (iter);
862 /* Ask for user permission to download the messages */
865 GtkResponseType response;
867 modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
868 _("mcen_nc_get_multi_msg_txt"));
869 if (response == GTK_RESPONSE_CANCEL)
877 * Common code for the reply and forward actions
880 reply_forward (ReplyForwardAction action, ModestWindow *win)
882 ModestMailOperation *mail_op = NULL;
883 TnyList *header_list = NULL;
884 ReplyForwardHelper *rf_helper = NULL;
885 guint reply_forward_type;
886 gboolean continue_download;
888 g_return_if_fail (MODEST_IS_WINDOW(win));
890 header_list = get_selected_headers (win);
894 /* Check that the messages have been previously downloaded */
895 continue_download = download_uncached_messages (header_list, GTK_WINDOW (win));
896 if (!continue_download) {
897 g_object_unref (header_list);
902 modest_conf_get_int (modest_runtime_get_conf (),
903 (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE,
905 /* We assume that we can only select messages of the
906 same folder and that we reply all of them from the
907 same account. In fact the interface currently only
908 allows single selection */
911 rf_helper = g_slice_new0 (ReplyForwardHelper);
912 rf_helper->reply_forward_type = reply_forward_type;
913 rf_helper->action = action;
914 rf_helper->account_name = g_strdup (modest_window_get_active_account (win));
915 if ((win != NULL) && (MODEST_IS_WINDOW (win)))
916 rf_helper->parent_window = GTK_WIDGET (win);
917 if (!rf_helper->account_name)
918 rf_helper->account_name =
919 modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
921 if (MODEST_IS_MSG_VIEW_WINDOW(win)) {
924 /* Get header and message. Do not free them here, the
925 reply_forward_cb must do it */
926 msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW(win));
927 header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW(win));
928 if (!msg || !header) {
930 g_object_unref (msg);
932 g_object_unref (header);
933 g_printerr ("modest: no message found\n");
936 reply_forward_cb (NULL, header, msg, rf_helper);
938 /* Retrieve messages */
939 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
941 modest_ui_actions_get_msgs_full_error_handler,
943 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
944 modest_mail_operation_get_msgs_full (mail_op,
948 free_reply_forward_helper);
951 g_object_unref(mail_op);
955 g_object_unref (header_list);
959 modest_ui_actions_on_reply (GtkAction *action, ModestWindow *win)
961 g_return_if_fail (MODEST_IS_WINDOW(win));
963 reply_forward (ACTION_REPLY, win);
967 modest_ui_actions_on_forward (GtkAction *action, ModestWindow *win)
969 g_return_if_fail (MODEST_IS_WINDOW(win));
971 reply_forward (ACTION_FORWARD, win);
975 modest_ui_actions_on_reply_all (GtkAction *action, ModestWindow *win)
977 g_return_if_fail (MODEST_IS_WINDOW(win));
979 reply_forward (ACTION_REPLY_TO_ALL, win);
983 modest_ui_actions_on_next (GtkAction *action,
984 ModestWindow *window)
986 if (MODEST_IS_MAIN_WINDOW (window)) {
987 GtkWidget *header_view;
989 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
990 MODEST_WIDGET_TYPE_HEADER_VIEW);
994 modest_header_view_select_next (MODEST_HEADER_VIEW(header_view));
995 } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
996 modest_msg_view_window_select_next_message (MODEST_MSG_VIEW_WINDOW (window));
998 g_return_if_reached ();
1003 modest_ui_actions_on_prev (GtkAction *action,
1004 ModestWindow *window)
1006 g_return_if_fail (MODEST_IS_WINDOW(window));
1008 if (MODEST_IS_MAIN_WINDOW (window)) {
1009 GtkWidget *header_view;
1010 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
1011 MODEST_WIDGET_TYPE_HEADER_VIEW);
1015 modest_header_view_select_prev (MODEST_HEADER_VIEW(header_view));
1016 } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
1017 modest_msg_view_window_select_previous_message (MODEST_MSG_VIEW_WINDOW (window));
1019 g_return_if_reached ();
1024 modest_ui_actions_on_sort (GtkAction *action,
1025 ModestWindow *window)
1027 g_return_if_fail (MODEST_IS_WINDOW(window));
1029 if (MODEST_IS_MAIN_WINDOW (window)) {
1030 GtkWidget *header_view;
1031 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
1032 MODEST_WIDGET_TYPE_HEADER_VIEW);
1036 /* Show sorting dialog */
1037 modest_platform_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);
1042 * This function performs the send & receive required actions. The
1043 * window is used to create the mail operation. Typically it should
1044 * always be the main window, but we pass it as argument in order to
1048 modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win)
1050 gchar *acc_name = NULL;
1051 ModestMailOperation *mail_op;
1053 /* If no account name was provided then get the current account, and if
1054 there is no current account then pick the default one: */
1055 if (!account_name) {
1056 acc_name = g_strdup (modest_window_get_active_account(win));
1058 acc_name = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
1060 g_printerr ("modest: cannot get default account\n");
1064 acc_name = g_strdup (account_name);
1067 /* Set send/receive operation in progress */
1068 modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW(win));
1070 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
1071 g_signal_connect (G_OBJECT(mail_op), "progress-changed",
1072 G_CALLBACK (_on_send_receive_progress_changed),
1075 /* Send & receive. */
1076 /* TODO: The spec wants us to first do any pending deletions, before receiving. */
1077 /* Receive and then send. The operation is tagged initially as
1078 a receive operation because the account update performs a
1079 receive and then a send. The operation changes its type
1080 internally, so the progress objects will receive the proper
1081 progress information */
1082 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
1083 modest_mail_operation_update_account (mail_op, acc_name);
1084 g_object_unref (G_OBJECT (mail_op));
1091 * Refreshes all accounts. This function will be used by automatic
1095 modest_ui_actions_do_send_receive_all (ModestWindow *win)
1097 GSList *account_names, *iter;
1099 account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr(),
1102 iter = account_names;
1104 modest_ui_actions_do_send_receive ((const char*) iter->data, win);
1105 iter = g_slist_next (iter);
1108 g_slist_foreach (account_names, (GFunc) g_free, NULL);
1109 g_slist_free (account_names);
1113 * Handler of the click on Send&Receive button in the main toolbar
1116 modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
1118 /* Check if accounts exist */
1119 gboolean accounts_exist =
1120 modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE);
1122 /* If not, allow the user to create an account before trying to send/receive. */
1123 if (!accounts_exist)
1124 modest_ui_actions_on_accounts (NULL, win);
1126 /* Refresh the active account */
1127 modest_ui_actions_do_send_receive (NULL, win);
1132 modest_ui_actions_toggle_header_list_view (GtkAction *action, ModestMainWindow *main_window)
1135 GtkWidget *header_view;
1137 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1139 header_view = modest_main_window_get_child_widget (main_window,
1140 MODEST_WIDGET_TYPE_HEADER_VIEW);
1144 conf = modest_runtime_get_conf ();
1146 /* what is saved/restored is depending on the style; thus; we save with
1147 * old style, then update the style, and restore for this new style
1149 modest_widget_memory_save (conf, G_OBJECT(header_view), MODEST_CONF_HEADER_VIEW_KEY);
1151 if (modest_header_view_get_style
1152 (MODEST_HEADER_VIEW(header_view)) == MODEST_HEADER_VIEW_STYLE_DETAILS)
1153 modest_header_view_set_style (MODEST_HEADER_VIEW(header_view),
1154 MODEST_HEADER_VIEW_STYLE_TWOLINES);
1156 modest_header_view_set_style (MODEST_HEADER_VIEW(header_view),
1157 MODEST_HEADER_VIEW_STYLE_DETAILS);
1159 modest_widget_memory_restore (conf, G_OBJECT(header_view),
1160 MODEST_CONF_HEADER_VIEW_KEY);
1165 modest_ui_actions_on_header_selected (ModestHeaderView *header_view,
1167 ModestMainWindow *main_window)
1169 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1170 g_return_if_fail (MODEST_IS_HEADER_VIEW (header_view));
1172 /* If no header has been selected then exit */
1176 /* Update Main window title */
1177 if (GTK_WIDGET_HAS_FOCUS (header_view)) {
1178 const gchar *subject = tny_header_get_subject (header);
1179 if (subject && strlen(subject) > 0)
1180 gtk_window_set_title (GTK_WINDOW (main_window), subject);
1182 gtk_window_set_title (GTK_WINDOW (main_window), _("mail_va_no_subject"));
1185 /* Update toolbar dimming state */
1186 modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
1190 modest_ui_actions_on_header_activated (ModestHeaderView *header_view,
1192 ModestMainWindow *main_window)
1196 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1201 headers = tny_simple_list_new ();
1202 tny_list_prepend (headers, G_OBJECT (header));
1204 _modest_ui_actions_open (headers, MODEST_WINDOW (main_window));
1206 g_object_unref (headers);
1210 set_active_account_from_tny_account (TnyAccount *account,
1211 ModestWindow *window)
1213 const gchar *server_acc_name = tny_account_get_id (account);
1215 /* We need the TnyAccount provided by the
1216 account store because that is the one that
1217 knows the name of the Modest account */
1218 TnyAccount *modest_server_account = modest_server_account =
1219 modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store (),
1222 const gchar *modest_acc_name =
1223 modest_tny_account_get_parent_modest_account_name_for_server_account (modest_server_account);
1224 modest_window_set_active_account (window, modest_acc_name);
1225 g_object_unref (modest_server_account);
1229 modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
1230 TnyFolderStore *folder_store,
1232 ModestMainWindow *main_window)
1235 GtkWidget *header_view;
1237 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1239 header_view = modest_main_window_get_child_widget(main_window,
1240 MODEST_WIDGET_TYPE_HEADER_VIEW);
1244 conf = modest_runtime_get_conf ();
1246 if (TNY_IS_ACCOUNT (folder_store)) {
1247 /* Update active account */
1248 set_active_account_from_tny_account (TNY_ACCOUNT (folder_store), MODEST_WINDOW (main_window));
1249 /* Show account details */
1250 modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS);
1252 if (TNY_IS_FOLDER (folder_store) && selected) {
1254 if (!TNY_IS_MERGE_FOLDER (folder_store)) { /* TnyMergeFolder can have no get_account() implementation. */
1255 /* Update the active account */
1256 TnyAccount *account = modest_tny_folder_get_account (TNY_FOLDER (folder_store));
1257 set_active_account_from_tny_account (account, MODEST_WINDOW (main_window));
1258 g_object_unref (account);
1261 /* Set folder on header view */
1262 modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view),
1263 TNY_FOLDER (folder_store));
1265 /* Resore configuration */
1266 modest_widget_memory_restore (conf, G_OBJECT(header_view),
1267 MODEST_CONF_HEADER_VIEW_KEY);
1269 /* Set main view style */
1270 /* modest_main_window_set_contents_style (main_window, */
1271 /* MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS); */
1272 /* modest_widget_memory_restore (conf, G_OBJECT(header_view), */
1273 /* MODEST_CONF_HEADER_VIEW_KEY); */
1276 /* Update the active account */
1277 modest_window_set_active_account (MODEST_WINDOW (main_window), NULL);
1278 /* Do not show folder */
1279 modest_widget_memory_save (conf, G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY);
1280 modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view), NULL);
1284 /* Update toolbar dimming state */
1285 modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
1289 modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,ModestItemType type,
1296 item = (type == MODEST_ITEM_TYPE_FOLDER) ? "folder" : "message";
1298 if (g_main_depth > 0)
1299 gdk_threads_enter ();
1300 online = tny_device_is_online (modest_runtime_get_device());
1303 /* already online -- the item is simply not there... */
1304 dialog = gtk_message_dialog_new (GTK_WINDOW (win),
1306 GTK_MESSAGE_WARNING,
1308 _("The %s you selected cannot be found"),
1310 gtk_dialog_run (GTK_DIALOG(dialog));
1312 dialog = gtk_dialog_new_with_buttons (_("Connection requested"),
1316 GTK_RESPONSE_REJECT,
1318 GTK_RESPONSE_ACCEPT,
1320 txt = g_strdup_printf (_("This %s is not available in offline mode.\n"
1321 "Do you want to get online?"), item);
1322 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1323 gtk_label_new (txt), FALSE, FALSE, 0);
1324 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
1327 gtk_window_set_default_size (GTK_WINDOW(dialog), 300, 300);
1328 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
1329 // modest_platform_connect_and_wait ();
1332 gtk_widget_destroy (dialog);
1333 if (g_main_depth > 0)
1334 gdk_threads_leave ();
1338 modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, const gchar* link,
1341 /* g_message ("%s %s", __FUNCTION__, link); */
1346 modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview, const gchar* link,
1349 modest_platform_activate_uri (link);
1353 modest_ui_actions_on_msg_link_contextual (ModestMsgView *msgview, const gchar* link,
1356 modest_platform_show_uri_popup (link);
1360 modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, TnyMimePart *mime_part,
1363 modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (win), mime_part);
1367 modest_ui_actions_on_msg_recpt_activated (ModestMsgView *msgview,
1368 const gchar *address,
1371 /* g_message ("%s %s", __FUNCTION__, address); */
1375 modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edit_window)
1377 TnyTransportAccount *transport_account;
1378 ModestMailOperation *mail_operation;
1380 gchar *account_name, *from;
1381 ModestAccountMgr *account_mgr;
1383 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
1385 data = modest_msg_edit_window_get_msg_data (edit_window);
1387 account_mgr = modest_runtime_get_account_mgr();
1388 account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window)));
1390 account_name = modest_account_mgr_get_default_account (account_mgr);
1391 if (!account_name) {
1392 g_printerr ("modest: no account found\n");
1393 modest_msg_edit_window_free_msg_data (edit_window, data);
1397 if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
1398 account_name = g_strdup (data->account_name);
1402 TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_server_account
1403 (modest_runtime_get_account_store(),
1405 TNY_ACCOUNT_TYPE_TRANSPORT));
1406 if (!transport_account) {
1407 g_printerr ("modest: no transport account found for '%s'\n", account_name);
1408 g_free (account_name);
1409 modest_msg_edit_window_free_msg_data (edit_window, data);
1412 from = modest_account_mgr_get_from_string (account_mgr, account_name);
1414 /* Create the mail operation */
1415 mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(edit_window));
1416 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
1418 modest_mail_operation_save_to_drafts (mail_operation,
1429 data->priority_flags);
1432 g_free (account_name);
1433 g_object_unref (G_OBJECT (transport_account));
1434 g_object_unref (G_OBJECT (mail_operation));
1436 modest_msg_edit_window_free_msg_data (edit_window, data);
1438 /* Save settings and close the window */
1439 gtk_widget_destroy (GTK_WIDGET (edit_window));
1442 /* For instance, when clicking the Send toolbar button when editing a message: */
1444 modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
1446 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
1448 if (!modest_msg_edit_window_check_names (edit_window))
1451 /* FIXME: Code added just for testing. The final version will
1452 use the send queue provided by tinymail and some
1454 ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
1455 gchar *account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window)));
1457 account_name = modest_account_mgr_get_default_account (account_mgr);
1459 if (!account_name) {
1460 g_printerr ("modest: no account found\n");
1464 MsgData *data = modest_msg_edit_window_get_msg_data (edit_window);
1466 if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
1467 account_name = g_strdup (data->account_name);
1470 /* Get the currently-active transport account for this modest account: */
1471 TnyTransportAccount *transport_account =
1472 TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_transport_account_for_open_connection
1473 (modest_runtime_get_account_store(),
1475 if (!transport_account) {
1476 g_printerr ("modest: no transport account found for '%s'\n", account_name);
1477 g_free (account_name);
1478 modest_msg_edit_window_free_msg_data (edit_window, data);
1482 gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name);
1484 /* mail content checks and dialogs */
1485 if (data->subject == NULL || data->subject[0] == '\0') {
1486 GtkResponseType response;
1487 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (edit_window),
1488 _("mcen_nc_subject_is_empty_send"));
1489 if (response == GTK_RESPONSE_CANCEL) {
1490 g_free (account_name);
1495 if (data->plain_body == NULL || data->plain_body[0] == '\0') {
1496 GtkResponseType response;
1497 gchar *note_message;
1498 gchar *note_subject = data->subject;
1499 if (note_subject == NULL || note_subject[0] == '\0')
1500 note_subject = _("mail_va_no_subject");
1501 note_message = g_strdup_printf (_("emev_ni_ui_smtp_message_null"), note_subject);
1502 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (edit_window),
1504 g_free (note_message);
1505 if (response == GTK_RESPONSE_CANCEL) {
1506 g_free (account_name);
1511 /* Create the mail operation */
1512 ModestMailOperation *mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_SEND, G_OBJECT(edit_window));
1513 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
1515 modest_mail_operation_send_new_mail (mail_operation,
1526 data->priority_flags);
1530 g_free (account_name);
1531 g_object_unref (G_OBJECT (transport_account));
1532 g_object_unref (G_OBJECT (mail_operation));
1534 modest_msg_edit_window_free_msg_data (edit_window, data);
1536 /* Save settings and close the window: */
1537 gtk_widget_destroy (GTK_WIDGET (edit_window));
1541 modest_ui_actions_on_toggle_bold (GtkToggleAction *action,
1542 ModestMsgEditWindow *window)
1544 ModestMsgEditFormatState *format_state = NULL;
1546 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1547 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1549 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW (window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1552 format_state = modest_msg_edit_window_get_format_state (window);
1553 g_return_if_fail (format_state != NULL);
1555 format_state->bold = gtk_toggle_action_get_active (action);
1556 modest_msg_edit_window_set_format_state (window, format_state);
1557 g_free (format_state);
1562 modest_ui_actions_on_toggle_italics (GtkToggleAction *action,
1563 ModestMsgEditWindow *window)
1565 ModestMsgEditFormatState *format_state = NULL;
1567 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1568 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1570 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1573 format_state = modest_msg_edit_window_get_format_state (window);
1574 g_return_if_fail (format_state != NULL);
1576 format_state->italics = gtk_toggle_action_get_active (action);
1577 modest_msg_edit_window_set_format_state (window, format_state);
1578 g_free (format_state);
1583 modest_ui_actions_on_toggle_bullets (GtkToggleAction *action,
1584 ModestMsgEditWindow *window)
1586 ModestMsgEditFormatState *format_state = NULL;
1588 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1589 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1591 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW (window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1594 format_state = modest_msg_edit_window_get_format_state (window);
1595 g_return_if_fail (format_state != NULL);
1597 format_state->bullet = gtk_toggle_action_get_active (action);
1598 modest_msg_edit_window_set_format_state (window, format_state);
1599 g_free (format_state);
1604 modest_ui_actions_on_change_justify (GtkRadioAction *action,
1605 GtkRadioAction *selected,
1606 ModestMsgEditWindow *window)
1608 ModestMsgEditFormatState *format_state = NULL;
1609 GtkJustification value;
1611 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1613 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1616 value = gtk_radio_action_get_current_value (selected);
1618 format_state = modest_msg_edit_window_get_format_state (window);
1619 g_return_if_fail (format_state != NULL);
1621 format_state->justification = value;
1622 modest_msg_edit_window_set_format_state (window, format_state);
1623 g_free (format_state);
1627 modest_ui_actions_on_select_editor_color (GtkAction *action,
1628 ModestMsgEditWindow *window)
1630 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1631 g_return_if_fail (GTK_IS_ACTION (action));
1633 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1636 modest_msg_edit_window_select_color (window);
1640 modest_ui_actions_on_select_editor_background_color (GtkAction *action,
1641 ModestMsgEditWindow *window)
1643 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1644 g_return_if_fail (GTK_IS_ACTION (action));
1646 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1649 modest_msg_edit_window_select_background_color (window);
1653 modest_ui_actions_on_insert_image (GtkAction *action,
1654 ModestMsgEditWindow *window)
1656 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1657 g_return_if_fail (GTK_IS_ACTION (action));
1659 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1662 modest_msg_edit_window_insert_image (window);
1666 modest_ui_actions_on_attach_file (GtkAction *action,
1667 ModestMsgEditWindow *window)
1669 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1670 g_return_if_fail (GTK_IS_ACTION (action));
1672 modest_msg_edit_window_attach_file (window);
1676 modest_ui_actions_on_remove_attachments (GtkAction *action,
1677 ModestMsgEditWindow *window)
1679 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1680 g_return_if_fail (GTK_IS_ACTION (action));
1682 modest_msg_edit_window_remove_attachments (window, NULL);
1686 * Shows a dialog with an entry that asks for some text. The returned
1687 * value must be freed by the caller. The dialog window title will be
1691 ask_for_folder_name (GtkWindow *parent_window,
1694 GtkWidget *dialog, *entry;
1695 gchar *folder_name = NULL;
1697 /* Ask for folder name */
1698 dialog = gtk_dialog_new_with_buttons (_("New Folder Name"),
1702 GTK_RESPONSE_REJECT,
1704 GTK_RESPONSE_ACCEPT,
1706 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1707 gtk_label_new(title),
1710 entry = gtk_entry_new_with_max_length (40);
1711 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1715 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
1717 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
1718 folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
1720 gtk_widget_destroy (dialog);
1726 modest_ui_actions_on_new_folder (GtkAction *action, ModestMainWindow *main_window)
1728 TnyFolderStore *parent_folder;
1729 GtkWidget *folder_view;
1731 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1733 folder_view = modest_main_window_get_child_widget (main_window,
1734 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1738 parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
1740 if (parent_folder) {
1741 gboolean finished = FALSE;
1743 gchar *folder_name = NULL, *suggested_name = NULL;
1745 /* Run the new folder dialog */
1747 result = modest_platform_run_new_folder_dialog (GTK_WINDOW (main_window),
1752 if (result == GTK_RESPONSE_REJECT) {
1755 ModestMailOperation *mail_op;
1756 TnyFolder *new_folder = NULL;
1758 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO,
1759 G_OBJECT(main_window));
1760 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1762 new_folder = modest_mail_operation_create_folder (mail_op,
1764 (const gchar *) folder_name);
1766 g_object_unref (new_folder);
1769 g_object_unref (mail_op);
1771 g_free (folder_name);
1775 g_object_unref (parent_folder);
1780 modest_ui_actions_on_rename_folder (GtkAction *action,
1781 ModestMainWindow *main_window)
1783 TnyFolderStore *folder;
1784 GtkWidget *folder_view;
1785 GtkWidget *header_view;
1787 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1789 folder_view = modest_main_window_get_child_widget (main_window,
1790 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1794 header_view = modest_main_window_get_child_widget (main_window,
1795 MODEST_WIDGET_TYPE_HEADER_VIEW);
1800 folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
1802 if (folder && TNY_IS_FOLDER (folder)) {
1804 folder_name = ask_for_folder_name (GTK_WINDOW (main_window),
1805 _("Please enter a new name for the folder"));
1807 if (folder_name != NULL && strlen (folder_name) > 0) {
1808 ModestMailOperation *mail_op;
1810 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(main_window));
1811 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1814 modest_header_view_set_folder (MODEST_HEADER_VIEW (header_view), NULL);
1816 modest_mail_operation_rename_folder (mail_op,
1817 TNY_FOLDER (folder),
1818 (const gchar *) folder_name);
1820 g_object_unref (mail_op);
1821 g_free (folder_name);
1823 g_object_unref (folder);
1828 modest_ui_actions_delete_folder_error_handler (ModestMailOperation *mail_op,
1831 GObject *win = modest_mail_operation_get_source (mail_op);
1833 modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
1834 _("mail_in_ui_folder_delete_error"));
1838 delete_folder (ModestMainWindow *main_window, gboolean move_to_trash)
1840 TnyFolderStore *folder;
1841 GtkWidget *folder_view;
1845 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1847 folder_view = modest_main_window_get_child_widget (main_window,
1848 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1852 folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
1854 /* Show an error if it's an account */
1855 if (!TNY_IS_FOLDER (folder)) {
1856 modest_platform_run_information_dialog (GTK_WINDOW (main_window),
1857 _("mail_in_ui_folder_delete_error"));
1862 message = g_strdup_printf (_("mcen_nc_delete_folder_text"),
1863 tny_folder_get_name (TNY_FOLDER (folder)));
1864 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (main_window),
1865 (const gchar *) message);
1868 if (response == GTK_RESPONSE_OK) {
1869 ModestMailOperation *mail_op =
1870 modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_DELETE,
1871 G_OBJECT(main_window),
1872 modest_ui_actions_delete_folder_error_handler,
1875 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1877 modest_mail_operation_remove_folder (mail_op, TNY_FOLDER (folder), move_to_trash);
1878 g_object_unref (G_OBJECT (mail_op));
1881 g_object_unref (G_OBJECT (folder));
1885 modest_ui_actions_on_delete_folder (GtkAction *action,
1886 ModestMainWindow *main_window)
1888 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1890 delete_folder (main_window, FALSE);
1894 modest_ui_actions_on_move_folder_to_trash_folder (GtkAction *action, ModestMainWindow *main_window)
1896 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1898 delete_folder (main_window, TRUE);
1902 modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
1903 const gchar* server_account_name,
1908 ModestMainWindow *main_window)
1910 g_return_if_fail(server_account_name);
1911 /* printf("DEBUG: %s: server_account_name=%s\n", __FUNCTION__, server_account_name); */
1913 /* Initalize output parameters: */
1920 #ifdef MODEST_PLATFORM_MAEMO
1921 /* Maemo uses a different (awkward) button order,
1922 * It should probably just use gtk_alternative_dialog_button_order ().
1924 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
1928 GTK_RESPONSE_ACCEPT,
1930 GTK_RESPONSE_REJECT,
1933 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
1937 GTK_RESPONSE_REJECT,
1939 GTK_RESPONSE_ACCEPT,
1941 #endif /* MODEST_PLATFORM_MAEMO */
1943 gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(main_window));
1945 gchar *server_name = modest_server_account_get_hostname (
1946 modest_runtime_get_account_mgr(), server_account_name);
1947 if (!server_name) {/* This happened once, though I don't know why. murrayc. */
1948 g_warning("%s: Could not get server name for server account '%s'", __FUNCTION__, server_account_name);
1953 /* This causes a warning because the logical ID has no %s in it,
1954 * though the translation does, but there is not much we can do about that: */
1955 gchar *txt = g_strdup_printf (_("mail_ia_password_info"), server_name);
1956 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt),
1959 g_free (server_name);
1963 gchar *initial_username = modest_server_account_get_username (
1964 modest_runtime_get_account_mgr(), server_account_name);
1966 GtkWidget *entry_username = gtk_entry_new ();
1967 if (initial_username)
1968 gtk_entry_set_text (GTK_ENTRY (entry_username), initial_username);
1969 /* Dim this if a connection has ever succeeded with this username,
1970 * as per the UI spec: */
1971 const gboolean username_known =
1972 modest_server_account_get_username_has_succeeded(
1973 modest_runtime_get_account_mgr(), server_account_name);
1974 gtk_widget_set_sensitive (entry_username, !username_known);
1976 #ifdef MODEST_PLATFORM_MAEMO
1977 /* Auto-capitalization is the default, so let's turn it off: */
1978 hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_username), HILDON_GTK_INPUT_MODE_FULL);
1980 /* Create a size group to be used by all captions.
1981 * Note that HildonCaption does not create a default size group if we do not specify one.
1982 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
1983 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1985 GtkWidget *caption = hildon_caption_new (sizegroup,
1986 _("mail_fi_username"), entry_username, NULL, HILDON_CAPTION_MANDATORY);
1987 gtk_widget_show (entry_username);
1988 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption,
1989 FALSE, FALSE, MODEST_MARGIN_HALF);
1990 gtk_widget_show (caption);
1992 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_username,
1994 #endif /* MODEST_PLATFORM_MAEMO */
1997 GtkWidget *entry_password = gtk_entry_new ();
1998 gtk_entry_set_visibility (GTK_ENTRY(entry_password), FALSE);
1999 /* gtk_entry_set_invisible_char (GTK_ENTRY(entry_password), "*"); */
2001 #ifdef MODEST_PLATFORM_MAEMO
2002 /* Auto-capitalization is the default, so let's turn it off: */
2003 hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_password),
2004 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
2006 caption = hildon_caption_new (sizegroup,
2007 _("mail_fi_password"), entry_password, NULL, HILDON_CAPTION_MANDATORY);
2008 gtk_widget_show (entry_password);
2009 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption,
2010 FALSE, FALSE, MODEST_MARGIN_HALF);
2011 gtk_widget_show (caption);
2012 g_object_unref (sizegroup);
2014 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_password,
2016 #endif /* MODEST_PLATFORM_MAEMO */
2018 /* This is not in the Maemo UI spec:
2019 remember_pass_check = gtk_check_button_new_with_label (_("Remember password"));
2020 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), remember_pass_check,
2024 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
2026 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
2028 *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username)));
2030 modest_server_account_set_username (
2031 modest_runtime_get_account_mgr(), server_account_name,
2034 const gboolean username_was_changed =
2035 (strcmp (*username, initial_username) != 0);
2036 if (username_was_changed) {
2037 /* To actually use a changed username,
2038 * we must reset the connection, according to pvanhoof.
2039 * This _might_ be a sensible way to do that: */
2040 TnyDevice *device = modest_runtime_get_device();
2041 tny_device_force_offline (device);
2042 tny_device_force_online (device);
2047 *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password)));
2049 /* We do not save the password in the configuration,
2050 * because this function is only called for passwords that should
2051 * not be remembered:
2052 modest_server_account_set_password (
2053 modest_runtime_get_account_mgr(), server_account_name,
2072 /* This is not in the Maemo UI spec:
2073 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pass_check)))
2079 gtk_widget_destroy (dialog);
2081 /* printf ("DEBUG: %s: cancel=%d\n", __FUNCTION__, *cancel); */
2085 modest_ui_actions_on_cut (GtkAction *action,
2086 ModestWindow *window)
2088 GtkWidget *focused_widget;
2090 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2091 if (GTK_IS_EDITABLE (focused_widget)) {
2092 gtk_editable_cut_clipboard (GTK_EDITABLE(focused_widget));
2093 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2094 GtkTextBuffer *buffer;
2095 GtkClipboard *clipboard;
2097 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2098 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2099 gtk_text_buffer_cut_clipboard (buffer, clipboard, TRUE);
2104 modest_ui_actions_on_copy (GtkAction *action,
2105 ModestWindow *window)
2107 GtkClipboard *clipboard;
2108 GtkWidget *focused_widget;
2110 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2111 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2112 if (GTK_IS_LABEL (focused_widget)) {
2113 gtk_clipboard_set_text (clipboard, gtk_label_get_text (GTK_LABEL (focused_widget)), -1);
2114 } else if (GTK_IS_EDITABLE (focused_widget)) {
2115 gtk_editable_copy_clipboard (GTK_EDITABLE(focused_widget));
2116 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2117 GtkTextBuffer *buffer;
2119 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2120 gtk_text_buffer_copy_clipboard (buffer, clipboard);
2125 modest_ui_actions_on_undo (GtkAction *action,
2126 ModestWindow *window)
2128 if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
2129 modest_msg_edit_window_undo (MODEST_MSG_EDIT_WINDOW (window));
2131 g_return_if_reached ();
2136 modest_ui_actions_on_paste (GtkAction *action,
2137 ModestWindow *window)
2139 GtkWidget *focused_widget;
2141 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2142 if (GTK_IS_EDITABLE (focused_widget)) {
2143 gtk_editable_paste_clipboard (GTK_EDITABLE(focused_widget));
2144 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2145 GtkTextBuffer *buffer;
2146 GtkClipboard *clipboard;
2148 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2149 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2150 gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE);
2155 modest_ui_actions_on_select_all (GtkAction *action,
2156 ModestWindow *window)
2158 GtkWidget *focused_widget;
2160 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2161 if (MODEST_IS_ATTACHMENTS_VIEW (focused_widget)) {
2162 modest_attachments_view_select_all (MODEST_ATTACHMENTS_VIEW (focused_widget));
2163 } else if (GTK_IS_LABEL (focused_widget)) {
2164 gtk_label_select_region (GTK_LABEL (focused_widget), 0, -1);
2165 } else if (GTK_IS_EDITABLE (focused_widget)) {
2166 gtk_editable_select_region (GTK_EDITABLE(focused_widget), 0, -1);
2167 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2168 GtkTextBuffer *buffer;
2169 GtkTextIter start, end;
2171 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2172 gtk_text_buffer_get_start_iter (buffer, &start);
2173 gtk_text_buffer_get_end_iter (buffer, &end);
2174 gtk_text_buffer_select_range (buffer, &start, &end);
2176 else if ((MODEST_IS_FOLDER_VIEW (focused_widget)) ||
2177 (MODEST_IS_HEADER_VIEW (focused_widget))) {
2179 GtkTreeSelection *selection = NULL;
2181 /* Get header view */
2182 GtkWidget *header_view = focused_widget;
2183 if (MODEST_IS_FOLDER_VIEW (focused_widget))
2184 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
2185 MODEST_WIDGET_TYPE_HEADER_VIEW);
2187 /* Select all messages */
2188 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(header_view));
2189 gtk_tree_selection_select_all (selection);
2194 modest_ui_actions_on_mark_as_read (GtkAction *action,
2195 ModestWindow *window)
2197 g_return_if_fail (MODEST_IS_WINDOW(window));
2199 /* Mark each header as read */
2200 do_headers_action (window, headers_action_mark_as_read, NULL);
2204 modest_ui_actions_on_mark_as_unread (GtkAction *action,
2205 ModestWindow *window)
2207 g_return_if_fail (MODEST_IS_WINDOW(window));
2209 /* Mark each header as read */
2210 do_headers_action (window, headers_action_mark_as_unread, NULL);
2214 modest_ui_actions_on_change_zoom (GtkRadioAction *action,
2215 GtkRadioAction *selected,
2216 ModestWindow *window)
2220 value = gtk_radio_action_get_current_value (selected);
2221 if (MODEST_IS_WINDOW (window)) {
2222 modest_window_set_zoom (MODEST_WINDOW (window), ((gdouble)value)/100);
2226 void modest_ui_actions_msg_edit_on_change_priority (GtkRadioAction *action,
2227 GtkRadioAction *selected,
2228 ModestWindow *window)
2230 TnyHeaderFlags flags;
2231 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2233 flags = gtk_radio_action_get_current_value (selected);
2234 modest_msg_edit_window_set_priority_flags (MODEST_MSG_EDIT_WINDOW (window), flags);
2237 void modest_ui_actions_msg_edit_on_change_file_format (GtkRadioAction *action,
2238 GtkRadioAction *selected,
2239 ModestWindow *window)
2243 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2245 file_format = gtk_radio_action_get_current_value (selected);
2246 modest_msg_edit_window_set_file_format (MODEST_MSG_EDIT_WINDOW (window), file_format);
2251 modest_ui_actions_on_zoom_plus (GtkAction *action,
2252 ModestWindow *window)
2254 g_return_if_fail (MODEST_IS_WINDOW (window));
2256 modest_window_zoom_plus (MODEST_WINDOW (window));
2260 modest_ui_actions_on_zoom_minus (GtkAction *action,
2261 ModestWindow *window)
2263 g_return_if_fail (MODEST_IS_WINDOW (window));
2265 modest_window_zoom_minus (MODEST_WINDOW (window));
2269 modest_ui_actions_on_toggle_fullscreen (GtkToggleAction *toggle,
2270 ModestWindow *window)
2272 ModestWindowMgr *mgr;
2273 gboolean fullscreen, active;
2274 g_return_if_fail (MODEST_IS_WINDOW (window));
2276 mgr = modest_runtime_get_window_mgr ();
2278 active = (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle)))?1:0;
2279 fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
2281 if (active != fullscreen) {
2282 modest_window_mgr_set_fullscreen_mode (mgr, active);
2283 gtk_window_present (GTK_WINDOW (window));
2288 modest_ui_actions_on_change_fullscreen (GtkAction *action,
2289 ModestWindow *window)
2291 ModestWindowMgr *mgr;
2292 gboolean fullscreen;
2294 g_return_if_fail (MODEST_IS_WINDOW (window));
2296 mgr = modest_runtime_get_window_mgr ();
2297 fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
2298 modest_window_mgr_set_fullscreen_mode (mgr, !fullscreen);
2300 gtk_window_present (GTK_WINDOW (window));
2304 * Used by modest_ui_actions_on_details to call do_headers_action
2307 headers_action_show_details (TnyHeader *header,
2308 ModestWindow *window,
2315 dialog = modest_details_dialog_new_with_header (GTK_WINDOW (window), header);
2318 gtk_widget_show_all (dialog);
2319 gtk_dialog_run (GTK_DIALOG (dialog));
2321 gtk_widget_destroy (dialog);
2325 * Show the folder details in a ModestDetailsDialog widget
2328 show_folder_details (TnyFolder *folder,
2334 dialog = modest_details_dialog_new_with_folder (window, folder);
2337 gtk_widget_show_all (dialog);
2338 gtk_dialog_run (GTK_DIALOG (dialog));
2340 gtk_widget_destroy (dialog);
2344 * Show the header details in a ModestDetailsDialog widget
2347 modest_ui_actions_on_details (GtkAction *action,
2350 TnyList * headers_list;
2354 if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
2357 msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win));
2360 g_object_unref (msg);
2362 headers_list = get_selected_headers (win);
2366 iter = tny_list_create_iterator (headers_list);
2368 header = TNY_HEADER (tny_iterator_get_current (iter));
2369 headers_action_show_details (header, win, NULL);
2370 g_object_unref (header);
2372 g_object_unref (iter);
2373 g_object_unref (headers_list);
2375 } else if (MODEST_IS_MAIN_WINDOW (win)) {
2376 GtkWidget *folder_view, *header_view;
2378 /* Check which widget has the focus */
2379 folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
2380 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2381 if (gtk_widget_is_focus (folder_view)) {
2384 folder = (TnyFolder *) modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
2386 /* Show only when it's a folder */
2387 if (!folder || !TNY_IS_FOLDER (folder))
2390 show_folder_details (folder, GTK_WINDOW (win));
2393 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
2394 MODEST_WIDGET_TYPE_HEADER_VIEW);
2395 /* Show details of each header */
2396 do_headers_action (win, headers_action_show_details, header_view);
2402 modest_ui_actions_on_toggle_show_cc (GtkToggleAction *toggle,
2403 ModestMsgEditWindow *window)
2405 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2407 modest_msg_edit_window_show_cc (window, gtk_toggle_action_get_active (toggle));
2411 modest_ui_actions_on_toggle_show_bcc (GtkToggleAction *toggle,
2412 ModestMsgEditWindow *window)
2414 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2416 modest_msg_edit_window_show_bcc (window, gtk_toggle_action_get_active (toggle));
2420 modest_ui_actions_toggle_folders_view (GtkAction *action,
2421 ModestMainWindow *main_window)
2425 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
2427 conf = modest_runtime_get_conf ();
2429 if (modest_main_window_get_style (main_window) == MODEST_MAIN_WINDOW_STYLE_SPLIT)
2430 modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SIMPLE);
2432 modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SPLIT);
2436 modest_ui_actions_on_toggle_toolbar (GtkToggleAction *toggle,
2437 ModestWindow *window)
2439 gboolean active, fullscreen = FALSE;
2440 ModestWindowMgr *mgr;
2442 active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle));
2444 /* Check if we want to toggle the toolbar vuew in fullscreen
2446 if (!strcmp (gtk_action_get_name (GTK_ACTION (toggle)),
2447 "ViewShowToolbarFullScreen")) {
2451 /* Toggle toolbar */
2452 mgr = modest_runtime_get_window_mgr ();
2453 modest_window_mgr_show_toolbars (mgr, active, fullscreen);
2457 modest_ui_actions_msg_edit_on_select_font (GtkAction *action,
2458 ModestMsgEditWindow *window)
2460 modest_msg_edit_window_select_font (window);
2464 modest_ui_actions_on_folder_display_name_changed (ModestFolderView *folder_view,
2465 const gchar *display_name,
2468 /* Do not change the application name if the widget has not
2469 the focus. This callback could be called even if the folder
2470 view has not the focus, because the handled signal could be
2471 emitted when the folder view is redrawn */
2472 if (gtk_widget_is_focus (GTK_WIDGET (folder_view))) {
2474 gtk_window_set_title (window, display_name);
2476 gtk_window_set_title (window, " ");
2481 modest_ui_actions_on_select_contacts (GtkAction *action, ModestMsgEditWindow *window)
2483 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2484 modest_msg_edit_window_select_contacts (window);
2488 modest_ui_actions_on_check_names (GtkAction *action, ModestMsgEditWindow *window)
2490 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2491 modest_msg_edit_window_check_names (window);
2496 create_move_to_dialog (ModestWindow *win,
2497 GtkWidget *folder_view,
2498 GtkWidget **tree_view)
2500 GtkWidget *dialog, *scroll;
2502 dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"),
2504 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT,
2506 GTK_RESPONSE_ACCEPT,
2508 GTK_RESPONSE_REJECT,
2511 /* Create scrolled window */
2512 scroll = gtk_scrolled_window_new (NULL, NULL);
2513 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
2514 GTK_POLICY_AUTOMATIC,
2515 GTK_POLICY_AUTOMATIC);
2517 /* Create folder view */
2518 *tree_view = modest_folder_view_new (NULL);
2520 /* It could happen that we're trying to move a message from a
2521 window (msg window for example) after the main window was
2522 closed, so we can not just get the model of the folder
2524 if (MODEST_IS_FOLDER_VIEW (folder_view))
2525 gtk_tree_view_set_model (GTK_TREE_VIEW (*tree_view),
2526 gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view)));
2528 modest_folder_view_update_model (MODEST_FOLDER_VIEW (*tree_view),
2529 TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
2531 gtk_container_add (GTK_CONTAINER (scroll), *tree_view);
2533 /* Add scroll to dialog */
2534 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
2535 scroll, FALSE, FALSE, 0);
2537 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
2543 * Returns TRUE if at least one of the headers of the list belongs to
2544 * a message that has been fully retrieved.
2547 has_retrieved_msgs (TnyList *list)
2550 gboolean found = FALSE;
2552 iter = tny_list_create_iterator (list);
2553 while (tny_iterator_is_done (iter) && !found) {
2555 TnyHeaderFlags flags;
2557 header = TNY_HEADER (tny_iterator_get_current (iter));
2558 flags = tny_header_get_flags (header);
2559 if (!(flags & TNY_HEADER_FLAG_PARTIAL))
2563 tny_iterator_next (iter);
2565 g_object_unref (iter);
2571 * Shows a confirmation dialog to the user when we're moving messages
2572 * from a remote server to the local storage. Returns the dialog
2573 * response. If it's other kind of movement the it always returns
2577 msgs_move_to_confirmation (GtkWindow *win,
2578 TnyFolder *dest_folder,
2581 gint response = GTK_RESPONSE_OK;
2583 /* If the destination is a local folder */
2584 if (modest_tny_folder_is_local_folder (dest_folder)) {
2585 TnyFolder *src_folder;
2589 /* Get source folder */
2590 iter = tny_list_create_iterator (headers);
2591 header = TNY_HEADER (tny_iterator_get_current (iter));
2592 src_folder = tny_header_get_folder (header);
2593 g_object_unref (header);
2594 g_object_unref (iter);
2596 /* If the source is a remote folder */
2597 if (!modest_tny_folder_is_local_folder (src_folder)) {
2598 const gchar *message;
2600 if (tny_list_get_length (headers) == 1)
2601 if (has_retrieved_msgs (headers))
2602 message = _("mcen_nc_move_retrieve");
2604 message = _("mcen_nc_move_header");
2606 if (has_retrieved_msgs (headers))
2607 message = _("mcen_nc_move_retrieves");
2609 message = _("mcen_nc_move_headers");
2611 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
2612 (const gchar *) message);
2614 g_object_unref (src_folder);
2621 tranasfer_msgs_from_viewer_cb (const GObject *object, gpointer user_data)
2623 ModestMsgViewWindow *self = NULL;
2624 gboolean found = FALSE;
2626 g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (object));
2627 self = MODEST_MSG_VIEW_WINDOW (object);
2629 found = modest_msg_view_window_select_first_message (self);
2630 g_return_if_fail (found);
2634 modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
2637 GObject *win = modest_mail_operation_get_source (mail_op);
2639 /* TODO: show error message */
2640 modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
2641 _("mail_in_ui_folder_move_target_error"));
2645 * UI handler for the "Move to" action when invoked from the
2649 modest_ui_actions_on_main_window_move_to (GtkAction *action,
2650 ModestMainWindow *win)
2652 GtkWidget *dialog = NULL, *folder_view = NULL, *tree_view = NULL;
2653 GtkWidget *header_view = NULL;
2655 TnyFolderStore *folder_store = NULL;
2656 ModestMailOperation *mail_op = NULL;
2658 g_return_if_fail (MODEST_IS_MAIN_WINDOW (win));
2660 /* Get the folder view */
2661 folder_view = modest_main_window_get_child_widget (win,
2662 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2664 /* Get header view */
2665 header_view = modest_main_window_get_child_widget (win,
2666 MODEST_WIDGET_TYPE_HEADER_VIEW);
2668 /* Create and run the dialog */
2669 dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
2670 modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view));
2671 result = gtk_dialog_run (GTK_DIALOG(dialog));
2672 g_object_ref (tree_view);
2674 /* We do this to save an indentation level ;-) */
2675 if (result != GTK_RESPONSE_ACCEPT)
2678 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (tree_view));
2680 if (TNY_IS_ACCOUNT (folder_store))
2683 /* Get folder or messages to transfer */
2684 if (gtk_widget_is_focus (folder_view)) {
2685 TnyFolderStore *src_folder;
2686 src_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
2688 /* Clean folder on header view before moving it */
2689 modest_header_view_set_folder (MODEST_HEADER_VIEW (header_view), NULL);
2691 if (TNY_IS_FOLDER (src_folder)) {
2693 modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
2695 modest_ui_actions_move_folder_error_handler,
2697 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
2699 modest_mail_operation_xfer_folder (mail_op,
2700 TNY_FOLDER (src_folder),
2703 /* Unref mail operation */
2704 g_object_unref (G_OBJECT (mail_op));
2708 g_object_unref (G_OBJECT (src_folder));
2710 if (gtk_widget_is_focus (header_view)) {
2714 headers = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (header_view));
2716 /* Ask for user confirmation */
2717 response = msgs_move_to_confirmation (GTK_WINDOW (win),
2718 TNY_FOLDER (folder_store),
2721 /* Transfer messages */
2722 if (response == GTK_RESPONSE_OK) {
2723 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
2724 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
2727 modest_mail_operation_xfer_msgs (mail_op,
2729 TNY_FOLDER (folder_store),
2734 g_object_unref (G_OBJECT (mail_op));
2736 g_object_unref (headers);
2739 g_object_unref (folder_store);
2741 gtk_widget_destroy (dialog);
2746 * UI handler for the "Move to" action when invoked from the
2747 * ModestMsgViewWindow
2750 modest_ui_actions_on_msg_view_window_move_to (GtkAction *action,
2751 ModestMsgViewWindow *win)
2753 GtkWidget *dialog, *folder_view, *tree_view = NULL;
2755 ModestMainWindow *main_window;
2759 /* Get the folder view */
2760 main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()));
2762 folder_view = modest_main_window_get_child_widget (main_window,
2763 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2767 /* Create and run the dialog */
2768 dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
2769 result = gtk_dialog_run (GTK_DIALOG(dialog));
2770 g_object_ref (tree_view);
2772 if (result == GTK_RESPONSE_ACCEPT) {
2773 TnyFolderStore *folder_store;
2776 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (tree_view));
2778 /* Create header list */
2779 header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
2780 headers = tny_simple_list_new ();
2781 tny_list_prepend (headers, G_OBJECT (header));
2782 g_object_unref (header);
2784 /* Ask user for confirmation. MSG-NOT404 */
2785 response = msgs_move_to_confirmation (GTK_WINDOW (win),
2786 TNY_FOLDER (folder_store),
2789 /* Transfer current msg */
2790 if (response == GTK_RESPONSE_OK) {
2791 ModestMailOperation *mail_op;
2793 /* Create mail op */
2794 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
2795 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
2798 /* Transfer messages */
2799 modest_mail_operation_xfer_msgs (mail_op,
2801 TNY_FOLDER (folder_store),
2803 tranasfer_msgs_from_viewer_cb,
2805 g_object_unref (G_OBJECT (mail_op));
2807 g_object_unref (headers);
2808 g_object_unref (folder_store);
2810 gtk_widget_destroy (dialog);
2814 modest_ui_actions_on_move_to (GtkAction *action,
2817 g_return_if_fail (MODEST_IS_MAIN_WINDOW (win) ||
2818 MODEST_IS_MSG_VIEW_WINDOW (win));
2820 if (MODEST_IS_MAIN_WINDOW (win))
2821 modest_ui_actions_on_main_window_move_to (action,
2822 MODEST_MAIN_WINDOW (win));
2824 modest_ui_actions_on_msg_view_window_move_to (action,
2825 MODEST_MSG_VIEW_WINDOW (win));
2829 * Calls #HeadersFunc for each header already selected in the main
2830 * window or the message currently being shown in the msg view window
2833 do_headers_action (ModestWindow *win,
2837 TnyList *headers_list;
2841 headers_list = get_selected_headers (win);
2845 /* Call the function for each header */
2846 iter = tny_list_create_iterator (headers_list);
2847 while (!tny_iterator_is_done (iter)) {
2850 header = TNY_HEADER (tny_iterator_get_current (iter));
2851 func (header, win, user_data);
2852 g_object_unref (header);
2853 tny_iterator_next (iter);
2855 g_object_unref (iter);
2856 g_object_unref (headers_list);
2860 modest_ui_actions_view_attachment (GtkAction *action,
2861 ModestWindow *window)
2863 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2864 modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (window), NULL);
2866 /* not supported window for this action */
2867 g_return_if_reached ();
2872 modest_ui_actions_save_attachments (GtkAction *action,
2873 ModestWindow *window)
2875 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2876 modest_msg_view_window_save_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
2878 /* not supported window for this action */
2879 g_return_if_reached ();
2884 modest_ui_actions_remove_attachments (GtkAction *action,
2885 ModestWindow *window)
2887 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2888 modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
2890 /* not supported window for this action */
2891 g_return_if_reached ();
2896 modest_ui_actions_on_settings (GtkAction *action,
2901 dialog = modest_platform_get_global_settings_dialog ();
2902 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (win));
2903 gtk_widget_show (dialog);
2905 gtk_dialog_run (GTK_DIALOG (dialog));
2907 gtk_widget_destroy (dialog);
2911 modest_ui_actions_on_help (GtkAction *action,
2914 const gchar *help_id = NULL;
2916 if (MODEST_IS_MAIN_WINDOW (win)) {
2917 const gchar *action_name;
2918 action_name = gtk_action_get_name (action);
2920 if (!strcmp (action_name, "FolderViewCSMHelp") ||
2921 !strcmp (action_name, "HeaderViewCSMHelp")) {
2922 GtkWidget *folder_view;
2923 TnyFolderStore *folder_store;
2924 /* Get selected folder */
2925 folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
2926 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2927 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
2929 /* Switch help_id */
2930 if (TNY_IS_FOLDER (folder_store)) {
2931 switch (tny_folder_get_folder_type (TNY_FOLDER (folder_store))) {
2932 case TNY_FOLDER_TYPE_NORMAL:
2933 help_id = "applications_email_userfolder";
2935 case TNY_FOLDER_TYPE_INBOX:
2936 help_id = "applications_email_inbox";
2938 case TNY_FOLDER_TYPE_OUTBOX:
2939 help_id = "applications_email_outbox";
2941 case TNY_FOLDER_TYPE_SENT:
2942 help_id = "applications_email_sent";
2944 case TNY_FOLDER_TYPE_DRAFTS:
2945 help_id = "applications_email_drafts";
2947 case TNY_FOLDER_TYPE_ARCHIVE:
2948 help_id = "applications_email_archive";
2955 help_id = "applications_email_mainview";
2957 } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
2958 help_id = "applications_email_viewer";
2959 } else if (MODEST_IS_MSG_EDIT_WINDOW (win))
2960 help_id = "applications_email_editor";
2962 modest_platform_show_help (GTK_WINDOW (win), help_id);
2966 modest_ui_actions_on_retrieve_msg_contents (GtkAction *action,
2967 ModestWindow *window)
2969 ModestMailOperation *mail_op;
2973 headers = get_selected_headers (window);
2977 /* Create mail operation */
2978 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
2980 modest_ui_actions_get_msgs_full_error_handler,
2982 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
2983 modest_mail_operation_get_msgs_full (mail_op, headers, NULL, NULL, NULL);
2986 g_object_unref (headers);
2987 g_object_unref (mail_op);
2991 modest_ui_actions_on_email_menu_activated (GtkAction *action,
2992 ModestWindow *window)
2994 g_return_if_fail (MODEST_IS_WINDOW (window));
2997 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3001 modest_ui_actions_on_edit_menu_activated (GtkAction *action,
3002 ModestWindow *window)
3004 g_return_if_fail (MODEST_IS_WINDOW (window));
3007 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3011 modest_ui_actions_on_view_menu_activated (GtkAction *action,
3012 ModestWindow *window)
3014 g_return_if_fail (MODEST_IS_WINDOW (window));
3017 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3021 modest_ui_actions_on_tools_menu_activated (GtkAction *action,
3022 ModestWindow *window)
3024 g_return_if_fail (MODEST_IS_WINDOW (window));
3027 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3031 modest_ui_actions_on_attachment_menu_activated (GtkAction *action,
3032 ModestWindow *window)
3034 g_return_if_fail (MODEST_IS_WINDOW (window));
3037 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3041 modest_ui_actions_on_toolbar_csm_menu_activated (GtkAction *action,
3042 ModestWindow *window)
3044 g_return_if_fail (MODEST_IS_WINDOW (window));
3047 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3051 modest_ui_actions_on_folder_view_csm_menu_activated (GtkAction *action,
3052 ModestWindow *window)
3054 g_return_if_fail (MODEST_IS_WINDOW (window));
3057 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3061 modest_ui_actions_on_header_view_csm_menu_activated (GtkAction *action,
3062 ModestWindow *window)
3064 g_return_if_fail (MODEST_IS_WINDOW (window));
3067 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3071 modest_ui_actions_check_toolbar_dimming_rules (ModestWindow *window)
3073 g_return_if_fail (MODEST_IS_WINDOW (window));
3076 modest_window_check_dimming_rules_group (window, "ModestToolbarDimmingRules");
3080 modest_ui_actions_on_search_messages (GtkAction *action, ModestWindow *window)
3082 g_return_if_fail (MODEST_IS_WINDOW (window));
3084 modest_platform_show_search_messages (GTK_WINDOW (window));
3088 modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *win)
3090 g_return_if_fail (MODEST_IS_WINDOW (win));
3091 modest_platform_show_addressbook (GTK_WINDOW (win));
3096 modest_ui_actions_on_toggle_find_in_page (GtkToggleAction *action,
3097 ModestWindow *window)
3099 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
3101 modest_msg_edit_window_toggle_find_toolbar (MODEST_MSG_EDIT_WINDOW (window), gtk_toggle_action_get_active (action));
3105 _on_send_receive_progress_changed (ModestMailOperation *mail_op,
3106 ModestMailOperationState *state,
3109 g_return_if_fail (MODEST_IS_MAIN_WINDOW(user_data));
3111 /* Set send/receive operation finished */
3112 if (state->status != MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
3113 modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW(user_data));