Open Bug 1134277 Opened 10 years ago Updated 2 years ago

New API: register new toolbox button

Categories

(DevTools :: Framework, enhancement, P3)

x86_64
Windows 7
enhancement

Tracking

(Not tracked)

People

(Reporter: Honza, Unassigned)

References

Details

The list of "toolbox buttons" is generated from hardcoded |ToolboxButtons| array defined in toolbox.js (and also from devtools.toolbox.toolbarSpec pref) This array isn't accessible from extensions, and so it isn't possible to add new buttons to it. New API should allow: - register new tool buttons (e.g. when an extension is enabled) - unregister new tool buttons (e.g. when an extension is disabled) Does it make sense? Honza
I am not sure who to cc on this, but Brian, Alex, any insights? Honza
Flags: needinfo?(bgrinstead)
Some relevant code for toolbox button registration is in DeveloperToolbar.jsm [0], which is called on toolbox startup [1]. The way buttons are currently registered requires that they be set up with GCLI, which is done in a variety of places. One way this happens is if the command is stored in the toolkit/gcli/commands folder [2], in this case it is added to gcli in commands-index.js [3]. Another way is when a command [4] associated with a tool in main.js [5]. We should formalize a pattern for adding a command button, and allow for registration after a toolbox has been opened (probably through the gDevTools object). Perhaps we could add a gDevTools.addCommandButton() function that takes in a GCLI command object and registers the command and button at the same time. Or maybe we need to decouple the two objects - I remember at least one instance when I added a hidden command (that would never show up in the command line interface) just in order to get a button in the UI. Needinfoing Joe to for his thoughts. Either way, this is probably blocked on the gcli refactors for Bug 1128988. [0]: https://dxr.mozilla.org/mozilla-central/source/browser/devtools/shared/DeveloperToolbar.jsm#96 [1]: https://dxr.mozilla.org/mozilla-central/source/browser/devtools/framework/toolbox.js#680 [2]: https://dxr.mozilla.org/mozilla-central/source/toolkit/devtools/gcli/commands/paintflashing.js [3]: https://dxr.mozilla.org/mozilla-central/source/browser/devtools/commandline/commands-index.js#24 [4]: https://dxr.mozilla.org/mozilla-central/source/browser/devtools/inspector/inspector-commands.js#9 [5]: https://dxr.mozilla.org/mozilla-central/source/browser/devtools/main.js#108
Depends on: 1128988
Flags: needinfo?(bgrinstead) → needinfo?(jwalker)
GCLI commands, like Toolbox panels are metadata which is put somewhere accessible. That means we don't need to execute code to see what it offers and it gives devtools more control over what happens with the things offered by extensions, I think toolbox buttons should be similar. I also think it was probably a mistake to conflate the definition of a button so tightly with a command. I think we should have buttons that can kick off commands or other functions, but buttons should not be in and of themselves commands. So I think we could do something like this in main.js: Tools.webConsole = { id: "webconsole", ... commands: "devtools/webconsole/console-commands", buttons: [ { buttonId: "command-button-splitconsole", buttonClass: "command-button command-button-invertable", tooltipText: l10n.lookup("splitconsoleTooltip"), isChecked: function(target) { ... }, onChange: function(target, changeHandler) { ... }, exec: "splitconsole" // executes the command, could be function }, ] };
Flags: needinfo?(jwalker)
Severity: normal → enhancement
Priority: -- → P3
Product: Firefox → DevTools
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.