-
-
Notifications
You must be signed in to change notification settings - Fork 90
Style Guide
Sonny Piers edited this page Aug 26, 2023
·
8 revisions
- Follow the GNOME HIG Writing Style
- Use Adwaita's Style Classes
- Mark user-visible strings as translatable (e.g.
_("Example")) - Prefer high-level widgets like
Adw.StatusPageandGtk.Stack - Prefer properties like
Gtk.Box:spacingtoGtk.Widget:margin-topfor layout - Avoid hard-coded height and width, except for e.g. images with fixed geometry
- Prefer HIG terms (Radio Groups, Checkboxes) over technical ones (Checkbuttons)
- Use Adwaita's Named Colors
- Use Adwaita's Style Classes
- Use 2-space indentation for all elements
- Use one space between colon and values (e.g.
property-name: value;) - Use double-quotes for strings (e.g.
"quoted")
- Use 2-space indentation for all elements
- Use one space between colon and values (e.g.
property-name: value;) - Use double-quotes for strings (e.g.
"quoted") - Mark user-visible strings as translatable (e.g.
_("Example"))
Prefix the object id with the name of the class.
- KO:
next_button - OK:
button_next
// OK
Parent {
child: Box {
property-name: value;
};
}
// NOT OK
Parent {
child:
Box {
property-name: value;
};
}- Use construct-time properties, when possible
- Use properties (eg
widget.sensitive) over methods (egwidget.set_sensitive)
- Prefer
async/await - Use ESModules for imports
- Do not use
asyncsignal handlers, instead usemyFunction().catch(logError) - camelCase for functions for example
function openFile - snake_case for variables/constants for example
const button_ok - Use named functions except for inline callbacks where you should use anonymous functions
- Use 2-space indentation for all elements
-
Gio._promisify()should be directly below theimportstatements
- All errors should use
logError()
Please see existing code, or ask. Add anything you learn here.
- ...
- ...