detached 2ffecd9

fix(shortcuts): migrate window_shortcuts.go to gotk4 API

- Replace InitializeGlobalShortcuts() with NewWindowShortcuts()
- Change RegisterGlobalShortcut() to RegisterShortcut()
- Fix GetZoom() return value (no error return in gotk4)
- Convert WebView IDs to string using IDString() helper:
  - getWebViewId() return value
  - close-popup message WebViewID field
- Simplify Cleanup() (WindowShortcuts needs no explicit cleanup)

Fixed 7 compilation errors in window-level keyboard shortcuts.
commit
2ffecd946497160f8674ea4399d7eb13f77d9254
author
bamen · · 2025-10-08 19:38 UTC
committer
bamen · · 2025-10-08 17:37 UTC
parent
042e3de
signature
unsigned
1 file · +8 -18
M internal/app/browser/window_shortcuts.go +8 -18
@@ -41,8 +41,8 @@ func NewWindowShortcutHandler(window *webkit.Window, app *BrowserApp) *WindowSho
4141 }
4242
4343 func (h *WindowShortcutHandler) initialize() error {
44- // Initialize GTK4 global shortcuts
45- h.shortcuts = h.window.InitializeGlobalShortcuts()
44+ // Create WindowShortcuts manager
45+ h.shortcuts = webkit.NewWindowShortcuts(h.window)
4646 if h.shortcuts == nil {
4747 return ErrFailedToInitialize
4848 }
@@ -75,11 +75,7 @@ func (h *WindowShortcutHandler) registerGlobalShortcuts() error {
7575 }
7676
7777 for _, shortcut := range shortcuts {
78- if err := h.shortcuts.RegisterGlobalShortcut(shortcut.key, shortcut.handler); err != nil {
79- log.Printf("[window-shortcuts] Failed to register %s (%s): %v",
80- shortcut.key, shortcut.desc, err)
81- return err
82- }
78+ h.shortcuts.RegisterShortcut(shortcut.key, shortcut.handler)
8379 log.Printf("[window-shortcuts] Registered global shortcut: %s (%s)",
8480 shortcut.key, shortcut.desc)
8581 }
@@ -208,11 +204,7 @@ func (h *WindowShortcutHandler) handleZoom(action string, multiplier float64) {
208204 log.Printf("[window-shortcuts] Zoom %s -> pane %p", action, activeWebView)
209205
210206 // Get current zoom level
211- currentZoom, err := activeWebView.GetZoom()
212- if err != nil {
213- log.Printf("[window-shortcuts] Failed to get current zoom: %v", err)
214- return
215- }
207+ currentZoom := activeWebView.GetZoom()
216208
217209 // Calculate new zoom level
218210 var newZoom float64
@@ -261,7 +253,7 @@ func (h *WindowShortcutHandler) getWebViewId(pane *BrowserPane) string {
261253 if pane == nil || pane.webView == nil {
262254 return "unknown"
263255 }
264- return pane.webView.ID()
256+ return pane.webView.IDString()
265257 }
266258
267259 func (h *WindowShortcutHandler) handleUIToggle(lastToggle *time.Time, featureName, action string) {
@@ -342,7 +334,7 @@ func (h *WindowShortcutHandler) handleClosePane() {
342334 // Use the proper close-popup message for popups
343335 msg := messaging.Message{
344336 Event: "close-popup",
345- WebViewID: activeWebView.ID(),
337+ WebViewID: activeWebView.IDString(),
346338 Reason: "user-ctrl-w",
347339 }
348340 h.app.workspace.OnWorkspaceMessage(activeWebView, msg)
@@ -355,10 +347,8 @@ func (h *WindowShortcutHandler) handleClosePane() {
355347
356348 // Cleanup releases resources
357349 func (h *WindowShortcutHandler) Cleanup() {
358- if h.shortcuts != nil {
359- h.shortcuts.Cleanup()
360- h.shortcuts = nil
361- }
350+ // WindowShortcuts doesn't require explicit cleanup
351+ h.shortcuts = nil
362352 }
363353
364354 // Error definitions
@@ -41,8 +41,8 @@ func NewWindowShortcutHandler(window *webkit.Window, app *BrowserApp) *WindowSho
41 }41 }
42 42
43 func (h *WindowShortcutHandler) initialize() error {43 func (h *WindowShortcutHandler) initialize() error {
44- // Initialize GTK4 global shortcuts44+ // Create WindowShortcuts manager
45- h.shortcuts = h.window.InitializeGlobalShortcuts()45+ h.shortcuts = webkit.NewWindowShortcuts(h.window)
46 if h.shortcuts == nil {46 if h.shortcuts == nil {
47 return ErrFailedToInitialize47 return ErrFailedToInitialize
48 }48 }
@@ -75,11 +75,7 @@ func (h *WindowShortcutHandler) registerGlobalShortcuts() error {
75 }75 }
76 76
77 for _, shortcut := range shortcuts {77 for _, shortcut := range shortcuts {
78- if err := h.shortcuts.RegisterGlobalShortcut(shortcut.key, shortcut.handler); err != nil {78+ h.shortcuts.RegisterShortcut(shortcut.key, shortcut.handler)
79- log.Printf("[window-shortcuts] Failed to register %s (%s): %v",
80- shortcut.key, shortcut.desc, err)
81- return err
82- }
83 log.Printf("[window-shortcuts] Registered global shortcut: %s (%s)",79 log.Printf("[window-shortcuts] Registered global shortcut: %s (%s)",
84 shortcut.key, shortcut.desc)80 shortcut.key, shortcut.desc)
85 }81 }
@@ -208,11 +204,7 @@ func (h *WindowShortcutHandler) handleZoom(action string, multiplier float64) {
208 log.Printf("[window-shortcuts] Zoom %s -> pane %p", action, activeWebView)204 log.Printf("[window-shortcuts] Zoom %s -> pane %p", action, activeWebView)
209 205
210 // Get current zoom level206 // Get current zoom level
211- currentZoom, err := activeWebView.GetZoom()207+ currentZoom := activeWebView.GetZoom()
212- if err != nil {
213- log.Printf("[window-shortcuts] Failed to get current zoom: %v", err)
214- return
215- }
216 208
217 // Calculate new zoom level209 // Calculate new zoom level
218 var newZoom float64210 var newZoom float64
@@ -261,7 +253,7 @@ func (h *WindowShortcutHandler) getWebViewId(pane *BrowserPane) string {
261 if pane == nil || pane.webView == nil {253 if pane == nil || pane.webView == nil {
262 return "unknown"254 return "unknown"
263 }255 }
264- return pane.webView.ID()256+ return pane.webView.IDString()
265 }257 }
266 258
267 func (h *WindowShortcutHandler) handleUIToggle(lastToggle *time.Time, featureName, action string) {259 func (h *WindowShortcutHandler) handleUIToggle(lastToggle *time.Time, featureName, action string) {
@@ -342,7 +334,7 @@ func (h *WindowShortcutHandler) handleClosePane() {
342 // Use the proper close-popup message for popups334 // Use the proper close-popup message for popups
343 msg := messaging.Message{335 msg := messaging.Message{
344 Event: "close-popup",336 Event: "close-popup",
345- WebViewID: activeWebView.ID(),337+ WebViewID: activeWebView.IDString(),
346 Reason: "user-ctrl-w",338 Reason: "user-ctrl-w",
347 }339 }
348 h.app.workspace.OnWorkspaceMessage(activeWebView, msg)340 h.app.workspace.OnWorkspaceMessage(activeWebView, msg)
@@ -355,10 +347,8 @@ func (h *WindowShortcutHandler) handleClosePane() {
355 347
356 // Cleanup releases resources348 // Cleanup releases resources
357 func (h *WindowShortcutHandler) Cleanup() {349 func (h *WindowShortcutHandler) Cleanup() {
358- if h.shortcuts != nil {350+ // WindowShortcuts doesn't require explicit cleanup
359- h.shortcuts.Cleanup()351+ h.shortcuts = nil
360- h.shortcuts = nil
361- }
362 }352 }
363 353
364 // Error definitions354 // Error definitions

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close