v0.21.0 73bf644

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

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