-
Notifications
You must be signed in to change notification settings - Fork 8
How to add a new "Custom Column" with DYNAMIC CODE (v4.0)
FOR ADDON VERSION 4.0
From version 5.0 new columns will be added directly from the addons settings panel.
The word COLNAME
is a placeholder for the new custom column internal name.
To add a new custom column these files must be modified:
-
mzcw-settings.xul
to add the new option in the addon settings. -
prefs.js
to add the new default setting. -
mzcw-overlay.js
to add the new column definition. -
mzcw-customcolumns.js
to add the new handler functions.
Under the en-US
locale folder:
-
overlay.properties
to add the needed text strings. -
settings.dtd
to add the needed text strings.
Under
<prefpane id="ColumnsWizard_PrefPane">
<preferences>
Add a code snippet like this
<preference id="ColumnsWizard.CustCols.AddCOLNAME"
name="extensions.ColumnsWizard.CustCols.AddCOLNAME"
type="bool" />
Then, under
<tabpanel id="custcols" orient="vertical">
just before the closing tag
</tabpanel>
Add a code snippet like this
<checkbox id="ColumnsWizard.AddCOLNAME_checkbox" label="&ColumnsWizard.AddCOLNAME.label;"
preference="ColumnsWizard.CustCols.AddCOLNAME"/>
Add a line like this one:
pref("extensions.ColumnsWizard.CustCols.AddCOLNAME", false);
Inside the loadCustCols
function definition, add these four lines:
loadedCustColPref["COLNAME"] = {};
loadedCustColPref["COLNAME"].Pref = prefs.getBoolPref("AddCOLNAME");
loadedCustColPref["COLNAME"].Def = "AddCOLNAME";
loadedCustColPref["COLNAME"].customDBHeader = false;
If you need to make Thunderbird save a custom header, replace the last line by this one:
loadedCustColPref["COLNAME"].customDBHeader = "header_field_name";
Add to the miczColumnsWizard.CustCols
object the following methods, after the object literal.
miczColumnsWizard.CustCols["columnHandler_COLNAME"]={
getCellText: function(row, col) {
return <This method must return the field value>;
},
getSortStringForRow: function(hdr) {return <This method must return the field value used for sorting>;},
isString: function() {return true;},
getCellProperties: function(row, col, props){},
getRowProperties: function(row, props){},
getImageSrc: function(row, col) {return null;},
getSortLongForRow: function(hdr) {return 0;}
};
Append those lines at the end of the file
ColumnsWizardAddCOLNAME.label=<Write here the column header display name>
ColumnsWizardAddCOLNAMEDesc.label=<Write here the column header tooltip>
Append this line at the end of the file
<!ENTITY ColumnsWizard.AddCOLNAME.label "<Column name>">
Thunderbird source browser: http://lxr.mozilla.org/comm-central/
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMsgDBHdr