X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-dimming-rules.c;h=b2fa8acba59782f2e2b4adeca69c5d5c1db5e8e1;hp=aaef4602555f151eedc9c80ae47d9fa1b5c4069d;hb=78b5f8e5fce0a1910e85c8a23114bb9826acb692;hpb=b34db34cc6dafa816286e59b364793b5bcdd4c4b diff --git a/src/modest-ui-dimming-rules.c b/src/modest-ui-dimming-rules.c index aaef460..b2fa8ac 100644 --- a/src/modest-ui-dimming-rules.c +++ b/src/modest-ui-dimming-rules.c @@ -70,6 +70,7 @@ static gboolean _msg_download_in_progress (ModestWindow *win); static gboolean _msg_download_completed (ModestMainWindow *win); static gboolean _selected_msg_sent_in_progress (ModestWindow *win); static gboolean _sending_in_progress (ModestWindow *win); +static gboolean _invalid_account_for_purge (ModestWindow *win, ModestDimmingRule *rule); static gboolean _invalid_folder_for_purge (ModestWindow *win, ModestDimmingRule *rule); static gboolean _transfer_mode_enabled (ModestWindow *win); static gboolean _selected_folder_has_subfolder_with_same_name (ModestWindow *win); @@ -1240,6 +1241,11 @@ modest_ui_dimming_rules_on_remove_attachments (ModestWindow *win, gpointer user_ } } + /* cannot purge in pop accounts */ + if (!dimmed) { + dimmed = _invalid_account_for_purge (win, rule); + } + /* cannot purge in editable drafts nor pop folders */ if (!dimmed) { dimmed = _invalid_folder_for_purge (win, rule); @@ -2287,13 +2293,6 @@ _clipboard_is_empty (ModestWindow *win) } static gboolean -_forward_search_image_char (gunichar ch, - gpointer userdata) -{ - return (ch == 0xFFFC); -} - -static gboolean _invalid_clipboard_selected (ModestWindow *win, ModestDimmingRule *rule) { @@ -2310,23 +2309,8 @@ _invalid_clipboard_selected (ModestWindow *win, gboolean has_selection = FALSE; if (GTK_IS_TEXT_VIEW (focused)) { GtkTextBuffer *buffer = NULL; - GtkTextIter start, end; buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused)); - has_selection = gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buffer)); - - /* check there are no images in selection */ - if (has_selection) { - gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer), &start, &end); - if (gtk_text_iter_get_char (&start)== 0xFFFC) - has_selection = FALSE; - else { - gtk_text_iter_backward_char (&end); - if (gtk_text_iter_forward_find_char (&start, _forward_search_image_char, - NULL, &end)) - has_selection = FALSE; - } - - } + has_selection = modest_text_utils_buffer_selection_is_valid (buffer); } else if (GTK_IS_EDITABLE (focused)) { has_selection = gtk_editable_get_selection_bounds (GTK_EDITABLE (focused), NULL, NULL); } @@ -2618,6 +2602,49 @@ _sending_in_progress (ModestWindow *win) } static gboolean +_invalid_account_for_purge (ModestWindow *win, + ModestDimmingRule *rule) +{ + const gchar *account_name; + ModestTnyAccountStore *account_store; + TnyAccount *store_account; + gboolean result = FALSE; + const gchar *protocol_name; + + account_name = modest_window_get_active_account (win); + if (account_name == NULL) + goto frees; + + account_store = modest_runtime_get_account_store (); + store_account = modest_tny_account_store_get_server_account (account_store, account_name, TNY_ACCOUNT_TYPE_STORE); + if (store_account == NULL) + goto frees; + + protocol_name = tny_account_get_proto (store_account); + if (modest_protocol_info_get_transport_store_protocol (protocol_name) == MODEST_PROTOCOL_STORE_POP) { + gint n_selected = 0; + result = TRUE; + + if (MODEST_IS_MSG_VIEW_WINDOW (win)) { + TnyList *attachments; + attachments = modest_msg_view_window_get_attachments (MODEST_MSG_VIEW_WINDOW(win)); + n_selected = tny_list_get_length (attachments); + g_object_unref (attachments); + } + + modest_dimming_rule_set_notification (rule, + ngettext ("mail_ib_unable_to_pure_attach_pop_mail_singular", + "mail_ib_unable_to_pure_attach_pop_mail_plural", + n_selected)); + + } +frees: + if (store_account) + g_object_unref (store_account); + return result; +} + +static gboolean _invalid_folder_for_purge (ModestWindow *win, ModestDimmingRule *rule) {