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);
g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
rule = MODEST_DIMMING_RULE (user_data);
+ types[0] = TNY_FOLDER_TYPE_DRAFTS;
+ types[1] = TNY_FOLDER_TYPE_OUTBOX;
+ types[2] = TNY_FOLDER_TYPE_ROOT;
+
+ /* Check dimmed rule */
+ if (!dimmed) {
+ dimmed = _selected_folder_is_any_of_type (win, types, 3);
+ if (dimmed)
+ modest_dimming_rule_set_notification (rule, _("mcen_ib_unable_to_reply"));
+ }
+
/* main window dimming rules */
if (MODEST_IS_MAIN_WINDOW(win)) {
- types[0] = TNY_FOLDER_TYPE_DRAFTS;
- types[1] = TNY_FOLDER_TYPE_OUTBOX;
- types[2] = TNY_FOLDER_TYPE_ROOT;
-
- /* Check dimmed rule */
- if (!dimmed) {
- dimmed = _selected_folder_is_any_of_type (win, types, 3);
- if (dimmed)
- modest_dimming_rule_set_notification (rule, _("mcen_ib_unable_to_reply"));
- }
if (!dimmed) {
dimmed = _selected_folder_is_empty (MODEST_MAIN_WINDOW(win));
if (dimmed)
}
}
+ /* 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);
selection = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
}
} else if (GTK_IS_LABEL (focused)) {
- gint start, end;
- if (gtk_label_get_selection_bounds (GTK_LABEL (focused), &start, &end)) {
- const gchar *start_offset;
- start_offset = gtk_label_get_text (GTK_LABEL (focused));
- start_offset = g_utf8_offset_to_pointer (start_offset, start);
- selection = g_new0 (gchar, end - start + 1);
- g_utf8_strncpy (selection, start_offset, end - start);
- }
+ selection = modest_text_utils_label_get_selection (GTK_LABEL (focused));
} else {
gboolean do_check = TRUE;
GtkClipboard *clipboard;
/* free */
- g_object_unref (folder);
+ if (folder)
+ g_object_unref (folder);
return result;
}
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;
+ 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)
{