Showcode: click to see inside toolbars and menus
Tuesday, January 8, 2008 7:05:31 AM
Buttons you add to menus and toolbars; click to see the code for the menu or toolbar they're on. Useful for examining code, identifying function calls you were wondering about - or copying off the screen to make a button for someone else. If you see something that needs changing, two more taps (sourceview, F3) open sourceview for editing and take you back to the item.
What it does is very simple - open a file, run a search. Here's the code for one button:
Go to page,"tb" & Enable mediumscreen mode & Delay,200 & Find inline, "Pagebar Head.content"
(Mediumscreen is fit-to-width. The delay command is needed to prevent the Find from being issued before the page loads.) The idea is to make code access effortless, and pushbutton simple: almost like having "edit item code" on a context menu. You don't have to think about which file to call, dredge up a toolbar name, and work out what search string to type in: you just point at the thing that's puzzling you and click.
Actually, I use it quite often just to check the names of menus and toolbars: tap Showcode, read the name, dismiss the page.
setup: making sure you have custom INI files, making sure they open with no dialog, and nicknaming them:
- making sure you have custom menu & toolbar INIs: Prefs / Advanced / Toolbars; look at the Toolbar setup window: more than one file, one saying "modified"? If not, click "duplicate". Now rename the modified file (so you know it's your custom one, especially if Opera generates other duplicates, which happens quite a bit): you could call it "tb", to match the nickname we'll give it - or any other name you like. To make it the active file, select it and click OK. Same for menu, in the lower window: duplicate if necessary to get a "modified" file, then give it a distinctive name.
- making sure they open: navigate to your toolbar folder within Profile, and open it. (If you don't know how: type the drive ID of your hard drive (usually C:) into the address field & press Enter; click on folders to work your way to Profile (if not sure where it is, check Help / About Opera / Opera directory); click on the Toolbar folder inside Profile.) There you will see your custom toolbar INI (which may not have the name you gave it - Opera's name being different from the filename). It's a text file, and Opera can open them. Click on it. If you get a "save or open?" dialog, that's an issue: need them to just open (and - longstanding bug - the "Remember This" option on the dialog doesn't work). What does work is adding the INI file type to the set of extensions on the Text/plain line at Prefs / Advanced / Downloads (uncheck "hide file types opened by Opera" and type "text" in the quickfind box to see it). Button for that (adding ini,adr,dat,lng,mbs,idx to the list: making it possible to inspect and edit most of Opera's innards within the browser): MakeSystemFilesEditable. Some people don't have this problem; file types handling is a murky topic (discussed here).
- assigning nicknames: to avoid the need for paths, Showcode uses nicknames - calls your toolbar INI by the nickname "tb", and menu INI by the nickname "mn" (short nicks used to make the files very easy to open by keystroke as well: F2,tb,Enter). So you have to assign these: with INI file displayed, bookmark it, click the Details button on the bookmark dialog, and assign the nickname.
Here are the buttons, in two versions: the form with the toolbar name as anchor has the benefit of displaying the name when hovered, and the drawback of occupying a stretch of toolbar as wide as the name if you choose to display button titles. So - you may want to use the nameless specimen for bars where you display titles, but be sure you get the right one! (It's still easy to check names: just click the button. Read, close page.)
// . . Main bar
// . . Status bar
// . . Start bar
// . . Address bar
My Buttons (special case: buttons on the panel are not clickable - must go on a toolbar)
// . . Pagebar head
// . . Source View Toolbar
// . . Panel header
// . . Notes panel toolbar
// . . Boomarks panel toolbar
// . . History panel toolbar
// . . Notes full toolbar
Manage Bookmarks toolbar: // . . Bookmarks full toolbar
Manage History toolbar: // . . History full toolbar
For a trial, pick one for a toolbar you use, drag and drop it on the far right (or bottom, if the toolbar is vertical) of the bar (so the showcode line will be at the bottom of the listing to give you a search-hit bracketing effect), and click. Hopefully your toolbar INI pops open, the search dialog pops up with "(bar you picked) content" in its field, and the search runs. You should see the code for your toolbar, with a green search hit on the section header. You probably won't see the yellow search hit on the Showcode-button line - because that line won't exist in the file on disk yet; if you close and restart Opera, your toolbar changes will be saved to disk and then you'll see it. (Neat, eh? The search string finds itself.)
Edit & swapout/save/reload From there, if you want to edit, you use View Document Source to open it in editable form (Ctrl+F3 or Alt,v,o), and tap F3 to repeat the search and get you back to the proper section in the sourceview window. (One could have Showcode open sourceview automatically; this however creates another tab to dismiss. Which is more efficient depends on how often you edit, and how often only inspect.)
A caution: you can get versioning glitches by editing the toolbar INI you have loaded. This is because after loading it into memory, Opera does not automatically save to disk after changes, or reload after filesaves. So - if you have modified your toolbars during a session, and open the toolbar.ini on disk, it may be stale. And if you edit the loaded file but then do not reload it, the changes will be lost when the file is overwritten during Opera shutdown. So it's safest to swap back to the standard toolbar INI (causing Opera to update your custom INI on disk) before opening the custom INI file. That's Prefs /Advanced/toolbars again (you'll be putting that on a keystroke if you use this as much as I do); select the standard file, click OK.
You save your edits by clicking the "save changes" button on the sourceview toolbar, or tapping F5 - then reload your custom file.
Same concept: for each menu you'd like to be able to pop open, add this line at the bottom of its section in your menu INI file:
Item, "Z: showcode (whichever)" = New page & go to page, "mn" & enable mediumscreen mode & delay,200 & Find inline, "(whichever) menu*"
And nickname your menu.ini as "mn". (The asterisk is to prevent search hits where menus are mentioned elsewhere in the file: the line only finds itself.) Putting the menu name in the label is pointless for those on the menu-bar, but useful for popups.
There's no danger of versioning problems with menu.ini, because it's not modifiable through dialogs and therefore never gets saved from memory to disk. So there's no need to swap out of it. Quickest way to reload after saving changes: tap the "rename" button, then "OK".