[gnome-shell] overview: Add OverviewActor and use as main actor of the Overlay



commit 91eb84fa4eada6a51095db5c3ee3fee464ce4127
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date:   Sat Aug 31 03:51:02 2019 +0200

    overview: Add OverviewActor and use as main actor of the Overlay
    
    Use the Overview class as controller, while create the actual overlay actor
    using a GObject-derived class.
    
    Replace actual properties with getter-only properties.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559

 js/perf/core.js     |   4 +-
 js/perf/hwtest.js   |   2 +-
 js/ui/appDisplay.js |   7 +--
 js/ui/overview.js   | 135 ++++++++++++++++++++++++++++++++--------------------
 4 files changed, 90 insertions(+), 58 deletions(-)
---
diff --git a/js/perf/core.js b/js/perf/core.js
index a2af0f9be9..9d4a89cd09 100644
--- a/js/perf/core.js
+++ b/js/perf/core.js
@@ -127,11 +127,11 @@ function *run() {
     for (let i = 0; i < 2; i++) {
         Scripting.scriptEvent('applicationsShowStart');
         // eslint-disable-next-line require-atomic-updates
-        Main.overview._dash.showAppsButton.checked = true;
+        Main.overview.dash.showAppsButton.checked = true;
         yield Scripting.waitLeisure();
         Scripting.scriptEvent('applicationsShowDone');
         // eslint-disable-next-line require-atomic-updates
-        Main.overview._dash.showAppsButton.checked = false;
+        Main.overview.dash.showAppsButton.checked = false;
         yield Scripting.waitLeisure();
     }
 }
diff --git a/js/perf/hwtest.js b/js/perf/hwtest.js
index 5b8934332d..bcca3ee3b9 100644
--- a/js/perf/hwtest.js
+++ b/js/perf/hwtest.js
@@ -127,7 +127,7 @@ function *run() {
 
     Scripting.scriptEvent('applicationsShowStart');
     // eslint-disable-next-line require-atomic-updates
-    Main.overview._dash.showAppsButton.checked = true;
+    Main.overview.dash.showAppsButton.checked = true;
 
     yield Scripting.waitLeisure();
     Scripting.scriptEvent('applicationsShowDone');
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 4bb22e9201..1754d9c70d 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -229,8 +229,9 @@ class BaseAppView {
 
     _doSpringAnimation(animationDirection) {
         this._grid.opacity = 255;
-        this._grid.animateSpring(animationDirection,
-                                 Main.overview.getShowAppsButton());
+        this._grid.animateSpring(
+            animationDirection,
+            Main.overview.dash.showAppsButton);
     }
 
     animate(animationDirection, onComplete) {
@@ -2260,7 +2261,7 @@ var AppIcon = class AppIcon {
     }
 
     getDragActor() {
-        return this.app.create_icon_texture(Main.overview.dashIconSize);
+        return this.app.create_icon_texture(Main.overview.dash.iconSize);
     }
 
     // Returns the original actor that should align with the actor
diff --git a/js/ui/overview.js b/js/ui/overview.js
index dac6e82604..255d6e478d 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported Overview */
 
-const { Clutter, GLib, Meta, Shell, St } = imports.gi;
+const { Clutter, GLib, GObject, Meta, Shell, St } = imports.gi;
 const Signals = imports.signals;
 
 const Background = imports.ui.background;
@@ -76,32 +76,92 @@ var ShellInfo = class {
     }
 };
 
+var OverviewActor = GObject.registerClass(
+class OverviewActor extends St.BoxLayout {
+    _init() {
+        super._init({
+            name: 'overview',
+            /* Translators: This is the main view to select
+                activities. See also note for "Activities" string. */
+            accessible_name: _("Overview"),
+            vertical: true
+        });
+
+        this.add_constraint(new LayoutManager.MonitorConstraint({ primary: true }));
+
+        // Add a clone of the panel to the overview so spacing and such is
+        // automatic
+        let panelGhost = new St.Bin({
+            child: new Clutter.Clone({ source: Main.panel }),
+            reactive: false,
+            opacity: 0
+        });
+        this.add_actor(panelGhost);
+
+        this._searchEntry = new St.Entry({
+            style_class: 'search-entry',
+            /* Translators: this is the text displayed
+               in the search entry when no search is
+               active; it should not exceed ~30
+               characters. */
+            hint_text: _("Type to search…"),
+            track_hover: true,
+            can_focus: true
+        });
+        let searchEntryBin = new St.Bin({
+            child: this._searchEntry,
+            x_align: St.Align.MIDDLE
+        });
+        this.add_actor(searchEntryBin);
+
+        this._controls = new OverviewControls.ControlsManager(this._searchEntry);
+
+        // Add our same-line elements after the search entry
+        this.add(this._controls.actor, { y_fill: true, expand: true });
+    }
+
+    get dash() {
+        return this._controls.dash;
+    }
+
+    get searchEntry() {
+        return this._searchEntry;
+    }
+
+    get viewSelector() {
+        return this._controls.viewSelector;
+    }
+});
+
 var Overview = class {
     constructor() {
-        this._overviewCreated = false;
         this._initCalled = false;
 
         Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
         this._sessionUpdated();
     }
 
+    get dash() {
+        return this._overview.dash;
+    }
+
+    get dashIconSize() {
+        logError(new Error('Usage of Overview.\'dashIconSize\' is deprecated, ' +
+            'use \'dash.iconSize\' property instead'));
+        return this.dash.iconSize;
+    }
+
+    get viewSelector() {
+        return this._overview.viewSelector;
+    }
+
     _createOverview() {
-        if (this._overviewCreated)
+        if (this._overview)
             return;
 
         if (this.isDummy)
             return;
 
-        this._overviewCreated = true;
-
-        this._overview = new St.BoxLayout({ name: 'overview',
-                                            /* Translators: This is the main view to select
-                                               activities. See also note for "Activities" string. */
-                                            accessible_name: _("Overview"),
-                                            vertical: true });
-        this._overview.add_constraint(new LayoutManager.MonitorConstraint({ primary: true }));
-        this._overview._delegate = this;
-
         // The main Background actors are inside global.window_group which are
         // hidden when displaying the overview, so we create a new
         // one. Instances of this class share a single CoglTexture behind the
@@ -129,9 +189,6 @@ var Overview = class {
                                               reactive: true });
         Main.layoutManager.overviewGroup.add_child(this._coverPane);
         this._coverPane.connect('event', () => Clutter.EVENT_STOP);
-
-        Main.layoutManager.overviewGroup.add_child(this._overview);
-
         this._coverPane.hide();
 
         // XDND
@@ -213,40 +270,11 @@ var Overview = class {
         if (this.isDummy)
             return;
 
-        this._shellInfo = new ShellInfo();
-
-        // Add a clone of the panel to the overview so spacing and such is
-        // automatic
-        this._panelGhost = new St.Bin({ child: new Clutter.Clone({ source: Main.panel }),
-                                        reactive: false,
-                                        opacity: 0 });
-        this._overview.add_actor(this._panelGhost);
-
-        this._searchEntry = new St.Entry({ style_class: 'search-entry',
-                                           /* Translators: this is the text displayed
-                                              in the search entry when no search is
-                                              active; it should not exceed ~30
-                                              characters. */
-                                           hint_text: _("Type to search…"),
-                                           track_hover: true,
-                                           can_focus: true });
-        this._searchEntryBin = new St.Bin({ child: this._searchEntry,
-                                            x_align: St.Align.MIDDLE });
-        this._overview.add_actor(this._searchEntryBin);
-
-        // Create controls
-        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._controls.actor, { y_fill: true, expand: true });
+        this._overview = new OverviewActor();
+        this._overview._delegate = this;
+        Main.layoutManager.overviewGroup.add_child(this._overview);
 
-        // TODO - recalculate everything when desktop size changes
-        this.dashIconSize = this._dash.iconSize;
-        this._dash.connect('icon-size-changed', () => {
-            this.dashIconSize = this._dash.iconSize;
-        });
+        this._shellInfo = new ShellInfo();
 
         Main.layoutManager.connect('monitors-changed', this._relayout.bind(this));
         this._relayout();
@@ -426,7 +454,7 @@ var Overview = class {
 
     focusSearch() {
         this.show();
-        this._searchEntry.grab_key_focus();
+        this._overview.searchEntry.grab_key_focus();
     }
 
     fadeInDesktop() {
@@ -468,7 +496,7 @@ var Overview = class {
             return false;
         if (this._inItemDrag || this._inWindowDrag)
             return false;
-        if (this._activationTime == 0 ||
+        if (!this._activationTime ||
             GLib.get_monotonic_time() / GLib.USEC_PER_SEC - this._activationTime > 
OVERVIEW_ACTIVATION_TIMEOUT)
             return true;
         return false;
@@ -640,7 +668,10 @@ var Overview = class {
     }
 
     getShowAppsButton() {
-        return this._dash.showAppsButton;
+        logError(new Error('Usage of Overview.\'getShowAppsButton\' is deprecated, ' +
+            'use \'dash.showAppsButton\' property instead'));
+
+        return this.dash.showAppsButton;
     }
 };
 Signals.addSignalMethods(Overview.prototype);


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