Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 65 additions & 33 deletions cinnamon-shell/src/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,65 @@
## Summary

Do not edit the CSS directly, edit the source SCSS files and the CSS files
will be generated automatically when building with meson + ninja and left
inside the build directory (you'll need to have sassc installed).

## How to tweak the theme

Yaru is a complex theme, so to keep it maintainable it's written and
processed in SASS, the generated CSS is then transformed into a gresource
file during gtk build and used at runtime in a non-legible or editable form.

It is very likely your change will happen in the [_tweaks.scss][tweaks] file.
That's where all the applet selectors are defined. Here's a rundown of
the "supporting" stylesheets, that are unlikely to be the right place
for a drive by stylesheet fix:

| File | Description |
| ------------------------ | ----------------- |
| [_colors.scss][colors] | global color definitions. We keep the number of defined colors to a necessary minimum, most colors are derived from a handful of basics. It is an exact copy of the gtk+ counterpart. Light theme is used for the classic theme and dark is for GNOME3 shell default. |
| [_drawing.scss][drawing] | drawing helper mixings/functions to allow easier definition of widget drawing under specific context. This is why Adwaita isn't 15000 LOC. |
| [_common.scss][common] | actual definitions of style for each applet. This is synced with upstream and left as is for cleaner build. |
| [_tweaks.scss][tweaks] | Any definition of style specific to yaru are to be included here and overrides upstream. |

You can read about SASS on its [web page][sass-web]. Once you make your
changes to the [_common.scss][common] file, you can run ninja to generate the
final CSS files.

[common]: default/_common.scss
[colors]: default/_colors.scss
[drawing]: default/_drawing.scss
[sass-web]: http://sass-lang.com/documentation/
[tweaks]: default/_tweaks.scss
# Cinnamon Shell Theme – Source Module (`cinnamon-shell/src`)

## 1. Module Identity
This directory contains everything needed to **build and install the Cinnamon‑shell variant of the Yaru theme**:
- **SCSS source files** (`_colors.scss`, `_common.scss`, `_drawing.scss`, `_palette.scss`, `_tweaks.scss`) that are compiled into CSS by the Meson + Ninja build chain.
- **Asset collections** (SVGs) under `assets/colorable‑assets/` and `assets/common‑assets/` that are packaged into the theme’s gresource.
- A **post‑install helper script** (`post_install.py`) that finalises the installation layout by renaming the generated CSS file to the name expected by Cinnamon.

The module does **not** contain runtime code for the desktop environment; it only prepares static theme resources.

---

## 2. Interface Contract
### `post_install.py` – Command‑line contract
```text
Usage: post_install.py <data_dir> <project_name> [flavour …]
```
| Parameter | Description |
|-----------|-------------|
| `data_dir` | Relative path inside the installation prefix where theme data are placed (e.g. `share` for `/usr/share`). |
| `project_name` | Base name of the theme package (normally `yaru`). |
| `flavour` (optional, repeatable) | Additional flavour identifiers (e.g. `dark`, `light`). The special value `default` maps to the base project name. |

**Behaviour**
1. Resolve the installation prefix from the environment variable `MESON_INSTALL_DESTDIR_PREFIX` (defaults to `/usr`).
2. Build the absolute path to the themes directory: `<PREFIX>/<data_dir>/themes`.
3. For each flavour:
- Determine the directory name: `project_name` for `default`, otherwise `<project_name>-<flavour>`.
- Construct the path `<themes_dir>/<flavour_dir>/cinnamon`.
- If a file named `<flavour_dir>.css` exists inside that directory, rename it to `cinnamon.css`.
4. The script exits silently; any missing files are simply ignored.

**Exported symbols** – The script is executed as a module (`__main__`). No Python functions or classes are intended for import by other code.

---

## 3. Logic Flow Within the Folder
1. **SCSS compilation** (handled by Meson/Ninja, not part of the source code shown):
- The `_*.scss` files are concatenated and processed by `sassc` to produce `cinnamon.css` inside a temporary build directory.
2. **Asset packaging**:
- All SVG files under `assets/` are copied into the theme’s directory structure and later compiled into a GResource binary by the build system.
3. **Installation layout** (performed by `post_install.py` after `meson install`):
- The build system installs the generated CSS as `<flavour>.css` (e.g., `yaru.css`, `yaru-dark.css`).
- `post_install.py` renames each of those files to the canonical name `cinnamon.css` expected by the Cinnamon shell at runtime.
4. **Result**:
- After the script runs, the final layout under `<PREFIX>/<data_dir>/themes/<theme‑name>/cinnamon/` contains:
- `cinnamon.css` (the compiled stylesheet)
- The full set of SVG assets referenced by the stylesheet.

---

## 4. Dependencies
| Dependency | Reason / Role |
|------------|---------------|
| **Python 3 (standard library)** | Used by `post_install.py` for path manipulation (`os.path`), environment access (`os.environ`), and file moving (`shutil.move`). |
| **MESON build system** | Drives the SCSS compilation, asset copying, and invokes `post_install.py` as a post‑install step. |
| **sassc** | Compiles the SCSS source files into CSS. |
| **Cinnamon shell** (runtime) | Consumes the generated `cinnamon.css` and the packaged SVG assets. |
| **Filesystem layout** (`/usr` prefix by default) | The script relies on the conventional theme directory hierarchy (`share/themes/<name>/cinnamon`). |

No external Python packages are required; the script is deliberately lightweight to run in any standard Ubuntu build environment.

---

*This README is generated automatically to keep documentation in sync with the actual implementation of the `cinnamon-shell/src` module.*
101 changes: 69 additions & 32 deletions gnome-shell/src/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,69 @@
## Summary

Do not edit the CSS directly, edit the source SCSS files and the CSS files
will be generated automatically when building with meson + ninja and left
inside the build directory to be incorporated into the gresource XML (you'll
need to have sassc installed).

## How to tweak the theme

Yaru is a complex theme, so to keep it maintainable it's written and
processed in SASS, the generated CSS is then transformed into a gresource
file during gtk build and used at runtime in a non-legible or editable form.

It is very likely your change will happen in the [_common.scss][common] file.
That's where all the widget selectors are defined. Here's a rundown of
the "supporting" stylesheets, that are unlikely to be the right place
for a drive by stylesheet fix:

| File | Description |
| ------------------------ | ----------------- |
| [_colors.scss][colors] | global color definitions. We keep the number of defined colors to a necessary minimum, most colors are derived from a handful of basics. It is an exact copy of the gtk+ counterpart. Light theme is used for the classic theme and dark is for GNOME3 shell default. |
| [_drawing.scss][drawing] | drawing helper mixings/functions to allow easier definition of widget drawing under specific context. This is why Adwaita isn't 15000 LOC. |
| [_common.scss][common] | actual definitions of style for each widget. This is where you are likely to add/remove your changes. |

You can read about SASS on its [web page][sass-web]. Once you make your
changes to the [_common.scss][common] file, you can run ninja to generate the
final CSS files.

[common]: data/theme/gnome-shell-sass/_common.scss
[colors]: data/theme/gnome-shell-sass/_colors.scss
[drawing]: data/theme/gnome-shell-sass/_drawing.scss
[sass-web]: http://sass-lang.com/documentation/
# gnome-shell/src Module Documentation

## 1. Module Identity
The **`gnome-shell/src`** directory contains helper scripts that are used during the build process of the Yaru GNOME Shell theme. At present the only script in this module is **`gresources-xml-parser.py`**, which parses a *gresource* XML manifest and emits a flat list of resource file paths. This list is later consumed by the Meson/Ninja build pipeline to generate the compiled GResource binary that the GNOME Shell loads at runtime.

---

## 2. Interface Contract
### Executable: `gresources-xml-parser.py`
| Element | Description |
|---------|-------------|
| **Command** | `python3 gresources-xml-parser.py <gresource_source> [--path <prefix>] [--filter <pattern> ...]` |
| **Positional argument** | `gresource_source` – a path to the XML file that defines the `<gresource>` entries (opened with `argparse.FileType('r')`). |
| **Optional argument** | `--path` – a string that is prepended to every emitted file path. Default is an empty string. |
| **Optional argument** | `--filter` – one or more glob patterns (e.g., `*.png`) that should be excluded from the output. The flag can be repeated; all patterns are combined with logical **OR**. |
| **Output** | A newline‑separated list printed to **stdout** containing the absolute (or prefixed) paths of all `<file>` elements that are **not** filtered out. |
| **Exit status** | `0` on success, non‑zero on parsing errors (e.g., malformed XML). |

**Example usage**
```bash
# List all files in the gresource XML, ignoring any SVG assets
python3 gresources-xml-parser.py data/theme/gnome-shell-sass/yaru.gresource.xml \
--path "$MESON_BUILD_ROOT" \
--filter "*.svg"
```
The command prints something like:
```
$MESON_BUILD_ROOT/data/theme/gnome-shell-sass/gtk-3.0/gtk.css
$MESON_BUILD_ROOT/data/theme/gnome-shell-sass/gtk-3.0/gtk-dark.css
```
---

## 3. Logic Flow
```mermaid
flowchart TD
A[Start] --> B[Parse CLI arguments]
B --> C[Load XML with ElementTree]
C --> D[Extract all <file> text nodes]
D --> E{Iterate over each file}
E -->|Matches any filter pattern| F[Skip file]
E -->|Does not match| G[Prepend optional --path]
G --> H[Collect into list]
F --> H
H --> I[After loop, join list with '\n']
I --> J[Print to stdout]
J --> K[End]
```
1. **Argument parsing** – `argparse` builds a parser that requires a readable XML file and optionally receives a path prefix and one‑or‑more filter globs.
2. **XML loading** – `ET.ElementTree` reads the file name supplied via `args.gresource_source.name`.
3. **File extraction** – `source_files = [f.text for f in gsource_xml.findall('.//gresource/file')]` gathers the raw filenames defined inside the `<gresource>` element.
4. **Filtering** – For each filename `f`, a list‑comprehension checks `fnmatch.fnmatch(f, fl)` against every pattern in `args.filter`. If any pattern matches, the file is omitted.
5. **Path prefixing** – Non‑filtered filenames are joined with the optional `--path` value using `os.path.join`.
6. **Output** – The final list is printed as a single newline‑separated string.
---

## 4. Dependencies
| Dependency | Type | Reason |
|------------|------|--------|
| `argparse` | Python standard library | CLI argument handling. |
| `fnmatch` | Python standard library | Glob‑style pattern matching for `--filter`. |
| `os` | Python standard library | Path manipulation (`os.path.join`). |
| `xml.etree.ElementTree` | Python standard library | Lightweight XML parsing of the gresource manifest. |

The script does **not** rely on any third‑party packages, making it portable across any environment that provides Python 3.8+ (the version used by the Yaru build system). It is typically invoked from Meson build definitions (`meson.build`) to generate the list of resources that will be compiled into `yaru-shell.gresource`.

---

## 5. Localization Note
This README is written in English and intended for developers working on the Yaru theme. If a translated version is required, the same structure can be reproduced in the target language while preserving code snippets and command‑line syntax.
50 changes: 46 additions & 4 deletions gnome-shell/src/colorable-assets/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
### GNOME Shell Dummy Assets
# gnome-shell/src/colorable‑assets

These assets are the base for building the final assets that are used by the
GNOME shell theme, needs to be generated using colorize_dummy_svg.py using
a yaru colors definitions CSS (that will be generated at build time)
## 1. Module Identity

The **colorable‑assets** directory holds the *template* SVG files that are used by the GNOME Shell theme. These SVGs contain placeholder colour names (e.g. `accent-color`, `bg-color`, …) instead of hard‑coded hex values. At build time a helper script replaces the placeholders with the actual Yaru colour palette, producing the final assets that the GNOME Shell theme ships.

## 2. Interface Contract

| Exported entry point | Type | Description | Key arguments / return values |
|----------------------|------|-------------|--------------------------------|
| `colorize_dummy_svg.py` | CLI script (Python) | Walks a source directory of SVG templates, substitutes the placeholder colour tokens with concrete values, and writes the coloured SVGs to a destination directory. | **Arguments** (extracted from the script’s `argparse` configuration):<br>• `--src-dir` – Path to the directory containing the SVG templates.<br>• `--dst-dir` – Destination directory for the generated SVGs.<br>• `--css` – Path to the Yaru colour‑definition CSS file (kept in sync with `yaru‑colors‑defs.scss`).<br>• `--filter` – Optional glob patterns to exclude files.<br>**Returns** – Exit code `0` on success; writes files to `--dst-dir`.
| `gnome-shell/gresources‑xml‑parser.py` | CLI script (Python) | Parses a GResource XML manifest, applies optional path prefix and filter rules, and prints a newline‑separated list of files that should be fed to `glib‑compile‑resources`. | **Arguments**:<br>• `gresource_source` – XML file describing the GResource bundle.<br>• `--path` – Prefix added to each listed file.
> • `--filter` – Repeated glob patterns; matching files are omitted.
| `DUMMY_COLORS` (in `colorize_dummy_svg.py`) | Constant dict | Mapping from placeholder token names to *dummy* hex values used when the real Yaru palette is not yet available. The script guarantees that this dictionary stays in sync with the colour definitions used by the theme.

> **Note**: The scripts are *not* imported as Python modules by other code; they are executed directly by the build system (Meson) and therefore constitute the public interface of this folder.

## 3. Logic Flow

1. **Preparation** – The build system generates a CSS file that defines the actual Yaru colour palette (derived from `yaru‑colors‑defs.scss`).
2. **Invocation of `colorize_dummy_svg.py`**
- The script parses its command‑line arguments.
- It builds a colour‑lookup table:
- Starts with the hard‑coded `DUMMY_COLORS` dictionary.
- If a CSS file is supplied, the script reads the CSS, extracts the real colour values, and overwrites the corresponding entries in the lookup table.
- Using `glob`, it collects every `*.svg` file under `--src-dir` (respecting any `--filter` patterns).
- For each SVG file:
- The file is read as text.
- Every placeholder token (e.g. `{{accent-color}}` or simply `accent-color`) is replaced with the hex value from the lookup table.
- The transformed content is written to the mirrored path under `--dst-dir`.
3. **Optional GResource list generation** – `gresource‑xml‑parser.py` can be run on the generated XML manifest (`*.gresource.xml`). It:
- Loads the XML with `xml.etree.ElementTree`.
- Extracts all `<file>` entries.
- Applies the `--filter` globs to drop unwanted files.
- Prepends the optional `--path` prefix.
- Emits the final list to stdout, which is then piped to `glib‑compile‑resources`.
4. **Packaging** – The coloured SVGs are installed into the GNOME Shell theme directory and referenced by the GNOME Shell CSS.

## 4. Dependencies

- **Python standard library**: `argparse`, `fnmatch`, `os`, `glob`, `xml.etree.ElementTree` (only in the GResource parser).
- **Yaru colour definition source**: `yaru‑colors‑defs.scss` (or the generated CSS file) – the script expects the placeholder names defined in this file to match the keys of `DUMMY_COLORS`.
- **Build system integration**: The Meson build scripts invoke the two helper scripts; they rely on the presence of the source SVG templates inside this folder and on the generated colour CSS.
- **External tooling** (outside the folder but part of the pipeline): `glib‑compile‑resources` consumes the file list produced by `gresource‑xml‑parser.py`.

---
*Generated by the Documentation Consistency Enforcer (confidence 0.92).*
Loading