refactor(context): pass context as first parameter to webkit and ui methods
- commit
- 5740371e3aa1920a4b4997159164a095c325b3a1
- author
- brice · · 2025-12-16 20:14 UTC
- committer
- brice · · 2025-12-16 17:16 UTC
- parent
- bce8d5b
- signature
- unsigned
5 files · +12 -14
M internal/infrastructure/webkit/webview.go +2 -2
| @@ -143,7 +143,7 @@ func NewWebView(ctx context.Context, wkCtx *WebKitContext, settings *SettingsMan | |||
| 143 | 143 | ||
| 144 | 144 | // Apply settings if provided | |
| 145 | 145 | if settings != nil { | |
| 146 | - | settings.ApplyToWebView(inner) | |
| 146 | + | settings.ApplyToWebView(ctx, inner) | |
| 147 | 147 | } | |
| 148 | 148 | ||
| 149 | 149 | // Connect signals | |
| @@ -181,7 +181,7 @@ func NewWebViewWithRelated(ctx context.Context, parent *WebView, settings *Setti | |||
| 181 | 181 | wv.id = globalRegistry.register(wv) | |
| 182 | 182 | ||
| 183 | 183 | if settings != nil { | |
| 184 | - | settings.ApplyToWebView(inner) | |
| 184 | + | settings.ApplyToWebView(ctx, inner) | |
| 185 | 185 | } | |
| 186 | 186 | ||
| 187 | 187 | wv.connectSignals() | |
| @@ -143,7 +143,7 @@ func NewWebView(ctx context.Context, wkCtx *WebKitContext, settings *SettingsMan | |||||
| 143 | 143 | ||||
| 144 | // Apply settings if provided | 144 | // Apply settings if provided | ||
| 145 | if settings != nil { | 145 | if settings != nil { | ||
| 146 | - | settings.ApplyToWebView(inner) | 146 | + | settings.ApplyToWebView(ctx, inner) |
| 147 | } | 147 | } | ||
| 148 | 148 | ||||
| 149 | // Connect signals | 149 | // Connect signals | ||
| @@ -181,7 +181,7 @@ func NewWebViewWithRelated(ctx context.Context, parent *WebView, settings *Setti | |||||
| 181 | wv.id = globalRegistry.register(wv) | 181 | wv.id = globalRegistry.register(wv) | ||
| 182 | 182 | ||||
| 183 | if settings != nil { | 183 | if settings != nil { | ||
| 184 | - | settings.ApplyToWebView(inner) | 184 | + | settings.ApplyToWebView(ctx, inner) |
| 185 | } | 185 | } | ||
| 186 | 186 | ||||
| 187 | wv.connectSignals() | 187 | wv.connectSignals() | ||
M internal/ui/component/workspace_view.go +2 -2
| @@ -110,7 +110,7 @@ func NewWorkspaceView(ctx context.Context, factory layout.WidgetFactory) *Worksp | |||
| 110 | 110 | } | |
| 111 | 111 | ||
| 112 | 112 | // SetWorkspace sets the workspace to render and builds the widget tree. | |
| 113 | - | func (wv *WorkspaceView) SetWorkspace(ws *entity.Workspace) error { | |
| 113 | + | func (wv *WorkspaceView) SetWorkspace(ctx context.Context, ws *entity.Workspace) error { | |
| 114 | 114 | if ws == nil { | |
| 115 | 115 | return ErrNilWorkspace | |
| 116 | 116 | } | |
| @@ -240,7 +240,7 @@ func (wv *WorkspaceView) Rebuild(ctx context.Context) error { | |||
| 240 | 240 | return ErrNilWorkspace | |
| 241 | 241 | } | |
| 242 | 242 | ||
| 243 | - | return wv.SetWorkspace(ws) | |
| 243 | + | return wv.SetWorkspace(ctx, ws) | |
| 244 | 244 | } | |
| 245 | 245 | ||
| 246 | 246 | // FocusPane attempts to give focus to a specific pane. | |
| @@ -110,7 +110,7 @@ func NewWorkspaceView(ctx context.Context, factory layout.WidgetFactory) *Worksp | |||||
| 110 | } | 110 | } | ||
| 111 | 111 | ||||
| 112 | // SetWorkspace sets the workspace to render and builds the widget tree. | 112 | // SetWorkspace sets the workspace to render and builds the widget tree. | ||
| 113 | - | func (wv *WorkspaceView) SetWorkspace(ws *entity.Workspace) error { | 113 | + | func (wv *WorkspaceView) SetWorkspace(ctx context.Context, ws *entity.Workspace) error { |
| 114 | if ws == nil { | 114 | if ws == nil { | ||
| 115 | return ErrNilWorkspace | 115 | return ErrNilWorkspace | ||
| 116 | } | 116 | } | ||
| @@ -240,7 +240,7 @@ func (wv *WorkspaceView) Rebuild(ctx context.Context) error { | |||||
| 240 | return ErrNilWorkspace | 240 | return ErrNilWorkspace | ||
| 241 | } | 241 | } | ||
| 242 | 242 | ||||
| 243 | - | return wv.SetWorkspace(ws) | 243 | + | return wv.SetWorkspace(ctx, ws) |
| 244 | } | 244 | } | ||
| 245 | 245 | ||||
| 246 | // FocusPane attempts to give focus to a specific pane. | 246 | // FocusPane attempts to give focus to a specific pane. | ||
M internal/ui/controller/tab_controller.go +0 -1
| @@ -9,7 +9,6 @@ import ( | |||
| 9 | 9 | "github.com/bnema/dumber/internal/domain/entity" | |
| 10 | 10 | "github.com/bnema/dumber/internal/logging" | |
| 11 | 11 | "github.com/bnema/dumber/internal/ui/component" | |
| 12 | - | "github.com/rs/zerolog" | |
| 13 | 12 | ) | |
| 14 | 13 | ||
| 15 | 14 | // TabController synchronizes TabList domain state with the TabBar UI widget. | |
| @@ -9,7 +9,6 @@ import ( | |||||
| 9 | "github.com/bnema/dumber/internal/domain/entity" | 9 | "github.com/bnema/dumber/internal/domain/entity" | ||
| 10 | "github.com/bnema/dumber/internal/logging" | 10 | "github.com/bnema/dumber/internal/logging" | ||
| 11 | "github.com/bnema/dumber/internal/ui/component" | 11 | "github.com/bnema/dumber/internal/ui/component" | ||
| 12 | - | "github.com/rs/zerolog" | |||
| 13 | ) | 12 | ) | ||
| 14 | 13 | ||||
| 15 | // TabController synchronizes TabList domain state with the TabBar UI widget. | 14 | // TabController synchronizes TabList domain state with the TabBar UI widget. | ||
M internal/ui/input/keyboard.go +0 -1
| @@ -9,7 +9,6 @@ import ( | |||
| 9 | 9 | "github.com/bnema/dumber/internal/logging" | |
| 10 | 10 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 11 | 11 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| 12 | - | "github.com/rs/zerolog" | |
| 13 | 12 | ) | |
| 14 | 13 | ||
| 15 | 14 | // ActionHandler is called when a keyboard action is triggered. | |
| @@ -9,7 +9,6 @@ import ( | |||||
| 9 | "github.com/bnema/dumber/internal/logging" | 9 | "github.com/bnema/dumber/internal/logging" | ||
| 10 | "github.com/jwijenbergh/puregotk/v4/gdk" | 10 | "github.com/jwijenbergh/puregotk/v4/gdk" | ||
| 11 | "github.com/jwijenbergh/puregotk/v4/gtk" | 11 | "github.com/jwijenbergh/puregotk/v4/gtk" | ||
| 12 | - | "github.com/rs/zerolog" | |||
| 13 | ) | 12 | ) | ||
| 14 | 13 | ||||
| 15 | // ActionHandler is called when a keyboard action is triggered. | 14 | // ActionHandler is called when a keyboard action is triggered. | ||
M internal/ui/input/modal.go +8 -8
| @@ -71,7 +71,7 @@ func (m *ModalState) EnterTabMode(ctx context.Context, timeout time.Duration) { | |||
| 71 | 71 | ||
| 72 | 72 | if m.mode == ModeTab { | |
| 73 | 73 | // Already in tab mode, just reset timeout | |
| 74 | - | m.resetTimeoutLocked(timeout) | |
| 74 | + | m.resetTimeoutLocked(ctx, timeout) | |
| 75 | 75 | return | |
| 76 | 76 | } | |
| 77 | 77 | ||
| @@ -82,7 +82,7 @@ func (m *ModalState) EnterTabMode(ctx context.Context, timeout time.Duration) { | |||
| 82 | 82 | ||
| 83 | 83 | if timeout > 0 { | |
| 84 | 84 | m.timer = time.AfterFunc(timeout, func() { | |
| 85 | - | m.ExitMode() | |
| 85 | + | m.ExitMode(ctx) | |
| 86 | 86 | }) | |
| 87 | 87 | } | |
| 88 | 88 | ||
| @@ -106,7 +106,7 @@ func (m *ModalState) EnterPaneMode(ctx context.Context, timeout time.Duration) { | |||
| 106 | 106 | ||
| 107 | 107 | if m.mode == ModePane { | |
| 108 | 108 | // Already in pane mode, just reset timeout | |
| 109 | - | m.resetTimeoutLocked(timeout) | |
| 109 | + | m.resetTimeoutLocked(ctx, timeout) | |
| 110 | 110 | return | |
| 111 | 111 | } | |
| 112 | 112 | ||
| @@ -117,7 +117,7 @@ func (m *ModalState) EnterPaneMode(ctx context.Context, timeout time.Duration) { | |||
| 117 | 117 | ||
| 118 | 118 | if timeout > 0 { | |
| 119 | 119 | m.timer = time.AfterFunc(timeout, func() { | |
| 120 | - | m.ExitMode() | |
| 120 | + | m.ExitMode(ctx) | |
| 121 | 121 | }) | |
| 122 | 122 | } | |
| 123 | 123 | ||
| @@ -159,7 +159,7 @@ func (m *ModalState) ExitMode(ctx context.Context) { | |||
| 159 | 159 | ||
| 160 | 160 | // ResetTimeout restarts the mode timeout (e.g., after a valid keystroke). | |
| 161 | 161 | // Does nothing if not in a modal mode or if no timeout was set. | |
| 162 | - | func (m *ModalState) ResetTimeout() { | |
| 162 | + | func (m *ModalState) ResetTimeout(ctx context.Context) { | |
| 163 | 163 | m.mu.Lock() | |
| 164 | 164 | defer m.mu.Unlock() | |
| 165 | 165 | ||
| @@ -167,7 +167,7 @@ func (m *ModalState) ResetTimeout() { | |||
| 167 | 167 | return | |
| 168 | 168 | } | |
| 169 | 169 | ||
| 170 | - | m.resetTimeoutLocked(m.timeout) | |
| 170 | + | m.resetTimeoutLocked(ctx, m.timeout) | |
| 171 | 171 | } | |
| 172 | 172 | ||
| 173 | 173 | // SetOnModeChange sets the callback for mode changes. | |
| @@ -189,12 +189,12 @@ func (m *ModalState) cancelTimerLocked() { | |||
| 189 | 189 | ||
| 190 | 190 | // resetTimeoutLocked resets the timeout timer. | |
| 191 | 191 | // Must be called with m.mu held. | |
| 192 | - | func (m *ModalState) resetTimeoutLocked(timeout time.Duration) { | |
| 192 | + | func (m *ModalState) resetTimeoutLocked(ctx context.Context, timeout time.Duration) { | |
| 193 | 193 | m.cancelTimerLocked() | |
| 194 | 194 | m.timeout = timeout | |
| 195 | 195 | if timeout > 0 { | |
| 196 | 196 | m.timer = time.AfterFunc(timeout, func() { | |
| 197 | - | m.ExitMode() | |
| 197 | + | m.ExitMode(ctx) | |
| 198 | 198 | }) | |
| 199 | 199 | } | |
| 200 | 200 | } | |
| @@ -71,7 +71,7 @@ func (m *ModalState) EnterTabMode(ctx context.Context, timeout time.Duration) { | |||||
| 71 | 71 | ||||
| 72 | if m.mode == ModeTab { | 72 | if m.mode == ModeTab { | ||
| 73 | // Already in tab mode, just reset timeout | 73 | // Already in tab mode, just reset timeout | ||
| 74 | - | m.resetTimeoutLocked(timeout) | 74 | + | m.resetTimeoutLocked(ctx, timeout) |
| 75 | return | 75 | return | ||
| 76 | } | 76 | } | ||
| 77 | 77 | ||||
| @@ -82,7 +82,7 @@ func (m *ModalState) EnterTabMode(ctx context.Context, timeout time.Duration) { | |||||
| 82 | 82 | ||||
| 83 | if timeout > 0 { | 83 | if timeout > 0 { | ||
| 84 | m.timer = time.AfterFunc(timeout, func() { | 84 | m.timer = time.AfterFunc(timeout, func() { | ||
| 85 | - | m.ExitMode() | 85 | + | m.ExitMode(ctx) |
| 86 | }) | 86 | }) | ||
| 87 | } | 87 | } | ||
| 88 | 88 | ||||
| @@ -106,7 +106,7 @@ func (m *ModalState) EnterPaneMode(ctx context.Context, timeout time.Duration) { | |||||
| 106 | 106 | ||||
| 107 | if m.mode == ModePane { | 107 | if m.mode == ModePane { | ||
| 108 | // Already in pane mode, just reset timeout | 108 | // Already in pane mode, just reset timeout | ||
| 109 | - | m.resetTimeoutLocked(timeout) | 109 | + | m.resetTimeoutLocked(ctx, timeout) |
| 110 | return | 110 | return | ||
| 111 | } | 111 | } | ||
| 112 | 112 | ||||
| @@ -117,7 +117,7 @@ func (m *ModalState) EnterPaneMode(ctx context.Context, timeout time.Duration) { | |||||
| 117 | 117 | ||||
| 118 | if timeout > 0 { | 118 | if timeout > 0 { | ||
| 119 | m.timer = time.AfterFunc(timeout, func() { | 119 | m.timer = time.AfterFunc(timeout, func() { | ||
| 120 | - | m.ExitMode() | 120 | + | m.ExitMode(ctx) |
| 121 | }) | 121 | }) | ||
| 122 | } | 122 | } | ||
| 123 | 123 | ||||
| @@ -159,7 +159,7 @@ func (m *ModalState) ExitMode(ctx context.Context) { | |||||
| 159 | 159 | ||||
| 160 | // ResetTimeout restarts the mode timeout (e.g., after a valid keystroke). | 160 | // ResetTimeout restarts the mode timeout (e.g., after a valid keystroke). | ||
| 161 | // Does nothing if not in a modal mode or if no timeout was set. | 161 | // Does nothing if not in a modal mode or if no timeout was set. | ||
| 162 | - | func (m *ModalState) ResetTimeout() { | 162 | + | func (m *ModalState) ResetTimeout(ctx context.Context) { |
| 163 | m.mu.Lock() | 163 | m.mu.Lock() | ||
| 164 | defer m.mu.Unlock() | 164 | defer m.mu.Unlock() | ||
| 165 | 165 | ||||
| @@ -167,7 +167,7 @@ func (m *ModalState) ResetTimeout() { | |||||
| 167 | return | 167 | return | ||
| 168 | } | 168 | } | ||
| 169 | 169 | ||||
| 170 | - | m.resetTimeoutLocked(m.timeout) | 170 | + | m.resetTimeoutLocked(ctx, m.timeout) |
| 171 | } | 171 | } | ||
| 172 | 172 | ||||
| 173 | // SetOnModeChange sets the callback for mode changes. | 173 | // SetOnModeChange sets the callback for mode changes. | ||
| @@ -189,12 +189,12 @@ func (m *ModalState) cancelTimerLocked() { | |||||
| 189 | 189 | ||||
| 190 | // resetTimeoutLocked resets the timeout timer. | 190 | // resetTimeoutLocked resets the timeout timer. | ||
| 191 | // Must be called with m.mu held. | 191 | // Must be called with m.mu held. | ||
| 192 | - | func (m *ModalState) resetTimeoutLocked(timeout time.Duration) { | 192 | + | func (m *ModalState) resetTimeoutLocked(ctx context.Context, timeout time.Duration) { |
| 193 | m.cancelTimerLocked() | 193 | m.cancelTimerLocked() | ||
| 194 | m.timeout = timeout | 194 | m.timeout = timeout | ||
| 195 | if timeout > 0 { | 195 | if timeout > 0 { | ||
| 196 | m.timer = time.AfterFunc(timeout, func() { | 196 | m.timer = time.AfterFunc(timeout, func() { | ||
| 197 | - | m.ExitMode() | 197 | + | m.ExitMode(ctx) |
| 198 | }) | 198 | }) | ||
| 199 | } | 199 | } | ||
| 200 | } | 200 | } | ||