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;
672 TnyList *not_opened_headers;
674 /* Look if we already have a message view for each header. If
675 true, then remove the header from the list of headers to
677 mgr = modest_runtime_get_window_mgr ();
678 iter = tny_list_create_iterator (headers);
679 not_opened_headers = tny_simple_list_new ();
680 while (!tny_iterator_is_done (iter)) {
681 ModestWindow *window;
684 header = TNY_HEADER (tny_iterator_get_current (iter));
685 window = modest_window_mgr_find_window_by_header (mgr, header);
686 /* Do not open again the message and present the
687 window to the user */
689 gtk_window_present (GTK_WINDOW (window));
691 tny_list_append (not_opened_headers, G_OBJECT (header));
693 g_object_unref (header);
694 tny_iterator_next (iter);
697 /* Open each message */
698 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
700 modest_ui_actions_get_msgs_full_error_handler,
702 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
703 modest_mail_operation_get_msgs_full (mail_op,
709 g_object_unref (not_opened_headers);
710 g_object_unref (iter);
711 g_object_unref (mail_op);
715 modest_ui_actions_on_open (GtkAction *action, ModestWindow *win)
720 headers = get_selected_headers (win);
725 _modest_ui_actions_open (headers, win);
727 g_object_unref(headers);
732 free_reply_forward_helper (gpointer data)
734 ReplyForwardHelper *helper;
736 helper = (ReplyForwardHelper *) data;
737 g_free (helper->account_name);
738 g_slice_free (ReplyForwardHelper, helper);
742 reply_forward_cb (ModestMailOperation *mail_op,
748 ReplyForwardHelper *rf_helper;
749 ModestWindow *msg_win;
750 ModestEditType edit_type;
752 TnyAccount *account = NULL;
753 ModestWindowMgr *mgr;
754 gchar *signature = NULL;
756 g_return_if_fail (user_data != NULL);
757 rf_helper = (ReplyForwardHelper *) user_data;
759 from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
760 rf_helper->account_name);
761 if (modest_account_mgr_get_bool (modest_runtime_get_account_mgr(),
762 rf_helper->account_name,
763 MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) {
764 signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (),
765 rf_helper->account_name,
766 MODEST_ACCOUNT_SIGNATURE, FALSE);
769 /* Create reply mail */
770 switch (rf_helper->action) {
773 modest_tny_msg_create_reply_msg (msg, from, signature,
774 rf_helper->reply_forward_type,
775 MODEST_TNY_MSG_REPLY_MODE_SENDER);
777 case ACTION_REPLY_TO_ALL:
779 modest_tny_msg_create_reply_msg (msg, from, signature, rf_helper->reply_forward_type,
780 MODEST_TNY_MSG_REPLY_MODE_ALL);
781 edit_type = MODEST_EDIT_TYPE_REPLY;
785 modest_tny_msg_create_forward_msg (msg, from, signature, rf_helper->reply_forward_type);
786 edit_type = MODEST_EDIT_TYPE_FORWARD;
789 g_return_if_reached ();
796 g_printerr ("modest: failed to create message\n");
800 account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store(),
801 rf_helper->account_name,
802 TNY_ACCOUNT_TYPE_STORE);
804 g_printerr ("modest: failed to get tnyaccount for '%s'\n", rf_helper->account_name);
808 /* Create and register the windows */
809 msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account_name);
810 mgr = modest_runtime_get_window_mgr ();
811 modest_window_mgr_register_window (mgr, msg_win);
813 if (rf_helper->parent_window != NULL) {
816 parent_zoom = modest_window_get_zoom (MODEST_WINDOW (rf_helper->parent_window));
817 modest_window_set_zoom (msg_win, parent_zoom);
820 /* Show edit window */
821 gtk_widget_show_all (GTK_WIDGET (msg_win));
825 g_object_unref (G_OBJECT (new_msg));
827 g_object_unref (G_OBJECT (account));
828 g_object_unref (msg);
829 g_object_unref (header);
833 * Checks a list of headers. If any of them are not currently
834 * downloaded (CACHED) then it asks the user for permission to
837 * Returns FALSE if the user does not want to download the
838 * messages. Returns TRUE if the user allowed the download or if all
839 * of them are currently downloaded
842 download_uncached_messages (TnyList *header_list, GtkWindow *win)
845 gboolean found, retval;
847 iter = tny_list_create_iterator (header_list);
849 while (!tny_iterator_is_done (iter) && !found) {
851 TnyHeaderFlags flags;
853 header = TNY_HEADER (tny_iterator_get_current (iter));
854 flags = tny_header_get_flags (header);
855 /* TODO: is this the right flag?, it seems that some
856 headers that have been previously downloaded do not
858 found = !(flags & TNY_HEADER_FLAG_CACHED);
859 g_object_unref (header);
860 tny_iterator_next (iter);
862 g_object_unref (iter);
864 /* Ask for user permission to download the messages */
867 GtkResponseType response;
869 modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
870 _("mcen_nc_get_multi_msg_txt"));
871 if (response == GTK_RESPONSE_CANCEL)
879 * Common code for the reply and forward actions
882 reply_forward (ReplyForwardAction action, ModestWindow *win)
884 ModestMailOperation *mail_op = NULL;
885 TnyList *header_list = NULL;
886 ReplyForwardHelper *rf_helper = NULL;
887 guint reply_forward_type;
888 gboolean continue_download;
890 g_return_if_fail (MODEST_IS_WINDOW(win));
892 header_list = get_selected_headers (win);
896 /* Check that the messages have been previously downloaded */
897 continue_download = download_uncached_messages (header_list, GTK_WINDOW (win));
898 if (!continue_download) {
899 g_object_unref (header_list);
904 modest_conf_get_int (modest_runtime_get_conf (),
905 (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE,
907 /* We assume that we can only select messages of the
908 same folder and that we reply all of them from the
909 same account. In fact the interface currently only
910 allows single selection */
913 rf_helper = g_slice_new0 (ReplyForwardHelper);
914 rf_helper->reply_forward_type = reply_forward_type;
915 rf_helper->action = action;
916 rf_helper->account_name = g_strdup (modest_window_get_active_account (win));
917 if ((win != NULL) && (MODEST_IS_WINDOW (win)))
918 rf_helper->parent_window = GTK_WIDGET (win);
919 if (!rf_helper->account_name)
920 rf_helper->account_name =
921 modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
923 if (MODEST_IS_MSG_VIEW_WINDOW(win)) {
926 /* Get header and message. Do not free them here, the
927 reply_forward_cb must do it */
928 msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW(win));
929 header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW(win));
930 if (!msg || !header) {
932 g_object_unref (msg);
934 g_object_unref (header);
935 g_printerr ("modest: no message found\n");
938 reply_forward_cb (NULL, header, msg, rf_helper);
940 /* Retrieve messages */
941 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
943 modest_ui_actions_get_msgs_full_error_handler,
945 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
946 modest_mail_operation_get_msgs_full (mail_op,
950 free_reply_forward_helper);
953 g_object_unref(mail_op);
957 g_object_unref (header_list);
961 modest_ui_actions_on_reply (GtkAction *action, ModestWindow *win)
963 g_return_if_fail (MODEST_IS_WINDOW(win));
965 reply_forward (ACTION_REPLY, win);
969 modest_ui_actions_on_forward (GtkAction *action, ModestWindow *win)
971 g_return_if_fail (MODEST_IS_WINDOW(win));
973 reply_forward (ACTION_FORWARD, win);
977 modest_ui_actions_on_reply_all (GtkAction *action, ModestWindow *win)
979 g_return_if_fail (MODEST_IS_WINDOW(win));
981 reply_forward (ACTION_REPLY_TO_ALL, win);
985 modest_ui_actions_on_next (GtkAction *action,
986 ModestWindow *window)
988 if (MODEST_IS_MAIN_WINDOW (window)) {
989 GtkWidget *header_view;
991 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
992 MODEST_WIDGET_TYPE_HEADER_VIEW);
996 modest_header_view_select_next (MODEST_HEADER_VIEW(header_view));
997 } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
998 modest_msg_view_window_select_next_message (MODEST_MSG_VIEW_WINDOW (window));
1000 g_return_if_reached ();
1005 modest_ui_actions_on_prev (GtkAction *action,
1006 ModestWindow *window)
1008 g_return_if_fail (MODEST_IS_WINDOW(window));
1010 if (MODEST_IS_MAIN_WINDOW (window)) {
1011 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_prev (MODEST_HEADER_VIEW(header_view));
1018 } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
1019 modest_msg_view_window_select_previous_message (MODEST_MSG_VIEW_WINDOW (window));
1021 g_return_if_reached ();
1026 modest_ui_actions_on_sort (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 /* Show sorting dialog */
1039 modest_platform_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);
1044 * This function performs the send & receive required actions. The
1045 * window is used to create the mail operation. Typically it should
1046 * always be the main window, but we pass it as argument in order to
1050 modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win)
1052 gchar *acc_name = NULL;
1053 ModestMailOperation *mail_op;
1055 /* If no account name was provided then get the current account, and if
1056 there is no current account then pick the default one: */
1057 if (!account_name) {
1058 acc_name = g_strdup (modest_window_get_active_account(win));
1060 acc_name = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
1062 g_printerr ("modest: cannot get default account\n");
1066 acc_name = g_strdup (account_name);
1069 /* Set send/receive operation in progress */
1070 modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW(win));
1072 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
1073 g_signal_connect (G_OBJECT(mail_op), "progress-changed",
1074 G_CALLBACK (_on_send_receive_progress_changed),
1077 /* Send & receive. */
1078 /* TODO: The spec wants us to first do any pending deletions, before receiving. */
1079 /* Receive and then send. The operation is tagged initially as
1080 a receive operation because the account update performs a
1081 receive and then a send. The operation changes its type
1082 internally, so the progress objects will receive the proper
1083 progress information */
1084 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
1085 modest_mail_operation_update_account (mail_op, acc_name);
1086 g_object_unref (G_OBJECT (mail_op));
1093 * Refreshes all accounts. This function will be used by automatic
1097 modest_ui_actions_do_send_receive_all (ModestWindow *win)
1099 GSList *account_names, *iter;
1101 account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr(),
1104 iter = account_names;
1106 modest_ui_actions_do_send_receive ((const char*) iter->data, win);
1107 iter = g_slist_next (iter);
1110 g_slist_foreach (account_names, (GFunc) g_free, NULL);
1111 g_slist_free (account_names);
1115 * Handler of the click on Send&Receive button in the main toolbar
1118 modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
1120 /* Check if accounts exist */
1121 gboolean accounts_exist =
1122 modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE);
1124 /* If not, allow the user to create an account before trying to send/receive. */
1125 if (!accounts_exist)
1126 modest_ui_actions_on_accounts (NULL, win);
1128 /* Refresh the active account */
1129 modest_ui_actions_do_send_receive (NULL, win);
1134 modest_ui_actions_toggle_header_list_view (GtkAction *action, ModestMainWindow *main_window)
1137 GtkWidget *header_view;
1139 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1141 header_view = modest_main_window_get_child_widget (main_window,
1142 MODEST_WIDGET_TYPE_HEADER_VIEW);
1146 conf = modest_runtime_get_conf ();
1148 /* what is saved/restored is depending on the style; thus; we save with
1149 * old style, then update the style, and restore for this new style
1151 modest_widget_memory_save (conf, G_OBJECT(header_view), MODEST_CONF_HEADER_VIEW_KEY);
1153 if (modest_header_view_get_style
1154 (MODEST_HEADER_VIEW(header_view)) == MODEST_HEADER_VIEW_STYLE_DETAILS)
1155 modest_header_view_set_style (MODEST_HEADER_VIEW(header_view),
1156 MODEST_HEADER_VIEW_STYLE_TWOLINES);
1158 modest_header_view_set_style (MODEST_HEADER_VIEW(header_view),
1159 MODEST_HEADER_VIEW_STYLE_DETAILS);
1161 modest_widget_memory_restore (conf, G_OBJECT(header_view),
1162 MODEST_CONF_HEADER_VIEW_KEY);
1167 modest_ui_actions_on_header_selected (ModestHeaderView *header_view,
1169 ModestMainWindow *main_window)
1171 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1172 g_return_if_fail (MODEST_IS_HEADER_VIEW (header_view));
1174 /* If no header has been selected then exit */
1178 /* Update Main window title */
1179 if (GTK_WIDGET_HAS_FOCUS (header_view)) {
1180 const gchar *subject = tny_header_get_subject (header);
1181 if (subject && strlen(subject) > 0)
1182 gtk_window_set_title (GTK_WINDOW (main_window), subject);
1184 gtk_window_set_title (GTK_WINDOW (main_window), _("mail_va_no_subject"));
1187 /* Update toolbar dimming state */
1188 modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
1192 modest_ui_actions_on_header_activated (ModestHeaderView *header_view,
1194 ModestMainWindow *main_window)
1198 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1203 headers = tny_simple_list_new ();
1204 tny_list_prepend (headers, G_OBJECT (header));
1206 _modest_ui_actions_open (headers, MODEST_WINDOW (main_window));
1208 g_object_unref (headers);
1212 set_active_account_from_tny_account (TnyAccount *account,
1213 ModestWindow *window)
1215 const gchar *server_acc_name = tny_account_get_id (account);
1217 /* We need the TnyAccount provided by the
1218 account store because that is the one that
1219 knows the name of the Modest account */
1220 TnyAccount *modest_server_account = modest_server_account =
1221 modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store (),
1222 MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
1225 const gchar *modest_acc_name =
1226 modest_tny_account_get_parent_modest_account_name_for_server_account (modest_server_account);
1227 modest_window_set_active_account (window, modest_acc_name);
1228 g_object_unref (modest_server_account);
1233 folder_refreshed_cb (const GObject *obj,
1237 ModestMainWindow *win = NULL;
1238 GtkWidget *header_view;
1240 g_return_if_fail (TNY_IS_FOLDER (folder));
1242 win = MODEST_MAIN_WINDOW (user_data);
1244 modest_main_window_get_child_widget(win, MODEST_WIDGET_TYPE_HEADER_VIEW);
1246 /* Check if folder is empty and set headers view contents style */
1247 if (tny_folder_get_all_count (folder) == 0) {
1248 modest_main_window_set_contents_style (win,
1249 MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY);
1251 modest_main_window_set_contents_style (win,
1252 MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS);
1254 /* Restore configuration */
1255 modest_widget_memory_restore (modest_runtime_get_conf (),
1256 G_OBJECT(header_view),
1257 MODEST_CONF_HEADER_VIEW_KEY);
1262 modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
1263 TnyFolderStore *folder_store,
1265 ModestMainWindow *main_window)
1268 GtkWidget *header_view;
1270 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1272 header_view = modest_main_window_get_child_widget(main_window,
1273 MODEST_WIDGET_TYPE_HEADER_VIEW);
1277 conf = modest_runtime_get_conf ();
1279 if (TNY_IS_ACCOUNT (folder_store)) {
1280 /* Update active account */
1281 set_active_account_from_tny_account (TNY_ACCOUNT (folder_store), MODEST_WINDOW (main_window));
1282 /* Show account details */
1283 modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS);
1285 if (TNY_IS_FOLDER (folder_store) && selected) {
1287 if (!TNY_IS_MERGE_FOLDER (folder_store)) { /* TnyMergeFolder can have no get_account() implementation. */
1288 /* Update the active account */
1289 TnyAccount *account = modest_tny_folder_get_account (TNY_FOLDER (folder_store));
1290 set_active_account_from_tny_account (account, MODEST_WINDOW (main_window));
1291 g_object_unref (account);
1294 /* Set folder on header view */
1295 modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view),
1296 TNY_FOLDER (folder_store),
1297 folder_refreshed_cb,
1300 /* Update the active account */
1301 modest_window_set_active_account (MODEST_WINDOW (main_window), NULL);
1302 /* Do not show folder */
1303 modest_widget_memory_save (conf, G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY);
1304 modest_header_view_clear (MODEST_HEADER_VIEW(header_view));
1308 /* Update toolbar dimming state */
1309 modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
1313 modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,ModestItemType type,
1320 item = (type == MODEST_ITEM_TYPE_FOLDER) ? "folder" : "message";
1322 if (g_main_depth > 0)
1323 gdk_threads_enter ();
1324 online = tny_device_is_online (modest_runtime_get_device());
1327 /* already online -- the item is simply not there... */
1328 dialog = gtk_message_dialog_new (GTK_WINDOW (win),
1330 GTK_MESSAGE_WARNING,
1332 _("The %s you selected cannot be found"),
1334 gtk_dialog_run (GTK_DIALOG(dialog));
1336 dialog = gtk_dialog_new_with_buttons (_("Connection requested"),
1340 GTK_RESPONSE_REJECT,
1342 GTK_RESPONSE_ACCEPT,
1344 txt = g_strdup_printf (_("This %s is not available in offline mode.\n"
1345 "Do you want to get online?"), item);
1346 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1347 gtk_label_new (txt), FALSE, FALSE, 0);
1348 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
1351 gtk_window_set_default_size (GTK_WINDOW(dialog), 300, 300);
1352 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
1353 // modest_platform_connect_and_wait ();
1356 gtk_widget_destroy (dialog);
1357 if (g_main_depth > 0)
1358 gdk_threads_leave ();
1362 modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, const gchar* link,
1365 /* g_message ("%s %s", __FUNCTION__, link); */
1370 modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview, const gchar* link,
1373 modest_platform_activate_uri (link);
1377 modest_ui_actions_on_msg_link_contextual (ModestMsgView *msgview, const gchar* link,
1380 modest_platform_show_uri_popup (link);
1384 modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, TnyMimePart *mime_part,
1387 modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (win), mime_part);
1391 modest_ui_actions_on_msg_recpt_activated (ModestMsgView *msgview,
1392 const gchar *address,
1395 /* g_message ("%s %s", __FUNCTION__, address); */
1399 modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edit_window)
1401 TnyTransportAccount *transport_account;
1402 ModestMailOperation *mail_operation;
1404 gchar *account_name, *from;
1405 ModestAccountMgr *account_mgr;
1407 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
1409 data = modest_msg_edit_window_get_msg_data (edit_window);
1411 account_mgr = modest_runtime_get_account_mgr();
1412 account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window)));
1414 account_name = modest_account_mgr_get_default_account (account_mgr);
1415 if (!account_name) {
1416 g_printerr ("modest: no account found\n");
1417 modest_msg_edit_window_free_msg_data (edit_window, data);
1421 if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
1422 account_name = g_strdup (data->account_name);
1426 TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_server_account
1427 (modest_runtime_get_account_store(),
1429 TNY_ACCOUNT_TYPE_TRANSPORT));
1430 if (!transport_account) {
1431 g_printerr ("modest: no transport account found for '%s'\n", account_name);
1432 g_free (account_name);
1433 modest_msg_edit_window_free_msg_data (edit_window, data);
1436 from = modest_account_mgr_get_from_string (account_mgr, account_name);
1438 /* Create the mail operation */
1439 mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(edit_window));
1440 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
1442 modest_mail_operation_save_to_drafts (mail_operation,
1453 data->priority_flags);
1456 g_free (account_name);
1457 g_object_unref (G_OBJECT (transport_account));
1458 g_object_unref (G_OBJECT (mail_operation));
1460 modest_msg_edit_window_free_msg_data (edit_window, data);
1462 /* Save settings and close the window */
1463 gtk_widget_destroy (GTK_WIDGET (edit_window));
1466 /* For instance, when clicking the Send toolbar button when editing a message: */
1468 modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
1470 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
1472 if (!modest_msg_edit_window_check_names (edit_window))
1475 /* FIXME: Code added just for testing. The final version will
1476 use the send queue provided by tinymail and some
1478 ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
1479 gchar *account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window)));
1481 account_name = modest_account_mgr_get_default_account (account_mgr);
1483 if (!account_name) {
1484 g_printerr ("modest: no account found\n");
1488 MsgData *data = modest_msg_edit_window_get_msg_data (edit_window);
1490 if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
1491 account_name = g_strdup (data->account_name);
1494 /* Get the currently-active transport account for this modest account: */
1495 TnyTransportAccount *transport_account =
1496 TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_transport_account_for_open_connection
1497 (modest_runtime_get_account_store(),
1499 if (!transport_account) {
1500 g_printerr ("modest: no transport account found for '%s'\n", account_name);
1501 g_free (account_name);
1502 modest_msg_edit_window_free_msg_data (edit_window, data);
1506 gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name);
1508 /* mail content checks and dialogs */
1509 if (data->subject == NULL || data->subject[0] == '\0') {
1510 GtkResponseType response;
1511 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (edit_window),
1512 _("mcen_nc_subject_is_empty_send"));
1513 if (response == GTK_RESPONSE_CANCEL) {
1514 g_free (account_name);
1519 if (data->plain_body == NULL || data->plain_body[0] == '\0') {
1520 GtkResponseType response;
1521 gchar *note_message;
1522 gchar *note_subject = data->subject;
1523 if (note_subject == NULL || note_subject[0] == '\0')
1524 note_subject = _("mail_va_no_subject");
1525 note_message = g_strdup_printf (_("emev_ni_ui_smtp_message_null"), note_subject);
1526 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (edit_window),
1528 g_free (note_message);
1529 if (response == GTK_RESPONSE_CANCEL) {
1530 g_free (account_name);
1535 /* Create the mail operation */
1536 ModestMailOperation *mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_SEND, G_OBJECT(edit_window));
1537 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
1539 modest_mail_operation_send_new_mail (mail_operation,
1550 data->priority_flags);
1554 g_free (account_name);
1555 g_object_unref (G_OBJECT (transport_account));
1556 g_object_unref (G_OBJECT (mail_operation));
1558 modest_msg_edit_window_free_msg_data (edit_window, data);
1560 /* Save settings and close the window: */
1561 gtk_widget_destroy (GTK_WIDGET (edit_window));
1565 modest_ui_actions_on_toggle_bold (GtkToggleAction *action,
1566 ModestMsgEditWindow *window)
1568 ModestMsgEditFormatState *format_state = NULL;
1570 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1571 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1573 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW (window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1576 format_state = modest_msg_edit_window_get_format_state (window);
1577 g_return_if_fail (format_state != NULL);
1579 format_state->bold = gtk_toggle_action_get_active (action);
1580 modest_msg_edit_window_set_format_state (window, format_state);
1581 g_free (format_state);
1586 modest_ui_actions_on_toggle_italics (GtkToggleAction *action,
1587 ModestMsgEditWindow *window)
1589 ModestMsgEditFormatState *format_state = NULL;
1591 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1592 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1594 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1597 format_state = modest_msg_edit_window_get_format_state (window);
1598 g_return_if_fail (format_state != NULL);
1600 format_state->italics = gtk_toggle_action_get_active (action);
1601 modest_msg_edit_window_set_format_state (window, format_state);
1602 g_free (format_state);
1607 modest_ui_actions_on_toggle_bullets (GtkToggleAction *action,
1608 ModestMsgEditWindow *window)
1610 ModestMsgEditFormatState *format_state = NULL;
1612 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1613 g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
1615 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW (window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1618 format_state = modest_msg_edit_window_get_format_state (window);
1619 g_return_if_fail (format_state != NULL);
1621 format_state->bullet = gtk_toggle_action_get_active (action);
1622 modest_msg_edit_window_set_format_state (window, format_state);
1623 g_free (format_state);
1628 modest_ui_actions_on_change_justify (GtkRadioAction *action,
1629 GtkRadioAction *selected,
1630 ModestMsgEditWindow *window)
1632 ModestMsgEditFormatState *format_state = NULL;
1633 GtkJustification value;
1635 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1637 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1640 value = gtk_radio_action_get_current_value (selected);
1642 format_state = modest_msg_edit_window_get_format_state (window);
1643 g_return_if_fail (format_state != NULL);
1645 format_state->justification = value;
1646 modest_msg_edit_window_set_format_state (window, format_state);
1647 g_free (format_state);
1651 modest_ui_actions_on_select_editor_color (GtkAction *action,
1652 ModestMsgEditWindow *window)
1654 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1655 g_return_if_fail (GTK_IS_ACTION (action));
1657 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1660 modest_msg_edit_window_select_color (window);
1664 modest_ui_actions_on_select_editor_background_color (GtkAction *action,
1665 ModestMsgEditWindow *window)
1667 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1668 g_return_if_fail (GTK_IS_ACTION (action));
1670 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1673 modest_msg_edit_window_select_background_color (window);
1677 modest_ui_actions_on_insert_image (GtkAction *action,
1678 ModestMsgEditWindow *window)
1680 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1681 g_return_if_fail (GTK_IS_ACTION (action));
1683 if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
1686 modest_msg_edit_window_insert_image (window);
1690 modest_ui_actions_on_attach_file (GtkAction *action,
1691 ModestMsgEditWindow *window)
1693 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
1694 g_return_if_fail (GTK_IS_ACTION (action));
1696 modest_msg_edit_window_attach_file (window);
1700 modest_ui_actions_on_remove_attachments (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 modest_msg_edit_window_remove_attachments (window, NULL);
1710 * Shows a dialog with an entry that asks for some text. The returned
1711 * value must be freed by the caller. The dialog window title will be
1715 ask_for_folder_name (GtkWindow *parent_window,
1718 GtkWidget *dialog, *entry;
1719 gchar *folder_name = NULL;
1721 /* Ask for folder name */
1722 dialog = gtk_dialog_new_with_buttons (_("New Folder Name"),
1726 GTK_RESPONSE_REJECT,
1728 GTK_RESPONSE_ACCEPT,
1730 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1731 gtk_label_new(title),
1734 entry = gtk_entry_new_with_max_length (40);
1735 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
1739 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
1741 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
1742 folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
1744 gtk_widget_destroy (dialog);
1750 modest_ui_actions_on_new_folder (GtkAction *action, ModestMainWindow *main_window)
1752 TnyFolderStore *parent_folder;
1753 GtkWidget *folder_view;
1755 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1757 folder_view = modest_main_window_get_child_widget (main_window,
1758 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1762 parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
1764 if (parent_folder) {
1765 gboolean finished = FALSE;
1767 gchar *folder_name = NULL, *suggested_name = NULL;
1769 /* Run the new folder dialog */
1771 result = modest_platform_run_new_folder_dialog (GTK_WINDOW (main_window),
1776 if (result == GTK_RESPONSE_REJECT) {
1779 ModestMailOperation *mail_op;
1780 TnyFolder *new_folder = NULL;
1782 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO,
1783 G_OBJECT(main_window));
1784 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1786 new_folder = modest_mail_operation_create_folder (mail_op,
1788 (const gchar *) folder_name);
1790 g_object_unref (new_folder);
1793 g_object_unref (mail_op);
1795 g_free (folder_name);
1799 g_object_unref (parent_folder);
1804 modest_ui_actions_on_rename_folder (GtkAction *action,
1805 ModestMainWindow *main_window)
1807 TnyFolderStore *folder;
1808 GtkWidget *folder_view;
1809 GtkWidget *header_view;
1811 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1813 folder_view = modest_main_window_get_child_widget (main_window,
1814 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1818 header_view = modest_main_window_get_child_widget (main_window,
1819 MODEST_WIDGET_TYPE_HEADER_VIEW);
1824 folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
1826 if (folder && TNY_IS_FOLDER (folder)) {
1828 folder_name = ask_for_folder_name (GTK_WINDOW (main_window),
1829 _("Please enter a new name for the folder"));
1831 if (folder_name != NULL && strlen (folder_name) > 0) {
1832 ModestMailOperation *mail_op;
1834 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(main_window));
1835 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1838 modest_header_view_clear (MODEST_HEADER_VIEW (header_view));
1840 modest_mail_operation_rename_folder (mail_op,
1841 TNY_FOLDER (folder),
1842 (const gchar *) folder_name);
1844 g_object_unref (mail_op);
1845 g_free (folder_name);
1847 g_object_unref (folder);
1852 modest_ui_actions_delete_folder_error_handler (ModestMailOperation *mail_op,
1855 GObject *win = modest_mail_operation_get_source (mail_op);
1857 modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
1858 _("mail_in_ui_folder_delete_error"));
1862 delete_folder (ModestMainWindow *main_window, gboolean move_to_trash)
1864 TnyFolderStore *folder;
1865 GtkWidget *folder_view;
1869 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1871 folder_view = modest_main_window_get_child_widget (main_window,
1872 MODEST_WIDGET_TYPE_FOLDER_VIEW);
1876 folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
1878 /* Show an error if it's an account */
1879 if (!TNY_IS_FOLDER (folder)) {
1880 modest_platform_run_information_dialog (GTK_WINDOW (main_window),
1881 _("mail_in_ui_folder_delete_error"));
1886 message = g_strdup_printf (_("mcen_nc_delete_folder_text"),
1887 tny_folder_get_name (TNY_FOLDER (folder)));
1888 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (main_window),
1889 (const gchar *) message);
1892 if (response == GTK_RESPONSE_OK) {
1893 ModestMailOperation *mail_op =
1894 modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_DELETE,
1895 G_OBJECT(main_window),
1896 modest_ui_actions_delete_folder_error_handler,
1899 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
1901 modest_mail_operation_remove_folder (mail_op, TNY_FOLDER (folder), move_to_trash);
1902 g_object_unref (G_OBJECT (mail_op));
1905 g_object_unref (G_OBJECT (folder));
1909 modest_ui_actions_on_delete_folder (GtkAction *action,
1910 ModestMainWindow *main_window)
1912 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1914 delete_folder (main_window, FALSE);
1918 modest_ui_actions_on_move_folder_to_trash_folder (GtkAction *action, ModestMainWindow *main_window)
1920 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
1922 delete_folder (main_window, TRUE);
1926 modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
1927 const gchar* server_account_name,
1932 ModestMainWindow *main_window)
1934 g_return_if_fail(server_account_name);
1935 /* printf("DEBUG: %s: server_account_name=%s\n", __FUNCTION__, server_account_name); */
1937 /* Initalize output parameters: */
1944 #ifdef MODEST_PLATFORM_MAEMO
1945 /* Maemo uses a different (awkward) button order,
1946 * It should probably just use gtk_alternative_dialog_button_order ().
1948 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
1952 GTK_RESPONSE_ACCEPT,
1954 GTK_RESPONSE_REJECT,
1957 GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
1961 GTK_RESPONSE_REJECT,
1963 GTK_RESPONSE_ACCEPT,
1965 #endif /* MODEST_PLATFORM_MAEMO */
1967 gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(main_window));
1969 gchar *server_name = modest_server_account_get_hostname (
1970 modest_runtime_get_account_mgr(), server_account_name);
1971 if (!server_name) {/* This happened once, though I don't know why. murrayc. */
1972 g_warning("%s: Could not get server name for server account '%s'", __FUNCTION__, server_account_name);
1977 /* This causes a warning because the logical ID has no %s in it,
1978 * though the translation does, but there is not much we can do about that: */
1979 gchar *txt = g_strdup_printf (_("mail_ia_password_info"), server_name);
1980 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt),
1983 g_free (server_name);
1987 gchar *initial_username = modest_server_account_get_username (
1988 modest_runtime_get_account_mgr(), server_account_name);
1990 GtkWidget *entry_username = gtk_entry_new ();
1991 if (initial_username)
1992 gtk_entry_set_text (GTK_ENTRY (entry_username), initial_username);
1993 /* Dim this if a connection has ever succeeded with this username,
1994 * as per the UI spec: */
1995 const gboolean username_known =
1996 modest_server_account_get_username_has_succeeded(
1997 modest_runtime_get_account_mgr(), server_account_name);
1998 gtk_widget_set_sensitive (entry_username, !username_known);
2000 #ifdef MODEST_PLATFORM_MAEMO
2001 /* Auto-capitalization is the default, so let's turn it off: */
2002 hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_username), HILDON_GTK_INPUT_MODE_FULL);
2004 /* Create a size group to be used by all captions.
2005 * Note that HildonCaption does not create a default size group if we do not specify one.
2006 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
2007 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2009 GtkWidget *caption = hildon_caption_new (sizegroup,
2010 _("mail_fi_username"), entry_username, NULL, HILDON_CAPTION_MANDATORY);
2011 gtk_widget_show (entry_username);
2012 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption,
2013 FALSE, FALSE, MODEST_MARGIN_HALF);
2014 gtk_widget_show (caption);
2016 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_username,
2018 #endif /* MODEST_PLATFORM_MAEMO */
2021 GtkWidget *entry_password = gtk_entry_new ();
2022 gtk_entry_set_visibility (GTK_ENTRY(entry_password), FALSE);
2023 /* gtk_entry_set_invisible_char (GTK_ENTRY(entry_password), "*"); */
2025 #ifdef MODEST_PLATFORM_MAEMO
2026 /* Auto-capitalization is the default, so let's turn it off: */
2027 hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_password),
2028 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
2030 caption = hildon_caption_new (sizegroup,
2031 _("mail_fi_password"), entry_password, NULL, HILDON_CAPTION_MANDATORY);
2032 gtk_widget_show (entry_password);
2033 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption,
2034 FALSE, FALSE, MODEST_MARGIN_HALF);
2035 gtk_widget_show (caption);
2036 g_object_unref (sizegroup);
2038 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_password,
2040 #endif /* MODEST_PLATFORM_MAEMO */
2042 /* This is not in the Maemo UI spec:
2043 remember_pass_check = gtk_check_button_new_with_label (_("Remember password"));
2044 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), remember_pass_check,
2048 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
2050 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
2052 *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username)));
2054 modest_server_account_set_username (
2055 modest_runtime_get_account_mgr(), server_account_name,
2058 const gboolean username_was_changed =
2059 (strcmp (*username, initial_username) != 0);
2060 if (username_was_changed) {
2061 /* To actually use a changed username,
2062 * we must reset the connection, according to pvanhoof.
2063 * This _might_ be a sensible way to do that: */
2064 TnyDevice *device = modest_runtime_get_device();
2065 tny_device_force_offline (device);
2066 tny_device_force_online (device);
2071 *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password)));
2073 /* We do not save the password in the configuration,
2074 * because this function is only called for passwords that should
2075 * not be remembered:
2076 modest_server_account_set_password (
2077 modest_runtime_get_account_mgr(), server_account_name,
2096 /* This is not in the Maemo UI spec:
2097 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pass_check)))
2103 gtk_widget_destroy (dialog);
2105 /* printf ("DEBUG: %s: cancel=%d\n", __FUNCTION__, *cancel); */
2109 modest_ui_actions_on_cut (GtkAction *action,
2110 ModestWindow *window)
2112 GtkWidget *focused_widget;
2114 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2115 if (GTK_IS_EDITABLE (focused_widget)) {
2116 gtk_editable_cut_clipboard (GTK_EDITABLE(focused_widget));
2117 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2118 GtkTextBuffer *buffer;
2119 GtkClipboard *clipboard;
2121 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2122 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2123 gtk_text_buffer_cut_clipboard (buffer, clipboard, TRUE);
2128 modest_ui_actions_on_copy (GtkAction *action,
2129 ModestWindow *window)
2131 GtkClipboard *clipboard;
2132 GtkWidget *focused_widget;
2134 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2135 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2136 if (GTK_IS_LABEL (focused_widget)) {
2137 gtk_clipboard_set_text (clipboard, gtk_label_get_text (GTK_LABEL (focused_widget)), -1);
2138 } else if (GTK_IS_EDITABLE (focused_widget)) {
2139 gtk_editable_copy_clipboard (GTK_EDITABLE(focused_widget));
2140 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2141 GtkTextBuffer *buffer;
2143 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2144 gtk_text_buffer_copy_clipboard (buffer, clipboard);
2149 modest_ui_actions_on_undo (GtkAction *action,
2150 ModestWindow *window)
2152 if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
2153 modest_msg_edit_window_undo (MODEST_MSG_EDIT_WINDOW (window));
2155 g_return_if_reached ();
2160 modest_ui_actions_on_paste (GtkAction *action,
2161 ModestWindow *window)
2163 GtkWidget *focused_widget;
2165 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2166 if (GTK_IS_EDITABLE (focused_widget)) {
2167 gtk_editable_paste_clipboard (GTK_EDITABLE(focused_widget));
2168 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2169 GtkTextBuffer *buffer;
2170 GtkClipboard *clipboard;
2172 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
2173 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2174 gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE);
2179 modest_ui_actions_on_select_all (GtkAction *action,
2180 ModestWindow *window)
2182 GtkWidget *focused_widget;
2184 focused_widget = gtk_window_get_focus (GTK_WINDOW (window));
2185 if (MODEST_IS_ATTACHMENTS_VIEW (focused_widget)) {
2186 modest_attachments_view_select_all (MODEST_ATTACHMENTS_VIEW (focused_widget));
2187 } else if (GTK_IS_LABEL (focused_widget)) {
2188 gtk_label_select_region (GTK_LABEL (focused_widget), 0, -1);
2189 } else if (GTK_IS_EDITABLE (focused_widget)) {
2190 gtk_editable_select_region (GTK_EDITABLE(focused_widget), 0, -1);
2191 } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
2192 GtkTextBuffer *buffer;
2193 GtkTextIter start, end;
2195 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));
2196 gtk_text_buffer_get_start_iter (buffer, &start);
2197 gtk_text_buffer_get_end_iter (buffer, &end);
2198 gtk_text_buffer_select_range (buffer, &start, &end);
2200 else if ((MODEST_IS_FOLDER_VIEW (focused_widget)) ||
2201 (MODEST_IS_HEADER_VIEW (focused_widget))) {
2203 GtkTreeSelection *selection = NULL;
2205 /* Get header view */
2206 GtkWidget *header_view = focused_widget;
2207 if (MODEST_IS_FOLDER_VIEW (focused_widget))
2208 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
2209 MODEST_WIDGET_TYPE_HEADER_VIEW);
2211 /* Select all messages */
2212 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(header_view));
2213 gtk_tree_selection_select_all (selection);
2218 modest_ui_actions_on_mark_as_read (GtkAction *action,
2219 ModestWindow *window)
2221 g_return_if_fail (MODEST_IS_WINDOW(window));
2223 /* Mark each header as read */
2224 do_headers_action (window, headers_action_mark_as_read, NULL);
2228 modest_ui_actions_on_mark_as_unread (GtkAction *action,
2229 ModestWindow *window)
2231 g_return_if_fail (MODEST_IS_WINDOW(window));
2233 /* Mark each header as read */
2234 do_headers_action (window, headers_action_mark_as_unread, NULL);
2238 modest_ui_actions_on_change_zoom (GtkRadioAction *action,
2239 GtkRadioAction *selected,
2240 ModestWindow *window)
2244 value = gtk_radio_action_get_current_value (selected);
2245 if (MODEST_IS_WINDOW (window)) {
2246 modest_window_set_zoom (MODEST_WINDOW (window), ((gdouble)value)/100);
2250 void modest_ui_actions_msg_edit_on_change_priority (GtkRadioAction *action,
2251 GtkRadioAction *selected,
2252 ModestWindow *window)
2254 TnyHeaderFlags flags;
2255 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2257 flags = gtk_radio_action_get_current_value (selected);
2258 modest_msg_edit_window_set_priority_flags (MODEST_MSG_EDIT_WINDOW (window), flags);
2261 void modest_ui_actions_msg_edit_on_change_file_format (GtkRadioAction *action,
2262 GtkRadioAction *selected,
2263 ModestWindow *window)
2267 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2269 file_format = gtk_radio_action_get_current_value (selected);
2270 modest_msg_edit_window_set_file_format (MODEST_MSG_EDIT_WINDOW (window), file_format);
2275 modest_ui_actions_on_zoom_plus (GtkAction *action,
2276 ModestWindow *window)
2278 g_return_if_fail (MODEST_IS_WINDOW (window));
2280 modest_window_zoom_plus (MODEST_WINDOW (window));
2284 modest_ui_actions_on_zoom_minus (GtkAction *action,
2285 ModestWindow *window)
2287 g_return_if_fail (MODEST_IS_WINDOW (window));
2289 modest_window_zoom_minus (MODEST_WINDOW (window));
2293 modest_ui_actions_on_toggle_fullscreen (GtkToggleAction *toggle,
2294 ModestWindow *window)
2296 ModestWindowMgr *mgr;
2297 gboolean fullscreen, active;
2298 g_return_if_fail (MODEST_IS_WINDOW (window));
2300 mgr = modest_runtime_get_window_mgr ();
2302 active = (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle)))?1:0;
2303 fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
2305 if (active != fullscreen) {
2306 modest_window_mgr_set_fullscreen_mode (mgr, active);
2307 gtk_window_present (GTK_WINDOW (window));
2312 modest_ui_actions_on_change_fullscreen (GtkAction *action,
2313 ModestWindow *window)
2315 ModestWindowMgr *mgr;
2316 gboolean fullscreen;
2318 g_return_if_fail (MODEST_IS_WINDOW (window));
2320 mgr = modest_runtime_get_window_mgr ();
2321 fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
2322 modest_window_mgr_set_fullscreen_mode (mgr, !fullscreen);
2324 gtk_window_present (GTK_WINDOW (window));
2328 * Used by modest_ui_actions_on_details to call do_headers_action
2331 headers_action_show_details (TnyHeader *header,
2332 ModestWindow *window,
2339 dialog = modest_details_dialog_new_with_header (GTK_WINDOW (window), header);
2342 gtk_widget_show_all (dialog);
2343 gtk_dialog_run (GTK_DIALOG (dialog));
2345 gtk_widget_destroy (dialog);
2349 * Show the folder details in a ModestDetailsDialog widget
2352 show_folder_details (TnyFolder *folder,
2358 dialog = modest_details_dialog_new_with_folder (window, folder);
2361 gtk_widget_show_all (dialog);
2362 gtk_dialog_run (GTK_DIALOG (dialog));
2364 gtk_widget_destroy (dialog);
2368 * Show the header details in a ModestDetailsDialog widget
2371 modest_ui_actions_on_details (GtkAction *action,
2374 TnyList * headers_list;
2378 if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
2381 msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win));
2384 g_object_unref (msg);
2386 headers_list = get_selected_headers (win);
2390 iter = tny_list_create_iterator (headers_list);
2392 header = TNY_HEADER (tny_iterator_get_current (iter));
2393 headers_action_show_details (header, win, NULL);
2394 g_object_unref (header);
2396 g_object_unref (iter);
2397 g_object_unref (headers_list);
2399 } else if (MODEST_IS_MAIN_WINDOW (win)) {
2400 GtkWidget *folder_view, *header_view;
2402 /* Check which widget has the focus */
2403 folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
2404 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2405 if (gtk_widget_is_focus (folder_view)) {
2408 folder = (TnyFolder *) modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
2410 /* Show only when it's a folder */
2411 if (!folder || !TNY_IS_FOLDER (folder))
2414 show_folder_details (folder, GTK_WINDOW (win));
2417 header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
2418 MODEST_WIDGET_TYPE_HEADER_VIEW);
2419 /* Show details of each header */
2420 do_headers_action (win, headers_action_show_details, header_view);
2426 modest_ui_actions_on_toggle_show_cc (GtkToggleAction *toggle,
2427 ModestMsgEditWindow *window)
2429 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2431 modest_msg_edit_window_show_cc (window, gtk_toggle_action_get_active (toggle));
2435 modest_ui_actions_on_toggle_show_bcc (GtkToggleAction *toggle,
2436 ModestMsgEditWindow *window)
2438 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2440 modest_msg_edit_window_show_bcc (window, gtk_toggle_action_get_active (toggle));
2444 modest_ui_actions_toggle_folders_view (GtkAction *action,
2445 ModestMainWindow *main_window)
2449 g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
2451 conf = modest_runtime_get_conf ();
2453 if (modest_main_window_get_style (main_window) == MODEST_MAIN_WINDOW_STYLE_SPLIT)
2454 modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SIMPLE);
2456 modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SPLIT);
2460 modest_ui_actions_on_toggle_toolbar (GtkToggleAction *toggle,
2461 ModestWindow *window)
2463 gboolean active, fullscreen = FALSE;
2464 ModestWindowMgr *mgr;
2466 active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle));
2468 /* Check if we want to toggle the toolbar vuew in fullscreen
2470 if (!strcmp (gtk_action_get_name (GTK_ACTION (toggle)),
2471 "ViewShowToolbarFullScreen")) {
2475 /* Toggle toolbar */
2476 mgr = modest_runtime_get_window_mgr ();
2477 modest_window_mgr_show_toolbars (mgr, active, fullscreen);
2481 modest_ui_actions_msg_edit_on_select_font (GtkAction *action,
2482 ModestMsgEditWindow *window)
2484 modest_msg_edit_window_select_font (window);
2488 modest_ui_actions_on_folder_display_name_changed (ModestFolderView *folder_view,
2489 const gchar *display_name,
2492 /* Do not change the application name if the widget has not
2493 the focus. This callback could be called even if the folder
2494 view has not the focus, because the handled signal could be
2495 emitted when the folder view is redrawn */
2496 if (gtk_widget_is_focus (GTK_WIDGET (folder_view))) {
2498 gtk_window_set_title (window, display_name);
2500 gtk_window_set_title (window, " ");
2505 modest_ui_actions_on_select_contacts (GtkAction *action, ModestMsgEditWindow *window)
2507 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2508 modest_msg_edit_window_select_contacts (window);
2512 modest_ui_actions_on_check_names (GtkAction *action, ModestMsgEditWindow *window)
2514 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
2515 modest_msg_edit_window_check_names (window);
2520 create_move_to_dialog (ModestWindow *win,
2521 GtkWidget *folder_view,
2522 GtkWidget **tree_view)
2524 GtkWidget *dialog, *scroll;
2526 dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"),
2528 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT,
2530 GTK_RESPONSE_ACCEPT,
2532 GTK_RESPONSE_REJECT,
2535 /* Create scrolled window */
2536 scroll = gtk_scrolled_window_new (NULL, NULL);
2537 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
2538 GTK_POLICY_AUTOMATIC,
2539 GTK_POLICY_AUTOMATIC);
2541 /* Create folder view */
2542 *tree_view = modest_folder_view_new (NULL);
2544 /* It could happen that we're trying to move a message from a
2545 window (msg window for example) after the main window was
2546 closed, so we can not just get the model of the folder
2548 if (MODEST_IS_FOLDER_VIEW (folder_view))
2549 gtk_tree_view_set_model (GTK_TREE_VIEW (*tree_view),
2550 gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view)));
2552 modest_folder_view_update_model (MODEST_FOLDER_VIEW (*tree_view),
2553 TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
2555 gtk_container_add (GTK_CONTAINER (scroll), *tree_view);
2557 /* Add scroll to dialog */
2558 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
2559 scroll, FALSE, FALSE, 0);
2561 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
2567 * Returns TRUE if at least one of the headers of the list belongs to
2568 * a message that has been fully retrieved.
2571 has_retrieved_msgs (TnyList *list)
2574 gboolean found = FALSE;
2576 iter = tny_list_create_iterator (list);
2577 while (tny_iterator_is_done (iter) && !found) {
2579 TnyHeaderFlags flags;
2581 header = TNY_HEADER (tny_iterator_get_current (iter));
2582 flags = tny_header_get_flags (header);
2583 if (!(flags & TNY_HEADER_FLAG_PARTIAL))
2587 tny_iterator_next (iter);
2589 g_object_unref (iter);
2595 * Shows a confirmation dialog to the user when we're moving messages
2596 * from a remote server to the local storage. Returns the dialog
2597 * response. If it's other kind of movement the it always returns
2601 msgs_move_to_confirmation (GtkWindow *win,
2602 TnyFolder *dest_folder,
2605 gint response = GTK_RESPONSE_OK;
2607 /* If the destination is a local folder */
2608 if (modest_tny_folder_is_local_folder (dest_folder)) {
2609 TnyFolder *src_folder;
2613 /* Get source folder */
2614 iter = tny_list_create_iterator (headers);
2615 header = TNY_HEADER (tny_iterator_get_current (iter));
2616 src_folder = tny_header_get_folder (header);
2617 g_object_unref (header);
2618 g_object_unref (iter);
2620 /* If the source is a remote folder */
2621 if (!modest_tny_folder_is_local_folder (src_folder)) {
2622 const gchar *message;
2624 if (tny_list_get_length (headers) == 1)
2625 if (has_retrieved_msgs (headers))
2626 message = _("mcen_nc_move_retrieve");
2628 message = _("mcen_nc_move_header");
2630 if (has_retrieved_msgs (headers))
2631 message = _("mcen_nc_move_retrieves");
2633 message = _("mcen_nc_move_headers");
2635 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
2636 (const gchar *) message);
2638 g_object_unref (src_folder);
2645 tranasfer_msgs_from_viewer_cb (const GObject *object, gpointer user_data)
2647 ModestMsgViewWindow *self = NULL;
2648 gboolean found = FALSE;
2650 g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (object));
2651 self = MODEST_MSG_VIEW_WINDOW (object);
2653 found = modest_msg_view_window_select_first_message (self);
2654 g_return_if_fail (found);
2658 modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
2661 GObject *win = modest_mail_operation_get_source (mail_op);
2663 /* TODO: show error message */
2664 modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
2665 _("mail_in_ui_folder_move_target_error"));
2669 * UI handler for the "Move to" action when invoked from the
2673 modest_ui_actions_on_main_window_move_to (GtkAction *action,
2674 ModestMainWindow *win)
2676 GtkWidget *dialog = NULL, *folder_view = NULL, *tree_view = NULL;
2677 GtkWidget *header_view = NULL;
2679 TnyFolderStore *folder_store = NULL;
2680 ModestMailOperation *mail_op = NULL;
2682 g_return_if_fail (MODEST_IS_MAIN_WINDOW (win));
2684 /* Get the folder view */
2685 folder_view = modest_main_window_get_child_widget (win,
2686 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2688 /* Get header view */
2689 header_view = modest_main_window_get_child_widget (win,
2690 MODEST_WIDGET_TYPE_HEADER_VIEW);
2692 /* Create and run the dialog */
2693 dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
2694 modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view));
2695 result = gtk_dialog_run (GTK_DIALOG(dialog));
2696 g_object_ref (tree_view);
2698 /* We do this to save an indentation level ;-) */
2699 if (result != GTK_RESPONSE_ACCEPT)
2702 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (tree_view));
2704 if (TNY_IS_ACCOUNT (folder_store))
2707 /* Get folder or messages to transfer */
2708 if (gtk_widget_is_focus (folder_view)) {
2709 TnyFolderStore *src_folder;
2710 src_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
2712 /* Clean folder on header view before moving it */
2713 modest_header_view_clear (MODEST_HEADER_VIEW (header_view));
2715 if (TNY_IS_FOLDER (src_folder)) {
2717 modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
2719 modest_ui_actions_move_folder_error_handler,
2721 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
2723 modest_mail_operation_xfer_folder (mail_op,
2724 TNY_FOLDER (src_folder),
2727 /* Unref mail operation */
2728 g_object_unref (G_OBJECT (mail_op));
2732 g_object_unref (G_OBJECT (src_folder));
2734 if (gtk_widget_is_focus (header_view)) {
2738 headers = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (header_view));
2740 /* Ask for user confirmation */
2741 response = msgs_move_to_confirmation (GTK_WINDOW (win),
2742 TNY_FOLDER (folder_store),
2745 /* Transfer messages */
2746 if (response == GTK_RESPONSE_OK) {
2747 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
2748 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
2751 modest_mail_operation_xfer_msgs (mail_op,
2753 TNY_FOLDER (folder_store),
2758 g_object_unref (G_OBJECT (mail_op));
2760 g_object_unref (headers);
2763 g_object_unref (folder_store);
2765 gtk_widget_destroy (dialog);
2770 * UI handler for the "Move to" action when invoked from the
2771 * ModestMsgViewWindow
2774 modest_ui_actions_on_msg_view_window_move_to (GtkAction *action,
2775 ModestMsgViewWindow *win)
2777 GtkWidget *dialog, *folder_view, *tree_view = NULL;
2779 ModestMainWindow *main_window;
2783 /* Get the folder view */
2784 main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()));
2786 folder_view = modest_main_window_get_child_widget (main_window,
2787 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2791 /* Create and run the dialog */
2792 dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
2793 result = gtk_dialog_run (GTK_DIALOG(dialog));
2794 g_object_ref (tree_view);
2796 if (result == GTK_RESPONSE_ACCEPT) {
2797 TnyFolderStore *folder_store;
2800 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (tree_view));
2802 /* Create header list */
2803 header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
2804 headers = tny_simple_list_new ();
2805 tny_list_prepend (headers, G_OBJECT (header));
2806 g_object_unref (header);
2808 /* Ask user for confirmation. MSG-NOT404 */
2809 response = msgs_move_to_confirmation (GTK_WINDOW (win),
2810 TNY_FOLDER (folder_store),
2813 /* Transfer current msg */
2814 if (response == GTK_RESPONSE_OK) {
2815 ModestMailOperation *mail_op;
2817 /* Create mail op */
2818 mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win));
2819 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
2822 /* Transfer messages */
2823 modest_mail_operation_xfer_msgs (mail_op,
2825 TNY_FOLDER (folder_store),
2827 tranasfer_msgs_from_viewer_cb,
2829 g_object_unref (G_OBJECT (mail_op));
2831 g_object_unref (headers);
2832 g_object_unref (folder_store);
2834 gtk_widget_destroy (dialog);
2838 modest_ui_actions_on_move_to (GtkAction *action,
2841 g_return_if_fail (MODEST_IS_MAIN_WINDOW (win) ||
2842 MODEST_IS_MSG_VIEW_WINDOW (win));
2844 if (MODEST_IS_MAIN_WINDOW (win))
2845 modest_ui_actions_on_main_window_move_to (action,
2846 MODEST_MAIN_WINDOW (win));
2848 modest_ui_actions_on_msg_view_window_move_to (action,
2849 MODEST_MSG_VIEW_WINDOW (win));
2853 * Calls #HeadersFunc for each header already selected in the main
2854 * window or the message currently being shown in the msg view window
2857 do_headers_action (ModestWindow *win,
2861 TnyList *headers_list;
2865 headers_list = get_selected_headers (win);
2869 /* Call the function for each header */
2870 iter = tny_list_create_iterator (headers_list);
2871 while (!tny_iterator_is_done (iter)) {
2874 header = TNY_HEADER (tny_iterator_get_current (iter));
2875 func (header, win, user_data);
2876 g_object_unref (header);
2877 tny_iterator_next (iter);
2879 g_object_unref (iter);
2880 g_object_unref (headers_list);
2884 modest_ui_actions_view_attachment (GtkAction *action,
2885 ModestWindow *window)
2887 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2888 modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (window), NULL);
2890 /* not supported window for this action */
2891 g_return_if_reached ();
2896 modest_ui_actions_save_attachments (GtkAction *action,
2897 ModestWindow *window)
2899 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2900 modest_msg_view_window_save_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
2902 /* not supported window for this action */
2903 g_return_if_reached ();
2908 modest_ui_actions_remove_attachments (GtkAction *action,
2909 ModestWindow *window)
2911 if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
2912 modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (window), NULL);
2914 /* not supported window for this action */
2915 g_return_if_reached ();
2920 modest_ui_actions_on_settings (GtkAction *action,
2925 dialog = modest_platform_get_global_settings_dialog ();
2926 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (win));
2927 gtk_widget_show (dialog);
2929 gtk_dialog_run (GTK_DIALOG (dialog));
2931 gtk_widget_destroy (dialog);
2935 modest_ui_actions_on_help (GtkAction *action,
2938 const gchar *help_id = NULL;
2940 if (MODEST_IS_MAIN_WINDOW (win)) {
2941 const gchar *action_name;
2942 action_name = gtk_action_get_name (action);
2944 if (!strcmp (action_name, "FolderViewCSMHelp") ||
2945 !strcmp (action_name, "HeaderViewCSMHelp")) {
2946 GtkWidget *folder_view;
2947 TnyFolderStore *folder_store;
2948 /* Get selected folder */
2949 folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
2950 MODEST_WIDGET_TYPE_FOLDER_VIEW);
2951 folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
2953 /* Switch help_id */
2954 if (TNY_IS_FOLDER (folder_store)) {
2955 switch (tny_folder_get_folder_type (TNY_FOLDER (folder_store))) {
2956 case TNY_FOLDER_TYPE_NORMAL:
2957 help_id = "applications_email_userfolder";
2959 case TNY_FOLDER_TYPE_INBOX:
2960 help_id = "applications_email_inbox";
2962 case TNY_FOLDER_TYPE_OUTBOX:
2963 help_id = "applications_email_outbox";
2965 case TNY_FOLDER_TYPE_SENT:
2966 help_id = "applications_email_sent";
2968 case TNY_FOLDER_TYPE_DRAFTS:
2969 help_id = "applications_email_drafts";
2971 case TNY_FOLDER_TYPE_ARCHIVE:
2972 help_id = "applications_email_archive";
2979 help_id = "applications_email_mainview";
2981 } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
2982 help_id = "applications_email_viewer";
2983 } else if (MODEST_IS_MSG_EDIT_WINDOW (win))
2984 help_id = "applications_email_editor";
2986 modest_platform_show_help (GTK_WINDOW (win), help_id);
2990 modest_ui_actions_on_retrieve_msg_contents (GtkAction *action,
2991 ModestWindow *window)
2993 ModestMailOperation *mail_op;
2997 headers = get_selected_headers (window);
3001 /* Create mail operation */
3002 mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
3004 modest_ui_actions_get_msgs_full_error_handler,
3006 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
3007 modest_mail_operation_get_msgs_full (mail_op, headers, NULL, NULL, NULL);
3010 g_object_unref (headers);
3011 g_object_unref (mail_op);
3015 modest_ui_actions_on_email_menu_activated (GtkAction *action,
3016 ModestWindow *window)
3018 g_return_if_fail (MODEST_IS_WINDOW (window));
3021 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3025 modest_ui_actions_on_edit_menu_activated (GtkAction *action,
3026 ModestWindow *window)
3028 g_return_if_fail (MODEST_IS_WINDOW (window));
3031 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3035 modest_ui_actions_on_view_menu_activated (GtkAction *action,
3036 ModestWindow *window)
3038 g_return_if_fail (MODEST_IS_WINDOW (window));
3041 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3045 modest_ui_actions_on_tools_menu_activated (GtkAction *action,
3046 ModestWindow *window)
3048 g_return_if_fail (MODEST_IS_WINDOW (window));
3051 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3055 modest_ui_actions_on_attachment_menu_activated (GtkAction *action,
3056 ModestWindow *window)
3058 g_return_if_fail (MODEST_IS_WINDOW (window));
3061 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3065 modest_ui_actions_on_toolbar_csm_menu_activated (GtkAction *action,
3066 ModestWindow *window)
3068 g_return_if_fail (MODEST_IS_WINDOW (window));
3071 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3075 modest_ui_actions_on_folder_view_csm_menu_activated (GtkAction *action,
3076 ModestWindow *window)
3078 g_return_if_fail (MODEST_IS_WINDOW (window));
3081 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3085 modest_ui_actions_on_header_view_csm_menu_activated (GtkAction *action,
3086 ModestWindow *window)
3088 g_return_if_fail (MODEST_IS_WINDOW (window));
3091 modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
3095 modest_ui_actions_check_toolbar_dimming_rules (ModestWindow *window)
3097 g_return_if_fail (MODEST_IS_WINDOW (window));
3100 modest_window_check_dimming_rules_group (window, "ModestToolbarDimmingRules");
3104 modest_ui_actions_on_search_messages (GtkAction *action, ModestWindow *window)
3106 g_return_if_fail (MODEST_IS_WINDOW (window));
3108 modest_platform_show_search_messages (GTK_WINDOW (window));
3112 modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *win)
3114 g_return_if_fail (MODEST_IS_WINDOW (win));
3115 modest_platform_show_addressbook (GTK_WINDOW (win));
3120 modest_ui_actions_on_toggle_find_in_page (GtkToggleAction *action,
3121 ModestWindow *window)
3123 g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
3125 modest_msg_edit_window_toggle_find_toolbar (MODEST_MSG_EDIT_WINDOW (window), gtk_toggle_action_get_active (action));
3129 _on_send_receive_progress_changed (ModestMailOperation *mail_op,
3130 ModestMailOperationState *state,
3133 g_return_if_fail (MODEST_IS_MAIN_WINDOW(user_data));
3135 /* Set send/receive operation finished */
3136 if (state->status != MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
3137 modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW(user_data));