X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-dimming-rules.c;h=da83293816eb6acb811efb30df26c714711cecae;hp=377329fb17ee2be9afe73b049932e6dbc5ee5dc5;hb=169f0a6ed724f1c98c5a35eea5742c092e8f5e8c;hpb=e374da56f67092cecb1572dd4bee2ca34e0bc04c;ds=sidebyside diff --git a/src/modest-ui-dimming-rules.c b/src/modest-ui-dimming-rules.c index 377329f..da83293 100644 --- a/src/modest-ui-dimming-rules.c +++ b/src/modest-ui-dimming-rules.c @@ -41,7 +41,7 @@ #include "modest-tny-msg.h" #include "modest-tny-mime-part.h" #include "modest-text-utils.h" -#include +#include "modest-address-book.h" #include #include #include @@ -345,9 +345,11 @@ modest_ui_dimming_rules_on_new_msg (ModestWindow *win, gpointer user_data) /* Check dimmed rule */ if (MODEST_IS_MSG_VIEW_WINDOW(win)) { +#ifndef MODEST_TOOLKIT_HILDON2 dimmed = _msg_download_in_progress (win); if (dimmed) - modest_dimming_rule_set_notification (rule, ""); + modest_dimming_rule_set_notification (rule, ""); +#endif } else if (MODEST_IS_MAIN_WINDOW(win)) { dimmed = !modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE); @@ -464,17 +466,17 @@ modest_ui_dimming_rules_on_delete (ModestWindow *win, gpointer user_data) !gtk_widget_is_focus (header_view) && !gtk_widget_is_focus (folder_view)) { dimmed = TRUE; - modest_dimming_rule_set_notification (rule, dgettext("hildon-common-strings", "ckct_ib_nothing_to_delete")); + modest_dimming_rule_set_notification (rule, _CS("ckct_ib_nothing_to_delete")); } - + #ifdef MODEST_TOOLKIT_HILDON2 } else if (MODEST_IS_HEADER_WINDOW (win)) { - if (!dimmed) { + if (!dimmed) dimmed = _transfer_mode_enabled (win); - } + if (dimmed) - modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading")); + modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading")); if (!dimmed) { GtkWidget *header_view; @@ -727,7 +729,7 @@ _message_already_sent (ModestMsgViewWindow *view_window) folder = tny_header_get_folder (header); if (folder) { if (modest_tny_folder_guess_folder_type (folder) == - TNY_FOLDER_TYPE_OUTBOX) { + TNY_FOLDER_TYPE_OUTBOX) { ModestTnySendQueueStatus status = modest_tny_all_send_queues_get_msg_status (header); if (status == MODEST_TNY_SEND_QUEUE_UNKNOWN || @@ -751,13 +753,20 @@ modest_ui_dimming_rules_on_delete_msg (ModestWindow *win, gpointer user_data) g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE); rule = MODEST_DIMMING_RULE (user_data); - state = modest_window_get_dimming_state (win); - - /* Check dimmed rule */ + state = modest_window_get_dimming_state (win); + + /* If we're in transfer mode then do not allow to delete messages */ + dimmed = _transfer_mode_enabled (win); + if (dimmed) { + modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading")); + return dimmed; + } + + /* Check dimmed rule */ if (MODEST_IS_MAIN_WINDOW (win)) { - dimmed = _selected_folder_is_empty (MODEST_MAIN_WINDOW(win)); + dimmed = _selected_folder_is_empty (MODEST_MAIN_WINDOW(win)); if (dimmed) - modest_dimming_rule_set_notification (rule, _CS("ckct_ib_nothing_to_delete")); + modest_dimming_rule_set_notification (rule, _CS("ckct_ib_nothing_to_delete")); if (!dimmed) { dimmed = _invalid_msg_selected (MODEST_MAIN_WINDOW(win), FALSE, user_data); } @@ -779,18 +788,15 @@ modest_ui_dimming_rules_on_delete_msg (ModestWindow *win, gpointer user_data) if (dimmed) { gchar *message = NULL; - message = g_strdup_printf(_("mcen_nc_unable_to_delete_n_messages"), + message = g_strdup_printf(_("mcen_nc_unable_to_delete_n_messages"), state->already_opened_msg); modest_dimming_rule_set_notification (rule, message); g_free(message); } - + } } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) { - dimmed = _transfer_mode_enabled (win); - if (dimmed) - modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading")); if (!dimmed) { dimmed = state->any_marked_as_deleted; if (dimmed) { @@ -809,7 +815,7 @@ modest_ui_dimming_rules_on_delete_msg (ModestWindow *win, gpointer user_data) outbox that has been already sent */ if (!dimmed) dimmed = _message_already_sent (MODEST_MSG_VIEW_WINDOW(win)); - + /* The delete button should be dimmed when viewing an attachment, * but should be enabled when viewing a message from the list, * or when viewing a search result. @@ -910,17 +916,21 @@ modest_ui_dimming_rules_on_mark_as_read_msg_in_view (ModestWindow *win, gpointer TnyHeader *header; TnyHeaderFlags flags; gboolean dimmed = FALSE; - + g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW(win), FALSE); g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE); rule = MODEST_DIMMING_RULE (user_data); - + header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win)); if (!header) { dimmed = TRUE; } + /* If the viewer is showing a message sent as attachment */ + if (!dimmed) + dimmed = !modest_msg_view_window_has_headers_model (MODEST_MSG_VIEW_WINDOW (win)); + if (!dimmed) { flags = tny_header_get_flags (header); if (flags & TNY_HEADER_FLAG_SEEN) @@ -951,6 +961,10 @@ modest_ui_dimming_rules_on_mark_as_unread_msg_in_view (ModestWindow *win, gpoint dimmed = TRUE; } + /* If the viewer is showing a message sent as attachment */ + if (!dimmed) + dimmed = !modest_msg_view_window_has_headers_model (MODEST_MSG_VIEW_WINDOW (win)); + if (!dimmed) { flags = tny_header_get_flags (header); if (!(flags & TNY_HEADER_FLAG_SEEN)) @@ -1163,7 +1177,7 @@ modest_ui_dimming_rules_on_header_window_move_to (ModestWindow *win, gpointer us rule = MODEST_DIMMING_RULE (user_data); /* Check dimmed rule */ - dimmed = _transfer_mode_enabled (win); + dimmed = _transfer_mode_enabled (win); if (dimmed) modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading")); @@ -1220,28 +1234,24 @@ modest_ui_dimming_rules_on_paste (ModestWindow *win, gpointer user_data) dimmed = _clipboard_is_empty (win); if (dimmed) modest_dimming_rule_set_notification (rule, - dgettext("hildon-common-strings", - "ecoc_ib_edwin_nothing_to_paste")); + _CS("ecoc_ib_edwin_nothing_to_paste")); if (!dimmed) { dimmed = _selected_folder_is_any_of_type (win, types, 3); if (dimmed) modest_dimming_rule_set_notification (rule, - dgettext("hildon-common-strings", - "ckct_ib_unable_to_paste_here")); + _CS("ckct_ib_unable_to_paste_here")); } if (!dimmed) { dimmed = !_folder_view_has_focus (win); if (dimmed) modest_dimming_rule_set_notification (rule, - dgettext("hildon-common-strings", - "ckct_ib_unable_to_paste_here")); + _CS("ckct_ib_unable_to_paste_here")); } if (!dimmed) { dimmed = _selected_folder_not_writeable (MODEST_MAIN_WINDOW(win), TRUE); if (dimmed) modest_dimming_rule_set_notification (rule, - dgettext("hildon-common-strings", - "ckct_ib_unable_to_paste_here")); + _CS("ckct_ib_unable_to_paste_here")); } if (!dimmed) { dimmed = _selected_folder_is_same_as_source (win); @@ -1364,6 +1374,7 @@ modest_ui_dimming_rules_on_remove_attachments (ModestWindow *win, gpointer user_ modest_dimming_rule_set_notification (rule, _("FIXME:no attachment selected")); } +#ifndef MODEST_TOOLKIT_HILDON2 /* Messages as attachments could not be removed */ if (!dimmed && MODEST_IS_MSG_VIEW_WINDOW (win)) { TnyList *attachments; @@ -1383,6 +1394,7 @@ modest_ui_dimming_rules_on_remove_attachments (ModestWindow *win, gpointer user_ g_object_unref (attachments); } } +#endif if (!dimmed) { @@ -1855,13 +1867,21 @@ modest_ui_dimming_rules_on_send_receive (ModestWindow *win, gpointer user_data) { ModestDimmingRule *rule = NULL; gboolean dimmed = FALSE; - + ModestAccountMgr *mgr; + const gchar* account_name; + g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE); rule = MODEST_DIMMING_RULE (user_data); - - /* Check dimmed rule */ - dimmed = !modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), - TRUE); + mgr = modest_runtime_get_account_mgr(); + + /* Check dimmed rule */ + account_name = modest_window_get_active_account (win); + + if (account_name) + dimmed = modest_account_mgr_account_is_busy (mgr, account_name); + else + dimmed = TRUE; + if (dimmed) modest_dimming_rule_set_notification (rule, _("mcen_nc_no_email_acnts_defined")); @@ -1873,17 +1893,17 @@ modest_ui_dimming_rules_on_send_receive_all (ModestWindow *win, gpointer user_da { ModestDimmingRule *rule = NULL; gboolean dimmed = FALSE; - + g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE); rule = MODEST_DIMMING_RULE (user_data); /* Check dimmed rule */ GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr (), TRUE); - if (g_slist_length (account_names) <= 1) + if (g_slist_length (account_names) < 1) dimmed = TRUE; if (dimmed) modest_dimming_rule_set_notification (rule, _("mcen_nc_no_email_acnts_defined")); - + modest_account_mgr_free_account_names (account_names); if (!dimmed) { @@ -1907,10 +1927,23 @@ modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_dat msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win)); /* Message is loaded asynchronously, so this could happen */ - if (!msg) - return TRUE; + if (!msg) { +#ifdef MODEST_TOOLKIT_HILDON2 + TnyHeader *header; + + header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win)); + if (!header) + return TRUE; - recipients = modest_tny_msg_get_all_recipients_list (msg); + recipients = modest_tny_msg_header_get_all_recipients_list (header); + g_object_unref (header); +#else + return TRUE; +#endif + } else { + recipients = modest_tny_msg_get_all_recipients_list (msg); + g_object_unref (msg); + } has_recipients_to_add = FALSE; for (node = recipients; node != NULL; node = g_slist_next (node)) { @@ -1922,7 +1955,6 @@ modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_dat g_slist_foreach (recipients, (GFunc) g_free, NULL); g_slist_free (recipients); - g_object_unref (msg); return !has_recipients_to_add; } @@ -2507,29 +2539,48 @@ _invalid_attach_selected (ModestWindow *win, TnyIterator *iter; iter = tny_list_create_iterator (attachments); while (!tny_iterator_is_done (iter) && !result) { +#ifdef MODEST_TOOLKIT_HILDON2 + gboolean not_selectable = FALSE; +#endif TnyMimePart *mime_part = TNY_MIME_PART (tny_iterator_get_current (iter)); TnyList *nested_list = tny_simple_list_new (); + tny_mime_part_get_parts (mime_part, nested_list); if (!for_remove && modest_tny_mime_part_is_msg (mime_part)) { TnyMsg *window_msg; window_msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win)); if ((TnyMimePart *) window_msg != mime_part) { selected_messages = TRUE; +#ifdef MODEST_TOOLKIT_HILDON2 + not_selectable = TRUE; +#else result = TRUE; +#endif } g_object_unref (window_msg); } - tny_mime_part_get_parts (mime_part, nested_list); if (!for_remove && tny_list_get_length (nested_list) > 0) { nested_attachments = TRUE; +#ifdef MODEST_TOOLKIT_HILDON2 + not_selectable = TRUE; +#else result = TRUE; +#endif } +#ifdef MODEST_TOOLKIT_HILDON2 + if (not_selectable) + n_selected --; +#endif g_object_unref (nested_list); g_object_unref (mime_part); tny_iterator_next (iter); } g_object_unref (iter); } + + /* No valid attachment available */ + if (n_selected == 0) + result = TRUE; /* Set notifications */ if (result && rule != NULL) { @@ -2868,12 +2919,12 @@ _msgs_send_in_progress (void) cache_mgr = modest_runtime_get_cache_mgr (); send_queue_cache = modest_cache_mgr_get_cache (cache_mgr, MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE); - + g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues); - + for (node = send_queues; node != NULL && !found; node = g_slist_next (node)) { send_queue = MODEST_TNY_SEND_QUEUE (node->data); - + /* Check if msg uid is being processed inside send queue */ if (modest_tny_send_queue_sending_in_progress (send_queue)) { found = TRUE;