[geary] Add folder progress monitor, hook it up to spinner



commit ab4de5e3f6e0d4224937ba20e869c4f2137f6792
Author: Charles Lindsay <chaz yorba org>
Date:   Tue Feb 25 15:28:22 2014 -0800

    Add folder progress monitor, hook it up to spinner
    
    This adds a progress monitor to the folder open operation.  The spinner
    in the status bar is hooked up to it only for the currently selected
    folder, so that background updates don't trigger the spinner.
    
    Closes: bgo #713703

 src/client/components/main-window.vala             |   14 ++++++++++++++
 src/engine/abstract/geary-abstract-folder.vala     |    2 ++
 src/engine/api/geary-folder.vala                   |    2 ++
 .../imap-engine/imap-engine-minimal-folder.vala    |    6 ++++++
 4 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 887bd43..7bce867 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -30,6 +30,7 @@ public class MainWindow : Gtk.ApplicationWindow {
     private MonitoredSpinner spinner = new MonitoredSpinner();
     private Geary.AggregateProgressMonitor progress_monitor = new Geary.AggregateProgressMonitor();
     private Geary.ProgressMonitor? conversation_monitor_progress = null;
+    private Geary.ProgressMonitor? folder_progress = null;
     
     public MainWindow(GearyApplication application) {
         Object(application: application);
@@ -67,6 +68,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         focus_in_event.connect(on_focus_event);
         GearyApplication.instance.controller.notify[GearyController.PROP_CURRENT_CONVERSATION].
             connect(on_conversation_monitor_changed);
+        GearyApplication.instance.controller.folder_selected.connect(on_folder_selected);
         Geary.Engine.instance.account_available.connect(on_account_available);
         Geary.Engine.instance.account_unavailable.connect(on_account_unavailable);
         
@@ -212,6 +214,18 @@ public class MainWindow : Gtk.ApplicationWindow {
         }
     }
     
+    private void on_folder_selected(Geary.Folder? folder) {
+        if (folder_progress != null) {
+            progress_monitor.remove(folder_progress);
+            folder_progress = null;
+        }
+        
+        if (folder != null) {
+            folder_progress = folder.opening_monitor;
+            progress_monitor.add(folder_progress);
+        }
+    }
+    
     private void on_account_available(Geary.AccountInformation account) {
         try {
             progress_monitor.add(Geary.Engine.instance.get_account_instance(account).opening_monitor);
diff --git a/src/engine/abstract/geary-abstract-folder.vala b/src/engine/abstract/geary-abstract-folder.vala
index 2f32387..9ff96b3 100644
--- a/src/engine/abstract/geary-abstract-folder.vala
+++ b/src/engine/abstract/geary-abstract-folder.vala
@@ -5,6 +5,8 @@
  */
 
 public abstract class Geary.AbstractFolder : BaseObject, Geary.Folder {
+    public Geary.ProgressMonitor opening_monitor { get; protected set; }
+    
     /*
      * notify_* methods for AbstractFolder are marked internal because the SendReplayOperations
      * need access to them to report changes as they occur.
diff --git a/src/engine/api/geary-folder.vala b/src/engine/api/geary-folder.vala
index 9fa9e61..c43fce0 100644
--- a/src/engine/api/geary-folder.vala
+++ b/src/engine/api/geary-folder.vala
@@ -145,6 +145,8 @@ public interface Geary.Folder : BaseObject {
     
     public abstract Geary.SpecialFolderType special_folder_type { get; }
     
+    public abstract Geary.ProgressMonitor opening_monitor { get; protected set; }
+    
     /**
      * Fired when the folder is successfully opened by a caller.
      *
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala 
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index 2c65acd..e23528e 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -55,6 +55,8 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
         _special_folder_type = special_folder_type;
         _properties.add(local_folder.get_properties());
         
+        opening_monitor = new Geary.SimpleProgressMonitor(Geary.ProgressType.ACTIVITY);
+        
         email_flag_watcher = new EmailFlagWatcher(this);
         email_flag_watcher.email_flags_changed.connect(on_email_flags_changed);
         
@@ -512,6 +514,8 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
         if (open_count == 0)
             return;
         
+        opening_monitor.notify_start();
+        
         Imap.Folder? opening_folder = null;
         try {
             debug("Fetching information for remote folder %s", to_string());
@@ -601,6 +605,8 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
                 cancellable);
             
             return;
+        } finally {
+            opening_monitor.notify_finish();
         }
         
         // open success, reset reestablishment delay


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