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
This commit is contained in:
Jasper St. Pierre 2013-02-25 18:05:45 -05:00
parent 254740cf68
commit 8772edcd33
2 changed files with 45 additions and 50 deletions

View File

@ -11,7 +11,6 @@ const Shell = imports.gi.Shell;
const Gdk = imports.gi.Gdk; const Gdk = imports.gi.Gdk;
const Background = imports.ui.background; const Background = imports.ui.background;
const Dash = imports.ui.dash;
const DND = imports.ui.dnd; const DND = imports.ui.dnd;
const LayoutManager = imports.ui.layout; const LayoutManager = imports.ui.layout;
const Main = imports.ui.main; const Main = imports.ui.main;
@ -20,8 +19,6 @@ const OverviewControls = imports.ui.overviewControls;
const Panel = imports.ui.panel; const Panel = imports.ui.panel;
const Params = imports.misc.params; const Params = imports.misc.params;
const Tweener = imports.ui.tweener; const Tweener = imports.ui.tweener;
const ViewSelector = imports.ui.viewSelector;
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
// Time for initial animation going into Overview mode // Time for initial animation going into Overview mode
const ANIMATION_TIME = 0.25; const ANIMATION_TIME = 0.25;
@ -133,14 +130,6 @@ const Overview = new Lang.Class({
y_expand: true }); y_expand: true });
this._overview._delegate = this; 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(); this._backgroundGroup = new Meta.BackgroundGroup();
global.overlay_group.add_child(this._backgroundGroup); global.overlay_group.add_child(this._backgroundGroup);
this._backgroundGroup.hide(); this._backgroundGroup.hide();
@ -177,7 +166,6 @@ const Overview = new Lang.Class({
Main.xdndHandler.connect('drag-end', Lang.bind(this, this._onDragEnd)); Main.xdndHandler.connect('drag-end', Lang.bind(this, this._onDragEnd));
global.screen.connect('restacked', Lang.bind(this, this._onRestacked)); global.screen.connect('restacked', Lang.bind(this, this._onRestacked));
this._group.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
this._windowSwitchTimeoutId = 0; this._windowSwitchTimeoutId = 0;
this._windowSwitchTimestamp = 0; this._windowSwitchTimestamp = 0;
@ -276,28 +264,13 @@ const Overview = new Lang.Class({
this._overview.add_actor(this._searchEntryBin); this._overview.add_actor(this._searchEntryBin);
// Create controls // Create controls
this._dash = new Dash.Dash(); this._controls = new OverviewControls.ControlsManager(this._searchEntry);
this._viewSelector = new ViewSelector.ViewSelector(this._searchEntry, this._dash = this._controls.dash;
this._dash.showAppsButton); this._viewSelector = this._controls.viewSelector;
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);
// Add our same-line elements after the search entry // 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); this._stack.add_actor(this._controls.indicatorActor);

View File

@ -6,10 +6,12 @@ const Meta = imports.gi.Meta;
const St = imports.gi.St; const St = imports.gi.St;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Dash = imports.ui.dash;
const Main = imports.ui.main; const Main = imports.ui.main;
const Params = imports.misc.params; const Params = imports.misc.params;
const Tweener = imports.ui.tweener; const Tweener = imports.ui.tweener;
const ViewSelector = imports.ui.viewSelector; const ViewSelector = imports.ui.viewSelector;
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
const SIDE_CONTROLS_ANIMATION_TIME = 0.16; const SIDE_CONTROLS_ANIMATION_TIME = 0.16;
@ -309,6 +311,10 @@ const DashSlider = new Lang.Class({
// available allocation // available allocation
this._dash.actor.x_expand = true; this._dash.actor.x_expand = true;
this._dash.actor.y_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.actor.add_actor(this._dash.actor);
this._dash.connect('icon-size-changed', Lang.bind(this, this.updateSlide)); 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({ const ControlsManager = new Lang.Class({
Name: 'ControlsManager', Name: 'ControlsManager',
_init: function(dash, thumbnails, viewSelector) { _init: function(searchEntry) {
this._dashSlider = new DashSlider(dash); this.dash = new Dash.Dash();
this.dashActor = this._dashSlider.actor; this._dashSlider = new DashSlider(this.dash);
this.dashSpacer = new DashSpacer(); this._dashSpacer = new DashSpacer();
this.dashSpacer.setDashActor(this.dashActor); this._dashSpacer.setDashActor(this._dashSlider.actor);
this._thumbnailsSlider = new ThumbnailsSlider(thumbnails); this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
this.thumbnailsActor = this._thumbnailsSlider.actor; this._thumbnailsSlider = new ThumbnailsSlider(this._thumbnailsBox);
this._indicator = new MessagesIndicator(viewSelector); 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(this.viewSelector);
this.indicatorActor = this._indicator.actor; this.indicatorActor = this._indicator.actor;
this._viewSelector = viewSelector; this.actor = new St.Widget({ layout_manager: new Clutter.BinLayout(),
this._viewSelector.connect('page-changed', Lang.bind(this, this._setVisibility)); x_expand: true, y_expand: true,
this._viewSelector.connect('page-empty', Lang.bind(this, this._onPageEmpty)); 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('showing', Lang.bind(this, this._updateSpacerVisibility));
Main.overview.connect('item-drag-begin', Lang.bind(this, Main.overview.connect('item-drag-begin', Lang.bind(this,
function() { function() {
let activePage = this._viewSelector.getActivePage(); let activePage = this.viewSelector.getActivePage();
if (activePage != ViewSelector.ViewPage.WINDOWS) if (activePage != ViewSelector.ViewPage.WINDOWS)
this._viewSelector.fadeHalf(); this.viewSelector.fadeHalf();
})); }));
Main.overview.connect('item-drag-end', Lang.bind(this, Main.overview.connect('item-drag-end', Lang.bind(this,
function() { function() {
this._viewSelector.fadeIn(); this.viewSelector.fadeIn();
})); }));
Main.overview.connect('item-drag-cancelled', Lang.bind(this, Main.overview.connect('item-drag-cancelled', Lang.bind(this,
function() { function() {
this._viewSelector.fadeIn(); this.viewSelector.fadeIn();
})); }));
}, },
@ -521,7 +543,7 @@ const ControlsManager = new Lang.Class({
(Main.overview.animationInProgress && !Main.overview.visibleTarget)) (Main.overview.animationInProgress && !Main.overview.visibleTarget))
return; return;
let activePage = this._viewSelector.getActivePage(); let activePage = this.viewSelector.getActivePage();
let dashVisible = (activePage == ViewSelector.ViewPage.WINDOWS || let dashVisible = (activePage == ViewSelector.ViewPage.WINDOWS ||
activePage == ViewSelector.ViewPage.APPS); activePage == ViewSelector.ViewPage.APPS);
let thumbnailsVisible = (activePage == ViewSelector.ViewPage.WINDOWS); let thumbnailsVisible = (activePage == ViewSelector.ViewPage.WINDOWS);
@ -541,8 +563,8 @@ const ControlsManager = new Lang.Class({
if (Main.overview.animationInProgress && !Main.overview.visibleTarget) if (Main.overview.animationInProgress && !Main.overview.visibleTarget)
return; return;
let activePage = this._viewSelector.getActivePage(); let activePage = this.viewSelector.getActivePage();
this.dashSpacer.visible = (activePage == ViewSelector.ViewPage.WINDOWS); this._dashSpacer.visible = (activePage == ViewSelector.ViewPage.WINDOWS);
}, },
_onPageEmpty: function() { _onPageEmpty: function() {