detached 163e508

Tighten CEF file dialog callback and GIO cleanup

commit
163e508f7eb16335fc9505906b1aa59f87b05a8f
author
brice · · 2026-05-08 00:55 UTC
parent
f2194b1
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +17 -5
M internal/infrastructure/cef/file_dialog.go +17 -5
@@ -108,7 +108,7 @@ func presentGTKFileDialog(wv *WebView, req cefFileDialogRequest, callback purece
108108 Int32("mode", req.Mode).
109109 Msg("cef: GTK file dialog response received")
110110 if normalizedResponseID != int(gtk.ResponseAcceptValue) {
111- logCEFFileDialog(wv).Debug().Msg("cef: file dialog cancelled")
111+ logCEFFileDialog(wv).Debug().Msg("cef: file dialog canceled")
112112 dispatchFileDialogResult(wv, callback, nil)
113113 return
114114 }
@@ -196,6 +196,7 @@ func applyDefaultDialogPath(dialog *gtk.FileChooserNative, req cefFileDialogRequ
196196 if req.Mode == purecef.FileDialogModeFileDialogSave {
197197 if dir := filepath.Dir(path); dir != "." && dir != "" {
198198 if folder := gio.FileNewForPath(dir); folder != nil {
199+ defer unrefGObjectPointer(folder.GoPointer())
199200 _, _ = dialog.SetCurrentFolder(folder)
200201 }
201202 }
@@ -207,6 +208,7 @@ func applyDefaultDialogPath(dialog *gtk.FileChooserNative, req cefFileDialogRequ
207208
208209 if info, err := os.Stat(path); err == nil && info.IsDir() {
209210 if folder := gio.FileNewForPath(path); folder != nil {
211+ defer unrefGObjectPointer(folder.GoPointer())
210212 _, _ = dialog.SetCurrentFolder(folder)
211213 }
212214 return
@@ -214,11 +216,13 @@ func applyDefaultDialogPath(dialog *gtk.FileChooserNative, req cefFileDialogRequ
214216
215217 if dir := filepath.Dir(path); dir != "." && dir != "" {
216218 if folder := gio.FileNewForPath(dir); folder != nil {
219+ defer unrefGObjectPointer(folder.GoPointer())
217220 _, _ = dialog.SetCurrentFolder(folder)
218221 }
219222 }
220223 if req.Mode != purecef.FileDialogModeFileDialogOpenFolder {
221224 if file := gio.FileNewForPath(path); file != nil {
225+ defer unrefGObjectPointer(file.GoPointer())
222226 _, _ = dialog.SetFile(file)
223227 }
224228 }
@@ -353,7 +357,10 @@ func folderUploadPaths(wv *WebView, mode purecef.FileDialogMode, paths []string)
353357 }
354358 info, err := os.Stat(folder)
355359 if err != nil || !info.IsDir() {
356- logCEFFileDialog(wv).Warn().Err(err).Str("path", folder).Msg("cef: folder upload path expansion skipped; selected path is not a directory")
360+ logCEFFileDialog(wv).Warn().
361+ Err(err).
362+ Str("path", folder).
363+ Msg("cef: folder upload path expansion skipped; selected path is not a directory")
357364 return paths
358365 }
359366
@@ -379,11 +386,16 @@ func folderUploadPaths(wv *WebView, mode purecef.FileDialogMode, paths []string)
379386 return nil
380387 })
381388 if walkErr != nil {
382- logCEFFileDialog(wv).Warn().Err(walkErr).Str("folder", folder).Msg("cef: folder upload descendant enumeration failed; using selected directory path")
389+ logCEFFileDialog(wv).Warn().
390+ Err(walkErr).
391+ Str("folder", folder).
392+ Msg("cef: folder upload descendant enumeration failed; using selected directory path")
383393 return paths
384394 }
385395 if len(files) == 0 {
386- logCEFFileDialog(wv).Warn().Str("folder", folder).Msg("cef: folder upload descendant enumeration found no regular files; using selected directory path")
396+ logCEFFileDialog(wv).Warn().
397+ Str("folder", folder).
398+ Msg("cef: folder upload descendant enumeration found no regular files; using selected directory path")
387399 return paths
388400 }
389401
@@ -445,11 +457,11 @@ func dispatchFileDialogResult(wv *WebView, callback purecef.FileDialogCallback,
445457
446458 func continueCEFFileDialogWithLogs(logger *zerolog.Logger, callback purecef.FileDialogCallback, filePaths ...string) {
447459 logger = nonNilCEFFileDialogLogger(logger)
448- callbackPtr := rawCEFPointer(callback)
449460 if callback == nil {
450461 logger.Debug().Msg("cef: file dialog callback continuation skipped; callback is nil")
451462 return
452463 }
464+ callbackPtr := rawCEFPointer(callback)
453465
454466 if len(filePaths) == 0 {
455467 logger.Debug().Uint64("callback_ptr", uint64(callbackPtr)).Msg("cef: invoking file dialog callback cancel")
@@ -108,7 +108,7 @@ func presentGTKFileDialog(wv *WebView, req cefFileDialogRequest, callback purece
108 Int32("mode", req.Mode).108 Int32("mode", req.Mode).
109 Msg("cef: GTK file dialog response received")109 Msg("cef: GTK file dialog response received")
110 if normalizedResponseID != int(gtk.ResponseAcceptValue) {110 if normalizedResponseID != int(gtk.ResponseAcceptValue) {
111- logCEFFileDialog(wv).Debug().Msg("cef: file dialog cancelled")111+ logCEFFileDialog(wv).Debug().Msg("cef: file dialog canceled")
112 dispatchFileDialogResult(wv, callback, nil)112 dispatchFileDialogResult(wv, callback, nil)
113 return113 return
114 }114 }
@@ -196,6 +196,7 @@ func applyDefaultDialogPath(dialog *gtk.FileChooserNative, req cefFileDialogRequ
196 if req.Mode == purecef.FileDialogModeFileDialogSave {196 if req.Mode == purecef.FileDialogModeFileDialogSave {
197 if dir := filepath.Dir(path); dir != "." && dir != "" {197 if dir := filepath.Dir(path); dir != "." && dir != "" {
198 if folder := gio.FileNewForPath(dir); folder != nil {198 if folder := gio.FileNewForPath(dir); folder != nil {
199+ defer unrefGObjectPointer(folder.GoPointer())
199 _, _ = dialog.SetCurrentFolder(folder)200 _, _ = dialog.SetCurrentFolder(folder)
200 }201 }
201 }202 }
@@ -207,6 +208,7 @@ func applyDefaultDialogPath(dialog *gtk.FileChooserNative, req cefFileDialogRequ
207 208
208 if info, err := os.Stat(path); err == nil && info.IsDir() {209 if info, err := os.Stat(path); err == nil && info.IsDir() {
209 if folder := gio.FileNewForPath(path); folder != nil {210 if folder := gio.FileNewForPath(path); folder != nil {
211+ defer unrefGObjectPointer(folder.GoPointer())
210 _, _ = dialog.SetCurrentFolder(folder)212 _, _ = dialog.SetCurrentFolder(folder)
211 }213 }
212 return214 return
@@ -214,11 +216,13 @@ func applyDefaultDialogPath(dialog *gtk.FileChooserNative, req cefFileDialogRequ
214 216
215 if dir := filepath.Dir(path); dir != "." && dir != "" {217 if dir := filepath.Dir(path); dir != "." && dir != "" {
216 if folder := gio.FileNewForPath(dir); folder != nil {218 if folder := gio.FileNewForPath(dir); folder != nil {
219+ defer unrefGObjectPointer(folder.GoPointer())
217 _, _ = dialog.SetCurrentFolder(folder)220 _, _ = dialog.SetCurrentFolder(folder)
218 }221 }
219 }222 }
220 if req.Mode != purecef.FileDialogModeFileDialogOpenFolder {223 if req.Mode != purecef.FileDialogModeFileDialogOpenFolder {
221 if file := gio.FileNewForPath(path); file != nil {224 if file := gio.FileNewForPath(path); file != nil {
225+ defer unrefGObjectPointer(file.GoPointer())
222 _, _ = dialog.SetFile(file)226 _, _ = dialog.SetFile(file)
223 }227 }
224 }228 }
@@ -353,7 +357,10 @@ func folderUploadPaths(wv *WebView, mode purecef.FileDialogMode, paths []string)
353 }357 }
354 info, err := os.Stat(folder)358 info, err := os.Stat(folder)
355 if err != nil || !info.IsDir() {359 if err != nil || !info.IsDir() {
356- logCEFFileDialog(wv).Warn().Err(err).Str("path", folder).Msg("cef: folder upload path expansion skipped; selected path is not a directory")360+ logCEFFileDialog(wv).Warn().
361+ Err(err).
362+ Str("path", folder).
363+ Msg("cef: folder upload path expansion skipped; selected path is not a directory")
357 return paths364 return paths
358 }365 }
359 366
@@ -379,11 +386,16 @@ func folderUploadPaths(wv *WebView, mode purecef.FileDialogMode, paths []string)
379 return nil386 return nil
380 })387 })
381 if walkErr != nil {388 if walkErr != nil {
382- logCEFFileDialog(wv).Warn().Err(walkErr).Str("folder", folder).Msg("cef: folder upload descendant enumeration failed; using selected directory path")389+ logCEFFileDialog(wv).Warn().
390+ Err(walkErr).
391+ Str("folder", folder).
392+ Msg("cef: folder upload descendant enumeration failed; using selected directory path")
383 return paths393 return paths
384 }394 }
385 if len(files) == 0 {395 if len(files) == 0 {
386- logCEFFileDialog(wv).Warn().Str("folder", folder).Msg("cef: folder upload descendant enumeration found no regular files; using selected directory path")396+ logCEFFileDialog(wv).Warn().
397+ Str("folder", folder).
398+ Msg("cef: folder upload descendant enumeration found no regular files; using selected directory path")
387 return paths399 return paths
388 }400 }
389 401
@@ -445,11 +457,11 @@ func dispatchFileDialogResult(wv *WebView, callback purecef.FileDialogCallback,
445 457
446 func continueCEFFileDialogWithLogs(logger *zerolog.Logger, callback purecef.FileDialogCallback, filePaths ...string) {458 func continueCEFFileDialogWithLogs(logger *zerolog.Logger, callback purecef.FileDialogCallback, filePaths ...string) {
447 logger = nonNilCEFFileDialogLogger(logger)459 logger = nonNilCEFFileDialogLogger(logger)
448- callbackPtr := rawCEFPointer(callback)
449 if callback == nil {460 if callback == nil {
450 logger.Debug().Msg("cef: file dialog callback continuation skipped; callback is nil")461 logger.Debug().Msg("cef: file dialog callback continuation skipped; callback is nil")
451 return462 return
452 }463 }
464+ callbackPtr := rawCEFPointer(callback)
453 465
454 if len(filePaths) == 0 {466 if len(filePaths) == 0 {
455 logger.Debug().Uint64("callback_ptr", uint64(callbackPtr)).Msg("cef: invoking file dialog callback cancel")467 logger.Debug().Uint64("callback_ptr", uint64(callbackPtr)).Msg("cef: invoking file dialog callback cancel")

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