v0.22.0 a85da87

gtk_widgets.go RawHistoryFolder

1package layout
2
3import (
4	"github.com/jwijenbergh/puregotk/v4/gdk"
5	"github.com/jwijenbergh/puregotk/v4/gobject"
6	"github.com/jwijenbergh/puregotk/v4/graphene"
7	"github.com/jwijenbergh/puregotk/v4/gtk"
8	"github.com/jwijenbergh/puregotk/v4/pango"
9)
10
11// Ensure implementations satisfy interfaces at compile time.
12var (
13	_ Widget            = (*gtkWidget)(nil)
14	_ PanedWidget       = (*gtkPaned)(nil)
15	_ BoxWidget         = (*gtkBox)(nil)
16	_ OverlayWidget     = (*gtkOverlay)(nil)
17	_ LabelWidget       = (*gtkLabel)(nil)
18	_ ButtonWidget      = (*gtkButton)(nil)
19	_ ImageWidget       = (*gtkImage)(nil)
20	_ ProgressBarWidget = (*gtkProgressBar)(nil)
21	_ SpinnerWidget     = (*gtkSpinner)(nil)
22	_ WidgetFactory     = (*GtkWidgetFactory)(nil)
23)
24
25// gtkWidget wraps a gtk.Widget to implement the Widget interface.
26type gtkWidget struct {
27	inner *gtk.Widget
28}
29
30func (w *gtkWidget) Show()                         { w.inner.Show() }
31func (w *gtkWidget) Hide()                         { w.inner.Hide() }
32func (w *gtkWidget) SetVisible(visible bool)       { w.inner.SetVisible(visible) }
33func (w *gtkWidget) IsVisible() bool               { return w.inner.GetVisible() }
34func (w *gtkWidget) GrabFocus() bool               { return w.inner.GrabFocus() }
35func (w *gtkWidget) HasFocus() bool                { return w.inner.HasFocus() }
36func (w *gtkWidget) SetCanFocus(canFocus bool)     { w.inner.SetCanFocus(canFocus) }
37func (w *gtkWidget) SetFocusOnClick(focus bool)    { w.inner.SetFocusOnClick(focus) }
38func (w *gtkWidget) SetCanTarget(canTarget bool)   { w.inner.SetCanTarget(canTarget) }
39func (w *gtkWidget) SetHexpand(expand bool)        { w.inner.SetHexpand(expand) }
40func (w *gtkWidget) SetVexpand(expand bool)        { w.inner.SetVexpand(expand) }
41func (w *gtkWidget) GetHexpand() bool              { return w.inner.GetHexpand() }
42func (w *gtkWidget) GetVexpand() bool              { return w.inner.GetVexpand() }
43func (w *gtkWidget) SetHalign(align gtk.Align)     { w.inner.SetHalign(align) }
44func (w *gtkWidget) SetValign(align gtk.Align)     { w.inner.SetValign(align) }
45func (w *gtkWidget) SetSizeRequest(w2, h int)      { w.inner.SetSizeRequest(w2, h) }
46func (w *gtkWidget) AddCssClass(class string)      { w.inner.AddCssClass(class) }
47func (w *gtkWidget) RemoveCssClass(class string)   { w.inner.RemoveCssClass(class) }
48func (w *gtkWidget) HasCssClass(class string) bool { return w.inner.HasCssClass(class) }
49func (w *gtkWidget) Unparent()                     { w.inner.Unparent() }
50func (w *gtkWidget) GtkWidget() *gtk.Widget        { return w.inner }
51
52func (w *gtkWidget) GetParent() Widget {
53	parent := w.inner.GetParent()
54	if parent == nil {
55		return nil
56	}
57	return &gtkWidget{inner: parent}
58}
59
60func (w *gtkWidget) GetAllocatedWidth() int               { return w.inner.GetAllocatedWidth() }
61func (w *gtkWidget) GetAllocatedHeight() int              { return w.inner.GetAllocatedHeight() }
62func (w *gtkWidget) AddController(c *gtk.EventController) { w.inner.AddController(c) }
63
64func (w *gtkWidget) ComputePoint(target Widget) (x, y float64, ok bool) {
65	srcPoint := &graphene.Point{X: 0, Y: 0}
66	outPoint := &graphene.Point{}
67
68	var targetGtk *gtk.Widget
69	if target != nil {
70		targetGtk = target.GtkWidget()
71	}
72
73	ok = w.inner.ComputePoint(targetGtk, srcPoint, outPoint)
74	if !ok {
75		return 0, 0, false
76	}
77	return float64(outPoint.X), float64(outPoint.Y), true
78}
79
80// gtkPaned wraps gtk.Paned to implement PanedWidget.
81type gtkPaned struct {
82	inner *gtk.Paned
83}
84
85func (p *gtkPaned) Show()                         { p.inner.Show() }
86func (p *gtkPaned) Hide()                         { p.inner.Hide() }
87func (p *gtkPaned) SetVisible(visible bool)       { p.inner.SetVisible(visible) }
88func (p *gtkPaned) IsVisible() bool               { return p.inner.GetVisible() }
89func (p *gtkPaned) GrabFocus() bool               { return p.inner.GrabFocus() }
90func (p *gtkPaned) HasFocus() bool                { return p.inner.HasFocus() }
91func (p *gtkPaned) SetCanFocus(canFocus bool)     { p.inner.SetCanFocus(canFocus) }
92func (p *gtkPaned) SetFocusOnClick(focus bool)    { p.inner.SetFocusOnClick(focus) }
93func (p *gtkPaned) SetCanTarget(canTarget bool)   { p.inner.SetCanTarget(canTarget) }
94func (p *gtkPaned) SetHexpand(expand bool)        { p.inner.SetHexpand(expand) }
95func (p *gtkPaned) SetVexpand(expand bool)        { p.inner.SetVexpand(expand) }
96func (p *gtkPaned) GetHexpand() bool              { return p.inner.GetHexpand() }
97func (p *gtkPaned) GetVexpand() bool              { return p.inner.GetVexpand() }
98func (p *gtkPaned) SetHalign(align gtk.Align)     { p.inner.SetHalign(align) }
99func (p *gtkPaned) SetValign(align gtk.Align)     { p.inner.SetValign(align) }
100func (p *gtkPaned) SetSizeRequest(w, h int)       { p.inner.SetSizeRequest(w, h) }
101func (p *gtkPaned) AddCssClass(class string)      { p.inner.AddCssClass(class) }
102func (p *gtkPaned) RemoveCssClass(class string)   { p.inner.RemoveCssClass(class) }
103func (p *gtkPaned) HasCssClass(class string) bool { return p.inner.HasCssClass(class) }
104func (p *gtkPaned) Unparent()                     { p.inner.Unparent() }
105func (p *gtkPaned) GtkWidget() *gtk.Widget        { return &p.inner.Widget }
106
107func (p *gtkPaned) GetParent() Widget {
108	parent := p.inner.GetParent()
109	if parent == nil {
110		return nil
111	}
112	return &gtkWidget{inner: parent}
113}
114
115func (p *gtkPaned) SetStartChild(child Widget) {
116	if child == nil {
117		p.inner.SetStartChild(nil)
118		return
119	}
120	p.inner.SetStartChild(child.GtkWidget())
121}
122
123func (p *gtkPaned) SetEndChild(child Widget) {
124	if child == nil {
125		p.inner.SetEndChild(nil)
126		return
127	}
128	p.inner.SetEndChild(child.GtkWidget())
129}
130
131func (p *gtkPaned) GetStartChild() Widget {
132	child := p.inner.GetStartChild()
133	if child == nil {
134		return nil
135	}
136	return &gtkWidget{inner: child}
137}
138
139func (p *gtkPaned) GetEndChild() Widget {
140	child := p.inner.GetEndChild()
141	if child == nil {
142		return nil
143	}
144	return &gtkWidget{inner: child}
145}
146
147func (p *gtkPaned) SetPosition(pos int)        { p.inner.SetPosition(pos) }
148func (p *gtkPaned) GetPosition() int           { return p.inner.GetPosition() }
149func (p *gtkPaned) SetResizeStartChild(r bool) { p.inner.SetResizeStartChild(r) }
150func (p *gtkPaned) SetResizeEndChild(r bool)   { p.inner.SetResizeEndChild(r) }
151func (p *gtkPaned) GetResizeStartChild() bool  { return p.inner.GetResizeStartChild() }
152func (p *gtkPaned) GetResizeEndChild() bool    { return p.inner.GetResizeEndChild() }
153func (p *gtkPaned) SetShrinkStartChild(s bool) { p.inner.SetShrinkStartChild(s) }
154func (p *gtkPaned) SetShrinkEndChild(s bool)   { p.inner.SetShrinkEndChild(s) }
155func (p *gtkPaned) GetShrinkStartChild() bool  { return p.inner.GetShrinkStartChild() }
156func (p *gtkPaned) GetShrinkEndChild() bool    { return p.inner.GetShrinkEndChild() }
157func (p *gtkPaned) SetWideHandle(wide bool)    { p.inner.SetWideHandle(wide) }
158func (p *gtkPaned) GetWideHandle() bool        { return p.inner.GetWideHandle() }
159
160func (p *gtkPaned) ConnectMap(callback func()) uint32 {
161	cb := func(_ gtk.Widget) {
162		callback()
163	}
164	return p.inner.ConnectMap(&cb)
165}
166
167func (p *gtkPaned) ConnectNotifyPosition(callback func()) uint32 {
168	cb := func(_ gobject.Object, _ uintptr) {
169		callback()
170	}
171	return p.inner.ConnectNotifyWithDetail("position", &cb)
172}
173
174func (p *gtkPaned) AddTickCallback(callback func() bool) uint {
175	cb := gtk.TickCallback(func(widget uintptr, frameClock uintptr, userData uintptr) bool {
176		return callback()
177	})
178	return p.inner.AddTickCallback(&cb, 0, nil)
179}
180
181func (p *gtkPaned) GetAllocatedWidth() int               { return p.inner.GetAllocatedWidth() }
182func (p *gtkPaned) GetAllocatedHeight() int              { return p.inner.GetAllocatedHeight() }
183func (p *gtkPaned) AddController(c *gtk.EventController) { p.inner.AddController(c) }
184
185func (p *gtkPaned) ComputePoint(target Widget) (x, y float64, ok bool) {
186	srcPoint := &graphene.Point{X: 0, Y: 0}
187	outPoint := &graphene.Point{}
188
189	var targetGtk *gtk.Widget
190	if target != nil {
191		targetGtk = target.GtkWidget()
192	}
193
194	ok = p.inner.ComputePoint(targetGtk, srcPoint, outPoint)
195	if !ok {
196		return 0, 0, false
197	}
198	return float64(outPoint.X), float64(outPoint.Y), true
199}
200
201// gtkBox wraps gtk.Box to implement BoxWidget.
202type gtkBox struct {
203	inner *gtk.Box
204}
205
206func (b *gtkBox) Show()                         { b.inner.Show() }
207func (b *gtkBox) Hide()                         { b.inner.Hide() }
208func (b *gtkBox) SetVisible(visible bool)       { b.inner.SetVisible(visible) }
209func (b *gtkBox) IsVisible() bool               { return b.inner.GetVisible() }
210func (b *gtkBox) GrabFocus() bool               { return b.inner.GrabFocus() }
211func (b *gtkBox) HasFocus() bool                { return b.inner.HasFocus() }
212func (b *gtkBox) SetCanFocus(canFocus bool)     { b.inner.SetCanFocus(canFocus) }
213func (b *gtkBox) SetFocusOnClick(focus bool)    { b.inner.SetFocusOnClick(focus) }
214func (b *gtkBox) SetCanTarget(canTarget bool)   { b.inner.SetCanTarget(canTarget) }
215func (b *gtkBox) SetHexpand(expand bool)        { b.inner.SetHexpand(expand) }
216func (b *gtkBox) SetVexpand(expand bool)        { b.inner.SetVexpand(expand) }
217func (b *gtkBox) GetHexpand() bool              { return b.inner.GetHexpand() }
218func (b *gtkBox) GetVexpand() bool              { return b.inner.GetVexpand() }
219func (b *gtkBox) SetHalign(align gtk.Align)     { b.inner.SetHalign(align) }
220func (b *gtkBox) SetValign(align gtk.Align)     { b.inner.SetValign(align) }
221func (b *gtkBox) SetSizeRequest(w, h int)       { b.inner.SetSizeRequest(w, h) }
222func (b *gtkBox) AddCssClass(class string)      { b.inner.AddCssClass(class) }
223func (b *gtkBox) RemoveCssClass(class string)   { b.inner.RemoveCssClass(class) }
224func (b *gtkBox) HasCssClass(class string) bool { return b.inner.HasCssClass(class) }
225func (b *gtkBox) Unparent()                     { b.inner.Unparent() }
226func (b *gtkBox) GtkWidget() *gtk.Widget        { return &b.inner.Widget }
227
228func (b *gtkBox) GetParent() Widget {
229	parent := b.inner.GetParent()
230	if parent == nil {
231		return nil
232	}
233	return &gtkWidget{inner: parent}
234}
235
236func (b *gtkBox) Append(child Widget) {
237	if child == nil {
238		return
239	}
240	b.inner.Append(child.GtkWidget())
241}
242
243func (b *gtkBox) Prepend(child Widget) {
244	if child == nil {
245		return
246	}
247	b.inner.Prepend(child.GtkWidget())
248}
249
250func (b *gtkBox) Remove(child Widget) {
251	if child == nil {
252		return
253	}
254	b.inner.Remove(child.GtkWidget())
255}
256
257func (b *gtkBox) InsertChildAfter(child, sibling Widget) {
258	if child == nil {
259		return
260	}
261	var sibGtk *gtk.Widget
262	if sibling != nil {
263		sibGtk = sibling.GtkWidget()
264	}
265	b.inner.InsertChildAfter(child.GtkWidget(), sibGtk)
266}
267
268func (b *gtkBox) ReorderChildAfter(child, sibling Widget) {
269	if child == nil {
270		return
271	}
272	var sibGtk *gtk.Widget
273	if sibling != nil {
274		sibGtk = sibling.GtkWidget()
275	}
276	b.inner.ReorderChildAfter(child.GtkWidget(), sibGtk)
277}
278
279func (b *gtkBox) SetHomogeneous(h bool)        { b.inner.SetHomogeneous(h) }
280func (b *gtkBox) GetHomogeneous() bool         { return b.inner.GetHomogeneous() }
281func (b *gtkBox) SetSpacing(s int)             { b.inner.SetSpacing(s) }
282func (b *gtkBox) GetSpacing() int              { return b.inner.GetSpacing() }
283func (b *gtkBox) SetOrientation(o Orientation) { b.inner.SetOrientation(o) }
284func (b *gtkBox) GetOrientation() Orientation  { return b.inner.GetOrientation() }
285
286func (b *gtkBox) GetAllocatedWidth() int               { return b.inner.GetAllocatedWidth() }
287func (b *gtkBox) GetAllocatedHeight() int              { return b.inner.GetAllocatedHeight() }
288func (b *gtkBox) AddController(c *gtk.EventController) { b.inner.AddController(c) }
289
290func (b *gtkBox) ComputePoint(target Widget) (x, y float64, ok bool) {
291	srcPoint := &graphene.Point{X: 0, Y: 0}
292	outPoint := &graphene.Point{}
293
294	var targetGtk *gtk.Widget
295	if target != nil {
296		targetGtk = target.GtkWidget()
297	}
298
299	ok = b.inner.ComputePoint(targetGtk, srcPoint, outPoint)
300	if !ok {
301		return 0, 0, false
302	}
303	return float64(outPoint.X), float64(outPoint.Y), true
304}
305
306// gtkOverlay wraps gtk.Overlay to implement OverlayWidget.
307type gtkOverlay struct {
308	inner *gtk.Overlay
309}
310
311func (o *gtkOverlay) Show()                         { o.inner.Show() }
312func (o *gtkOverlay) Hide()                         { o.inner.Hide() }
313func (o *gtkOverlay) SetVisible(visible bool)       { o.inner.SetVisible(visible) }
314func (o *gtkOverlay) IsVisible() bool               { return o.inner.GetVisible() }
315func (o *gtkOverlay) GrabFocus() bool               { return o.inner.GrabFocus() }
316func (o *gtkOverlay) HasFocus() bool                { return o.inner.HasFocus() }
317func (o *gtkOverlay) SetCanFocus(canFocus bool)     { o.inner.SetCanFocus(canFocus) }
318func (o *gtkOverlay) SetFocusOnClick(focus bool)    { o.inner.SetFocusOnClick(focus) }
319func (o *gtkOverlay) SetCanTarget(canTarget bool)   { o.inner.SetCanTarget(canTarget) }
320func (o *gtkOverlay) SetHexpand(expand bool)        { o.inner.SetHexpand(expand) }
321func (o *gtkOverlay) SetVexpand(expand bool)        { o.inner.SetVexpand(expand) }
322func (o *gtkOverlay) GetHexpand() bool              { return o.inner.GetHexpand() }
323func (o *gtkOverlay) GetVexpand() bool              { return o.inner.GetVexpand() }
324func (o *gtkOverlay) SetHalign(align gtk.Align)     { o.inner.SetHalign(align) }
325func (o *gtkOverlay) SetValign(align gtk.Align)     { o.inner.SetValign(align) }
326func (o *gtkOverlay) SetSizeRequest(w, h int)       { o.inner.SetSizeRequest(w, h) }
327func (o *gtkOverlay) AddCssClass(class string)      { o.inner.AddCssClass(class) }
328func (o *gtkOverlay) RemoveCssClass(class string)   { o.inner.RemoveCssClass(class) }
329func (o *gtkOverlay) HasCssClass(class string) bool { return o.inner.HasCssClass(class) }
330func (o *gtkOverlay) Unparent()                     { o.inner.Unparent() }
331func (o *gtkOverlay) GtkWidget() *gtk.Widget        { return &o.inner.Widget }
332
333func (o *gtkOverlay) GetParent() Widget {
334	parent := o.inner.GetParent()
335	if parent == nil {
336		return nil
337	}
338	return &gtkWidget{inner: parent}
339}
340
341func (o *gtkOverlay) SetChild(child Widget) {
342	if child == nil {
343		o.inner.SetChild(nil)
344		return
345	}
346	o.inner.SetChild(child.GtkWidget())
347}
348
349func (o *gtkOverlay) GetChild() Widget {
350	child := o.inner.GetChild()
351	if child == nil {
352		return nil
353	}
354	return &gtkWidget{inner: child}
355}
356
357func (o *gtkOverlay) AddOverlay(overlay Widget) {
358	if overlay == nil {
359		return
360	}
361	o.inner.AddOverlay(overlay.GtkWidget())
362}
363
364func (o *gtkOverlay) RemoveOverlay(overlay Widget) {
365	if overlay == nil {
366		return
367	}
368	o.inner.RemoveOverlay(overlay.GtkWidget())
369}
370
371func (o *gtkOverlay) SetClipOverlay(overlay Widget, clip bool) {
372	if overlay == nil {
373		return
374	}
375	o.inner.SetClipOverlay(overlay.GtkWidget(), clip)
376}
377
378func (o *gtkOverlay) GetClipOverlay(overlay Widget) bool {
379	if overlay == nil {
380		return false
381	}
382	return o.inner.GetClipOverlay(overlay.GtkWidget())
383}
384
385func (o *gtkOverlay) SetMeasureOverlay(overlay Widget, measure bool) {
386	if overlay == nil {
387		return
388	}
389	o.inner.SetMeasureOverlay(overlay.GtkWidget(), measure)
390}
391
392func (o *gtkOverlay) GetMeasureOverlay(overlay Widget) bool {
393	if overlay == nil {
394		return false
395	}
396	return o.inner.GetMeasureOverlay(overlay.GtkWidget())
397}
398
399func (o *gtkOverlay) GetAllocatedWidth() int               { return o.inner.GetAllocatedWidth() }
400func (o *gtkOverlay) GetAllocatedHeight() int              { return o.inner.GetAllocatedHeight() }
401func (o *gtkOverlay) AddController(c *gtk.EventController) { o.inner.AddController(c) }
402
403func (o *gtkOverlay) ComputePoint(target Widget) (x, y float64, ok bool) {
404	srcPoint := &graphene.Point{X: 0, Y: 0}
405	outPoint := &graphene.Point{}
406
407	var targetGtk *gtk.Widget
408	if target != nil {
409		targetGtk = target.GtkWidget()
410	}
411
412	ok = o.inner.ComputePoint(targetGtk, srcPoint, outPoint)
413	if !ok {
414		return 0, 0, false
415	}
416	return float64(outPoint.X), float64(outPoint.Y), true
417}
418
419// gtkLabel wraps gtk.Label to implement LabelWidget.
420type gtkLabel struct {
421	inner *gtk.Label
422}
423
424func (l *gtkLabel) Show()                         { l.inner.Show() }
425func (l *gtkLabel) Hide()                         { l.inner.Hide() }
426func (l *gtkLabel) SetVisible(visible bool)       { l.inner.SetVisible(visible) }
427func (l *gtkLabel) IsVisible() bool               { return l.inner.GetVisible() }
428func (l *gtkLabel) GrabFocus() bool               { return l.inner.GrabFocus() }
429func (l *gtkLabel) HasFocus() bool                { return l.inner.HasFocus() }
430func (l *gtkLabel) SetCanFocus(canFocus bool)     { l.inner.SetCanFocus(canFocus) }
431func (l *gtkLabel) SetFocusOnClick(focus bool)    { l.inner.SetFocusOnClick(focus) }
432func (l *gtkLabel) SetCanTarget(canTarget bool)   { l.inner.SetCanTarget(canTarget) }
433func (l *gtkLabel) SetHexpand(expand bool)        { l.inner.SetHexpand(expand) }
434func (l *gtkLabel) SetVexpand(expand bool)        { l.inner.SetVexpand(expand) }
435func (l *gtkLabel) GetHexpand() bool              { return l.inner.GetHexpand() }
436func (l *gtkLabel) GetVexpand() bool              { return l.inner.GetVexpand() }
437func (l *gtkLabel) SetHalign(align gtk.Align)     { l.inner.SetHalign(align) }
438func (l *gtkLabel) SetValign(align gtk.Align)     { l.inner.SetValign(align) }
439func (l *gtkLabel) SetSizeRequest(w, h int)       { l.inner.SetSizeRequest(w, h) }
440func (l *gtkLabel) AddCssClass(class string)      { l.inner.AddCssClass(class) }
441func (l *gtkLabel) RemoveCssClass(class string)   { l.inner.RemoveCssClass(class) }
442func (l *gtkLabel) HasCssClass(class string) bool { return l.inner.HasCssClass(class) }
443func (l *gtkLabel) Unparent()                     { l.inner.Unparent() }
444func (l *gtkLabel) GtkWidget() *gtk.Widget        { return &l.inner.Widget }
445
446func (l *gtkLabel) GetParent() Widget {
447	parent := l.inner.GetParent()
448	if parent == nil {
449		return nil
450	}
451	return &gtkWidget{inner: parent}
452}
453
454func (l *gtkLabel) SetText(text string)             { l.inner.SetText(text) }
455func (l *gtkLabel) GetText() string                 { return l.inner.GetText() }
456func (l *gtkLabel) SetMarkup(markup string)         { l.inner.SetMarkup(markup) }
457func (l *gtkLabel) SetEllipsize(mode EllipsizeMode) { l.inner.SetEllipsize(pango.EllipsizeMode(mode)) }
458func (l *gtkLabel) SetMaxWidthChars(n int)          { l.inner.SetMaxWidthChars(n) }
459func (l *gtkLabel) SetXalign(x float32)             { l.inner.SetXalign(x) }
460
461func (l *gtkLabel) GetAllocatedWidth() int               { return l.inner.GetAllocatedWidth() }
462func (l *gtkLabel) GetAllocatedHeight() int              { return l.inner.GetAllocatedHeight() }
463func (l *gtkLabel) AddController(c *gtk.EventController) { l.inner.AddController(c) }
464
465func (l *gtkLabel) ComputePoint(target Widget) (x, y float64, ok bool) {
466	srcPoint := &graphene.Point{X: 0, Y: 0}
467	outPoint := &graphene.Point{}
468
469	var targetGtk *gtk.Widget
470	if target != nil {
471		targetGtk = target.GtkWidget()
472	}
473
474	ok = l.inner.ComputePoint(targetGtk, srcPoint, outPoint)
475	if !ok {
476		return 0, 0, false
477	}
478	return float64(outPoint.X), float64(outPoint.Y), true
479}
480
481// gtkButton wraps gtk.Button to implement ButtonWidget.
482type gtkButton struct {
483	inner *gtk.Button
484}
485
486func (btn *gtkButton) Show()                         { btn.inner.Show() }
487func (btn *gtkButton) Hide()                         { btn.inner.Hide() }
488func (btn *gtkButton) SetVisible(visible bool)       { btn.inner.SetVisible(visible) }
489func (btn *gtkButton) IsVisible() bool               { return btn.inner.GetVisible() }
490func (btn *gtkButton) GrabFocus() bool               { return btn.inner.GrabFocus() }
491func (btn *gtkButton) HasFocus() bool                { return btn.inner.HasFocus() }
492func (btn *gtkButton) SetCanFocus(canFocus bool)     { btn.inner.SetCanFocus(canFocus) }
493func (btn *gtkButton) SetFocusOnClick(focus bool)    { btn.inner.SetFocusOnClick(focus) }
494func (btn *gtkButton) SetCanTarget(canTarget bool)   { btn.inner.SetCanTarget(canTarget) }
495func (btn *gtkButton) SetHexpand(expand bool)        { btn.inner.SetHexpand(expand) }
496func (btn *gtkButton) SetVexpand(expand bool)        { btn.inner.SetVexpand(expand) }
497func (btn *gtkButton) GetHexpand() bool              { return btn.inner.GetHexpand() }
498func (btn *gtkButton) GetVexpand() bool              { return btn.inner.GetVexpand() }
499func (btn *gtkButton) SetHalign(align gtk.Align)     { btn.inner.SetHalign(align) }
500func (btn *gtkButton) SetValign(align gtk.Align)     { btn.inner.SetValign(align) }
501func (btn *gtkButton) SetSizeRequest(w, h int)       { btn.inner.SetSizeRequest(w, h) }
502func (btn *gtkButton) AddCssClass(class string)      { btn.inner.AddCssClass(class) }
503func (btn *gtkButton) RemoveCssClass(class string)   { btn.inner.RemoveCssClass(class) }
504func (btn *gtkButton) HasCssClass(class string) bool { return btn.inner.HasCssClass(class) }
505func (btn *gtkButton) Unparent()                     { btn.inner.Unparent() }
506func (btn *gtkButton) GtkWidget() *gtk.Widget        { return &btn.inner.Widget }
507
508func (btn *gtkButton) GetParent() Widget {
509	parent := btn.inner.GetParent()
510	if parent == nil {
511		return nil
512	}
513	return &gtkWidget{inner: parent}
514}
515
516func (btn *gtkButton) SetLabel(label string) { btn.inner.SetLabel(label) }
517func (btn *gtkButton) GetLabel() string      { return btn.inner.GetLabel() }
518
519func (btn *gtkButton) SetChild(child Widget) {
520	if child == nil {
521		btn.inner.SetChild(nil)
522		return
523	}
524	btn.inner.SetChild(child.GtkWidget())
525}
526
527func (btn *gtkButton) GetChild() Widget {
528	child := btn.inner.GetChild()
529	if child == nil {
530		return nil
531	}
532	return &gtkWidget{inner: child}
533}
534
535func (btn *gtkButton) ConnectClicked(callback func()) uint32 {
536	cb := func(_ gtk.Button) {
537		callback()
538	}
539	return btn.inner.ConnectClicked(&cb)
540}
541
542func (btn *gtkButton) GetAllocatedWidth() int               { return btn.inner.GetAllocatedWidth() }
543func (btn *gtkButton) GetAllocatedHeight() int              { return btn.inner.GetAllocatedHeight() }
544func (btn *gtkButton) AddController(c *gtk.EventController) { btn.inner.AddController(c) }
545
546func (btn *gtkButton) ComputePoint(target Widget) (x, y float64, ok bool) {
547	srcPoint := &graphene.Point{X: 0, Y: 0}
548	outPoint := &graphene.Point{}
549
550	var targetGtk *gtk.Widget
551	if target != nil {
552		targetGtk = target.GtkWidget()
553	}
554
555	ok = btn.inner.ComputePoint(targetGtk, srcPoint, outPoint)
556	if !ok {
557		return 0, 0, false
558	}
559	return float64(outPoint.X), float64(outPoint.Y), true
560}
561
562// gtkImage wraps gtk.Image to implement ImageWidget.
563type gtkImage struct {
564	inner *gtk.Image
565}
566
567func (img *gtkImage) Show()                         { img.inner.Show() }
568func (img *gtkImage) Hide()                         { img.inner.Hide() }
569func (img *gtkImage) SetVisible(visible bool)       { img.inner.SetVisible(visible) }
570func (img *gtkImage) IsVisible() bool               { return img.inner.GetVisible() }
571func (img *gtkImage) GrabFocus() bool               { return img.inner.GrabFocus() }
572func (img *gtkImage) HasFocus() bool                { return img.inner.HasFocus() }
573func (img *gtkImage) SetCanFocus(canFocus bool)     { img.inner.SetCanFocus(canFocus) }
574func (img *gtkImage) SetFocusOnClick(focus bool)    { img.inner.SetFocusOnClick(focus) }
575func (img *gtkImage) SetCanTarget(canTarget bool)   { img.inner.SetCanTarget(canTarget) }
576func (img *gtkImage) SetHexpand(expand bool)        { img.inner.SetHexpand(expand) }
577func (img *gtkImage) SetVexpand(expand bool)        { img.inner.SetVexpand(expand) }
578func (img *gtkImage) GetHexpand() bool              { return img.inner.GetHexpand() }
579func (img *gtkImage) GetVexpand() bool              { return img.inner.GetVexpand() }
580func (img *gtkImage) SetHalign(align gtk.Align)     { img.inner.SetHalign(align) }
581func (img *gtkImage) SetValign(align gtk.Align)     { img.inner.SetValign(align) }
582func (img *gtkImage) SetSizeRequest(w, h int)       { img.inner.SetSizeRequest(w, h) }
583func (img *gtkImage) AddCssClass(class string)      { img.inner.AddCssClass(class) }
584func (img *gtkImage) RemoveCssClass(class string)   { img.inner.RemoveCssClass(class) }
585func (img *gtkImage) HasCssClass(class string) bool { return img.inner.HasCssClass(class) }
586func (img *gtkImage) Unparent()                     { img.inner.Unparent() }
587func (img *gtkImage) GtkWidget() *gtk.Widget        { return &img.inner.Widget }
588
589func (img *gtkImage) GetParent() Widget {
590	parent := img.inner.GetParent()
591	if parent == nil {
592		return nil
593	}
594	return &gtkWidget{inner: parent}
595}
596
597func (img *gtkImage) SetFromIconName(name string) { img.inner.SetFromIconName(&name) }
598func (img *gtkImage) SetFromFile(filename string) { img.inner.SetFromFile(&filename) }
599func (img *gtkImage) SetFromPaintable(p Paintable) {
600	if p == nil {
601		img.inner.Clear()
602		return
603	}
604	// Create a gdk.Paintable from the pointer
605	// gdk.Texture implements gdk.Paintable
606	texture := &gdk.Texture{}
607	texture.Ptr = p.GoPointer()
608	img.inner.SetFromPaintable(texture)
609}
610func (img *gtkImage) SetPixelSize(size int) { img.inner.SetPixelSize(size) }
611func (img *gtkImage) Clear()                { img.inner.Clear() }
612
613func (img *gtkImage) GetAllocatedWidth() int               { return img.inner.GetAllocatedWidth() }
614func (img *gtkImage) GetAllocatedHeight() int              { return img.inner.GetAllocatedHeight() }
615func (img *gtkImage) AddController(c *gtk.EventController) { img.inner.AddController(c) }
616
617func (img *gtkImage) ComputePoint(target Widget) (x, y float64, ok bool) {
618	srcPoint := &graphene.Point{X: 0, Y: 0}
619	outPoint := &graphene.Point{}
620
621	var targetGtk *gtk.Widget
622	if target != nil {
623		targetGtk = target.GtkWidget()
624	}
625
626	ok = img.inner.ComputePoint(targetGtk, srcPoint, outPoint)
627	if !ok {
628		return 0, 0, false
629	}
630	return float64(outPoint.X), float64(outPoint.Y), true
631}
632
633// gtkProgressBar wraps gtk.ProgressBar to implement ProgressBarWidget.
634type gtkProgressBar struct {
635	inner *gtk.ProgressBar
636}
637
638func (p *gtkProgressBar) Show()                         { p.inner.Show() }
639func (p *gtkProgressBar) Hide()                         { p.inner.Hide() }
640func (p *gtkProgressBar) SetVisible(visible bool)       { p.inner.SetVisible(visible) }
641func (p *gtkProgressBar) IsVisible() bool               { return p.inner.GetVisible() }
642func (p *gtkProgressBar) GrabFocus() bool               { return p.inner.GrabFocus() }
643func (p *gtkProgressBar) HasFocus() bool                { return p.inner.HasFocus() }
644func (p *gtkProgressBar) SetCanFocus(canFocus bool)     { p.inner.SetCanFocus(canFocus) }
645func (p *gtkProgressBar) SetFocusOnClick(focus bool)    { p.inner.SetFocusOnClick(focus) }
646func (p *gtkProgressBar) SetCanTarget(canTarget bool)   { p.inner.SetCanTarget(canTarget) }
647func (p *gtkProgressBar) SetHexpand(expand bool)        { p.inner.SetHexpand(expand) }
648func (p *gtkProgressBar) SetVexpand(expand bool)        { p.inner.SetVexpand(expand) }
649func (p *gtkProgressBar) GetHexpand() bool              { return p.inner.GetHexpand() }
650func (p *gtkProgressBar) GetVexpand() bool              { return p.inner.GetVexpand() }
651func (p *gtkProgressBar) SetHalign(align gtk.Align)     { p.inner.SetHalign(align) }
652func (p *gtkProgressBar) SetValign(align gtk.Align)     { p.inner.SetValign(align) }
653func (p *gtkProgressBar) SetSizeRequest(w, h int)       { p.inner.SetSizeRequest(w, h) }
654func (p *gtkProgressBar) AddCssClass(class string)      { p.inner.AddCssClass(class) }
655func (p *gtkProgressBar) RemoveCssClass(class string)   { p.inner.RemoveCssClass(class) }
656func (p *gtkProgressBar) HasCssClass(class string) bool { return p.inner.HasCssClass(class) }
657func (p *gtkProgressBar) Unparent()                     { p.inner.Unparent() }
658func (p *gtkProgressBar) GtkWidget() *gtk.Widget        { return &p.inner.Widget }
659
660func (p *gtkProgressBar) GetParent() Widget {
661	parent := p.inner.GetParent()
662	if parent == nil {
663		return nil
664	}
665	return &gtkWidget{inner: parent}
666}
667
668func (p *gtkProgressBar) GetAllocatedWidth() int               { return p.inner.GetAllocatedWidth() }
669func (p *gtkProgressBar) GetAllocatedHeight() int              { return p.inner.GetAllocatedHeight() }
670func (p *gtkProgressBar) AddController(c *gtk.EventController) { p.inner.AddController(c) }
671
672func (p *gtkProgressBar) ComputePoint(target Widget) (x, y float64, ok bool) {
673	srcPoint := &graphene.Point{X: 0, Y: 0}
674	outPoint := &graphene.Point{}
675
676	var targetGtk *gtk.Widget
677	if target != nil {
678		targetGtk = target.GtkWidget()
679	}
680
681	ok = p.inner.ComputePoint(targetGtk, srcPoint, outPoint)
682	if !ok {
683		return 0, 0, false
684	}
685	return float64(outPoint.X), float64(outPoint.Y), true
686}
687
688func (p *gtkProgressBar) SetFraction(fraction float64) { p.inner.SetFraction(fraction) }
689func (p *gtkProgressBar) GetFraction() float64         { return p.inner.GetFraction() }
690
691// gtkSpinner wraps gtk.Spinner to implement SpinnerWidget.
692type gtkSpinner struct {
693	inner *gtk.Spinner
694}
695
696func (s *gtkSpinner) Show()                         { s.inner.Show() }
697func (s *gtkSpinner) Hide()                         { s.inner.Hide() }
698func (s *gtkSpinner) SetVisible(visible bool)       { s.inner.SetVisible(visible) }
699func (s *gtkSpinner) IsVisible() bool               { return s.inner.GetVisible() }
700func (s *gtkSpinner) GrabFocus() bool               { return s.inner.GrabFocus() }
701func (s *gtkSpinner) HasFocus() bool                { return s.inner.HasFocus() }
702func (s *gtkSpinner) SetCanFocus(canFocus bool)     { s.inner.SetCanFocus(canFocus) }
703func (s *gtkSpinner) SetFocusOnClick(focus bool)    { s.inner.SetFocusOnClick(focus) }
704func (s *gtkSpinner) SetCanTarget(canTarget bool)   { s.inner.SetCanTarget(canTarget) }
705func (s *gtkSpinner) SetHexpand(expand bool)        { s.inner.SetHexpand(expand) }
706func (s *gtkSpinner) SetVexpand(expand bool)        { s.inner.SetVexpand(expand) }
707func (s *gtkSpinner) GetHexpand() bool              { return s.inner.GetHexpand() }
708func (s *gtkSpinner) GetVexpand() bool              { return s.inner.GetVexpand() }
709func (s *gtkSpinner) SetHalign(align gtk.Align)     { s.inner.SetHalign(align) }
710func (s *gtkSpinner) SetValign(align gtk.Align)     { s.inner.SetValign(align) }
711func (s *gtkSpinner) SetSizeRequest(w, h int)       { s.inner.SetSizeRequest(w, h) }
712func (s *gtkSpinner) AddCssClass(class string)      { s.inner.AddCssClass(class) }
713func (s *gtkSpinner) RemoveCssClass(class string)   { s.inner.RemoveCssClass(class) }
714func (s *gtkSpinner) HasCssClass(class string) bool { return s.inner.HasCssClass(class) }
715func (s *gtkSpinner) Unparent()                     { s.inner.Unparent() }
716func (s *gtkSpinner) GtkWidget() *gtk.Widget        { return &s.inner.Widget }
717
718func (s *gtkSpinner) GetParent() Widget {
719	parent := s.inner.GetParent()
720	if parent == nil {
721		return nil
722	}
723	return &gtkWidget{inner: parent}
724}
725
726func (s *gtkSpinner) GetAllocatedWidth() int               { return s.inner.GetAllocatedWidth() }
727func (s *gtkSpinner) GetAllocatedHeight() int              { return s.inner.GetAllocatedHeight() }
728func (s *gtkSpinner) AddController(c *gtk.EventController) { s.inner.AddController(c) }
729
730func (s *gtkSpinner) ComputePoint(target Widget) (x, y float64, ok bool) {
731	srcPoint := &graphene.Point{X: 0, Y: 0}
732	outPoint := &graphene.Point{}
733
734	var targetGtk *gtk.Widget
735	if target != nil {
736		targetGtk = target.GtkWidget()
737	}
738
739	ok = s.inner.ComputePoint(targetGtk, srcPoint, outPoint)
740	if !ok {
741		return 0, 0, false
742	}
743	return float64(outPoint.X), float64(outPoint.Y), true
744}
745
746func (s *gtkSpinner) Start()                    { s.inner.Start() }
747func (s *gtkSpinner) Stop()                     { s.inner.Stop() }
748func (s *gtkSpinner) SetSpinning(spinning bool) { s.inner.SetSpinning(spinning) }
749func (s *gtkSpinner) GetSpinning() bool         { return s.inner.GetSpinning() }
750
751// GtkWidgetFactory creates real GTK widgets.
752type GtkWidgetFactory struct{}
753
754// NewGtkWidgetFactory creates a new factory for real GTK widgets.
755func NewGtkWidgetFactory() *GtkWidgetFactory {
756	return &GtkWidgetFactory{}
757}
758
759func (f *GtkWidgetFactory) NewPaned(orientation Orientation) PanedWidget {
760	paned := gtk.NewPaned(orientation)
761	paned.SetHexpand(true)
762	paned.SetVexpand(true)
763	return &gtkPaned{inner: paned}
764}
765
766func (f *GtkWidgetFactory) NewBox(orientation Orientation, spacing int) BoxWidget {
767	box := gtk.NewBox(orientation, spacing)
768	box.SetHexpand(true)
769	box.SetVexpand(true)
770	return &gtkBox{inner: box}
771}
772
773func (f *GtkWidgetFactory) NewOverlay() OverlayWidget {
774	overlay := gtk.NewOverlay()
775	overlay.SetHexpand(true)
776	overlay.SetVexpand(true)
777	return &gtkOverlay{inner: overlay}
778}
779
780func (f *GtkWidgetFactory) NewLabel(text string) LabelWidget {
781	label := gtk.NewLabel(&text)
782	return &gtkLabel{inner: label}
783}
784
785func (f *GtkWidgetFactory) NewButton() ButtonWidget {
786	button := gtk.NewButton()
787	return &gtkButton{inner: button}
788}
789
790func (f *GtkWidgetFactory) NewImage() ImageWidget {
791	image := gtk.NewImage()
792	return &gtkImage{inner: image}
793}
794
795func (f *GtkWidgetFactory) NewProgressBar() ProgressBarWidget {
796	progressBar := gtk.NewProgressBar()
797	return &gtkProgressBar{inner: progressBar}
798}
799
800func (f *GtkWidgetFactory) NewSpinner() SpinnerWidget {
801	spinner := gtk.NewSpinner()
802	return &gtkSpinner{inner: spinner}
803}
804
805func (f *GtkWidgetFactory) WrapWidget(w *gtk.Widget) Widget {
806	if w == nil {
807		return nil
808	}
809	return &gtkWidget{inner: w}
810}

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