Skip to content

Commit

Permalink
dash: Only create trash/mount apps if they are turned on
Browse files Browse the repository at this point in the history
Previously, the apps always existed even if the icons were not shown.
This meant that the event handling was still being done wastefully.

So, let's only create the apps when they are actually needed.
  • Loading branch information
philipl committed May 14, 2018
1 parent 06cfc6d commit 26cacaf
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,6 @@ var MyDash = new Lang.Class({

this._appSystem = Shell.AppSystem.get_default();

// Remove Drive Icons
this._removables = new Locations.Removables();

// Trash Icon
this._trash = new Locations.Trash();

this._signalsHandler.add([
this._appSystem,
'installed-changed',
Expand Down Expand Up @@ -311,14 +305,6 @@ var MyDash = new Lang.Class({
Main.overview,
'item-drag-cancelled',
Lang.bind(this, this._onDragCancelled)
], [
this._trash,
'changed',
Lang.bind(this, this._queueRedisplay)
], [
this._removables,
'changed',
Lang.bind(this, this._queueRedisplay)
]);
},

Expand Down Expand Up @@ -763,11 +749,31 @@ var MyDash = new Lang.Class({
}

if (this._dtdSettings.get_boolean('show-mounts')) {
if (!this._removables) {
this._removables = new Locations.Removables();
this._signalsHandler.addWithLabel('show-mounts',
[ this._removables,
'changed',
Lang.bind(this, this._queueRedisplay) ]);
}
Array.prototype.push.apply(newApps, this._removables.getApps());
} else if (this._removables) {
this._signalsHandler.removeWithLabel('show-mounts');
this._removables = null;
}

if (this._dtdSettings.get_boolean('show-trash')) {
if (!this._trash) {
this._trash = new Locations.Trash();
this._signalsHandler.addWithLabel('show-trash',
[ this._trash,
'changed',
Lang.bind(this, this._queueRedisplay) ]);
}
newApps.push(this._trash.getApp());
} else if (this._trash) {
this._signalsHandler.removeWithLabel('show-trash');
this._trash = null;
}

// Figure out the actual changes to the list of items; we iterate
Expand Down

0 comments on commit 26cacaf

Please sign in to comment.