[geary/geary-0.12] Reduce CPU use when idle.



commit 1e8b265de346816b877abd842d7bea8687d0f18f
Author: Michael James Gratton <mike vee net>
Date:   Mon Apr 9 12:31:39 2018 +1000

    Reduce CPU use when idle.
    
    It looks like Gtk.Spinner triggers repaints when running, even when the
    widget is not visible. This ensures the conversation is stopped when not
    visible.
    
    Fix for Bug 783025.
    
    * src/client/conversation-viewer/conversation-viewer.vala
      (ConversationViewer): Start the conversation spinner when showing it,
      stop the conversation spinner when it is hidden.

 .../conversation-viewer/conversation-viewer.vala   |   21 +++++++++++++------
 ui/conversation-viewer.ui                          |    1 -
 2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index a941929..7fde896 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -154,6 +154,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
      * Shows the loading UI.
      */
     public void show_loading() {
+        this.loading_page.start();
         set_visible_child(this.loading_page);
     }
 
@@ -294,13 +295,19 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
      */
     private new void set_visible_child(Gtk.Widget widget) {
         debug("Showing: %s", widget.get_name());
-        if (widget != this.conversation_page &&
-            get_visible_child() == this.conversation_page) {
-            // By removing the current list, any load it is currently
-            // performing is also cancelled, which is important to
-            // avoid a possible crit warning when switching folders,
-            // etc.
-            remove_current_list();
+        Gtk.Widget current = get_visible_child();
+        if (current == this.conversation_page) {
+            if (widget != this.conversation_page) {
+                // By removing the current list, any load it is currently
+                // performing is also cancelled, which is important to
+                // avoid a possible crit warning when switching folders,
+                // etc.
+                remove_current_list();
+            }
+        } else if (current == this.loading_page) {
+            // Stop the spinner running so it doesn't trigger repaints
+            // and wake up Geary even when idle. See Bug 783025.
+            this.loading_page.stop();
         }
         base.set_visible_child(widget);
     }
diff --git a/ui/conversation-viewer.ui b/ui/conversation-viewer.ui
index b67be0e..a47567a 100644
--- a/ui/conversation-viewer.ui
+++ b/ui/conversation-viewer.ui
@@ -15,7 +15,6 @@
         <property name="can_focus">False</property>
         <property name="halign">center</property>
         <property name="valign">center</property>
-        <property name="active">True</property>
       </object>
       <packing>
         <property name="name">loading_page</property>


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