The nsIMsgCustomColumnHandler
interface allows you to create custom handlers for columns. It can be used in the Thunderbird threadpane for extensions to overlay their own columns.
Inherits from: nsITreeView
This interface is meant to be implemented by extensions, as shown in the tutorial. The interface inherits from nsITreeView
, however when you're implementing a custom handler in Javascript its not necessary to implement all of nsITreeView's methods. You must implement:
nsITreeView.isEditable()
nsITreeView.GetCellProperties()
nsITreeView.GetImageSrc()
nsITreeView.GetCellText()
nsITreeView.cycleCell()
nsIMsgCustomColumnHandler.getSortStringForRow()
nsIMsgCustomColumnHandler.getSortLongForRow()
nsIMsgCustomColumnHandler.isString()
and optionally: nsITreeView.GetRowProperties()
From C++ you must implement all of nsITreeView
and nsIMsgCustomColumnHandler
.
An example Javascript implementation that does nothing:
var columnHandler = { isEditable: function(aRow, aCol) {return false;}, cycleCell: function(aRow, aCol) { }, getCellText: function(aRow, aCol) { }, getSortStringForRow: function(aHdr) { return ""; }, isString: function() {return true;}, getCellProperties: function(aRow, aCol, aProps) { }, getRowProperties: function(aRow, aProps) { }, getImageSrc: function(aRow, aCol) {return null;}, getSortLongForRow: function(aHdr) {return 0;} }
to attach it use the nsIMsgDBView.addColumnHandler()
method (recall gDBView
is the global nsIMsgDBView
in Thunderbird):
gDBView.addColumnHandler("newColumn", columnHandler);
after which it can be retrieved using the nsIMsgDBView.getColumnHandler()
method:
var handler = gDBView.getColumnHandler("newColumn");
and removed using the nsIMsgDBView.removeColumnHandler()
method:
gDBView.removeColumnHandler("newColumn");
AString getSortStringForRow(in nsIMsgDBHdr aHdr); |
unsigned long getSortLongForRow(in nsIMsgDBHdr aHdr); |
boolean isString(); |
If the column displays a string, this will return the string that the column should be sorted by.
AString getSortStringForRow(in nsIMsgDBHdr aHdr);
nsIMsgDBHdr
.The string value that sorting will be done with.
If the column displays a number, this will return the number that the column should be sorted by.
unsigned long getSortLongForRow(in nsIMsgDBHdr aHdr);
nsIMsgDBHdr
.The long value that sorting will be done with.
boolean isString();
None.
true
if the column displays a string value. false
otherwise.
This affects whether getSortStringForRow or getSortLongForRow is used to determine the sort key for the column. It does not affect whether getCellText vs. getImageSrc is used to determine what to display.