v0.31.0 bf0756b

popup_staging_host.go RawHistoryFolder

1package ui
2
3import (
4	"context"
5	"fmt"
6	"sync"
7
8	"github.com/bnema/dumber/internal/ui/coordinator/content"
9	"github.com/bnema/dumber/internal/ui/window"
10	"github.com/bnema/puregotk/v4/gtk"
11)
12
13type popupStagingShell interface {
14	SetContent(*gtk.Widget)
15	DetachContent() *gtk.Widget
16	Destroy()
17}
18
19type popupStagingHost struct {
20	shell      popupStagingShell
21	attached   *gtk.Widget
22	once       sync.Once
23	cleanupErr error
24}
25
26var newPopupStagingWindow = func(ctx context.Context, app *gtk.Application) (popupStagingShell, error) {
27	return window.NewPopup(ctx, app)
28}
29
30var preparePopupStagingContentWidget = prepareNativePopupContentWidget
31
32func (h *popupStagingHost) cleanup() {
33	if h == nil {
34		return
35	}
36	h.once.Do(func() {
37		if h.shell != nil {
38			detached := h.shell.DetachContent()
39			if h.attached != nil && detached == nil {
40				h.cleanupErr = fmt.Errorf("popup staging content was not attached")
41			}
42			h.shell.Destroy()
43		}
44		h.attached = nil
45	})
46}
47
48func (h *popupStagingHost) Detach() error {
49	h.cleanup()
50	return h.cleanupErr
51}
52
53func (h *popupStagingHost) Destroy() { h.cleanup() }
54
55// stagePopup temporarily parents a WebKit popup widget in a hidden GTK shell.
56// The shell is deliberately never shown or presented.
57func (a *App) stagePopup(ctx context.Context, input content.StagePopupInput) (content.PopupStagingHost, error) {
58	if a == nil || a.gtkApp == nil {
59		return nil, fmt.Errorf("gtk application not available for popup staging")
60	}
61	if input.PopupWebView == nil {
62		return nil, fmt.Errorf("popup staging webview is nil")
63	}
64	if a.contentCoord == nil {
65		return nil, fmt.Errorf("content coordinator not available for popup staging")
66	}
67
68	shell, err := newPopupStagingWindow(ctx, a.gtkApp)
69	if err != nil {
70		return nil, err
71	}
72	widget := a.contentCoord.WrapWidget(ctx, input.PopupWebView)
73	gtkWidget, err := preparePopupStagingContentWidget(widget)
74	if err != nil {
75		shell.Destroy()
76		return nil, fmt.Errorf("prepare popup staging webview widget: %w", err)
77	}
78	shell.SetContent(gtkWidget)
79	return &popupStagingHost{shell: shell, attached: gtkWidget}, nil
80}
81
82var _ content.PopupStagingHost = (*popupStagingHost)(nil)

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