User:Mconnor/Past/Extensions2.0: Difference between revisions
(→Prefs) |
|||
Line 40: | Line 40: | ||
=== showSidebar === | === showSidebar === | ||
'''Description''': opens aURL in the sidebar (HTML, can be local) | '''Description''': opens aURL in the sidebar (HTML, can be local) | ||
showSidebar(aOpen, aURL) | showSidebar(aOpen, aURL) | ||
Revision as of 21:58, 23 January 2009
This is totally a draft/work in progress/piece of junk.
We propose to add an Extensions object to the sandbox, which exposes the following:
UI
General Notes
These are objects, they have add/remove methods, take an argument that specifies a mount point (left as null, we do the right thing).
Possible example would be something like:
var menuitem = new Extensions.UI.Menuitem(); menuitem.label = "Click Me!"; menuitem.action = "doStuff()"; menuitem.add("myButton", "context-menu");
Menu
Menuitem
ContextMenu
Toolbar
ToolbarButton
StatusbarItem
Shortcut
Actions
showAlert
Exposes nsIAlertsService.showAlertNotification
showAlert(aTitle, aMessage, aImage, aCallback)
showPrompt
showPrompt(title, message, button0Label, button1Label, button2Label, checkboxLabel, checked);
Description: wraps promptservice, used for all modal dialogs
- returns an array: [0/1/2, checked]
- if a label is not provided, the element is not used
- Extensions.Actions.showPrompt("Hi","Please click OK","OK");
showSidebar
Description: opens aURL in the sidebar (HTML, can be local)
showSidebar(aOpen, aURL)
Content
TBD
Prefs
Notes: this is just going to be a basic key pair array, that gets saved as JSON. No int/bool/etc nonsense, duck typing hurrah, screw prefapi and about:config, this at least is isolated and doesn't need prefbranches or about:config or anything.
savePrefs
savePrefs()
takes no args, just allows an explicit dump of prefs to disk. Prefs are automatically saved on exit.
loadPrefs
loadPrefs()
loads the saved prefs from disk, replacing the current in-memory prefs
resetPrefs
resetPrefs()
clears all prefs.
setPref
setPref(prefName, value)
Saves the value given for the given prefName
getPref
getPref(prefName, defaultValue)
Gets the stored value of prefName, returns defaultValue if no value is provided.
clearPref
clearPref(prefName)
Deletes the pref and stored value.
Storage
TBD
need to talk to sdwilsh about this. Looking to provide minimal functionality to store stuff beyond prefs, not sure we need more than one table in a DB. Seems elaborate for what is otherwise a simple API