[gnome-shell] overview: Move the group construction to the controls manager



commit 8772edcd3368f62b44a3e4f8b6f7bcff7e519270
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Feb 25 18:05:45 2013 -0500

    overview: Move the group construction to the controls manager
    
    Instead of creating a bunch of random actors and then passing
    them off to the controls manager, let the controls manager
    construct them. This leaves the controls manager in charge
    of the ordeal.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694469

 js/ui/overview.js         | 37 ++++--------------------------
 js/ui/overviewControls.js | 58 ++++++++++++++++++++++++++++++++---------------
 2 files changed, 45 insertions(+), 50 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index a6ed7fd..ee2c076 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -11,7 +11,6 @@ const Shell = imports.gi.Shell;
 const Gdk = imports.gi.Gdk;
 
 const Background = imports.ui.background;
-const Dash = imports.ui.dash;
 const DND = imports.ui.dnd;
 const LayoutManager = imports.ui.layout;
 const Main = imports.ui.main;
@@ -20,8 +19,6 @@ const OverviewControls = imports.ui.overviewControls;
 const Panel = imports.ui.panel;
 const Params = imports.misc.params;
 const Tweener = imports.ui.tweener;
-const ViewSelector = imports.ui.viewSelector;
-const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
 
 // Time for initial animation going into Overview mode
 const ANIMATION_TIME = 0.25;
@@ -133,14 +130,6 @@ const Overview = new Lang.Class({
                                             y_expand: true });
         this._overview._delegate = this;
 
-        this._groupStack = new St.Widget({ layout_manager: new Clutter.BinLayout(),
-                                           x_expand: true, y_expand: true,
-                                           clip_to_allocation: true });
-        this._group = new St.BoxLayout({ name: 'overview-group',
-                                         reactive: true,
-                                         x_expand: true, y_expand: true });
-        this._groupStack.add_actor(this._group);
-
         this._backgroundGroup = new Meta.BackgroundGroup();
         global.overlay_group.add_child(this._backgroundGroup);
         this._backgroundGroup.hide();
@@ -177,7 +166,6 @@ const Overview = new Lang.Class({
         Main.xdndHandler.connect('drag-end', Lang.bind(this, this._onDragEnd));
 
         global.screen.connect('restacked', Lang.bind(this, this._onRestacked));
-        this._group.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
 
         this._windowSwitchTimeoutId = 0;
         this._windowSwitchTimestamp = 0;
@@ -276,28 +264,13 @@ const Overview = new Lang.Class({
         this._overview.add_actor(this._searchEntryBin);
 
         // Create controls
-        this._dash = new Dash.Dash();
-        this._viewSelector = new ViewSelector.ViewSelector(this._searchEntry,
-                                                           this._dash.showAppsButton);
-        this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
-        this._controls = new OverviewControls.ControlsManager(this._dash,
-                                                              this._thumbnailsBox,
-                                                              this._viewSelector);
-
-        this._controls.dashActor.x_align = Clutter.ActorAlign.START;
-        this._controls.dashActor.y_expand = true;
-
-        // Put the dash in a separate layer to allow content to be centered
-        this._groupStack.add_actor(this._controls.dashActor);
-
-        // Pack all the actors into the group
-        this._group.add_actor(this._controls.dashSpacer);
-        this._group.add(this._viewSelector.actor, { x_fill: true,
-                                                    expand: true });
-        this._group.add_actor(this._controls.thumbnailsActor);
+        this._controls = new OverviewControls.ControlsManager(this._searchEntry);
+        this._dash = this._controls.dash;
+        this._viewSelector = this._controls.viewSelector;
 
         // Add our same-line elements after the search entry
-        this._overview.add(this._groupStack, { y_fill: true, expand: true });
+        this._overview.add(this._controls.actor, { y_fill: true, expand: true });
+        this._controls.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
 
         this._stack.add_actor(this._controls.indicatorActor);
 
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index ba5c7a8..b3eb5d3 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -6,10 +6,12 @@ const Meta = imports.gi.Meta;
 const St = imports.gi.St;
 const Shell = imports.gi.Shell;
 
+const Dash = imports.ui.dash;
 const Main = imports.ui.main;
 const Params = imports.misc.params;
 const Tweener = imports.ui.tweener;
 const ViewSelector = imports.ui.viewSelector;
+const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
 
 const SIDE_CONTROLS_ANIMATION_TIME = 0.16;
 
@@ -309,6 +311,10 @@ const DashSlider = new Lang.Class({
         // available allocation
         this._dash.actor.x_expand = true;
         this._dash.actor.y_expand = true;
+
+        this.actor.x_align = Clutter.ActorAlign.START;
+        this.actor.y_expand = true;
+
         this.actor.add_actor(this._dash.actor);
 
         this._dash.connect('icon-size-changed', Lang.bind(this, this.updateSlide));
@@ -479,36 +485,52 @@ const MessagesIndicator = new Lang.Class({
 const ControlsManager = new Lang.Class({
     Name: 'ControlsManager',
 
-    _init: function(dash, thumbnails, viewSelector) {
-        this._dashSlider = new DashSlider(dash);
-        this.dashActor = this._dashSlider.actor;
-        this.dashSpacer = new DashSpacer();
-        this.dashSpacer.setDashActor(this.dashActor);
+    _init: function(searchEntry) {
+        this.dash = new Dash.Dash();
+        this._dashSlider = new DashSlider(this.dash);
+        this._dashSpacer = new DashSpacer();
+        this._dashSpacer.setDashActor(this._dashSlider.actor);
+
+        this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
+        this._thumbnailsSlider = new ThumbnailsSlider(this._thumbnailsBox);
 
-        this._thumbnailsSlider = new ThumbnailsSlider(thumbnails);
-        this.thumbnailsActor = this._thumbnailsSlider.actor;
+        this.viewSelector = new ViewSelector.ViewSelector(searchEntry,
+                                                          this.dash.showAppsButton);
+        this.viewSelector.connect('page-changed', Lang.bind(this, this._setVisibility));
+        this.viewSelector.connect('page-empty', Lang.bind(this, this._onPageEmpty));
 
-        this._indicator = new MessagesIndicator(viewSelector);
+        this._indicator = new MessagesIndicator(this.viewSelector);
         this.indicatorActor = this._indicator.actor;
 
-        this._viewSelector = viewSelector;
-        this._viewSelector.connect('page-changed', Lang.bind(this, this._setVisibility));
-        this._viewSelector.connect('page-empty', Lang.bind(this, this._onPageEmpty));
+        this.actor = new St.Widget({ layout_manager: new Clutter.BinLayout(),
+                                     x_expand: true, y_expand: true,
+                                     clip_to_allocation: true });
+        this._group = new St.BoxLayout({ name: 'overview-group',
+                                        reactive: true,
+                                        x_expand: true, y_expand: true });
+        this.actor.add_actor(this._group);
+
+        this.actor.add_actor(this._dashSlider.actor);
+
+        this._group.add_actor(this._dashSpacer);
+        this._group.add(this.viewSelector.actor, { x_fill: true,
+                                                   expand: true });
+        this._group.add_actor(this._thumbnailsSlider.actor);
 
         Main.overview.connect('showing', Lang.bind(this, this._updateSpacerVisibility));
         Main.overview.connect('item-drag-begin', Lang.bind(this,
             function() {
-                let activePage = this._viewSelector.getActivePage();
+                let activePage = this.viewSelector.getActivePage();
                 if (activePage != ViewSelector.ViewPage.WINDOWS)
-                    this._viewSelector.fadeHalf();
+                    this.viewSelector.fadeHalf();
             }));
         Main.overview.connect('item-drag-end', Lang.bind(this,
             function() {
-                this._viewSelector.fadeIn();
+                this.viewSelector.fadeIn();
             }));
         Main.overview.connect('item-drag-cancelled', Lang.bind(this,
             function() {
-                this._viewSelector.fadeIn();
+                this.viewSelector.fadeIn();
             }));
     },
 
@@ -521,7 +543,7 @@ const ControlsManager = new Lang.Class({
             (Main.overview.animationInProgress && !Main.overview.visibleTarget))
             return;
 
-        let activePage = this._viewSelector.getActivePage();
+        let activePage = this.viewSelector.getActivePage();
         let dashVisible = (activePage == ViewSelector.ViewPage.WINDOWS ||
                            activePage == ViewSelector.ViewPage.APPS);
         let thumbnailsVisible = (activePage == ViewSelector.ViewPage.WINDOWS);
@@ -541,8 +563,8 @@ const ControlsManager = new Lang.Class({
         if (Main.overview.animationInProgress && !Main.overview.visibleTarget)
             return;
 
-        let activePage = this._viewSelector.getActivePage();
-        this.dashSpacer.visible = (activePage == ViewSelector.ViewPage.WINDOWS);
+        let activePage = this.viewSelector.getActivePage();
+        this._dashSpacer.visible = (activePage == ViewSelector.ViewPage.WINDOWS);
     },
 
     _onPageEmpty: function() {


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