Skip to content

refactor(widgets): extract duplicated container init into BaseWidget#825

Merged
amnweb merged 1 commit intomainfrom
refactor/extract-widget-container-init
Mar 29, 2026
Merged

refactor(widgets): extract duplicated container init into BaseWidget#825
amnweb merged 1 commit intomainfrom
refactor/extract-widget-container-init

Conversation

@amnweb
Copy link
Copy Markdown
Owner

@amnweb amnweb commented Mar 28, 2026

Move the repeated widget container setup block from widget subclasses into BaseWidget._init_container(). Move build_widget_label() from a standalone function in utilities.py to a BaseWidget instance method for better encapsulation.

Widgets NOT changed (we can consider refactoring these in the future for consistency)

Widget Reason
systray.py Complex setup, adds sub-widgets and popup before widget_layout.addWidget
taskbar.py Uses TaskbarDropWidget instead of QFrame, layout obtained from .main_layout
komorebi/stack.py Adds _offline_text and _no_window_text to layout before container creation, hides container
komorebi/workspaces.py Uses _workspace_container naming, different from standard pattern (buttons added dynamically, different class)
glazewm/workspaces.py Container hidden initially, offline_text added between creation and shadow, 2 items added to widget_layout
glazewm/tiling_direction.py Completely different pattern: uses QPushButton as container, no _widget_container at all
grouper.py Uses "container" class and also has collapse button logic interleaved
update_check.py Different widget structure

@amnweb amnweb changed the title refactor(widgets): extract duplicated container init into BaseWidget [WIP] refactor(widgets): extract duplicated container init into BaseWidget Mar 28, 2026
- Add _init_container() and build_widget_label() to BaseWidget
- Refactor all standard widgets to use the new base methods
- Remove build_widget_label() from utilities.py
- Clean up unused QFrame/QHBoxLayout/add_shadow imports per widget
- Update Writing-Widget.md documentation
@amnweb amnweb force-pushed the refactor/extract-widget-container-init branch from 5b2246e to 8de165b Compare March 29, 2026 16:08
@amnweb amnweb marked this pull request as ready for review March 29, 2026 16:21
@amnweb amnweb changed the title [WIP] refactor(widgets): extract duplicated container init into BaseWidget refactor(widgets): extract duplicated container init into BaseWidget Mar 29, 2026
@amnweb amnweb merged commit 20cd092 into main Mar 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant