Now that we know where to add our XUL changes in a CCK XPI, let's take a look at what we can change. You'll remember from the previous post, we added this line:
and we were able to disable the Options... menuitem. The obvious questions then are, what else can I do and how do I find out what things I can change.
First let's talk about what you can change. It's beyond the scope of this article to go into all the things you can change with XUL. If you want to learn more about XUL, you can check out XULPlanet. For enterprise customization, there are probably two main things we would want to do: disable something or make it go away. We already know how to do disabling, but how would we make the Options... menuitem go away? The answer is the collapsed attribute:
This will make the menuitem go away completely.
OK, so we know how to change the XUL, let's find out what we can change. You'll notice that in order to change the menuitem, we needed to know the ID of the menuitem. So how can we find the ID of what we want to change? For this, we need to understand a little more about how the Firefox UI works. Most of the main Firefox window's UI is contained in a file called browser.xul. By looking through this file, we can find various parts of the UI and use our knowledge of overlays to change them. For instance, looking through that file, we find out that the ID of the toolbar is toolbar-menubar. So if we wanted to make the menu go away, we could simply add:
Note that not only did we need to use the ID, but we had to use the name of the tag (toolbar) as well. You'll notice that the menu is not in browser.xul (you won't find menu_preferences, for instance). This is because the menu is contained in a separate file called browser-menubar.inc. You can consider this file to be a part of browser.xul for our purposes.
If you're having trouble finding some UI in the XUL file, try this. Go to the Mozilla 1.8 Cross-Reference and search on the text you are trying to find. For instance, we'll search on "Error Console." This will return a DTD file that contains the string for the menu item (we want the one that begins with browser). On the same line as the text, you'll see an identifier that usually ends in label. For the error console, it's
By searching on the label, we can find the exact place where it is used in Firefox. In this case, it points us to browser-menubar.inc. We can use the information there to create an overlay that disables or removes the Error Console menuitem.
In the next installment, we'll learn how to customize the default buttons on the toolbar.