Implement custom layout persistence

Features:
- Custom layouts now saved to ~/.local/share/gridsnap/layouts.json
- Layouts automatically loaded on extension initialization
- Layouts persist across Cinnamon restarts and extension reloads
- Only custom layouts saved to file (default layouts remain in code)
- Added GLib and Gio imports for file operations
- Error handling for file read/write operations

Technical implementation:
- _loadLayouts(): Merges default layouts with saved custom layouts on startup
- _saveLayouts(): Extracts and saves only custom-* layouts to JSON file
- Automatically creates storage directory if it doesn't exist
- Called when user saves a layout in the graphical editor

Fixes TODO item #1 - Custom Layout Persistence

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-15 21:02:58 -07:00
parent 30db2e3ed9
commit 19f7c7faec
2 changed files with 73 additions and 12 deletions

14
TODO.md
View File

@@ -2,14 +2,14 @@
## Critical Issues
### 1. Custom Layout Persistence (extension.js:297)
### 1. Custom Layout Persistence ✅ COMPLETED
**Priority: High**
- [ ] Custom layouts are only stored in memory
- [ ] Layouts are lost when extension reloads or Cinnamon restarts
- [ ] Need to implement file-based storage
- [ ] Location: `~/.config/gridsnap/layouts.json` or similar
- [ ] Save layouts when created in graphical editor
- [ ] Load layouts on extension initialization
- [x] Custom layouts are only stored in memory
- [x] Layouts are lost when extension reloads or Cinnamon restarts
- [x] Need to implement file-based storage
- [x] Location: `~/.local/share/gridsnap/layouts.json`
- [x] Save layouts when created in graphical editor
- [x] Load layouts on extension initialization
### 2. Remove Last Zone Implementation (extension.js:236-274)
**Priority: Medium**