[geary/wip/trash-714212: 1/4] First stab at separate archive/trash/delete actions
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/trash-714212: 1/4] First stab at separate archive/trash/delete actions
- Date: Thu, 19 Dec 2013 01:41:02 +0000 (UTC)
commit 1b60d41ddd5813ce3f3ec8edfeb9c3eba4abecf9
Author: Charles Lindsay <chaz yorba org>
Date: Tue Dec 17 17:16:36 2013 -0800
First stab at separate archive/trash/delete actions
Still need to deal with the toolbar.
src/client/application/geary-controller.vala | 114 +++++++++++++++++---------
src/client/components/main-toolbar.vala | 3 +-
2 files changed, 78 insertions(+), 39 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 1cbed51..9a28f7e 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -15,6 +15,8 @@ public class GearyController : Geary.BaseObject {
public const string ACTION_REPLY_TO_MESSAGE = "GearyReplyToMessage";
public const string ACTION_REPLY_ALL_MESSAGE = "GearyReplyAllMessage";
public const string ACTION_FORWARD_MESSAGE = "GearyForwardMessage";
+ public const string ACTION_ARCHIVE_MESSAGE = "GearyArchiveMessage";
+ public const string ACTION_TRASH_MESSAGE = "GearyTrashMessage";
public const string ACTION_DELETE_MESSAGE = "GearyDeleteMessage";
public const string ACTION_FIND_IN_CONVERSATION = "GearyFindInConversation";
public const string ACTION_FIND_NEXT_IN_CONVERSATION = "GearyFindNextInConversation";
@@ -40,13 +42,19 @@ public class GearyController : Geary.BaseObject {
public const int MIN_CONVERSATION_COUNT = 50;
private const string DELETE_MESSAGE_LABEL = _("_Delete");
- private const string DELETE_MESSAGE_TOOLTIP_SINGLE = _("Delete conversation (Delete, Backspace, A)");
- private const string DELETE_MESSAGE_TOOLTIP_MULTIPLE = _("Delete conversations (Delete, Backspace, A)");
+ private const string DELETE_MESSAGE_TOOLTIP_SINGLE = _("Delete conversation (Shitf+Delete)");
+ private const string DELETE_MESSAGE_TOOLTIP_MULTIPLE = _("Delete conversations (Shift+Delete)");
+ // TODO
private const string DELETE_MESSAGE_ICON_NAME = "user-trash-symbolic";
+ private const string TRASH_MESSAGE_LABEL = _("_Trash");
+ private const string TRASH_MESSAGE_TOOLTIP_SINGLE = _("Move conversation to trash (Delete, Backspace)");
+ private const string TRASH_MESSAGE_TOOLTIP_MULTIPLE = _("Move conversations to trash (Delete,
Backspace)");
+ private const string TRASH_MESSAGE_ICON_NAME = "user-trash-symbolic";
+
private const string ARCHIVE_MESSAGE_LABEL = _("_Archive");
- private const string ARCHIVE_MESSAGE_TOOLTIP_SINGLE = _("Archive conversation (Delete, Backspace, A)");
- private const string ARCHIVE_MESSAGE_TOOLTIP_MULTIPLE = _("Archive conversations (Delete, Backspace,
A)");
+ private const string ARCHIVE_MESSAGE_TOOLTIP_SINGLE = _("Archive conversation (A)");
+ private const string ARCHIVE_MESSAGE_TOOLTIP_MULTIPLE = _("Archive conversations (A)");
private const string ARCHIVE_MESSAGE_ICON_NAME = "archive-symbolic";
private const string MARK_AS_SPAM_LABEL = _("Mark as S_pam");
@@ -338,14 +346,24 @@ public class GearyController : Geary.BaseObject {
null, null, "<Shift><Ctrl>G", null, on_find_previous_in_conversation_action };
entries += find_previous_in_conversation;
- // although this action changes according to Geary.Folder capabilities, set to Archive
+ Gtk.ActionEntry archive_message = { ACTION_ARCHIVE_MESSAGE, ARCHIVE_MESSAGE_ICON_NAME,
+ ARCHIVE_MESSAGE_LABEL, "A", null, on_archive_message };
+ archive_message.tooltip = ARCHIVE_MESSAGE_TOOLTIP_SINGLE;
+ entries += archive_message;
+
+ // although this action changes according to the account's capabilities, set to Delete
// until they're known so the "translatable" string doesn't first appear
- Gtk.ActionEntry delete_message = { ACTION_DELETE_MESSAGE, ARCHIVE_MESSAGE_ICON_NAME,
- ARCHIVE_MESSAGE_LABEL, "A", null, on_delete_message };
- delete_message.tooltip = ARCHIVE_MESSAGE_TOOLTIP_SINGLE;
+ Gtk.ActionEntry trash_message = { ACTION_TRASH_MESSAGE, TRASH_MESSAGE_ICON_NAME,
+ TRASH_MESSAGE_LABEL, "Delete", null, on_trash_message };
+ trash_message.tooltip = TRASH_MESSAGE_TOOLTIP_SINGLE;
+ entries += trash_message;
+ add_accelerator("BackSpace", ACTION_TRASH_MESSAGE);
+
+ Gtk.ActionEntry delete_message = { ACTION_DELETE_MESSAGE, DELETE_MESSAGE_ICON_NAME,
+ DELETE_MESSAGE_LABEL, "<Shift>Delete", null, on_delete_message };
+ delete_message.tooltip = DELETE_MESSAGE_TOOLTIP_SINGLE;
entries += delete_message;
- add_accelerator("Delete", ACTION_DELETE_MESSAGE);
- add_accelerator("BackSpace", ACTION_DELETE_MESSAGE);
+ add_accelerator("<Shift>BackSpace", ACTION_DELETE_MESSAGE);
Gtk.ActionEntry zoom_in = { ACTION_ZOOM_IN, null, null, "<Ctrl>equal",
null, on_zoom_in };
@@ -1829,54 +1847,74 @@ public class GearyController : Geary.BaseObject {
main_window.conversation_viewer.find(false);
}
- // This method is used for both removing and archive a message; currently Geary only supports
- // one or the other in a folder
+ private void on_archive_message() {
+ archive_or_delete_selection_async.begin(true, false, cancellable_folder,
+ on_archive_or_delete_selection_finished);
+ }
+
+ private void on_trash_message() {
+ archive_or_delete_selection_async.begin(false, true, cancellable_folder,
+ on_archive_or_delete_selection_finished);
+ }
+
private void on_delete_message() {
- // Prevent deletes of the same conversation from repeating.
+ archive_or_delete_selection_async.begin(false, false, cancellable_folder,
+ on_archive_or_delete_selection_finished);
+ }
+
+ private async void archive_or_delete_selection_async(bool archive, bool trash,
+ Cancellable? cancellable) throws Error {
if (main_window.conversation_viewer.current_conversation != null
&& main_window.conversation_viewer.current_conversation == last_deleted_conversation) {
- debug("not archiving/deleting, viewed conversation is last deleted conversation");
-
+ debug("Not archiving/trashing/deleting; viewed conversation is last deleted conversation");
return;
}
- // There should always be at least one conversation selected here, otherwise the archive
- // button is disabled, but better safe than segfaulted.
last_deleted_conversation = selected_conversations.size > 0
- ? Geary.Collection.get_first<Geary.App.Conversation>(selected_conversations) : null;
+ ? Geary.traverse<Geary.App.Conversation>(selected_conversations).first() : null;
- // If the user clicked the toolbar button, we want to move focus back to the message list.
+ // Return focus to the conversation list from the clicked toolbar button.
main_window.conversation_list_view.grab_focus();
- delete_messages.begin(get_selected_email_ids(false), cancellable_folder,
on_delete_messages_completed);
- }
-
- // This method is used for both removing and archive a message; currently Geary only supports
- // one or the other in a folder. This will try archiving first, then remove.
- private async void delete_messages(Gee.List<Geary.EmailIdentifier> ids, Cancellable? cancellable)
- throws Error {
- Geary.FolderSupport.Archive? supports_archive = current_folder as Geary.FolderSupport.Archive;
- if (supports_archive != null) {
- yield supports_archive.archive_email_async(ids, cancellable);
+ Gee.List<Geary.EmailIdentifier> ids = get_selected_email_ids(false);
+ if (archive) {
+ debug("Archiving selected messages");
+ Geary.FolderSupport.Archive? supports_archive = current_folder as Geary.FolderSupport.Archive;
+ if (supports_archive == null)
+ debug("Folder %s doesn't support archive", current_folder.to_string());
+ else
+ yield supports_archive.archive_email_async(ids, cancellable);
return;
}
- Geary.FolderSupport.Remove? supports_remove = current_folder as Geary.FolderSupport.Remove;
- if (supports_remove != null) {
- yield supports_remove.remove_email_async(ids, cancellable);
+ if (trash) {
+ debug("Trashing selected messages");
+ Geary.FolderSupport.Move? supports_move = current_folder as Geary.FolderSupport.Move;
+ Geary.Folder? trash_folder = current_account.get_special_folder(Geary.SpecialFolderType.TRASH);
+ if (supports_move == null || trash_folder == null)
+ debug("Folder %s doesn't support move or account %s doesn't have a trash folder",
+ current_folder.to_string(), current_account.to_string());
+ else
+ yield supports_move.move_email_async(ids, trash_folder.path, cancellable);
return;
}
- debug("Folder %s supports neither remove nor archive", current_folder.to_string());
+ debug("Deleting selected messages");
+
+ Geary.FolderSupport.Remove? supports_remove = current_folder as Geary.FolderSupport.Remove;
+ if (supports_remove == null)
+ debug("Folder %s doesn't support remove", current_folder.to_string());
+ else
+ yield supports_remove.remove_email_async(ids, cancellable);
}
-
- private void on_delete_messages_completed(Object? source, AsyncResult result) {
+
+ private void on_archive_or_delete_selection_finished(Object? source, AsyncResult result) {
try {
- delete_messages.end(result);
- } catch (Error err) {
- debug("Error, unable to delete messages: %s", err.message);
+ archive_or_delete_selection_async.end(result);
+ } catch (Error e) {
+ debug("Unable to archive/trash/delete messages: %s", e.message);
}
}
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index b8fc3ce..0a8feee 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -64,7 +64,8 @@ public class MainToolbar : PillToolbar {
// Archive/delete button.
// For this button, the controller sets the tooltip and icon depending on the context.
insert.clear();
- insert.add(create_toolbar_button("", GearyController.ACTION_DELETE_MESSAGE, true));
+ insert.add(create_toolbar_button("", GearyController.ACTION_ARCHIVE_MESSAGE, true));
+ insert.add(create_toolbar_button("", GearyController.ACTION_TRASH_MESSAGE, true));
add(create_pill_buttons(insert));
// Spacer.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]