Skip to content

Commit 969c325

Browse files
authored
Added Code Structure (#214)
* docs: add code structure and prefs management documentation * docs: update heading level in desktop contribution guide
1 parent bff832a commit 969c325

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Code Structure
3+
description: Zen Browser Code Structure and Preference Management
4+
---
5+
6+
The Zen Browser is a fork of Firefox with custom features like vertical tabs, workspaces, and themes. The source code is organized in the `src/` directory, with patches and custom implementations for Zen-specific features.
7+
8+
## Main Directories
9+
- **src/zen/**: Contains Zen-specific features.
10+
- `workspaces/`: Implements workspace functionality (e.g., ZenWorkspaces.mjs, ZenWorkspace.mjs).
11+
- `compact-mode/`: Handles compact mode UI.
12+
- `glance/`: Quick tab preview feature.
13+
- `common/`: Shared utilities like ZenUIManager.mjs and ZenStartup.mjs.
14+
- `tabs/`: Tab management, including pinned tabs.
15+
- **src/browser/**: Browser components with patches (e.g., browser.xhtml patches).
16+
- **prefs/**: Preference files in YAML format for various features (e.g., zen.yaml for general prefs, glance.yaml for glance feature).
17+
18+
## How to Add New Preferences
19+
Preferences in Zen Browser are defined in YAML files under `prefs/`. These are loaded and applied to customize behavior.
20+
21+
### Steps to Add a New Pref
22+
1. **Choose or Create a YAML File**:
23+
- For workspace-related prefs, edit `prefs/zen.yaml` or create a new one like `workspaces.yaml` if needed.
24+
- Example structure in YAML:
25+
```yaml
26+
- name: zen.workspaces.new-pref
27+
value: true
28+
```
29+
30+
2. **Define the Pref**:
31+
- `name`: The preference key (e.g., 'zen.workspaces.enable-feature').
32+
- `value`: Default value (bool, string, int).
33+
- *`condition`: Optional*
34+
35+
3. **Integrate in Code**:
36+
- Use `Services.prefs.getBoolPref('zen.workspaces.new-pref', defaultValue)` in JavaScript files (e.g., ZenWorkspaces.mjs).
37+
38+
4. **Build and Test**:
39+
- Rebuild the browser.
40+
41+
42+
### Glance Example
43+
To add a pref for enabling/disabling the Glance feature:
44+
- In `prefs/glance.yaml`:
45+
```yaml
46+
- name: zen.glance.enabled
47+
value: true
48+
```
49+
- In `src/zen/glance/ZenGlanceManager.mjs`:
50+
```javascript
51+
const glanceEnabled = Services.prefs.getBoolPref('zen.glance.enabled', true);
52+
```
53+
54+
<Callout type="info" title="Tip">
55+
For more details, refer to existing preference definitions in the `prefs/` directory and their corresponding code implementations in `src/zen/`.
56+
</Callout>

0 commit comments

Comments
 (0)