itagagaki’s blog

Itagaki's Software Development Blog

Plan to modify the Thunderbird Supernova's folder pane

How can we freely sort the order of folders in Mozilla Thunderbird? For a while, this was possible with the popular "Manually sort folders" add-on. However, in Thunderbird 115 the add-on no longer works because of the redesigned folder UI. And even in the new "Supernova" UI, the ability to sort folders is still not implemented.

I was involved in the development of "Manually sort folders" for Thunderbird 78 and later as a collaborator. So, as an option, I have considered developing "Manually sort folders" for Thunderbird 115. This may not be impossible. But here I would consider implementing the ability to sort folders properly in Thunderbird.

I started by examining the source code for the new Thunderbird. Apparently the folder pane is var folderPane. The code is in about3Pane.js. And folderPane.handleEvent() looks like this:

  handleEvent(event) {
    switch (event.type) {
      case "select":
        this._onSelect(event);
        break;
      case "contextmenu":
        this._onContextMenu(event);
        break;
      case "collapsed":
        this._onCollapsed(event);
        break;
      case "expanded":
        this._onExpanded(event);
        break;
      case "dragstart":
        this._onDragStart(event);
        break;
      case "dragover":
        this._onDragOver(event);
        break;
      case "dragleave":
        this._clearDropTarget(event);
        break;
      case "drop":
        this._onDrop(event);
        break;
    }
  }

It would be good to modify handling dragstart, dragover, dragleave, and drop a bit. Currently, it is possible to move a folder as a child into the target where we drag and drop. This would be done by these handlers. Probably the only status is in drag or not. The first step is to add the following additional states to the state in drag.

  • Move into the target as a child
  • Move to the point before the target as a sibling
  • Move to the point after the target as a sibling

The above three states may be determined by the relative position of the Y-coordinate of the mouse pointer on the target when dragging. (Not sure if there is a way to get that yet.)

And we need display materials that make the above three states visible.

Once the above is done, the next step is to actually insert the folder into the dropped location.

And the order of the folders sorted in this UI must be stored somewhere.

And it must be replicated next time. The current process of alphabetical sorting needs to be stopped.

Help from someone familiar with the current architecture may be required to ensure that the folder order can be stored and reproduced without contradiction.