v0.20.1 d9a391f

gtk_widgets.go RawHistoryFolder

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

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