[gnome-shell/gbsneto/remove-generic-container: 25/39] messageTray: Drop Shell.GenericContainer usage



commit 75bd2aa2dc8c2bcd4a05db8e452e2853665b26ea
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jul 6 10:55:23 2018 +0200

    messageTray: Drop Shell.GenericContainer usage
    
    Nothing particularly outstanding with this class - it was
    a straightforward removal and subclassing.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153

 js/ui/messageTray.js  | 38 ++++++++++++--------------------------
 js/ui/screenShield.js |  4 ++--
 2 files changed, 14 insertions(+), 28 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 75740c6c0..c0766566c 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -587,16 +587,16 @@ var NotificationBanner = new Lang.Class({
 
 var SourceActor = new Lang.Class({
     Name: 'SourceActor',
+    Extends: St.Widget,
 
     _init(source, size) {
+        this.parent();
+
         this._source = source;
         this._size = size;
 
-        this.actor = new Shell.GenericContainer();
-        this.actor.connect('get-preferred-width', this._getPreferredWidth.bind(this));
-        this.actor.connect('get-preferred-height', this._getPreferredHeight.bind(this));
-        this.actor.connect('allocate', this._allocate.bind(this));
-        this.actor.connect('destroy', () => {
+        this.actor = this;
+        this.connect('destroy', () => {
             this._source.disconnect(this._iconUpdatedId);
             this._actorDestroyed = true;
         });
@@ -604,10 +604,11 @@ var SourceActor = new Lang.Class({
 
         let scale_factor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
         this._iconBin = new St.Bin({ x_fill: true,
+                                     x_expand: true,
                                      height: size * scale_factor,
                                      width: size * scale_factor });
 
-        this.actor.add_actor(this._iconBin);
+        this.add_actor(this._iconBin);
 
         this._iconUpdatedId = this._source.connect('icon-updated', this._updateIcon.bind(this));
         this._updateIcon();
@@ -618,21 +619,6 @@ var SourceActor = new Lang.Class({
         this._iconSet = true;
     },
 
-    _getPreferredWidth(actor, forHeight, alloc) {
-        let [min, nat] = this._iconBin.get_preferred_width(forHeight);
-        alloc.min_size = min; alloc.nat_size = nat;
-    },
-
-    _getPreferredHeight(actor, forWidth, alloc) {
-        let [min, nat] = this._iconBin.get_preferred_height(forWidth);
-        alloc.min_size = min; alloc.nat_size = nat;
-    },
-
-    _allocate(actor, box, flags) {
-        // the iconBin should fill our entire box
-        this._iconBin.allocate(box, flags);
-    },
-
     _updateIcon() {
         if (this._actorDestroyed)
             return;
@@ -665,23 +651,23 @@ var SourceActorWithLabel = new Lang.Class({
             this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y');
         });
 
-        this.actor.add_actor(this._counterBin);
+        this.add_actor(this._counterBin);
 
         this._countUpdatedId = this._source.connect('count-updated', this._updateCount.bind(this));
         this._updateCount();
 
-        this.actor.connect('destroy', () => {
+        this.connect('destroy', () => {
             this._source.disconnect(this._countUpdatedId);
         });
     },
 
-    _allocate(actor, box, flags) {
-        this.parent(actor, box, flags);
+    vfunc_allocate(box, flags) {
+        this.parent(box, flags);
 
         let childBox = new Clutter.ActorBox();
 
         let [minWidth, minHeight, naturalWidth, naturalHeight] = this._counterBin.get_preferred_size();
-        let direction = this.actor.get_text_direction();
+        let direction = this.get_text_direction();
 
         if (direction == Clutter.TextDirection.LTR) {
             // allocate on the right in LTR
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index dee290b36..7004c93dd 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -150,7 +150,7 @@ var NotificationsBox = new Lang.Class({
 
     _makeNotificationSource(source, box) {
         let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
-        box.add(sourceActor.actor, { y_fill: true });
+        box.add(sourceActor, { y_fill: true });
 
         let textBox = new St.BoxLayout({ vertical: true });
         box.add(textBox, { y_fill: false, y_align: St.Align.START });
@@ -172,7 +172,7 @@ var NotificationsBox = new Lang.Class({
         let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
         let sourceBin = new St.Bin({ y_align: St.Align.START,
                                      x_align: St.Align.START,
-                                     child: sourceActor.actor });
+                                     child: sourceActor });
         box.add(sourceBin);
 
         let textBox = new St.BoxLayout({ vertical: true });


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