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);
dimmed = _invalid_msg_selected (MODEST_MAIN_WINDOW(win), FALSE, user_data);
}
if (!dimmed) {
- dimmed = (state->already_opened_msg > 0) ? TRUE : FALSE;
- if (dimmed) {
- gchar *num = NULL, *message = NULL;
-
- num = g_strdup_printf ("%d", state->already_opened_msg);
- message = g_strdup_printf(_("mcen_nc_unable_to_delete_n_messages"), num);
- modest_dimming_rule_set_notification (rule, message);
- g_free(num);
- g_free(message);
- }
-
+ dimmed = state->sent_in_progress;
+ if (dimmed)
+ modest_dimming_rule_set_notification (rule, _CS("ckct_ib_unable_to_delete"));
}
if (!dimmed) {
dimmed = state->any_marked_as_deleted;
}
}
if (!dimmed) {
- dimmed = state->sent_in_progress;
- if (dimmed)
- modest_dimming_rule_set_notification (rule, _CS("ckct_ib_unable_to_delete"));
+ dimmed = (state->already_opened_msg > 0) ? TRUE : FALSE;
+ if (dimmed) {
+ gchar *message = NULL;
+
+ 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)) {
}
}
+ /* 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);
body_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (body_field));
subject = gtk_entry_get_text (GTK_ENTRY (subject_field));
- dimmed = ((subject == NULL || subject[0] == '\0')
- || (gtk_text_buffer_get_char_count(body_buffer) == 0));
+ dimmed = (subject == NULL || subject[0] == '\0');
if (dimmed)
modest_dimming_rule_set_notification (rule, _("mcen_ib_subject_or_body_not_modified"));
}
if (GTK_IS_TEXT_VIEW (focused)) {
GtkTextBuffer *buffer = NULL;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused));
- has_selection = gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buffer));
+ 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);
}
}
static gboolean
+_invalid_account_for_purge (ModestWindow *win,
+ ModestDimmingRule *rule)
+{
+ const gchar *account_name;
+ ModestTnyAccountStore *account_store;
+ TnyAccount *store_account = NULL;
+ 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)
{