GNOME Shell Style Guide
Gjs Style Guide
List external imports first, then list internal imports. Keep both sets in the alphabetical order and separate them by a blank line.
Imports of GNOME Shell C modules, such as imports.gi.Shell should be in the external imports set. This includes imports of modules that were copied from other projects, such as imports.gi.Big and imports.gi.Meta.
// Sample list of imports const Big = imports.gi.Big; const Clutter = imports.gi.Clutter; const Gtk = imports.gi.Gtk; const Lang = imports.lang; const Shell = imports.gi.Shell; const Main = imports.ui.main; const Overlay = imports.ui.overlay; const Panel = imports.ui.panel;
Place class methods into separate sections headed by the method type and maintained in the following order:
//// Public methods //// //// Protected methods //// //// Pure virtual protected methods //// //// Private methods ////
Have a comment on top of each method describing what the method does. Describe the return value if the method has one. There is no need to explicitly describe each argument if the method description makes it obvious what they are.
Protected Methods and Variables
Protected methods and variables, as well as private ones, should begin with an underscore.
Store a pointer from the wrapper to the actor in this.actor
Store a back-pointer from the actor to the wrapper in this.actor._delegate, if useful. (This is used by the drag-and-drop code, for instance, to find an acceptDrop() method for an actor.
Connect to the actor's destroy signal and perform cleanup there; don't assume that the actor will only be destroyed via codepaths in the wrapper. The wrapper may have a destroy() method of its own, but if so, it should just call this.actor.destroy();