[Pkg-mozext-commits] [tabmixplus] 09/13: Restore Defaults doesn't work when there are pending changes
David Prévot
taffit at moszumanska.debian.org
Mon Oct 20 02:33:50 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit f95373ade315983001a8daa3f3d0316956bff6e3
Author: onemen <tabmix.onemen at gmail.com>
Date: Thu Oct 16 13:27:27 2014 +0300
Restore Defaults doesn't work when there are pending changes
---
chrome/content/preferences/appearance.js | 14 ++++++++++----
chrome/content/preferences/preferences.js | 22 ++++++++++++++++++++--
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/chrome/content/preferences/appearance.js b/chrome/content/preferences/appearance.js
index 13f9ccb..6b72c86 100644
--- a/chrome/content/preferences/appearance.js
+++ b/chrome/content/preferences/appearance.js
@@ -136,25 +136,31 @@ var gAppearancePane = {
// block width cange on instantApply
// user is force to hit apply
userchangedWidth: function(item) {
- this.widthChanged = $("minWidth").value != $("pref_minWidth").valueFromPreferences ||
+ gPrefWindow.widthChanged = $("minWidth").value != $("pref_minWidth").valueFromPreferences ||
$("maxWidth").value != $("pref_maxWidth").valueFromPreferences
if (!gPrefWindow.instantApply)
return undefined;
- gPrefWindow.setButtons(!this.widthChanged);
+ gPrefWindow.setButtons(!gPrefWindow.widthChanged);
// block the change by returning the preference own value
return $(item.getAttribute("preference")).value;
},
changeTabsWidth: function() {
- if (!this.widthChanged)
+ if (!gPrefWindow.widthChanged)
return;
- this.widthChanged = false;
+ gPrefWindow.widthChanged = false;
let [minWidth, maxWidth] = [parseInt($("minWidth").value), parseInt($("maxWidth").value)];
if (minWidth > maxWidth)
[minWidth, maxWidth] = [maxWidth, minWidth];
[$("pref_minWidth").value, $("pref_maxWidth").value] = [minWidth, maxWidth];
},
+ resetWidthChange: function() {
+ gPrefWindow.widthChanged = false;
+ $("minWidth").value = $("pref_minWidth").value;
+ $("maxWidth").value = $("pref_maxWidth").value;
+ },
+
openAdvanceAppearance: function() {
let url = "chrome://tabmixplus/content/preferences/subdialogs/pref-appearance.xul";
window.openDialog(url, "advanceAppearanceDialog", "modal,titlebar,toolbar,centerscreen");
diff --git a/chrome/content/preferences/preferences.js b/chrome/content/preferences/preferences.js
index 5d237ce..6310e40 100644
--- a/chrome/content/preferences/preferences.js
+++ b/chrome/content/preferences/preferences.js
@@ -8,6 +8,7 @@ const PrefFn = {0: "", 32: "CharPref", 64: "IntPref", 128: "BoolPref"};
function $(id) document.getElementById(id);
var gPrefWindow = {
+ widthChanged: false,
_initialized: false,
init: function() {
this._initialized = true;
@@ -94,7 +95,7 @@ var gPrefWindow = {
this.updateApplyButton(aEvent);
break;
case "beforeaccept":
- if (typeof gAppearancePane == "object")
+ if (this.widthChanged)
gAppearancePane.changeTabsWidth();
if (!this.instantApply) {
// prevent TMP_SessionStore.setService from runing
@@ -106,6 +107,21 @@ var gPrefWindow = {
},
changes: [],
+ resetChanges: function() {
+ // remove all pending changes
+ if (!this.instantApply || this.widthChanged) {
+ if (this.widthChanged)
+ gAppearancePane.resetWidthChange();
+ while (this.changes.length) {
+ let preference = this.changes.shift();
+ preference.value = preference.valueFromPreferences;
+ if (preference.hasAttribute("notChecked"))
+ delete preference._lastValue;
+ }
+ this.setButtons(true);
+ }
+ },
+
updateApplyButton: function(aEvent) {
var item = aEvent.target;
if (item.localName != "preference")
@@ -121,7 +137,7 @@ var gPrefWindow = {
onApply: function() {
this.setButtons(true);
- if (typeof gAppearancePane == "object")
+ if (this.widthChanged)
gAppearancePane.changeTabsWidth();
if (this.instantApply)
return;
@@ -357,6 +373,7 @@ __defineGetter__("_sminstalled", function() {
});
function defaultSetting() {
+ gPrefWindow.resetChanges();
// set flag to prevent TabmixTabbar.updateSettings from run for each change
Tabmix.prefs.setBoolPref("setDefault", true);
Shortcuts.prefsChangedByTabmix = true;
@@ -459,6 +476,7 @@ function loadData (pattern) {
return;
}
+ gPrefWindow.resetChanges();
// set flag to prevent TabmixTabbar.updateSettings from run for each change
Tabmix.prefs.setBoolPref("setDefault", true);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list