[gnome-shell] viewSelector: Use state adjustment for apps page



commit e6e5a93dec2b7ac7f60c1e465968f4755abee001
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Dec 30 17:45:09 2020 -0300

    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>

 js/ui/overviewControls.js | 22 +++++++++++++++++++++-
 js/ui/viewSelector.js     | 22 ++++++----------------
 2 files changed, 27 insertions(+), 17 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index 4f0751d45f..9059d34e9b 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -4,8 +4,11 @@
 const { Clutter, GObject, St } = imports.gi;
 
 const Dash = imports.ui.dash;
+const Overview = imports.ui.overview;
 const ViewSelector = imports.ui.viewSelector;
 
+var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME;
+
 var ControlsState = {
     HIDDEN: 0,
     WINDOW_PICKER: 1,
@@ -123,7 +126,9 @@ class ControlsManager extends St.Widget {
                 this._updateAdjustment.bind(this));
 
         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(this.dash);
@@ -132,9 +137,24 @@ class ControlsManager extends St.Widget {
         this.layout_manager = new ControlsManagerLayout(searchEntryBin,
             this.viewSelector, this.dash, this._stateAdjustment);
 
+        this.dash.showAppsButton.connect('notify::checked',
+            this._onShowAppsButtonToggled.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() {
         global.workspace_manager.disconnect(this._nWorkspacesNotifyId);
     }
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index b120618892..bf6f5bb699 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -123,7 +123,7 @@ var ShowOverviewAction = GObject.registerClass({
 
 var ActivitiesContainer = GObject.registerClass(
 class ActivitiesContainer extends St.Widget {
-    _init(thumbnailsBox, workspacesDisplay, appDisplay, showAppsButton) {
+    _init(thumbnailsBox, workspacesDisplay, appDisplay, overviewAdjustment) {
         super._init();
 
         // 0 for window picker, 1 for app grid
@@ -138,9 +138,9 @@ class ActivitiesContainer extends St.Widget {
             this.queue_relayout();
         });
 
-        this._showAppsButton = showAppsButton;
-        showAppsButton.connect('notify::checked',
-            this._onShowAppsButtonToggled.bind(this));
+        overviewAdjustment.connect('notify::value', () => {
+            this._adjustment.value = Math.max(overviewAdjustment.value - 1, 0);
+        });
 
         this._thumbnailsBox = thumbnailsBox;
         this.add_child(thumbnailsBox);
@@ -158,16 +158,6 @@ class ActivitiesContainer extends St.Widget {
         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() {
         const progress = this._adjustment.value;
 
@@ -243,7 +233,7 @@ var ViewSelector = GObject.registerClass({
         'page-empty': {},
     },
 }, class ViewSelector extends Shell.Stack {
-    _init(searchEntry, workspaceAdjustment, showAppsButton) {
+    _init(searchEntry, workspaceAdjustment, showAppsButton, overviewAdjustment) {
         super._init({
             name: 'viewSelector',
             x_expand: true,
@@ -298,7 +288,7 @@ var ViewSelector = GObject.registerClass({
             this._thumbnailsBox,
             this._workspacesDisplay,
             this.appDisplay,
-            showAppsButton);
+            overviewAdjustment);
         this._activitiesPage =
             this._addPage(activitiesContainer, _('Activities'), 'view-app-grid-symbolic');
 


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