[gnome-shell/wip/fmuellner/notification-redux+sass: 60/61] separator: Don't draw anything when missing style properties



commit 4b36d871f47f6563491d2104ff1287ef93e8b848
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 19 02:46:46 2015 +0100

    separator: Don't draw anything when missing style properties
    
    Shuts up a couple of warnings

 js/ui/separator.js |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/separator.js b/js/ui/separator.js
index 1de1d89..727bb68 100644
--- a/js/ui/separator.js
+++ b/js/ui/separator.js
@@ -9,7 +9,25 @@ const HorizontalSeparator = new Lang.Class({
 
     _init: function (params) {
         this.actor = new St.DrawingArea(params);
-        this.actor.connect('repaint', Lang.bind(this, this._onRepaint));
+        this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged));
+        this._repaintId = 0;
+        this._gradientHeight = 0;
+    },
+
+    _onStyleChanged: function() {
+        let themeNode = this.actor.get_theme_node();
+        let [found, height] = themeNode.lookup_length('gradient-height', false);
+
+        if ((found && this._repaintId != 0) ||
+            (!found && this._repaintId == 0))
+            return;
+
+        if (found) {
+            this._repaintId = this.actor.connect('repaint', Lang.bind(this, this._onRepaint));
+        } else {
+            this.actor.disconnect(this._repaintId);
+            this._repaintId = 0;
+        }
     },
 
     _onRepaint: function(area) {


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