🪲 Fix rebinding of properties

This commit is contained in:
Simon Schneegans
2023-01-26 05:55:18 +01:00
parent 524345606c
commit 53e738b87b
+16 -14
View File
@@ -552,26 +552,24 @@ var PreferencesDialog = class PreferencesDialog {
if (!profiles.includes(activeProfile)) { if (!profiles.includes(activeProfile)) {
activeProfile = profiles[0]; activeProfile = profiles[0];
this._settings.set_string('active-profile', activeProfile); this._settings.set_string('active-profile', activeProfile);
return;
} }
utils.debug('loading ' + activeProfile); utils.debug('loading ' + activeProfile);
this._profileSettings = utils.getProfileSettings(activeProfile); this._profileSettings = utils.getProfileSettings(activeProfile);
// Bind all the profile-related settings. const setupProfileOption = (settingsKey) => {
{ this.bindComboRow(settingsKey);
const setupProfileOption = (settingsKey) => { this._profileSettings.connect('changed::' + settingsKey,
this.bindComboRow(settingsKey); () => this._updateProfileButton());
this._profileSettings.connect('changed::' + settingsKey, };
() => this._updateProfileButton());
};
setupProfileOption('profile-animation-type'); setupProfileOption('profile-animation-type');
setupProfileOption('profile-window-type'); setupProfileOption('profile-window-type');
setupProfileOption('profile-desktop-style'); setupProfileOption('profile-desktop-style');
setupProfileOption('profile-power-mode'); setupProfileOption('profile-power-mode');
setupProfileOption('profile-power-profile'); setupProfileOption('profile-power-profile');
}
this._ALL_EFFECTS.forEach(effect => { this._ALL_EFFECTS.forEach(effect => {
const [minMajor, minMinor] = effect.getMinShellVersion(); const [minMajor, minMinor] = effect.getMinShellVersion();
@@ -580,6 +578,8 @@ var PreferencesDialog = class PreferencesDialog {
effect.bindPreferences(this); effect.bindPreferences(this);
} }
}); });
utils.debug('loading done');
} }
_updateProfileButton() { _updateProfileButton() {
@@ -606,10 +606,11 @@ var PreferencesDialog = class PreferencesDialog {
// key when clicked. // key when clicked.
_bindResetButton(settingsKey) { _bindResetButton(settingsKey) {
const resetButton = this._builder.get_object('reset-' + settingsKey); const resetButton = this._builder.get_object('reset-' + settingsKey);
if (resetButton) { if (resetButton && !resetButton._isConnected) {
resetButton.connect('clicked', () => { resetButton.connect('clicked', () => {
this._profileSettings.reset(settingsKey); this._profileSettings.reset(settingsKey);
}); });
resetButton._isConnected = true;
} }
} }
@@ -619,6 +620,7 @@ var PreferencesDialog = class PreferencesDialog {
const object = this._builder.get_object(settingsKey); const object = this._builder.get_object(settingsKey);
if (object) { if (object) {
Gio.Settings.unbind(object, property);
this._profileSettings.bind(settingsKey, object, property, this._profileSettings.bind(settingsKey, object, property,
Gio.SettingsBindFlags.DEFAULT); Gio.SettingsBindFlags.DEFAULT);
} }