-
Notifications
You must be signed in to change notification settings - Fork 6
/
adw-tab-bar.go
629 lines (519 loc) · 15.4 KB
/
adw-tab-bar.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
// Code generated by girgen. DO NOT EDIT.
package adw
import (
"runtime"
"unsafe"
"github.com/diamondburned/gotk4/pkg/core/gextras"
coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
"github.com/diamondburned/gotk4/pkg/gdk/v4"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
)
// #include <stdlib.h>
// #include <adwaita.h>
// #include <glib-object.h>
// extern gboolean _gotk4_adw1_TabBar_ConnectExtraDragDrop(gpointer, AdwTabPage*, GValue, guintptr);
// extern GdkDragAction _gotk4_adw1_TabBar_ConnectExtraDragValue(gpointer, AdwTabPage*, GValue, guintptr);
import "C"
// GType values.
var (
GTypeTabBar = coreglib.Type(C.adw_tab_bar_get_type())
)
func init() {
coreglib.RegisterGValueMarshalers([]coreglib.TypeMarshaler{
coreglib.TypeMarshaler{T: GTypeTabBar, F: marshalTabBar},
})
}
// TabBarOverrides contains methods that are overridable.
type TabBarOverrides struct {
}
func defaultTabBarOverrides(v *TabBar) TabBarOverrides {
return TabBarOverrides{}
}
// TabBar: tab bar for tabview.
//
// <picture> <source srcset="tab-bar-dark.png" media="(prefers-color-scheme:
// dark)"> <img src="tab-bar.png" alt="tab-bar"> </picture>
//
// The AdwTabBar widget is a tab bar that can be used with conjunction with
// AdwTabView. It is typically used as a top bar within toolbarview.
//
// AdwTabBar can autohide and can optionally contain action widgets on both
// sides of the tabs.
//
// When there's not enough space to show all the tabs, AdwTabBar will scroll
// them. Pinned tabs always stay visible and aren't a part of the scrollable
// area.
//
// # CSS nodes
//
// AdwTabBar has a single CSS node with name tabbar.
type TabBar struct {
_ [0]func() // equal guard
gtk.Widget
}
var (
_ gtk.Widgetter = (*TabBar)(nil)
)
func init() {
coreglib.RegisterClassInfo[*TabBar, *TabBarClass, TabBarOverrides](
GTypeTabBar,
initTabBarClass,
wrapTabBar,
defaultTabBarOverrides,
)
}
func initTabBarClass(gclass unsafe.Pointer, overrides TabBarOverrides, classInitFunc func(*TabBarClass)) {
if classInitFunc != nil {
class := (*TabBarClass)(gextras.NewStructNative(gclass))
classInitFunc(class)
}
}
func wrapTabBar(obj *coreglib.Object) *TabBar {
return &TabBar{
Widget: gtk.Widget{
InitiallyUnowned: coreglib.InitiallyUnowned{
Object: obj,
},
Object: obj,
Accessible: gtk.Accessible{
Object: obj,
},
Buildable: gtk.Buildable{
Object: obj,
},
ConstraintTarget: gtk.ConstraintTarget{
Object: obj,
},
},
}
}
func marshalTabBar(p uintptr) (interface{}, error) {
return wrapTabBar(coreglib.ValueFromNative(unsafe.Pointer(p)).Object()), nil
}
// ConnectExtraDragDrop: this signal is emitted when content is dropped onto a
// tab.
//
// The content must be of one of the types set up via
// tabbar.SetupExtraDropTarget.
//
// See gtk.DropTarget::drop.
func (self *TabBar) ConnectExtraDragDrop(f func(page *TabPage, value coreglib.Value) (ok bool)) coreglib.SignalHandle {
return coreglib.ConnectGeneratedClosure(self, "extra-drag-drop", false, unsafe.Pointer(C._gotk4_adw1_TabBar_ConnectExtraDragDrop), f)
}
// ConnectExtraDragValue: this signal is emitted when the dropped content is
// preloaded.
//
// In order for data to be preloaded, tabbar:extra-drag-preload must be set to
// TRUE.
//
// The content must be of one of the types set up via
// tabbar.SetupExtraDropTarget.
//
// See gtk.DropTarget:value.
func (self *TabBar) ConnectExtraDragValue(f func(page *TabPage, value coreglib.Value) (dragAction gdk.DragAction)) coreglib.SignalHandle {
return coreglib.ConnectGeneratedClosure(self, "extra-drag-value", false, unsafe.Pointer(C._gotk4_adw1_TabBar_ConnectExtraDragValue), f)
}
// NewTabBar creates a new AdwTabBar.
//
// The function returns the following values:
//
// - tabBar: newly created AdwTabBar.
//
func NewTabBar() *TabBar {
var _cret *C.AdwTabBar // in
_cret = C.adw_tab_bar_new()
var _tabBar *TabBar // out
_tabBar = wrapTabBar(coreglib.Take(unsafe.Pointer(_cret)))
return _tabBar
}
// Autohide gets whether the tabs automatically hide.
//
// The function returns the following values:
//
// - ok: whether the tabs automatically hide.
//
func (self *TabBar) Autohide() bool {
var _arg0 *C.AdwTabBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_autohide(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// EndActionWidget gets the widget shown after the tabs.
//
// The function returns the following values:
//
// - widget (optional) shown after the tabs.
//
func (self *TabBar) EndActionWidget() gtk.Widgetter {
var _arg0 *C.AdwTabBar // out
var _cret *C.GtkWidget // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_end_action_widget(_arg0)
runtime.KeepAlive(self)
var _widget gtk.Widgetter // out
if _cret != nil {
{
objptr := unsafe.Pointer(_cret)
object := coreglib.Take(objptr)
casted := object.WalkCast(func(obj coreglib.Objector) bool {
_, ok := obj.(gtk.Widgetter)
return ok
})
rv, ok := casted.(gtk.Widgetter)
if !ok {
panic("no marshaler for " + object.TypeFromInstance().String() + " matching gtk.Widgetter")
}
_widget = rv
}
}
return _widget
}
// ExpandTabs gets whether tabs expand to full width.
//
// The function returns the following values:
//
// - ok: whether tabs expand to full width.
//
func (self *TabBar) ExpandTabs() bool {
var _arg0 *C.AdwTabBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_expand_tabs(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// ExtraDragPreferredAction gets the current action during a drop on the
// extra_drop_target.
//
// The function returns the following values:
//
// - dragAction: drag action of the current drop.
//
func (self *TabBar) ExtraDragPreferredAction() gdk.DragAction {
var _arg0 *C.AdwTabBar // out
var _cret C.GdkDragAction // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_extra_drag_preferred_action(_arg0)
runtime.KeepAlive(self)
var _dragAction gdk.DragAction // out
_dragAction = gdk.DragAction(_cret)
return _dragAction
}
// ExtraDragPreload gets whether drop data should be preloaded on hover.
//
// The function returns the following values:
//
// - ok: whether drop data should be preloaded on hover.
//
func (self *TabBar) ExtraDragPreload() bool {
var _arg0 *C.AdwTabBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_extra_drag_preload(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// Inverted gets whether tabs use inverted layout.
//
// The function returns the following values:
//
// - ok: whether tabs use inverted layout.
//
func (self *TabBar) Inverted() bool {
var _arg0 *C.AdwTabBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_inverted(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// IsOverflowing gets whether self is overflowing.
//
// If TRUE, all tabs cannot be displayed at once and require scrolling.
//
// The function returns the following values:
//
// - ok: whether self is overflowing.
//
func (self *TabBar) IsOverflowing() bool {
var _arg0 *C.AdwTabBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_is_overflowing(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// StartActionWidget gets the widget shown before the tabs.
//
// The function returns the following values:
//
// - widget (optional) shown before the tabs.
//
func (self *TabBar) StartActionWidget() gtk.Widgetter {
var _arg0 *C.AdwTabBar // out
var _cret *C.GtkWidget // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_start_action_widget(_arg0)
runtime.KeepAlive(self)
var _widget gtk.Widgetter // out
if _cret != nil {
{
objptr := unsafe.Pointer(_cret)
object := coreglib.Take(objptr)
casted := object.WalkCast(func(obj coreglib.Objector) bool {
_, ok := obj.(gtk.Widgetter)
return ok
})
rv, ok := casted.(gtk.Widgetter)
if !ok {
panic("no marshaler for " + object.TypeFromInstance().String() + " matching gtk.Widgetter")
}
_widget = rv
}
}
return _widget
}
// TabsRevealed gets whether the tabs are currently revealed.
//
// See tabbar:autohide.
//
// The function returns the following values:
//
// - ok: whether the tabs are currently revealed.
//
func (self *TabBar) TabsRevealed() bool {
var _arg0 *C.AdwTabBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_tabs_revealed(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// View gets the tab view self controls.
//
// The function returns the following values:
//
// - tabView (optional): view self controls.
//
func (self *TabBar) View() *TabView {
var _arg0 *C.AdwTabBar // out
var _cret *C.AdwTabView // in
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_tab_bar_get_view(_arg0)
runtime.KeepAlive(self)
var _tabView *TabView // out
if _cret != nil {
_tabView = wrapTabView(coreglib.Take(unsafe.Pointer(_cret)))
}
return _tabView
}
// SetAutohide sets whether the tabs automatically hide.
//
// If set to TRUE, the tab bar disappears when tabbar:view has 0 or 1 tab,
// no pinned tabs, and no tab is being transferred.
//
// See tabbar:tabs-revealed.
//
// The function takes the following parameters:
//
// - autohide: whether the tabs automatically hide.
//
func (self *TabBar) SetAutohide(autohide bool) {
var _arg0 *C.AdwTabBar // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if autohide {
_arg1 = C.TRUE
}
C.adw_tab_bar_set_autohide(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(autohide)
}
// SetEndActionWidget sets the widget to show after the tabs.
//
// The function takes the following parameters:
//
// - widget (optional) to show after the tabs.
//
func (self *TabBar) SetEndActionWidget(widget gtk.Widgetter) {
var _arg0 *C.AdwTabBar // out
var _arg1 *C.GtkWidget // out
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if widget != nil {
_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(widget).Native()))
}
C.adw_tab_bar_set_end_action_widget(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(widget)
}
// SetExpandTabs sets whether tabs expand to full width.
//
// If set to TRUE, the tabs will always vary width filling the whole width when
// possible, otherwise tabs will always have the minimum possible size.
//
// The function takes the following parameters:
//
// - expandTabs: whether to expand tabs.
//
func (self *TabBar) SetExpandTabs(expandTabs bool) {
var _arg0 *C.AdwTabBar // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if expandTabs {
_arg1 = C.TRUE
}
C.adw_tab_bar_set_expand_tabs(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(expandTabs)
}
// SetExtraDragPreload sets whether drop data should be preloaded on hover.
//
// See gtk.DropTarget:preload.
//
// The function takes the following parameters:
//
// - preload: whether to preload drop data.
//
func (self *TabBar) SetExtraDragPreload(preload bool) {
var _arg0 *C.AdwTabBar // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if preload {
_arg1 = C.TRUE
}
C.adw_tab_bar_set_extra_drag_preload(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(preload)
}
// SetInverted sets whether tabs tabs use inverted layout.
//
// If set to TRUE, non-pinned tabs will have the close button at the beginning
// and the indicator at the end rather than the opposite.
//
// The function takes the following parameters:
//
// - inverted: whether tabs use inverted layout.
//
func (self *TabBar) SetInverted(inverted bool) {
var _arg0 *C.AdwTabBar // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if inverted {
_arg1 = C.TRUE
}
C.adw_tab_bar_set_inverted(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(inverted)
}
// SetStartActionWidget sets the widget to show before the tabs.
//
// The function takes the following parameters:
//
// - widget (optional) to show before the tabs.
//
func (self *TabBar) SetStartActionWidget(widget gtk.Widgetter) {
var _arg0 *C.AdwTabBar // out
var _arg1 *C.GtkWidget // out
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if widget != nil {
_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(widget).Native()))
}
C.adw_tab_bar_set_start_action_widget(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(widget)
}
// SetView sets the tab view self controls.
//
// The function takes the following parameters:
//
// - view (optional): tab view.
//
func (self *TabBar) SetView(view *TabView) {
var _arg0 *C.AdwTabBar // out
var _arg1 *C.AdwTabView // out
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if view != nil {
_arg1 = (*C.AdwTabView)(unsafe.Pointer(coreglib.InternObject(view).Native()))
}
C.adw_tab_bar_set_view(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(view)
}
// SetupExtraDropTarget sets the supported types for this drop target.
//
// Sets up an extra drop target on tabs.
//
// This allows to drag arbitrary content onto tabs, for example URLs in a web
// browser.
//
// If a tab is hovered for a certain period of time while dragging the content,
// it will be automatically selected.
//
// The tabbar::extra-drag-drop signal can be used to handle the drop.
//
// The function takes the following parameters:
//
// - actions: supported actions.
// - types (optional): all supported GTypes that can be dropped.
//
func (self *TabBar) SetupExtraDropTarget(actions gdk.DragAction, types []coreglib.Type) {
var _arg0 *C.AdwTabBar // out
var _arg1 C.GdkDragAction // out
var _arg2 *C.GType // out
var _arg3 C.gsize
_arg0 = (*C.AdwTabBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_arg1 = C.GdkDragAction(actions)
_arg3 = (C.gsize)(len(types))
_arg2 = (*C.GType)(C.calloc(C.size_t(len(types)), C.size_t(C.sizeof_GType)))
defer C.free(unsafe.Pointer(_arg2))
{
out := unsafe.Slice((*C.GType)(_arg2), len(types))
for i := range types {
out[i] = C.GType(types[i])
}
}
C.adw_tab_bar_setup_extra_drop_target(_arg0, _arg1, _arg2, _arg3)
runtime.KeepAlive(self)
runtime.KeepAlive(actions)
runtime.KeepAlive(types)
}
// TabBarClass: instance of this type is always passed by reference.
type TabBarClass struct {
*tabBarClass
}
// tabBarClass is the struct that's finalized.
type tabBarClass struct {
native *C.AdwTabBarClass
}
func (t *TabBarClass) ParentClass() *gtk.WidgetClass {
valptr := &t.native.parent_class
var _v *gtk.WidgetClass // out
_v = (*gtk.WidgetClass)(gextras.NewStructNative(unsafe.Pointer(valptr)))
return _v
}