Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/main.js

Issue 4744516900749312: issue #1155 - Don't allow displaying icon text with Australis theme (Closed)
Patch Set: Created July 30, 2014, 9:13 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/content/settings.xul ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/content/settings.xul ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld