[gnome-shell] endSessionDialog: Factor out _updateDescription from _updateContent



commit 7b048fc092771a3f5a4a121d853975cbad9cf177
Author: Alejandro PiÃeiro <apinheiro igalia com>
Date:   Tue Jun 5 11:51:36 2012 +0200

    endSessionDialog: Factor out _updateDescription from _updateContent
    
    _startTimer adds a tweener to implement the description countdown, which
    updates the entire content on each iteration, including the icon. This
    causes a significant impact on performance, especially when accessibility
    is enabled, as it causes a flood of AtkObject:state-change:showing events.
    As the countdown only affects the description, factor out _updateDescription
    and use it in _startTimer, and only do a full update of all contents when
    necessary.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674210

 js/ui/endSessionDialog.js |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index ee0fc82..cd6faa1 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -342,7 +342,7 @@ const EndSessionDialog = new Lang.Class({
         }
     },
 
-    _updateContent: function() {
+    _updateDescription: function() {
         if (this.state != ModalDialog.State.OPENING &&
             this.state != ModalDialog.State.OPENED)
             return;
@@ -352,17 +352,6 @@ const EndSessionDialog = new Lang.Class({
         let subject = dialogContent.subject;
         let description;
 
-        if (this._user.is_loaded && !dialogContent.iconName) {
-            let iconFile = this._user.get_icon_file();
-            if (GLib.file_test(iconFile, GLib.FileTest.EXISTS))
-                this._setIconFromFile(iconFile, dialogContent.iconStyleClass);
-            else
-                this._setIconFromName('avatar-default', dialogContent.iconStyleClass);
-        } else if (dialogContent.iconName) {
-            this._setIconFromName(dialogContent.iconName,
-                                  dialogContent.iconStyleClass);
-        }
-
         if (this._inhibitors.length > 0) {
             this._stopTimer();
             description = dialogContent.inhibitedDescription;
@@ -395,6 +384,27 @@ const EndSessionDialog = new Lang.Class({
         _setLabelText(this._descriptionLabel, description);
     },
 
+    _updateContent: function() {
+        if (this.state != ModalDialog.State.OPENING &&
+            this.state != ModalDialog.State.OPENED)
+            return;
+
+        let dialogContent = DialogContent[this._type];
+
+        if (this._user.is_loaded && !dialogContent.iconName) {
+            let iconFile = this._user.get_icon_file();
+            if (GLib.file_test(iconFile, GLib.FileTest.EXISTS))
+                this._setIconFromFile(iconFile, dialogContent.iconStyleClass);
+            else
+                this._setIconFromName('avatar-default', dialogContent.iconStyleClass);
+        } else if (dialogContent.iconName) {
+            this._setIconFromName(dialogContent.iconName,
+                                  dialogContent.iconStyleClass);
+        }
+
+        this._updateDescription();
+    },
+
     _updateButtons: function() {
         let dialogContent = DialogContent[this._type];
         let buttons = [{ action: Lang.bind(this, this.cancel),
@@ -441,7 +451,7 @@ const EndSessionDialog = new Lang.Class({
                          { _secondsLeft: 0,
                            time: this._secondsLeft,
                            transition: 'linear',
-                           onUpdate: Lang.bind(this, this._updateContent),
+                           onUpdate: Lang.bind(this, this._updateDescription),
                            onComplete: Lang.bind(this, function() {
                                            let dialogContent = DialogContent[this._type];
                                            let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];



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