From e75292a4d3f4f5134cb932edfb5e131e4a6f28f5 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sat, 6 Oct 2018 10:26:16 -0400 Subject: [PATCH] Disconnect setting signals --- appIcons.js | 52 +++++++++++++++++-------------- intellihide.js | 6 +++- overview.js | 19 +++++++----- panel.js | 81 +++++++++++++++++++++++++++--------------------- panelStyle.js | 10 ++++-- taskbar.js | 57 +++++++++++++++++++--------------- windowPreview.js | 14 ++++++--- 7 files changed, 142 insertions(+), 97 deletions(-) diff --git a/appIcons.js b/appIcons.js index 5c2ceee..61b4080 100644 --- a/appIcons.js +++ b/appIcons.js @@ -194,29 +194,31 @@ var taskbarAppIcon = new Lang.Class({ this._setAppIconPadding(); this._showDots(); - this._dtpSettings.connect('changed::dot-position', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-size', Lang.bind(this, this._updateDotSize)); - this._dtpSettings.connect('changed::dot-style-focused', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-style-unfocused', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-override', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-1', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-2', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-3', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-4', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-unfocused-different', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-unfocused-1', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-unfocused-2', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-unfocused-3', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::dot-color-unfocused-4', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::focus-highlight', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::focus-highlight-color', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::focus-highlight-opacity', Lang.bind(this, this._settingsChangeRefresh)); - this._dtpSettings.connect('changed::group-apps-label-font-size', Lang.bind(this, this._updateWindowTitleStyle)); - this._dtpSettings.connect('changed::group-apps-label-font-weight', Lang.bind(this, this._updateWindowTitleStyle)); - this._dtpSettings.connect('changed::group-apps-label-font-color', Lang.bind(this, this._updateWindowTitleStyle)); - this._dtpSettings.connect('changed::group-apps-label-max-width', Lang.bind(this, this._updateWindowTitleStyle)); - this._dtpSettings.connect('changed::group-apps-use-fixed-width', Lang.bind(this, this._updateWindowTitleStyle)); - this._dtpSettings.connect('changed::group-apps-underline-unfocused', Lang.bind(this, this._settingsChangeRefresh)); + this._dtpSettingsSignalIds = [ + this._dtpSettings.connect('changed::dot-position', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-size', Lang.bind(this, this._updateDotSize)), + this._dtpSettings.connect('changed::dot-style-focused', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-style-unfocused', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-override', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-1', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-2', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-3', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-4', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-unfocused-different', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-unfocused-1', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-unfocused-2', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-unfocused-3', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::dot-color-unfocused-4', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::focus-highlight', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::focus-highlight-color', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::focus-highlight-opacity', Lang.bind(this, this._settingsChangeRefresh)), + this._dtpSettings.connect('changed::group-apps-label-font-size', Lang.bind(this, this._updateWindowTitleStyle)), + this._dtpSettings.connect('changed::group-apps-label-font-weight', Lang.bind(this, this._updateWindowTitleStyle)), + this._dtpSettings.connect('changed::group-apps-label-font-color', Lang.bind(this, this._updateWindowTitleStyle)), + this._dtpSettings.connect('changed::group-apps-label-max-width', Lang.bind(this, this._updateWindowTitleStyle)), + this._dtpSettings.connect('changed::group-apps-use-fixed-width', Lang.bind(this, this._updateWindowTitleStyle)), + this._dtpSettings.connect('changed::group-apps-underline-unfocused', Lang.bind(this, this._settingsChangeRefresh)) + ] this.forcedOverview = false; @@ -344,6 +346,10 @@ var taskbarAppIcon = new Lang.Class({ if(this._scaleFactorChangedId) St.ThemeContext.get_for_stage(global.stage).disconnect(this._scaleFactorChangedId); + + for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { + this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]); + } }, onWindowsChanged: function() { diff --git a/intellihide.js b/intellihide.js index a5a5e8e..ae80ee5 100644 --- a/intellihide.js +++ b/intellihide.js @@ -51,7 +51,7 @@ var Intellihide = new Lang.Class({ this._signalsHandler = new Utils.GlobalSignalsHandler(); this._timeoutsHandler = new Utils.TimeoutsHandler(); - this._dtpSettings.connect('changed::intellihide', Lang.bind(this, this._changeEnabledStatus)); + this._intellihideChangedId = this._dtpSettings.connect('changed::intellihide', Lang.bind(this, this._changeEnabledStatus)); if (this._dtpSettings.get_boolean('intellihide')) { this.enable(); @@ -88,6 +88,10 @@ var Intellihide = new Lang.Class({ }, disable: function(reset) { + if (!reset) { + this._dtpSettings.disconnect(this._intellihideChangedId); + } + this._setTrackPanel(reset, false); this._disconnectFocusedWindow(); diff --git a/overview.js b/overview.js index ba8cb24..6aac872 100644 --- a/overview.js +++ b/overview.js @@ -90,13 +90,18 @@ var dtpOverview = new Lang.Class({ let label = 'optionalWorkspaceIsolation'; - this._dtpSettings.connect('changed::isolate-workspaces', Lang.bind(this, function() { - this.taskbar.resetAppIcons(); - if (this._dtpSettings.get_boolean('isolate-workspaces')) - Lang.bind(this, enable)(); - else - Lang.bind(this, disable)(); - })); + this._signalsHandler.addWithLabel(label, [ + this._dtpSettings, + 'changed::isolate-workspaces', + Lang.bind(this, function() { + this.taskbar.resetAppIcons(); + + if (this._dtpSettings.get_boolean('isolate-workspaces')) + Lang.bind(this, enable)(); + else + Lang.bind(this, disable)(); + }) + ]); if (this._dtpSettings.get_boolean('isolate-workspaces')) Lang.bind(this, enable)(); diff --git a/panel.js b/panel.js index 0aeaead..7dc34b8 100644 --- a/panel.js +++ b/panel.js @@ -57,11 +57,6 @@ var dtpPanel = new Lang.Class({ _init: function(settings) { this._dtpSettings = settings; this.panelStyle = new PanelStyle.dtpPanelStyle(settings); - //rebuild panel when taskar-position change - this._dtpSettings.connect('changed::taskbar-position', Lang.bind(this, function() { - this.disable(); - this.enable(); - })); }, enable : function() { @@ -165,9 +160,6 @@ var dtpPanel = new Lang.Class({ if(Main.overview.viewSelector._activePage == null) Main.overview.viewSelector._activePage = Main.overview.viewSelector._workspacesPage; - // sync hover after a popupmenu is closed - this.taskbar.connect('menu-closed', Lang.bind(this, function(){this.container.sync_hover();})); - if(this.taskbar._showAppsIcon) this.taskbar._showAppsIcon._dtpPanel = this; @@ -186,6 +178,12 @@ var dtpPanel = new Lang.Class({ Main.overview.dashIconSize = this.taskbar.iconSize; }) ], + [ + // sync hover after a popupmenu is closed + this.taskbar, + 'menu-closed', + Lang.bind(this, function(){this.container.sync_hover();}) + ], // This duplicate the similar signal which is in overview.js. // Being connected and thus executed later this effectively // overwrite any attempt to use the size of the default dash @@ -280,6 +278,11 @@ var dtpPanel = new Lang.Class({ if(this._ScaleFactorListener !== null) { St.ThemeContext.get_for_stage(global.stage).disconnect(this._ScaleFactorListener); } + + for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { + this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]); + } + this._removeTopLimit(); this.panel.actor.set_height(this._oldPanelHeight); this.panelBox.set_anchor_point(0, 0); @@ -333,40 +336,48 @@ var dtpPanel = new Lang.Class({ }, _bindSettingsChanges: function() { - this._dtpSettings.connect('changed::panel-position', Lang.bind(this, function() { - this._setPanelPosition(); - })); + this._dtpSettingsSignalIds = [ + //rebuild panel when taskar-position change + this._dtpSettings.connect('changed::taskbar-position', Lang.bind(this, function() { + this.disable(); + this.enable(); + })), - this._dtpSettings.connect('changed::panel-size', Lang.bind(this, function() { - this._setPanelPosition(); - this.taskbar.resetAppIcons(); - })); + this._dtpSettings.connect('changed::panel-position', Lang.bind(this, function() { + this._setPanelPosition(); + })), - this._dtpSettings.connect('changed::appicon-margin', Lang.bind(this, function() { - this.taskbar.resetAppIcons(); - })); + this._dtpSettings.connect('changed::panel-size', Lang.bind(this, function() { + this._setPanelPosition(); + this.taskbar.resetAppIcons(); + })), - this._dtpSettings.connect('changed::appicon-padding', Lang.bind(this, function() { - this.taskbar.resetAppIcons(); - })); + this._dtpSettings.connect('changed::appicon-margin', Lang.bind(this, function() { + this.taskbar.resetAppIcons(); + })), - this._dtpSettings.connect('changed::show-activities-button', Lang.bind(this, function() { - this._setActivitiesButtonVisible(this._dtpSettings.get_boolean('show-activities-button')); - })); - - this._dtpSettings.connect('changed::show-appmenu', Lang.bind(this, function() { - this._setAppmenuVisible(this._dtpSettings.get_boolean('show-appmenu')); - })); + this._dtpSettings.connect('changed::appicon-padding', Lang.bind(this, function() { + this.taskbar.resetAppIcons(); + })), - this._dtpSettings.connect('changed::location-clock', Lang.bind(this, function() { - this._setClockLocation(this._dtpSettings.get_string('location-clock')); - })); + this._dtpSettings.connect('changed::show-activities-button', Lang.bind(this, function() { + this._setActivitiesButtonVisible(this._dtpSettings.get_boolean('show-activities-button')); + })), + + this._dtpSettings.connect('changed::show-appmenu', Lang.bind(this, function() { + this._setAppmenuVisible(this._dtpSettings.get_boolean('show-appmenu')); + })), - this._dtpSettings.connect('changed::show-showdesktop-button', Lang.bind(this, function() { - this._displayShowDesktopButton(this._dtpSettings.get_boolean('show-showdesktop-button')); - })); + this._dtpSettings.connect('changed::location-clock', Lang.bind(this, function() { + this._setClockLocation(this._dtpSettings.get_string('location-clock')); + })), - this._dtpSettings.connect('changed::showdesktop-button-width', () => this._setShowDesktopButtonWidth()); + this._dtpSettings.connect('changed::show-showdesktop-button', Lang.bind(this, function() { + this._displayShowDesktopButton(this._dtpSettings.get_boolean('show-showdesktop-button')); + })), + + this._dtpSettings.connect('changed::showdesktop-button-width', () => this._setShowDesktopButtonWidth()) + ]; }, _allocate: function(actor, box, flags) { diff --git a/panelStyle.js b/panelStyle.js index fadc2d7..7e9fe28 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -47,6 +47,10 @@ var dtpPanelStyle = new Lang.Class({ }, disable: function () { + for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { + this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]); + } + this._removeStyles(); }, @@ -58,12 +62,14 @@ var dtpPanelStyle = new Lang.Class({ "leftbox-padding", "status-icon-padding", ]; + + this._dtpSettingsSignalIds = []; for(let i in configKeys) { - this._dtpSettings.connect('changed::' + configKeys[i], Lang.bind(this, function () { + this._dtpSettingsSignalIds.push(this._dtpSettings.connect('changed::' + configKeys[i], Lang.bind(this, function () { this._removeStyles(); this._applyStyles(); - })); + }))); } }, diff --git a/taskbar.js b/taskbar.js index 83d19d3..5d79f2c 100644 --- a/taskbar.js +++ b/taskbar.js @@ -302,14 +302,44 @@ var taskbar = new Lang.Class({ this._dtpSettings, 'changed::show-window-previews', Lang.bind(this, this._toggleWindowPreview) + ], + [ + this._dtpSettings, + 'changed::show-show-apps-button', + Lang.bind(this, function() { + if (this._dtpSettings.get_boolean('show-show-apps-button')) + this.showShowAppsButton(); + else + this.hideShowAppsButton(); + }) + ], + [ + this._dtpSettings, + [ + 'changed::dot-size', + 'changed::show-favorites' + ], + Lang.bind(this, this._redisplay) + ], + [ + this._dtpSettings, + 'changed::group-apps', + Lang.bind(this, function() { + this.isGroupApps = this._dtpSettings.get_boolean('group-apps'); + this._connectWorkspaceSignals(); + this.resetAppIcons(); + }) + ], + [ + this._dtpSettings, + 'changed::group-apps-use-launchers', + () => this.resetAppIcons() ] ); this.isGroupApps = this._dtpSettings.get_boolean('group-apps'); this._connectWorkspaceSignals(); - - this._bindSettingsChanges(); }, destroy: function() { @@ -320,29 +350,6 @@ var taskbar = new Lang.Class({ this._disconnectWorkspaceSignals(); }, - _bindSettingsChanges: function () { - this._dtpSettings.connect('changed::show-show-apps-button', Lang.bind(this, function() { - if (this._dtpSettings.get_boolean('show-show-apps-button')) - this.showShowAppsButton(); - else - this.hideShowAppsButton(); - })); - - this._dtpSettings.connect('changed::dot-size', Lang.bind(this, this._redisplay)); - - this._dtpSettings.connect('changed::show-favorites', Lang.bind(this, this._redisplay)); - - this._dtpSettings.connect('changed::group-apps', Lang.bind(this, function() { - this.isGroupApps = this._dtpSettings.get_boolean('group-apps'); - this._connectWorkspaceSignals(); - this.resetAppIcons(); - })); - - this._dtpSettings.connect('changed::group-apps-use-launchers', Lang.bind(this, function() { - this.resetAppIcons(); - })); - }, - _onScrollEvent: function(actor, event) { // Event coordinates are relative to the stage but can be transformed diff --git a/windowPreview.js b/windowPreview.js index 0696b2f..497b16b 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -902,10 +902,12 @@ var thumbnailPreviewList = new Lang.Class({ this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); - this._dtpSettings.connect('changed::window-preview-width', () => this._resetPreviews()); - this._dtpSettings.connect('changed::window-preview-height', () => this._resetPreviews()); - this._dtpSettings.connect('changed::window-preview-show-title', () => this._resetPreviews()); - this._dtpSettings.connect('changed::window-preview-padding', () => this._resetPreviews()); + this._dtpSettingsSignalIds = [ + this._dtpSettings.connect('changed::window-preview-width', () => this._resetPreviews()), + this._dtpSettings.connect('changed::window-preview-height', () => this._resetPreviews()), + this._dtpSettings.connect('changed::window-preview-show-title', () => this._resetPreviews()), + this._dtpSettings.connect('changed::window-preview-padding', () => this._resetPreviews()) + ]; this._stateChangedId = this.window ? 0 : this.app.connect('windows-changed', Lang.bind(this, this._queueRedisplay)); @@ -996,6 +998,10 @@ var thumbnailPreviewList = new Lang.Class({ }, _onDestroy: function() { + for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { + this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]); + } + if (this._stateChangedId) { this.app.disconnect(this._stateChangedId); this._stateChangedId = 0;