6.5  Builtin Functions and Objects

gDesklets provides a few functions and objects for use in the scripting environment.

Name Arguments Description
add_timer

interval: integer

callback: function

Runs the function callback after interval milliseconds. If the function returns True, it will be called again after interval milliseconds.
get_config

key: string

default: any (optional)

Retrieves a previously stored configuration value for key or the value given by default, if the value had not been stored previously.
get_control [deprecated]

interface: string

Returns a control implementing the given interface interface. The use of this functions is deprecated and should be replaced by the <control> tag.
launch

command: string

Allows for safe execution of a command. A dialog asks the user if they want to allow it before it may run.
MenuItem

path: string

label: string (optional)

icon: uri (optional)

callback: function (optional)

args: list (optional)

active: boolean (optional)

Constructor for MenuItem objects. A menu is a list of MenuItem objects. See here for how to build custom menus.
set_config

key: string

value: any

Stores the value given by value for the key given by key. Stored values are private to each display instance and are saved across sessions.
Unit

value: float

unit: enum

Constructor for Unit objects. The unit argument must be one of PX, CM, IN, PT, PERCENT.
CM Enumeration value for centimeters for the Unit constructor.
IN Enumeration value for inches for the Unit constructor.
PERCENT Enumeration value for percentages for the Unit constructor. The percentage value is always relative to the size of the parent element.
PT Enumeration value for (DTP) points for the Unit constructor (one DTP point is 1/72 inch).
PX Enumeration value for pixels for the Unit constructor.