[geary/wip/714809-empty] Plumbing in the UI layer



commit a15ccb74d74b148dc39aa5ea8e81c0e14c572533
Author: Jim Nelson <jim yorba org>
Date:   Mon Jan 12 18:53:35 2015 -0800

    Plumbing in the UI layer

 src/client/application/geary-controller.vala       |   43 +++++++++++++++++++-
 src/client/components/main-toolbar.vala            |   12 ++++-
 src/client/dialogs/alert-dialog.vala               |    2 +-
 .../imap-engine-account-synchronizer.vala          |    2 +-
 ui/CMakeLists.txt                                  |    1 +
 ui/toolbar_empty_menu.ui                           |    7 +++
 6 files changed, 60 insertions(+), 7 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 39f5c75..33404ea 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -30,6 +30,9 @@ public class GearyController : Geary.BaseObject {
     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_EMPTY_MENU = "GearyEmptyMenu";
+    public const string ACTION_EMPTY_SPAM = "GearyEmptySpam";
+    public const string ACTION_EMPTY_TRASH = "GearyEmptyTrash";
     public const string ACTION_FIND_IN_CONVERSATION = "GearyFindInConversation";
     public const string ACTION_FIND_NEXT_IN_CONVERSATION = "GearyFindNextInConversation";
     public const string ACTION_FIND_PREVIOUS_IN_CONVERSATION = "GearyFindPreviousInConversation";
@@ -358,7 +361,7 @@ public class GearyController : Geary.BaseObject {
         add_accelerator("F", ACTION_FORWARD_MESSAGE);
         
         Gtk.ActionEntry find_in_conversation = { ACTION_FIND_IN_CONVERSATION, null, null, "<Ctrl>F",
-        null, on_find_in_conversation_action };
+            null, on_find_in_conversation_action };
         entries += find_in_conversation;
         add_accelerator("slash", ACTION_FIND_IN_CONVERSATION);
         
@@ -388,7 +391,21 @@ public class GearyController : Geary.BaseObject {
         delete_message.tooltip = DELETE_MESSAGE_TOOLTIP_SINGLE;
         entries += delete_message;
         add_accelerator("<Shift>BackSpace", ACTION_DELETE_MESSAGE);
-
+        
+        Gtk.ActionEntry empty_menu = { ACTION_EMPTY_MENU, "edit-clear-all-symbolic", null, null,
+            null, null };
+        empty_menu.label = _("Empty");
+        empty_menu.tooltip = _("Empty Spam or Trash folders");
+        entries += empty_menu;
+        
+        Gtk.ActionEntry empty_spam = { ACTION_EMPTY_SPAM, null, null, null, null, on_empty_spam };
+        empty_spam.label = _("Empty _Spam…");
+        entries += empty_spam;
+        
+        Gtk.ActionEntry empty_trash = { ACTION_EMPTY_TRASH, null, null, null, null, on_empty_trash };
+        empty_trash.label = _("Empty _Trash…");
+        entries += empty_trash;
+        
         Gtk.ActionEntry zoom_in = { ACTION_ZOOM_IN, null, null, "<Ctrl>equal",
             null, on_zoom_in };
         entries += zoom_in;
@@ -2257,6 +2274,28 @@ public class GearyController : Geary.BaseObject {
             on_archive_or_delete_selection_finished);
     }
     
+    private void on_empty_spam() {
+        on_empty_trash_or_spam(Geary.SpecialFolderType.SPAM,
+            _("Empty all email from your Spam folder?"), _("Empty Spam"));
+    }
+    
+    private void on_empty_trash() {
+        on_empty_trash_or_spam(Geary.SpecialFolderType.TRASH,
+            _("Empty all email from your Trash folder?"), _("Empty Trash"));
+    }
+    
+    private void on_empty_trash_or_spam(Geary.SpecialFolderType special_folder_type, string primary_q,
+        string ok_text) {
+        ConfirmationDialog dialog = new ConfirmationDialog(main_window, primary_q,
+            _("This removes the email from Geary and your email server.")
+                + _("  <b>") + _("This cannot be undone.") + _("</b>"),
+            ok_text);
+        dialog.use_secondary_markup(true);
+        dialog.set_focus_response(Gtk.ResponseType.CANCEL);
+        
+        dialog.run();
+    }
+    
     private bool current_folder_supports_trash() {
         return (current_folder != null && current_folder.special_folder_type != Geary.SpecialFolderType.TRASH
             && !current_folder.properties.is_local_only && current_account != null
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index 4f0a960..56eb493 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -61,6 +61,11 @@ public class MainToolbar : PillHeaderbar {
         insert.add(create_menu_button("folder-symbolic", move_folder_menu, 
GearyController.ACTION_MOVE_MENU));
         add_start(create_pill_buttons(insert));
         
+        // Assemble the empty menu
+        GearyApplication.instance.load_ui_file("toolbar_empty_menu.ui");
+        Gtk.Menu empty_menu = (Gtk.Menu) 
GearyApplication.instance.ui_manager.get_widget("/ui/ToolbarEmptyMenu");
+        empty_menu.foreach(GtkUtil.show_menuitem_accel_labels);
+        
         // The toolbar looks bad when you hide one of a pair of pill buttons.
         // Unfortunately, this means we have to have one pair for archive/trash
         // and one single button for just trash, for when the archive button is
@@ -68,7 +73,8 @@ public class MainToolbar : PillHeaderbar {
         insert.clear();
         insert.add(archive_button = create_toolbar_button(null, GearyController.ACTION_ARCHIVE_MESSAGE, 
true));
         insert.add(trash_buttons[0] = create_toolbar_button(null, GearyController.ACTION_TRASH_MESSAGE, 
true));
-        Gtk.Box trash_archive = create_pill_buttons(insert);
+        insert.add(create_menu_button(null, empty_menu, GearyController.ACTION_EMPTY_MENU));
+        Gtk.Box trash_archive_empty = create_pill_buttons(insert);
         insert.clear();
         insert.add(trash_buttons[1] = create_toolbar_button(null, GearyController.ACTION_TRASH_MESSAGE, 
true));
         Gtk.Box trash = create_pill_buttons(insert, false);
@@ -88,7 +94,7 @@ public class MainToolbar : PillHeaderbar {
         
         // pack_end() ordering is reversed in GtkHeaderBar in 3.12 and above
 #if !GTK_3_12
-        add_end(trash_archive);
+        add_end(trash_archive_empty);
         add_end(trash);
         add_end(search_upgrade_progress_bar);
         add_end(search_entry);
@@ -106,7 +112,7 @@ public class MainToolbar : PillHeaderbar {
         add_end(search_entry);
         add_end(search_upgrade_progress_bar);
         add_end(trash);
-        add_end(trash_archive);
+        add_end(trash_archive_empty);
 #endif
         
         set_search_placeholder_text(DEFAULT_SEARCH_TEXT);
diff --git a/src/client/dialogs/alert-dialog.vala b/src/client/dialogs/alert-dialog.vala
index 1675d38..98abb33 100644
--- a/src/client/dialogs/alert-dialog.vala
+++ b/src/client/dialogs/alert-dialog.vala
@@ -35,7 +35,7 @@ class AlertDialog : Object {
     }
 
     public void set_focus_response(Gtk.ResponseType response) {
-        Gtk.Widget? to_focus = dialog.get_widget_for_response(Gtk.ResponseType.OK);
+        Gtk.Widget? to_focus = dialog.get_widget_for_response(response);
         if (to_focus != null)
             to_focus.grab_focus();
     }
diff --git a/src/engine/imap-engine/imap-engine-account-synchronizer.vala 
b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
index 5b8ef8b..66d6aa3 100644
--- a/src/engine/imap-engine/imap-engine-account-synchronizer.vala
+++ b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
@@ -6,7 +6,7 @@
 
 private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
     private const int FETCH_DATE_RECEIVED_CHUNK_COUNT = 25;
-    private const int SYNC_DELAY_SEC = 2;
+    private const int SYNC_DELAY_SEC = 10;
     
     public GenericAccount account { get; private set; }
     
diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt
index cdf0f7b..bb1329f 100644
--- a/ui/CMakeLists.txt
+++ b/ui/CMakeLists.txt
@@ -14,6 +14,7 @@ install(FILES message.glade DESTINATION ${UI_DEST})
 install(FILES password-dialog.glade DESTINATION ${UI_DEST})
 install(FILES preferences.glade DESTINATION ${UI_DEST})
 install(FILES remove_confirm.glade DESTINATION ${UI_DEST})
+install(FILES toolbar_empty_menu.ui DESTINATION ${UI_DEST})
 install(FILES toolbar_mark_menu.ui DESTINATION ${UI_DEST})
 install(FILES toolbar_menu.ui DESTINATION ${UI_DEST})
 install(FILES upgrade_dialog.glade DESTINATION ${UI_DEST})
diff --git a/ui/toolbar_empty_menu.ui b/ui/toolbar_empty_menu.ui
new file mode 100644
index 0000000..cfc89bb
--- /dev/null
+++ b/ui/toolbar_empty_menu.ui
@@ -0,0 +1,7 @@
+<ui>
+    <popup name="ToolbarEmptyMenu">
+        <menuitem name="EmptySpam" action="GearyEmptySpam" />
+        <menuitem name="EmptyTrash" action="GearyEmptyTrash" />
+    </popup>
+</ui>
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]