From 5f299e109be85e66da4904f6fd61aa6e2abaa3ec Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Thu, 18 Aug 2011 16:17:53 +0200 Subject: [PATCH] auto-move-windows: port to new extension API main() has been replaced by init(), enable() and disable() I'm not sure it actually disables, it should unless you have more extensions messing with the same methods. --- extensions/auto-move-windows/extension.js | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/extensions/auto-move-windows/extension.js b/extensions/auto-move-windows/extension.js index eb3d70c6..fe5d7f97 100644 --- a/extensions/auto-move-windows/extension.js +++ b/extensions/auto-move-windows/extension.js @@ -25,7 +25,14 @@ WindowMover.prototype = { let display = global.screen.get_display(); // Connect after so the handler from ShellWindowTracker has already run - display.connect_after('window-created', Lang.bind(this, this._findAndMove)); + this._windowCreatedId = display.connect_after('window-created', Lang.bind(this, this._findAndMove)); + }, + + destroy: function() { + if (this._windowCreatedId) { + global.screen.get_display().disconnect(this._windowCreatedId); + this._windowCreatedId = 0; + } }, _ensureAtLeastWorkspaces: function(num, window) { @@ -69,7 +76,15 @@ WindowMover.prototype = { } } -function main(extensionMeta) { +let prevCheckWorkspaces; +let winMover; + +function init(extensionMeta) { + // do nothing here +} + +function enable() { + prevCheckWorkspaces = Main._checkWorkspaces; Main._checkWorkspaces = function() { let i; let emptyWorkspaces = new Array(Main._workspaces.length); @@ -138,5 +153,10 @@ function main(extensionMeta) { }; - new WindowMover(); + winMover = new WindowMover(); } + +function disable() { + Main._checkWorkspaces = prevCheckWorkspaces; + winMover.destroy(); +} \ No newline at end of file