[gnome-shell/eos3.8: 70/255] viewSelector: Prepare infrastructure to pack the desktop's widgets



commit 5733916b0ff530b9ba5b5517ef9f3e43ba203f28
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Fri Jun 9 15:56:21 2017 +0100

    viewSelector: Prepare infrastructure to pack the desktop's widgets
    
    Create the classes ViewsDisplay* to provide a way to pack the icon
    grid, search entry and search results widgets, and move the icon
    grid inside of it for now.
    
     * 2020-03-16:
          + Remove reentrant action loop
          + Simplify code
          + Squash with 85c961289

 js/ui/viewSelector.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 71 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 4917256ad2..9c8c0676a8 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -5,6 +5,7 @@ const { Clutter, Gio, GObject, Meta, Shell, St } = imports.gi;
 const Signals = imports.signals;
 
 const AppDisplay = imports.ui.appDisplay;
+const LayoutManager = imports.ui.layout;
 const Main = imports.ui.main;
 const OverviewControls = imports.ui.overviewControls;
 const Params = imports.misc.params;
@@ -23,6 +24,10 @@ var ViewPage = {
     SEARCH: 3,
 };
 
+const ViewsDisplayPage = {
+    APP_GRID: 1
+};
+
 var FocusTrap = GObject.registerClass(
 class FocusTrap extends St.Widget {
     vfunc_navigate_focus(from, direction) {
@@ -122,6 +127,64 @@ var ShowOverviewAction = GObject.registerClass({
     }
 });
 
+var ViewsDisplayLayout = GObject.registerClass(
+class ViewsDisplayLayout extends Clutter.BoxLayout {
+    _init(appDisplayActor) {
+        super._init();
+
+        this._appDisplayActor = appDisplayActor;
+        this._appDisplayActor.connect('style-changed', this._onStyleChanged.bind(this));
+    }
+
+    _onStyleChanged() {
+        this.layout_changed();
+    }
+});
+
+var ViewsDisplayConstraint = GObject.registerClass(
+class ViewsDisplayConstraint extends LayoutManager.MonitorConstraint {
+    vfunc_update_allocation(actor, actorBox) {
+        let originalBox = actorBox.copy();
+        super.vfunc_update_allocation(actor, actorBox);
+
+        actorBox.init_rect(
+            originalBox.get_x(), originalBox.get_y(),
+            actorBox.get_width(), originalBox.get_height());
+    }
+});
+
+var ViewsDisplay = GObject.registerClass(
+class ViewsDisplay extends St.Widget {
+    _init() {
+        this._activePage = ViewsDisplayPage.APP_GRID;
+
+        this._appDisplay = new AppDisplay.AppDisplay();
+
+        super._init({
+            layout_manager: new ViewsDisplayLayout(this._appDisplay),
+            x_expand: true,
+            y_expand: true,
+        });
+
+        this.add_actor(this._appDisplay);
+    }
+
+    showPage(page) {
+        if (this._activePage === page)
+            return;
+
+        this._activePage = page;
+    }
+
+    get appDisplay() {
+        return this._appDisplay;
+    }
+
+    get activeViewsPage() {
+        return this._activePage;
+    }
+});
+
 var ViewSelector = GObject.registerClass({
     Signals: {
         'page-changed': {},
@@ -175,9 +238,15 @@ var ViewSelector = GObject.registerClass({
         this._workspacesPage = this._addPage(this._workspacesDisplay,
                                              _("Windows"), 'focus-windows-symbolic');
 
-        this.appDisplay = new AppDisplay.AppDisplay();
-        this._appsPage = this._addPage(this.appDisplay,
+        this._viewsDisplay = new ViewsDisplay();
+        this._appsPage = this._addPage(this._viewsDisplay,
                                        _("Applications"), 'view-app-grid-symbolic');
+        this._appsPage.add_constraint(new ViewsDisplayConstraint({
+            primary: true,
+            work_area: true,
+        }));
+
+        this.appDisplay = this._viewsDisplay.appDisplay;
 
         this._searchResults = new Search.SearchResultsView();
         this._searchPage = this._addPage(this._searchResults,


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