diff --git a/appIcons.js b/appIcons.js index 36101d911..5117bcccf 100644 --- a/appIcons.js +++ b/appIcons.js @@ -30,7 +30,6 @@ const Workspace = imports.ui.workspace; const Me = imports.misc.extensionUtils.getCurrentExtension(); const Docking = Me.imports.docking; -const FileManager1API = Me.imports.fileManager1API; const Utils = Me.imports.utils; const WindowPreview = Me.imports.windowPreview; const AppIconIndicators = Me.imports.appIconIndicators; @@ -131,11 +130,14 @@ var MyAppIcon = class DashToDock_AppIcon extends AppDisplay.AppIcon { this._updateIndicatorStyle.bind(this) ]); }, this); - this._signalsHandler.add([ - FileManager1API.fm1Client, - 'windows-changed', - this.onWindowsChanged.bind(this) - ]); + + if (this._location) { + this._signalsHandler.add([ + Docking.DockManager.getDefault().fm1Client, + 'windows-changed', + this.onWindowsChanged.bind(this) + ]); + } this._signalsHandler.add([ Docking.DockManager.settings, @@ -995,8 +997,8 @@ const MyAppIconMenu = class DashToDock_MyAppIconMenu extends AppDisplay.AppIconM Signals.addSignalMethods(MyAppIconMenu.prototype); function getWindows(app, location) { - if (location != null) { - return FileManager1API.fm1Client.getWindows(location); + if (location != null && Docking.DockManager.getDefault().fm1Client) { + return Docking.DockManager.getDefault().fm1Client.getWindows(location); } else { return app.get_windows(); } diff --git a/docking.js b/docking.js index 41631d465..15680ea80 100644 --- a/docking.js +++ b/docking.js @@ -29,6 +29,7 @@ const Intellihide = Me.imports.intellihide; const Theming = Me.imports.theming; const MyDash = Me.imports.dash; const LauncherAPI = Me.imports.launcherAPI; +const FileManager1API = Me.imports.fileManager1API; const DOCK_DWELL_CHECK_INTERVAL = 100; @@ -1586,6 +1587,8 @@ var DockManager = class DashToDock_DockManager { this._remoteModel = new LauncherAPI.LauncherEntryRemoteModel(); this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.dash-to-dock'); this._oldDash = Main.overview._dash; + this._ensureFileManagerClient(); + /* Array of all the docks created */ this._allDocks = []; this._createDocks(); @@ -1606,6 +1609,24 @@ var DockManager = class DashToDock_DockManager { return DockManager.getDefault()._settings; } + get fm1Client() { + return this._fm1Client; + } + + _ensureFileManagerClient() { + let supportsLocations = ['show-trash', 'show-mounts'].some((s) => { + return this._settings.get_boolean(s); + }); + + if (supportsLocations) { + if (!this._fm1Client) + this._fm1Client = new FileManager1API.FileManager1Client(); + } else if (this._fm1Client) { + this._fm1Client.destroy(); + this._fm1Client = null; + } + } + _toggle() { this._deleteDocks(); this._createDocks(); @@ -1639,7 +1660,15 @@ var DockManager = class DashToDock_DockManager { this._settings, 'changed::dock-fixed', this._adjustPanelCorners.bind(this) - ]); + ], [ + this._settings, + 'changed::show-trash', + () => this._ensureFileManagerClient() + ], [ + this._settings, + 'changed::show-mounts', + () => this._ensureFileManagerClient() + ], ); } _createDocks() { @@ -1849,6 +1878,10 @@ var DockManager = class DashToDock_DockManager { this._deleteDocks(); this._revertPanelCorners(); this._restoreDash(); + if (this._fm1Client) { + this._fm1Client.destroy(); + this._fm1Client = null; + } this._remoteModel.destroy(); this._settings.run_dispose(); this._settings = null; diff --git a/fileManager1API.js b/fileManager1API.js index b8a671571..2b9bbe889 100644 --- a/fileManager1API.js +++ b/fileManager1API.js @@ -69,6 +69,7 @@ var FileManager1Client = class DashToDock_FileManager1Client { destroy() { this._signalsHandler.destroy(); + this._proxy.run_dispose(); } /** @@ -214,5 +215,3 @@ function guessWindowXID(win) { return null; } } - -var fm1Client = new FileManager1Client();