v0.15.0 9006957

window.go RawHistoryFolder

1package webkit
2
3import (
4	"fmt"
5
6	"github.com/bnema/dumber/internal/logging"
7	"github.com/diamondburned/gotk4/pkg/gtk/v4"
8)
9
10// Window wraps a GTK Window for the browser
11type Window struct {
12	win *gtk.Window
13}
14
15// NewWindow creates a new GTK window with the given title
16func NewWindow(title string) (*Window, error) {
17	InitMainThread()
18
19	win := gtk.NewWindow()
20	if win == nil {
21		return nil, ErrWebViewNotInitialized
22	}
23
24	win.SetTitle(title)
25	win.SetDefaultSize(1024, 768)
26
27	// Connect close-request signal to handle Cmd+Q and window close button
28	// Returning true prevents the default close behavior and allows graceful shutdown
29	win.ConnectCloseRequest(func() bool {
30		logging.Info(fmt.Sprintf("[window] Close request received (Cmd+Q or close button) - initiating graceful shutdown"))
31		// Quit the main loop gracefully, which will trigger cleanup
32		QuitMainLoop()
33		// Return true to prevent GTK from destroying the window immediately
34		// The cleanup process will handle window destruction
35		return true
36	})
37
38	return &Window{win: win}, nil
39}
40
41// SetTitle updates the window title
42func (w *Window) SetTitle(title string) {
43	if w == nil || w.win == nil {
44		return
45	}
46	w.win.SetTitle(title)
47}
48
49// SetChild sets the child widget of the window
50func (w *Window) SetChild(child gtk.Widgetter) {
51	if w == nil || w.win == nil {
52		return
53	}
54	w.win.SetChild(child)
55}
56
57// Show makes the window visible
58// Note: In GTK4, Show() is deprecated. Use SetVisible(true) instead.
59func (w *Window) Show() {
60	if w == nil || w.win == nil {
61		return
62	}
63	w.win.SetVisible(true)
64}
65
66// Present brings the window to the front
67func (w *Window) Present() {
68	if w == nil || w.win == nil {
69		return
70	}
71	w.win.Present()
72}
73
74// Close destroys the window
75func (w *Window) Close() {
76	if w == nil || w.win == nil {
77		return
78	}
79	w.win.Close()
80}
81
82// AsWindow returns the underlying gtk.Window for advanced operations
83func (w *Window) AsWindow() *gtk.Window {
84	if w == nil {
85		return nil
86	}
87	return w.win
88}
89
90// SetDefaultSize sets the default window size
91func (w *Window) SetDefaultSize(width, height int) {
92	if w == nil || w.win == nil {
93		return
94	}
95	w.win.SetDefaultSize(width, height)
96}
97
98// Destroy destroys the window
99func (w *Window) Destroy() {
100	if w == nil || w.win == nil {
101		return
102	}
103	w.win.Destroy()
104}
105
106// InitializeGlobalShortcuts is defined in shortcuts.go and implemented there

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