[sushi/wip/cosimoc/no-clutter: 15/66] fallbackRenderer: move function into only caller



commit 53a172eb5a5ccdcddc6b41cc1f54b68f2a265147
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Apr 3 12:40:58 2017 -0700

    fallbackRenderer: move function into only caller

 src/js/ui/fallbackRenderer.js | 28 +++++++++++++++++++++++++---
 src/js/ui/utils.js            | 26 --------------------------
 2 files changed, 25 insertions(+), 29 deletions(-)
---
diff --git a/src/js/ui/fallbackRenderer.js b/src/js/ui/fallbackRenderer.js
index 9e9bfbe..b1e7747 100644
--- a/src/js/ui/fallbackRenderer.js
+++ b/src/js/ui/fallbackRenderer.js
@@ -48,8 +48,8 @@ var FallbackRenderer = new Lang.Class({
 
     prepare : function(file, mainWindow, callback) {
         this._mainWindow = mainWindow;
-        this.lastWidth = 0;
-        this.lastHeight = 0;
+        this._lastWidth = 0;
+        this._lastHeight = 0;
 
         this._fileLoader = new Sushi.FileLoader();
         this._fileLoader.file = file;
@@ -159,6 +159,28 @@ var FallbackRenderer = new Lang.Class({
     },
 
     getSizeForAllocation : function(allocation) {
-        return Utils.getStaticSize(this, this._box);
+        let width = this._box.get_preferred_width()[1];
+        let height = this._box.get_preferred_height()[1];
+
+        if (width < Constants.VIEW_MIN &&
+            height < Constants.VIEW_MIN) {
+            width = Constants.VIEW_MIN;
+        }
+
+        /* never make it shrink; this could happen when the
+         * spinner hides.
+         */
+        if (width < this._lastWidth)
+            width = this._lastWidth;
+        else
+            this._lastWidth = width;
+
+        if (height < this._lastHeight)
+            height = this._lastHeight;
+        else
+            this._lastHeight = height;
+
+        /* return the natural */
+        return [width, height];
     }
 });
diff --git a/src/js/ui/utils.js b/src/js/ui/utils.js
index 0e5efdf..c400d0f 100644
--- a/src/js/ui/utils.js
+++ b/src/js/ui/utils.js
@@ -69,32 +69,6 @@ function getScaledSize(baseSize, allocSize, upscale) {
     return [ Math.floor(width), Math.floor(height) ];
 }
 
-function getStaticSize(renderer, widget) {
-    let width = widget.get_preferred_width()[1];
-    let height = widget.get_preferred_height()[1];
-
-    if (width < Constants.VIEW_MIN &&
-        height < Constants.VIEW_MIN) {
-        width = Constants.VIEW_MIN;
-    }
-
-    /* never make it shrink; this could happen when the
-     * spinner hides.
-     */
-    if (width < renderer.lastWidth)
-        width = renderer.lastWidth;
-    else
-        renderer.lastWidth = width;
-
-    if (height < renderer.lastHeight)
-        height = renderer.lastHeight;
-    else
-        renderer.lastHeight = height;
-
-    /* return the natural */
-    return [ width, height ];
-}
-
 function createToolButton(iconName, callback) {
     let button = new Gtk.ToolButton({ expand: false,
                                       icon_name: iconName });


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