| Index: lib/main.js |
| =================================================================== |
| --- a/lib/main.js |
| +++ b/lib/main.js |
| @@ -5,10 +5,13 @@ |
| */ |
| Cu.import("resource://gre/modules/Services.jsm"); |
| +let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", null); |
| let {Prefs} = require("prefs"); |
| let {WindowObserver} = require("windowObserver"); |
| +let CustomizableUI = null; |
|
Wladimir Palant
2014/07/30 09:38:55
No point keeping a global reference to Customizabl
saroyanm
2014/07/30 10:56:23
Done.
|
| + |
| var WindowFeature = |
| { |
| observer: null, |
| @@ -41,6 +44,41 @@ |
| } |
| } |
| +/** |
| + * Object initializing add-on options, observes add-on manager notifications |
| + * about add-on options being opened. |
| + * @type nsIObserver |
| + */ |
| +let optionsObserver = |
| +{ |
| + init: function() |
| + { |
| + Services.obs.addObserver(this, "addon-options-displayed", true); |
| + onShutdown.add(function() |
| + { |
| + Services.obs.removeObserver(this, "addon-options-displayed"); |
| + }.bind(this)); |
| + }, |
| + |
| + initOptionsDoc: function(/**Document*/ doc) |
| + { |
| + if (CustomizableUI) |
| + doc.getElementById("abpcustomization-icondisplay").collapsed = true; |
| + }, |
| + |
| + observe: function(subject, topic, data) |
| + { |
| + let {addonID} = require("info") |
| + if (data != addonID) |
| + return; |
| + |
| + this.initOptionsDoc(subject.QueryInterface(Ci.nsIDOMDocument)); |
| + }, |
| + |
| + QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]) |
| +}; |
| +optionsObserver.init(); |
| + |
| var VerticalPreferencesLayout = |
| { |
| __proto__: WindowFeature, |
| @@ -178,11 +216,18 @@ |
| function updateFeature(name) |
| { |
| + try |
| + { |
| + ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", null); |
| + } catch (e) {} |
|
Wladimir Palant
2014/07/30 09:38:55
Why run this for each feature? It should be best t
saroyanm
2014/07/30 10:56:23
Oops, too inattentive today!
|
| + |
| if (name in features) |
| { |
| let enabled; |
| if (name == "addon-page-styles") |
| enabled = true; |
|
Wladimir Palant
2014/07/30 09:38:55
Actually, seeing this - it's probably cleaner to i
saroyanm
2014/07/30 10:56:23
Awesome, great idea. How could I miss that.
|
| + else if (name == "toolbar-icon-display" && CustomizableUI) |
| + enabled = false; |
| else |
| enabled = Prefs[name]; |
| @@ -193,7 +238,6 @@ |
| } |
| } |
| - |
| // Initialize features and make sure to update them on changes |
| for (let feature in features) |
| updateFeature(feature); |