How folder modes work.
Earlier today, I was asked by Andreas Nilsson to give him a hand with a folder pane header bug he was trying to fix. In the middle of digging around in the code, I thought “I should really write this down, so that I can understand it later.”, and so here it is.
The main place we’ll need to change is in this object.
We start in the load method, which calls registerMode, to add the mode with its localized name. There is also a default list of modes, which will come into play later.
When the user chooses to cycle the mode, it calls the setter for mode, passing it the modename, which comes from the _modeNames list (which contains both the defaults and any newly-registered modes). Then, in the setter, if the mode is a default mode, it will fail the if-test, and get the localized name from the “bundle_messenger” string bundle. If it’s a newly-registered mode, they will have passed in a localized name which we will have stored in this._modeDisplayNames, and so we will use that.
The point of the bug is to switch the label-and-two-buttons to a dropdown menu, so at this point I think we should start with an empty menulist in the XUL, and in the load method add menuitems corresponding to the values in the _modeNames array. Then, in the registerMode and unregisterMode methods, we should add and remove new menuitems, which I’m hoping will just automatically show up in the dropdown. Finally, we need to change the setter for mode to not calculate the new name, but just select the appropriate menuitem set the mode attribute on the _treeElement, and call _rebuild(). At that point, I think we’re done, but only time will tell.
Okay, so this was really posted on Dec 22nd, but I wanted to back-date it so as not to bump Amy’s “Welcome” post off the top a mere day after she posted it.