nsIMsgCustomColumnHandler

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.


Please add a summary to this article.
  Last changed in Gecko 1.9 (Firefox 3)

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:

  1. nsITreeView.isEditable()
  2. nsITreeView.GetCellProperties()
  3. nsITreeView.GetImageSrc()
  4. nsITreeView.GetCellText()
  5. nsITreeView.cycleCell()
  6. nsIMsgCustomColumnHandler.getSortStringForRow()
  7. nsIMsgCustomColumnHandler.getSortLongForRow()
  8. nsIMsgCustomColumnHandler.isString()

and optionally: nsITreeView.GetRowProperties()

From C++ you must implement all of nsITreeView and nsIMsgCustomColumnHandler.

Example Implementation

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");

Method overview

AString getSortStringForRow(in nsIMsgDBHdr aHdr);
unsigned long getSortLongForRow(in nsIMsgDBHdr aHdr);
boolean isString();

Methods

getSortStringForRow()

If the column displays a string, this will return the string that the column should be sorted by.

 AString getSortStringForRow(in nsIMsgDBHdr aHdr);
Parameters
aHdr
The message's nsIMsgDBHdr.
Return value

The string value that sorting will be done with.

getSortLongForRow()

If the column displays a number, this will return the number that the column should be sorted by.

 unsigned long getSortLongForRow(in nsIMsgDBHdr aHdr);
Parameters
aHdr
The message's nsIMsgDBHdr.
Return value

The long value that sorting will be done with.

isString()

 boolean isString();
Parameters

None.

Return value

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.

See Also

Extensions:Thunderbird:Creating_a_Custom_Column

Document Tags and Contributors

 Contributors to this page: Sheppy, jik, Wjjohnst
 Last updated by: Sheppy,