[gnome-shell/T27795: 66/138] Remove the "Frequent Apps" view and the "Apps mode" selection button



commit f91388f3a68373f8bf639f1143d13d1db47620f7
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Tue May 16 15:24:12 2017 +0100

    Remove the "Frequent Apps" view and the "Apps mode" selection button
    
    We don't need this for Endless, and we will have to hide it explicitly
    not to show up in the desktop, so there's no much point on creating all
    the objects plus controls necessary to deal with that. Remove it.

 js/ui/appDisplay.js | 234 ++++------------------------------------------------
 1 file changed, 15 insertions(+), 219 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 15d412ff46..88ec73ae27 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -841,90 +841,6 @@ var AllView = class AllView extends BaseAppView {
 };
 Signals.addSignalMethods(AllView.prototype);
 
-var FrequentView = class FrequentView extends BaseAppView {
-    constructor() {
-        super(null, { fillParent: true });
-
-        this.actor = new St.Widget({ style_class: 'frequent-apps',
-                                     layout_manager: new Clutter.BinLayout(),
-                                     x_expand: true, y_expand: true });
-
-        this._noFrequentAppsLabel = new St.Label({ text: _("Frequently used applications will appear here"),
-                                                   style_class: 'no-frequent-applications-label',
-                                                   x_align: Clutter.ActorAlign.CENTER,
-                                                   x_expand: true,
-                                                   y_align: Clutter.ActorAlign.CENTER,
-                                                   y_expand: true });
-
-        this._grid.y_expand = true;
-
-        this.actor.add_actor(this._grid);
-        this.actor.add_actor(this._noFrequentAppsLabel);
-        this._noFrequentAppsLabel.hide();
-
-        this._usage = Shell.AppUsage.get_default();
-
-        this.actor.connect('notify::mapped', () => {
-            if (this.actor.mapped)
-                this._redisplay();
-        });
-    }
-
-    hasUsefulData() {
-        return this._usage.get_most_used().length >= MIN_FREQUENT_APPS_COUNT;
-    }
-
-    _compareItems() {
-        // The FrequentView does not need to be sorted alphabetically
-        return 0;
-    }
-
-    _loadApps() {
-        let apps = [];
-        let mostUsed = this._usage.get_most_used();
-        let hasUsefulData = this.hasUsefulData();
-        this._noFrequentAppsLabel.visible = !hasUsefulData;
-        if (!hasUsefulData)
-            return [];
-
-        // Allow dragging of the icon only if the Dash would accept a drop to
-        // change favorite-apps. There are no other possible drop targets from
-        // the app picker, so there's no other need for a drag to start,
-        // at least on single-monitor setups.
-        // This also disables drag-to-launch on multi-monitor setups,
-        // but we hope that is not used much.
-        let favoritesWritable = global.settings.is_writable('favorite-apps');
-
-        for (let i = 0; i < mostUsed.length; i++) {
-            if (!mostUsed[i].get_app_info().should_show())
-                continue;
-            let appIcon = new AppIcon(mostUsed[i],
-                                      { isDraggable: favoritesWritable });
-            apps.push(appIcon);
-        }
-
-        return apps;
-    }
-
-    // Called before allocation to calculate dynamic spacing
-    adaptToSize(width, height) {
-        let box = new Clutter.ActorBox();
-        box.x1 = box.y1 = 0;
-        box.x2 = width;
-        box.y2 = height;
-        box = this.actor.get_theme_node().get_content_box(box);
-        box = this._grid.get_theme_node().get_content_box(box);
-        let availWidth = box.x2 - box.x1;
-        let availHeight = box.y2 - box.y1;
-        this._grid.adaptToSize(availWidth, availHeight);
-    }
-};
-
-var Views = {
-    FREQUENT: 0,
-    ALL: 1
-};
-
 var ControlsBoxLayout = GObject.registerClass(
 class ControlsBoxLayout extends Clutter.BoxLayout {
     /**
@@ -965,148 +881,28 @@ var ViewStackLayout = GObject.registerClass({
 var AppDisplay = class AppDisplay {
     constructor() {
         this._privacySettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.privacy' });
-        this._privacySettings.connect('changed::remember-app-usage',
-                                      this._updateFrequentVisibility.bind(this));
-
-        this._views = [];
-
-        let view, button;
-        view = new FrequentView();
-        button = new St.Button({ label: _("Frequent"),
-                                 style_class: 'app-view-control button',
-                                 can_focus: true,
-                                 x_expand: true });
-        this._views[Views.FREQUENT] = { 'view': view, 'control': button };
-
-        view = new AllView();
-        button = new St.Button({ label: _("All"),
-                                 style_class: 'app-view-control button',
-                                 can_focus: true,
-                                 x_expand: true });
-        this._views[Views.ALL] = { 'view': view, 'control': button };
-
-        this.actor = new St.BoxLayout ({ style_class: 'app-display',
-                                         x_expand: true, y_expand: true,
-                                         vertical: true });
-        this._viewStackLayout = new ViewStackLayout();
-        this._viewStack = new St.Widget({ x_expand: true, y_expand: true,
-                                          layout_manager: this._viewStackLayout });
-        this._viewStackLayout.connect('allocated-size-changed', this._onAllocatedSizeChanged.bind(this));
-        this.actor.add_actor(this._viewStack);
-        let layout = new ControlsBoxLayout({ homogeneous: true });
-        this._controls = new St.Widget({ style_class: 'app-view-controls',
-                                         layout_manager: layout });
-        this._controls.connect('notify::mapped', () => {
-            // controls are faded either with their parent or
-            // explicitly in animate(); we can't know how they'll be
-            // shown next, so make sure to restore their opacity
-            // when they are hidden
-            if (this._controls.mapped)
-                return;
-
-            this._controls.remove_all_transitions();
-            this._controls.opacity = 255;
-        });
-
-        layout.hookup_style(this._controls);
-        this.actor.add_actor(new St.Bin({ child: this._controls }));
-
-        for (let i = 0; i < this._views.length; i++) {
-            this._viewStack.add_actor(this._views[i].view.actor);
-            this._controls.add_actor(this._views[i].control);
+        this._allView = new AllView();
 
-            let viewIndex = i;
-            this._views[i].control.connect('clicked', () => {
-                this._showView(viewIndex);
-                global.settings.set_uint('app-picker-view', viewIndex);
-            });
-        }
-        let initialView = Math.min(global.settings.get_uint('app-picker-view'),
-                                   this._views.length - 1);
-        let frequentUseful = this._views[Views.FREQUENT].view.hasUsefulData();
-        if (initialView == Views.FREQUENT && !frequentUseful)
-            initialView = Views.ALL;
-        this._showView(initialView);
-        this._updateFrequentVisibility();
-
-        Gio.DBus.system.watch_name(SWITCHEROO_BUS_NAME,
-                                   Gio.BusNameWatcherFlags.NONE,
-                                   this._switcherooProxyAppeared.bind(this),
-                                   () => {
-                                       this._switcherooProxy = null;
-                                       this._updateDiscreteGpuAvailable();
-                                   });
-    }
-
-    _updateDiscreteGpuAvailable() {
-        if (!this._switcherooProxy)
-            discreteGpuAvailable = false;
-        else
-            discreteGpuAvailable = this._switcherooProxy.HasDualGpu;
-    }
+        let viewStackLayout = new ViewStackLayout();
+        this.actor = new St.Widget({ x_expand: true, y_expand: true,
+                                     layout_manager: viewStackLayout });
+        viewStackLayout.connect('allocated-size-changed', this._onAllocatedSizeChanged.bind(this));
 
-    _switcherooProxyAppeared() {
-        this._switcherooProxy = new SwitcherooProxy(Gio.DBus.system, SWITCHEROO_BUS_NAME, 
SWITCHEROO_OBJECT_PATH,
-            (proxy, error) => {
-                if (error) {
-                    log(error.message);
-                    return;
-                }
-                this._updateDiscreteGpuAvailable();
-            });
+        this.actor.add_actor(this._allView.actor);
+        this._showView();
     }
 
     animate(animationDirection, onComplete) {
-        let currentView = this._views.filter(v => v.control.has_style_pseudo_class('checked')).pop().view;
-
-        // Animate controls opacity using iconGrid animation time, since
-        // it will be the time the AllView or FrequentView takes to show
-        // it entirely.
-        let finalOpacity;
-        if (animationDirection == IconGrid.AnimationDirection.IN) {
-            this._controls.opacity = 0;
-            finalOpacity = 255;
-        } else {
-            finalOpacity = 0;
-        }
-
-        this._controls.ease({
-            opacity: finalOpacity,
-            duration: IconGrid.ANIMATION_TIME_IN,
-            mode: Clutter.AnimationMode.EASE_IN_OUT_QUAD
-        });
-
-        currentView.animate(animationDirection, onComplete);
+        this._allView.animate(animationDirection, onComplete);
     }
 
-    _showView(activeIndex) {
-        for (let i = 0; i < this._views.length; i++) {
-            if (i == activeIndex)
-                this._views[i].control.add_style_pseudo_class('checked');
-            else
-                this._views[i].control.remove_style_pseudo_class('checked');
-
-            let animationDirection = i == activeIndex
-                ? IconGrid.AnimationDirection.IN
-                : IconGrid.AnimationDirection.OUT;
-            this._views[i].view.animateSwitch(animationDirection);
-        }
-    }
-
-    _updateFrequentVisibility() {
-        let enabled = this._privacySettings.get_boolean('remember-app-usage');
-        this._views[Views.FREQUENT].control.visible = enabled;
-
-        let visibleViews = this._views.filter(v => v.control.visible);
-        this._controls.visible = visibleViews.length > 1;
-
-        if (!enabled && this._views[Views.FREQUENT].view.actor.visible)
-            this._showView(Views.ALL);
+    _showView() {
+        this._allView.animateSwitch(IconGrid.AnimationDirection.IN);
     }
 
     selectApp(id) {
-        this._showView(Views.ALL);
-        this._views[Views.ALL].view.selectApp(id);
+        this._showView();
+        this._allView.view.selectApp(id);
     }
 
     _onAllocatedSizeChanged(actor, width, height) {
@@ -1114,11 +910,11 @@ var AppDisplay = class AppDisplay {
         box.x1 = box.y1 = 0;
         box.x2 = width;
         box.y2 = height;
-        box = this._viewStack.get_theme_node().get_content_box(box);
+        box = this.actor.get_theme_node().get_content_box(box);
         let availWidth = box.x2 - box.x1;
         let availHeight = box.y2 - box.y1;
-        for (let i = 0; i < this._views.length; i++)
-            this._views[i].view.adaptToSize(availWidth, availHeight);
+
+        this._allView.adaptToSize(availWidth, availHeight);
     }
 };
 


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