v0.12.0 d035193

window.go RawHistoryFolder

1package webkit
2
3import (
4	"github.com/diamondburned/gotk4/pkg/gtk/v4"
5)
6
7// Window wraps a GTK Window for the browser
8type Window struct {
9	win *gtk.Window
10}
11
12// NewWindow creates a new GTK window with the given title
13func NewWindow(title string) (*Window, error) {
14	InitMainThread()
15
16	win := gtk.NewWindow()
17	if win == nil {
18		return nil, ErrWebViewNotInitialized
19	}
20
21	win.SetTitle(title)
22	win.SetDefaultSize(1024, 768)
23
24	return &Window{win: win}, nil
25}
26
27// SetTitle updates the window title
28func (w *Window) SetTitle(title string) {
29	if w == nil || w.win == nil {
30		return
31	}
32	w.win.SetTitle(title)
33}
34
35// SetChild sets the child widget of the window
36func (w *Window) SetChild(child gtk.Widgetter) {
37	if w == nil || w.win == nil {
38		return
39	}
40	w.win.SetChild(child)
41}
42
43// Show makes the window visible
44// Note: In GTK4, Show() is deprecated. Use SetVisible(true) instead.
45func (w *Window) Show() {
46	if w == nil || w.win == nil {
47		return
48	}
49	w.win.SetVisible(true)
50}
51
52// Present brings the window to the front
53func (w *Window) Present() {
54	if w == nil || w.win == nil {
55		return
56	}
57	w.win.Present()
58}
59
60// Close destroys the window
61func (w *Window) Close() {
62	if w == nil || w.win == nil {
63		return
64	}
65	w.win.Close()
66}
67
68// AsWindow returns the underlying gtk.Window for advanced operations
69func (w *Window) AsWindow() *gtk.Window {
70	if w == nil {
71		return nil
72	}
73	return w.win
74}
75
76// SetDefaultSize sets the default window size
77func (w *Window) SetDefaultSize(width, height int) {
78	if w == nil || w.win == nil {
79		return
80	}
81	w.win.SetDefaultSize(width, height)
82}
83
84// Destroy destroys the window
85func (w *Window) Destroy() {
86	if w == nil || w.win == nil {
87		return
88	}
89	w.win.Destroy()
90}
91
92// 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