Showcode: click to see inside toolbars and menus
Tuesday, 8. January 2008, 07:05:31
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,"toolbar" & Find & Insert, "Pagebar Head.content" & delay,1 & click default button
(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: those are written into the Find dialog that pops up:
So I tap Showcode, read the name, and then dismiss it.
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 "toolbar", 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. I got the dialog, and found the "Remember This" option on the dialog didn't work. What does work is manually 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). Some people don't have this problem; file types handling is a murky topic (see here, if interested). (I have txt,ini,adr,dat,lng,mbs,idx on that list: making it possible to inspect and edit most of Opera's innards within the browser.)
-
assigning nicknames: to avoid the need for paths, Showcode uses nicknames - calls your toolbar INI by the nickname "toolbar", and menu INI by the nickname "menu". 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. The Find box will appear with the name in it - read, dismiss, close toolbar file.)
Mainbar: // . . Main bar
Status bar: // . . Status bar
StartBar: // . . Start bar
Address bar: // . . Address bar
My Buttons: // . . My Buttons
Pagebar Head: // . . Pagebar head
Source View toolbar:// . . Source View Toolbar
Panel header: // . . Panel header
Notes panel toolbar: // . . Notes panel toolbar
Bookmarks panel toolbar: // . . Boomarks panel toolbar
History Panel toolbar: // . . History panel toolbar
Notes fullpage toolbar: // . . Notes full tollbar
Bookmarks fullpage toolbar: // . . Bookmarks full toolbar
History fullpage 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, and the search dialog pops up with "(bar you picked) content" in its field. Run the search. You should see the code for your toolbar, bracketed by a green search hit on the section header and a yellow search hit on the Showcode-button line (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.
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.
Menu showcode
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, "menu" & Find & insert, "(whichever) menu*" & delay,1 & click default button
And nickname your menu.ini as "menu". (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".







Ted # 6. July 2008, 20:08