v0.12.1 1453d21

window.go RawHistoryFolder

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