[gnome-shell] messageTray: Add source actor without count label



commit 598f7508591c1ba039e4086f43c40cdb9e8d6a53
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Fri Feb 14 18:39:32 2014 +0100

    messageTray: Add source actor without count label
    
    Split the current implementation of SourceActor into
    SourceActor and SourceActorWithLabel.
    In this manner we can use source actors withouth count labels,
    required in the screenShield to not clash with the count
    text label.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709275

 js/ui/messageTray.js |   72 +++++++++++++++++++++++++++++--------------------
 1 files changed, 43 insertions(+), 29 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 53e838e..68a2257 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1162,32 +1162,12 @@ const SourceActor = new Lang.Class({
         }));
         this._actorDestroyed = false;
 
-        this._counterLabel = new St.Label({ x_align: Clutter.ActorAlign.CENTER,
-                                            x_expand: true,
-                                            y_align: Clutter.ActorAlign.CENTER,
-                                            y_expand: true });
-
-        this._counterBin = new St.Bin({ style_class: 'summary-source-counter',
-                                        child: this._counterLabel,
-                                        layout_manager: new Clutter.BinLayout() });
-        this._counterBin.hide();
-
-        this._counterBin.connect('style-changed', Lang.bind(this, function() {
-            let themeNode = this._counterBin.get_theme_node();
-            this._counterBin.translation_x = themeNode.get_length('-shell-counter-overlap-x');
-            this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y');
-        }));
-
         this._iconBin = new St.Bin({ width: size,
                                      height: size,
                                      x_fill: true,
                                      y_fill: true });
 
         this.actor.add_actor(this._iconBin);
-        this.actor.add_actor(this._counterBin);
-
-        this._source.connect('count-updated', Lang.bind(this, this._updateCount));
-        this._updateCount();
 
         this._source.connect('icon-updated', Lang.bind(this, this._updateIcon));
         this._updateIcon();
@@ -1211,6 +1191,48 @@ const SourceActor = new Lang.Class({
     _allocate: function(actor, box, flags) {
         // the iconBin should fill our entire box
         this._iconBin.allocate(box, flags);
+    },
+
+    _updateIcon: function() {
+        if (this._actorDestroyed)
+            return;
+
+        if (!this._iconSet)
+            this._iconBin.child = this._source.createIcon(this._size);
+    }
+});
+
+const SourceActorWithLabel = new Lang.Class({
+    Name: 'SourceActorWithLabel',
+    Extends: SourceActor,
+
+    _init: function(source, size) {
+        this.parent(source, size);
+
+        this._counterLabel = new St.Label({ x_align: Clutter.ActorAlign.CENTER,
+                                            x_expand: true,
+                                            y_align: Clutter.ActorAlign.CENTER,
+                                            y_expand: true });
+
+        this._counterBin = new St.Bin({ style_class: 'summary-source-counter',
+                                        child: this._counterLabel,
+                                        layout_manager: new Clutter.BinLayout() });
+        this._counterBin.hide();
+
+        this._counterBin.connect('style-changed', Lang.bind(this, function() {
+            let themeNode = this._counterBin.get_theme_node();
+            this._counterBin.translation_x = themeNode.get_length('-shell-counter-overlap-x');
+            this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y');
+        }));
+
+        this.actor.add_actor(this._counterBin);
+
+        this._source.connect('count-updated', Lang.bind(this, this._updateCount));
+        this._updateCount();
+    },
+
+    _allocate: function(actor, box, flags) {
+        this.parent(actor, box, flags);
 
         let childBox = new Clutter.ActorBox();
 
@@ -1233,14 +1255,6 @@ const SourceActor = new Lang.Class({
         this._counterBin.allocate(childBox, flags);
     },
 
-    _updateIcon: function() {
-        if (this._actorDestroyed)
-            return;
-
-        if (!this._iconSet)
-            this._iconBin.child = this._source.createIcon(this._size);
-    },
-
     _updateCount: function() {
         if (this._actorDestroyed)
             return;
@@ -1353,7 +1367,7 @@ const Source = new Lang.Class({
         if (this._mainIcon)
             return;
 
-        this._mainIcon = new SourceActor(this, this.SOURCE_ICON_SIZE);
+        this._mainIcon = new SourceActorWithLabel(this, this.SOURCE_ICON_SIZE);
     },
 
     // Unlike createIcon, this always returns the same actor;


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