- Developer Tools
Eric Promislow, July 14, 2010
With the second beta of Komodo 6, you're going to see a few changes to the project system. For years, the project system has served triple duty as a file manager, a toolbox, and a general container for preferences and other resources. We knew that, while the project system was adequate, we could improve the way Komodo handles files and tools.
After this beta, the project tab and the partviewer XBL binding are going to disappear, to be replaced by other components. If you're strictly a Komodo user, you shouldn't be affected by this. Life should go on, and the time spent using Komodo should get even better. However, if you've written macros or extensions, you'll need to do some extra work. Here are a couple of small improvements to your overlay XUL code that will keep your extensions working fine in version 6. Best of all, they're backward-compatible: you can stick them in your current extensions and they will work with Komodo 5 too.
Future-Proofing Sidebar Placement
First, if you've written an extension that adds a new sidebar to either the left or the right, you'll probably need to change its insertion code. The right sidebar "toolbox_tab" and "sharedtoolbox_tab" have been replaced with the single sidebar "toolbox2_tab" (I know, imaginative name there, no?). We're aware of only a couple of extensions that insert after "toolbox_tab", and if you're one of the authors, there will be a fix.
Far more extensions like to install a sidebar in the "project_tab".
Now by default, if Mozilla can't resolve the given id, it will place the element at the end of the list. If this is acceptable to you, you don't have to do any more. However, the positioning system for overlays is reasonably flexible. Quoting from http://mdn.beonex.com/en/XUL_Tutorial/Overlays:
- If the overlay's element contains an insertafter attribute, the element is added just after the element in the base window with the id that matches the value of this attribute.
- If the overlay's element contains an insertbefore attribute, the element is added just before the element in the base window with the id that matches the value of this attribute.
- If the overlay's element contains a position attribute, the element is added at the one-based index specified in this attribute.
- Otherwise, the element is added as the last child.
Actually, the values of insertbefore and insertafter can be comma-separated lists, in which case the first id in the list that is found in the window is used to determine the position.
So this means you can leave references to "project_tab" and "projectviewbox" in your code, and then future-proof the code by adding references to "places_tab" and "placesViewbox", the Projects sidebar's replacement. The following XUL code shows how I modified the JSTreeDrive XUL code so it would stay in sync once the project tab disappears:
<tabs id="project_toolbox_tabs"> <tab id="jstreedrive_tab" label="Files" insertafter="project_tab,places_tab" position="2" ... /> </tabs> <tabpanels id="project_toolbox_tabpanels"> <tabpanel flex="1" id="jstreedriveviewbox" insertafter="projectviewbox,placesViewbox" position="2" >
Getting Your Tabs in the Tab Selection Popup Menus
While working with other extensions, I noticed that some were adding new tabs, but the tabs weren't showing up in the tab-picker menu ([View|Tabs & Sidebars]). You do this by overlaying menuitems into the "menu_view_tabs_popup" and "tabPicker_popup" menupopups, which I do for Places (the new file management sidebar) like so:
<menupopup id="menu_view_tabs_popup"> <menuitem id="show_places_tab2" observes="show_places_tab" insertbefore="show_codebrowser_tab2" insertafter="show_project_tab2" position="1" oncommand="uilayout_ensureTabShown('places_tab', true)" label="&Places.label;" type="checkbox" /> </menupopup> <menupopup id="tabPicker_popup"> <menuitem id="show_places_tab" observes="show_places_tab" insertbefore="show_codebrowser_tab" insertafter="show_project_tab" position="1" oncommand="uilayout_ensureTabShown('places_tab', true)" label="&Places.label;" type="checkbox" /> </menupopup>
I noticed that there was no menuitem for "Places" or another extension I had installed in the "Tabs & Sidebars" menu. I used the JS Shell to determine that its parent was popupset#extensionPopupSet, and saw that the overlays were wrapping the references to menupopup#menu_view_tabs_popup and menupopup#tabPicker_popup in the popupset#extensionPopupSet element. This overlay element should be used only for standalone popups defined in extensions, not for adding XUL code to existing elements. By freeing the two menupopup items, they now showed up in the [View|Tabs & Sidebars] menu.
Subscribe to ActiveState Blogs by Email
Share this post: