Platform Team/Sweets Distribution/Features/Plugins

< Platform Team‎ | Sweets Distribution
Revision as of 03:13, 12 August 2012 by Alsroot (talk | contribs) (Created page with "Plugins are pluggable Sugar Shell code. By design, plugins are not isolated from the rest of shell code and each over, thus, they are assumed to be setup by Sugar distributors...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Plugins are pluggable Sugar Shell code. By design, plugins are not isolated from the rest of shell code and each over, thus, they are assumed to be setup by Sugar distributors or experienced users.

Plugin ia a Python module placed to /opt/sweets/sugar/src/jarabe/plugins/PLUGIN_NAME directory. To make plugin module useful, it should contain the following variables and functions:

  • ORDER
    Required. Variable with plugin order. Plugins with smaller ORDER will be initiated and started earlier.
  • TITLE
    Optional. This title will appear in Sweets Distribution Control Panel component to let user a chance to enable/disable plugin. If TITLE is omitted, plugin will be enabled unconditionally.
  • init()
    Required. Initialize the plugin. This function will be called before Shell initialization phase, so, it is possible to put here monkey patching code.
  • start()
    Required. Start the plugin. Actual starting the plugin. This function will be called when Shell starts heavy code like Journal.
  • binding()
    Optional. Posix shell commands to source before starting Sugar Shell. Function should return a list of strings. Resulting lines will be sourced before starting Sugar Shell process. Note that sourcing will happen before starting DBus session and after X session.
  • control_panel_section()
    Optional. If it exists, it should return a widget to place as a sub-section to Sweets Distribution Control Panel section. Returnig widget should take care about reading/writing plugin configuration on its own and should assume applying configuration changes right after making them, i.e., without any apply buttons. The regular way to handle plugin configuration is using Option class like below example code does.

Use example plugin source as a template for new one.