viewSelector: Use state adjustment for apps page

Currently, ActivitiesContainer reacts to showAppsButton and
transitions between app grid and window picking states on
its own. In the future, we want full control over this.

ControlsManager already has a state adjustment that represents
all possible overview states. Propagate this adjustment up to
ActivitiesContainer, and use it to drive the transition.

This requires moving the callback to the showAppsButton to
ControlsManager, since now it control the state adjustment
itself, not ActivitiesContainer's adjustment.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
This commit is contained in:
Georges Basile Stavracas Neto 2020-12-30 17:45:09 -03:00 committed by Marge Bot
parent 3887253823
commit e6e5a93dec
2 changed files with 27 additions and 17 deletions

View File

@ -4,8 +4,11 @@
const { Clutter, GObject, St } = imports.gi; const { Clutter, GObject, St } = imports.gi;
const Dash = imports.ui.dash; const Dash = imports.ui.dash;
const Overview = imports.ui.overview;
const ViewSelector = imports.ui.viewSelector; const ViewSelector = imports.ui.viewSelector;
var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME;
var ControlsState = { var ControlsState = {
HIDDEN: 0, HIDDEN: 0,
WINDOW_PICKER: 1, WINDOW_PICKER: 1,
@ -123,7 +126,9 @@ class ControlsManager extends St.Widget {
this._updateAdjustment.bind(this)); this._updateAdjustment.bind(this));
this.viewSelector = new ViewSelector.ViewSelector(this._searchEntry, this.viewSelector = new ViewSelector.ViewSelector(this._searchEntry,
this._workspaceAdjustment, this.dash.showAppsButton); this._workspaceAdjustment,
this.dash.showAppsButton,
this._stateAdjustment);
this.add_child(searchEntryBin); this.add_child(searchEntryBin);
this.add_child(this.dash); this.add_child(this.dash);
@ -132,9 +137,24 @@ class ControlsManager extends St.Widget {
this.layout_manager = new ControlsManagerLayout(searchEntryBin, this.layout_manager = new ControlsManagerLayout(searchEntryBin,
this.viewSelector, this.dash, this._stateAdjustment); this.viewSelector, this.dash, this._stateAdjustment);
this.dash.showAppsButton.connect('notify::checked',
this._onShowAppsButtonToggled.bind(this));
this.connect('destroy', this._onDestroy.bind(this)); this.connect('destroy', this._onDestroy.bind(this));
} }
_onShowAppsButtonToggled() {
const checked = this.dash.showAppsButton.checked;
const value = checked
? ControlsState.APP_GRID : ControlsState.WINDOW_PICKER;
this._stateAdjustment.remove_transition('value');
this._stateAdjustment.ease(value, {
duration: SIDE_CONTROLS_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
});
}
_onDestroy() { _onDestroy() {
global.workspace_manager.disconnect(this._nWorkspacesNotifyId); global.workspace_manager.disconnect(this._nWorkspacesNotifyId);
} }

View File

@ -123,7 +123,7 @@ var ShowOverviewAction = GObject.registerClass({
var ActivitiesContainer = GObject.registerClass( var ActivitiesContainer = GObject.registerClass(
class ActivitiesContainer extends St.Widget { class ActivitiesContainer extends St.Widget {
_init(thumbnailsBox, workspacesDisplay, appDisplay, showAppsButton) { _init(thumbnailsBox, workspacesDisplay, appDisplay, overviewAdjustment) {
super._init(); super._init();
// 0 for window picker, 1 for app grid // 0 for window picker, 1 for app grid
@ -138,9 +138,9 @@ class ActivitiesContainer extends St.Widget {
this.queue_relayout(); this.queue_relayout();
}); });
this._showAppsButton = showAppsButton; overviewAdjustment.connect('notify::value', () => {
showAppsButton.connect('notify::checked', this._adjustment.value = Math.max(overviewAdjustment.value - 1, 0);
this._onShowAppsButtonToggled.bind(this)); });
this._thumbnailsBox = thumbnailsBox; this._thumbnailsBox = thumbnailsBox;
this.add_child(thumbnailsBox); this.add_child(thumbnailsBox);
@ -158,16 +158,6 @@ class ActivitiesContainer extends St.Widget {
this._update(); this._update();
} }
_onShowAppsButtonToggled() {
const checked = this._showAppsButton.checked;
const value = checked ? 1 : 0;
this._adjustment.ease(value, {
duration: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
});
}
_update() { _update() {
const progress = this._adjustment.value; const progress = this._adjustment.value;
@ -243,7 +233,7 @@ var ViewSelector = GObject.registerClass({
'page-empty': {}, 'page-empty': {},
}, },
}, class ViewSelector extends Shell.Stack { }, class ViewSelector extends Shell.Stack {
_init(searchEntry, workspaceAdjustment, showAppsButton) { _init(searchEntry, workspaceAdjustment, showAppsButton, overviewAdjustment) {
super._init({ super._init({
name: 'viewSelector', name: 'viewSelector',
x_expand: true, x_expand: true,
@ -298,7 +288,7 @@ var ViewSelector = GObject.registerClass({
this._thumbnailsBox, this._thumbnailsBox,
this._workspacesDisplay, this._workspacesDisplay,
this.appDisplay, this.appDisplay,
showAppsButton); overviewAdjustment);
this._activitiesPage = this._activitiesPage =
this._addPage(activitiesContainer, _('Activities'), 'view-app-grid-symbolic'); this._addPage(activitiesContainer, _('Activities'), 'view-app-grid-symbolic');