-
-
Notifications
You must be signed in to change notification settings - Fork 89
Style Guide
Sonny Piers edited this page Aug 4, 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"))
// OK
Parent {
child: Box {
property-name: value;
};
}
// NOT OK
Parent {
child:
Box {
property-name: value;
};
}Prefer Blueprint when possible.
- Use 2-space indentation for all elements
- Use double-quotes for attributes (e.g.
<foo bar="baz">) - Place all tags on their own line, except elements with single-line values like
<property>
Use properties (eg widget.sensitive) over methods (eg widget.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
Please see existing code, or ask. Add anything you learn here.
- ...
- ...