Changes

Jump to: navigation, search

Thunderbird/Add-ons Guide 57

2,216 bytes added, 10:39, 21 February 2018
Added a very simple options.xul file and a few extra options.
== Also Note ==
The list above only contains selected changes relevant to add-ons. The full list of changes can be seen at [https://developer.mozilla.org/en-US/Firefox/Releases Firefox developer release notes] where all the details, bugzilla bug reports and patches implementing those changes can be found.
 
==Basic Example==
You either add OptionType = 3 to the install.rdf and get your options in a separate tab or you add at the top of the options.xul file =
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://messenger/skin/prefPanels.css" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/pref/pref.css" type="text/css"?>
(That gives you a dialog box.)
 
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" title = "Single Domain Preference"
id = "myDialogName"
onload = "onLoad()"
ondialogaccept = "savePrefs();">
 
<script type = "application/x-javascript">
<![CDATA[
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
function savePrefs() {
try {
prefs.setStringPref("extensions.myaddon.myvariable",document.getElementById("myID").value);
} catch (ex) {
prefs.setCharPref("extensions.myaddon.myvariable",document.getElementById("myID").value);
}
prefs.setBoolPref("extensions.myaddon.myvariable2") =
document.getElementById("myChkID").checked;
prefs.setCharPref("extensions.myaddon.myvariable3") =
document.getElementById("myCharID").value;
prefs.setIntPref("extensions.myaddon.myvariable4") =
document.getElementById("myIntID").value;
}
 
function onLoad() {
try {
document.getElementById("myID").value = prefs.getStringPref("extensions.myaddon.myvariable");
} catch (ex) {
document.getElementById("myID").value = prefs.getCharPref("extensions.myaddon.myvariable");
}
document.getElementById("myChkID").checked = prefs.getBoolPref("extensions.myaddon.myvariable2");
document.getElementById("myCharID").value = prefs.getCharPref("extensions.myaddon.myvariable3");
document.getElementById("myIntID").value = prefs.getIntPref("extensions.myaddon.myvariable4");
}
 
]]>
</script>
 
(That gives you the details actions of the dialog box)
<groupbox>
<caption label = "myLabel" />
<hbox align = "centre">
<textbox id = "myID" size = "28" />
</hbox>
<label value = "myText " />
<hbox align="center">
<checkbox id="myChkID" label="myLabel"/>
</hbox>
</groupbox>
</dialog>
(Char and Int Variables can be shown in a textbox.)
14
edits

Navigation menu