-
Notifications
You must be signed in to change notification settings - Fork 6
/
adw-header-bar.go
637 lines (538 loc) · 17.4 KB
/
adw-header-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
630
631
632
633
634
635
636
637
// Code generated by girgen. DO NOT EDIT.
package adw
import (
"fmt"
"runtime"
"unsafe"
"github.com/diamondburned/gotk4/pkg/core/gextras"
coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
)
// #include <stdlib.h>
// #include <adwaita.h>
// #include <glib-object.h>
import "C"
// GType values.
var (
GTypeCenteringPolicy = coreglib.Type(C.adw_centering_policy_get_type())
GTypeHeaderBar = coreglib.Type(C.adw_header_bar_get_type())
)
func init() {
coreglib.RegisterGValueMarshalers([]coreglib.TypeMarshaler{
coreglib.TypeMarshaler{T: GTypeCenteringPolicy, F: marshalCenteringPolicy},
coreglib.TypeMarshaler{T: GTypeHeaderBar, F: marshalHeaderBar},
})
}
// CenteringPolicy describes title centering behavior of a headerbar widget.
type CenteringPolicy C.gint
const (
// CenteringPolicyLoose: keep the title centered when possible.
CenteringPolicyLoose CenteringPolicy = iota
// CenteringPolicyStrict: keep the title centered at all cost.
CenteringPolicyStrict
)
func marshalCenteringPolicy(p uintptr) (interface{}, error) {
return CenteringPolicy(coreglib.ValueFromNative(unsafe.Pointer(p)).Enum()), nil
}
// String returns the name in string for CenteringPolicy.
func (c CenteringPolicy) String() string {
switch c {
case CenteringPolicyLoose:
return "Loose"
case CenteringPolicyStrict:
return "Strict"
default:
return fmt.Sprintf("CenteringPolicy(%d)", c)
}
}
// HeaderBarOverrides contains methods that are overridable.
type HeaderBarOverrides struct {
}
func defaultHeaderBarOverrides(v *HeaderBar) HeaderBarOverrides {
return HeaderBarOverrides{}
}
// HeaderBar: title bar widget.
//
// <picture> <source srcset="header-bar-dark.png" media="(prefers-color-scheme:
// dark)"> <img src="header-bar.png" alt="header-bar"> </picture>
//
// AdwHeaderBar is similar to gtk.HeaderBar, but provides additional features
// compared to it. Refer to GtkHeaderBar for details. It is typically used as a
// top bar within toolbarview.
//
// # Navigation View Integration
//
// When placed inside an navigationpage, AdwHeaderBar will display the page
// title instead of window title.
//
// When used together with navigationview or navigationsplitview, it will also
// display a back button that can be used to go back to the previous page.
// The button also has a context menu, allowing to pop multiple pages at once,
// potentially across multiple navigation views. In rare scenarios,
// set headerbar:show-back-button to FALSE to disable the back button if it's
// unwanted (e.g. in an extra header bar on the same page).
//
// # Split View Integration
//
// When placed inside AdwNavigationSplitView or AdwOverlaySplitView,
// AdwHeaderBar will automatically hide the title buttons other than at the
// edges of the window.
//
// # Centering Policy
//
// headerbar:centering-policy allows to enforce strict centering of the title
// widget. This can be useful for entries inside clamp.
//
// # Title Buttons
//
// Unlike GtkHeaderBar, AdwHeaderBar allows to toggle title button visibility
// for each side individually, using the headerbar:show-start-title-buttons and
// headerbar:show-end-title-buttons properties.
//
// CSS nodes
//
// headerbar
// ╰── windowhandle
// ╰── box
// ├── widget
// │ ╰── box.start
// │ ├── windowcontrols.start
// │ ├── widget
// │ │ ╰── [button.back]
// │ ╰── [other children]
// ├── widget
// │ ╰── [Title Widget]
// ╰── widget
// ╰── box.end
// ├── [other children]
// ╰── windowcontrols.end
//
// AdwHeaderBar's CSS node is called headerbar. It contains a windowhandle
// subnode, which contains a box subnode, which contains three widget subnodes
// at the start, center and end of the header bar. The start and end subnotes
// contain a box subnode with the .start and .end style classes respectively,
// and the center node contains a node that represents the title.
//
// Each of the boxes contains a windowcontrols subnode, see gtk.WindowControls
// for details, as well as other children.
//
// When headerbar:show-back-button is TRUE, the start box also contains a node
// with the name widget that contains a node with the name button and .back
// style class.
//
// # Accessibility
//
// AdwHeaderBar uses the GTK_ACCESSIBLE_ROLE_GROUP role.
type HeaderBar struct {
_ [0]func() // equal guard
gtk.Widget
}
var (
_ gtk.Widgetter = (*HeaderBar)(nil)
)
func init() {
coreglib.RegisterClassInfo[*HeaderBar, *HeaderBarClass, HeaderBarOverrides](
GTypeHeaderBar,
initHeaderBarClass,
wrapHeaderBar,
defaultHeaderBarOverrides,
)
}
func initHeaderBarClass(gclass unsafe.Pointer, overrides HeaderBarOverrides, classInitFunc func(*HeaderBarClass)) {
if classInitFunc != nil {
class := (*HeaderBarClass)(gextras.NewStructNative(gclass))
classInitFunc(class)
}
}
func wrapHeaderBar(obj *coreglib.Object) *HeaderBar {
return &HeaderBar{
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 marshalHeaderBar(p uintptr) (interface{}, error) {
return wrapHeaderBar(coreglib.ValueFromNative(unsafe.Pointer(p)).Object()), nil
}
// NewHeaderBar creates a new AdwHeaderBar.
//
// The function returns the following values:
//
// - headerBar: newly created AdwHeaderBar.
//
func NewHeaderBar() *HeaderBar {
var _cret *C.GtkWidget // in
_cret = C.adw_header_bar_new()
var _headerBar *HeaderBar // out
_headerBar = wrapHeaderBar(coreglib.Take(unsafe.Pointer(_cret)))
return _headerBar
}
// CenteringPolicy gets the policy for aligning the center widget.
//
// The function returns the following values:
//
// - centeringPolicy: centering policy.
//
func (self *HeaderBar) CenteringPolicy() CenteringPolicy {
var _arg0 *C.AdwHeaderBar // out
var _cret C.AdwCenteringPolicy // in
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_header_bar_get_centering_policy(_arg0)
runtime.KeepAlive(self)
var _centeringPolicy CenteringPolicy // out
_centeringPolicy = CenteringPolicy(_cret)
return _centeringPolicy
}
// DecorationLayout gets the decoration layout for self.
//
// The function returns the following values:
//
// - utf8 (optional): decoration layout.
//
func (self *HeaderBar) DecorationLayout() string {
var _arg0 *C.AdwHeaderBar // out
var _cret *C.char // in
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_header_bar_get_decoration_layout(_arg0)
runtime.KeepAlive(self)
var _utf8 string // out
if _cret != nil {
_utf8 = C.GoString((*C.gchar)(unsafe.Pointer(_cret)))
}
return _utf8
}
// ShowBackButton gets whether self can show the back button.
//
// The function returns the following values:
//
// - ok: whether to show the back button.
//
func (self *HeaderBar) ShowBackButton() bool {
var _arg0 *C.AdwHeaderBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_header_bar_get_show_back_button(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// ShowEndTitleButtons gets whether to show title buttons at the end of self.
//
// The function returns the following values:
//
// - ok: TRUE if title buttons at the end are shown.
//
func (self *HeaderBar) ShowEndTitleButtons() bool {
var _arg0 *C.AdwHeaderBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_header_bar_get_show_end_title_buttons(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// ShowStartTitleButtons gets whether to show title buttons at the start of
// self.
//
// The function returns the following values:
//
// - ok: TRUE if title buttons at the start are shown.
//
func (self *HeaderBar) ShowStartTitleButtons() bool {
var _arg0 *C.AdwHeaderBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_header_bar_get_show_start_title_buttons(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// ShowTitle gets whether the title widget should be shown.
//
// The function returns the following values:
//
// - ok: whether the title widget should be shown.
//
func (self *HeaderBar) ShowTitle() bool {
var _arg0 *C.AdwHeaderBar // out
var _cret C.gboolean // in
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_header_bar_get_show_title(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// TitleWidget gets the title widget widget of self.
//
// The function returns the following values:
//
// - widget (optional): title widget.
//
func (self *HeaderBar) TitleWidget() gtk.Widgetter {
var _arg0 *C.AdwHeaderBar // out
var _cret *C.GtkWidget // in
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_header_bar_get_title_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
}
// PackEnd adds child to self, packed with reference to the end of self.
//
// The function takes the following parameters:
//
// - child: widget to be added to self.
//
func (self *HeaderBar) PackEnd(child gtk.Widgetter) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 *C.GtkWidget // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))
C.adw_header_bar_pack_end(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(child)
}
// PackStart adds child to self, packed with reference to the start of the self.
//
// The function takes the following parameters:
//
// - child: widget to be added to self.
//
func (self *HeaderBar) PackStart(child gtk.Widgetter) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 *C.GtkWidget // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))
C.adw_header_bar_pack_start(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(child)
}
// Remove removes a child from self.
//
// The child must have been added with headerbar.PackStart, headerbar.PackEnd or
// headerbar:title-widget.
//
// The function takes the following parameters:
//
// - child to remove.
//
func (self *HeaderBar) Remove(child gtk.Widgetter) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 *C.GtkWidget // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(child).Native()))
C.adw_header_bar_remove(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(child)
}
// SetCenteringPolicy sets the policy for aligning the center widget.
//
// The function takes the following parameters:
//
// - centeringPolicy: centering policy.
//
func (self *HeaderBar) SetCenteringPolicy(centeringPolicy CenteringPolicy) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 C.AdwCenteringPolicy // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_arg1 = C.AdwCenteringPolicy(centeringPolicy)
C.adw_header_bar_set_centering_policy(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(centeringPolicy)
}
// SetDecorationLayout sets the decoration layout for self.
//
// If this property is not set, the gtk.Settings:gtk-decoration-layout setting
// is used.
//
// The format of the string is button names, separated by commas. A colon
// separates the buttons that should appear at the start from those at the end.
// Recognized button names are minimize, maximize, close and icon (the window
// icon).
//
// For example, “icon:minimize,maximize,close” specifies an icon at the start,
// and minimize, maximize and close buttons at the end.
//
// The function takes the following parameters:
//
// - layout (optional): decoration layout.
//
func (self *HeaderBar) SetDecorationLayout(layout string) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 *C.char // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if layout != "" {
_arg1 = (*C.char)(unsafe.Pointer(C.CString(layout)))
defer C.free(unsafe.Pointer(_arg1))
}
C.adw_header_bar_set_decoration_layout(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(layout)
}
// SetShowBackButton sets whether self can show the back button.
//
// The back button will never be shown unless the header bar is placed inside an
// navigationview. Usually, there is no reason to set it to FALSE.
//
// The function takes the following parameters:
//
// - showBackButton: whether to show the back button.
//
func (self *HeaderBar) SetShowBackButton(showBackButton bool) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if showBackButton {
_arg1 = C.TRUE
}
C.adw_header_bar_set_show_back_button(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(showBackButton)
}
// SetShowEndTitleButtons sets whether to show title buttons at the end of self.
//
// See headerbar:show-start-title-buttons for the other side.
//
// Which buttons are actually shown and where is determined by the
// headerbar:decoration-layout property, and by the state of the window (e.g.
// a close button will not be shown if the window can't be closed).
//
// The function takes the following parameters:
//
// - setting: TRUE to show standard title buttons.
//
func (self *HeaderBar) SetShowEndTitleButtons(setting bool) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if setting {
_arg1 = C.TRUE
}
C.adw_header_bar_set_show_end_title_buttons(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(setting)
}
// SetShowStartTitleButtons sets whether to show title buttons at the start of
// self.
//
// See headerbar:show-end-title-buttons for the other side.
//
// Which buttons are actually shown and where is determined by the
// headerbar:decoration-layout property, and by the state of the window (e.g.
// a close button will not be shown if the window can't be closed).
//
// The function takes the following parameters:
//
// - setting: TRUE to show standard title buttons.
//
func (self *HeaderBar) SetShowStartTitleButtons(setting bool) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if setting {
_arg1 = C.TRUE
}
C.adw_header_bar_set_show_start_title_buttons(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(setting)
}
// SetShowTitle sets whether the title widget should be shown.
//
// The function takes the following parameters:
//
// - showTitle: whether the title widget is visible.
//
func (self *HeaderBar) SetShowTitle(showTitle bool) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if showTitle {
_arg1 = C.TRUE
}
C.adw_header_bar_set_show_title(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(showTitle)
}
// SetTitleWidget sets the title widget for self.
//
// When set to NULL, the header bar will display the title of the window it is
// contained in.
//
// To use a different title, use windowtitle:
//
// <object class="AdwHeaderBar">
// <property name="title-widget">
// <object class="AdwWindowTitle">
// <property name="title" translatable="yes">Title</property>
// </object>
// </property>
// </object>.
//
// The function takes the following parameters:
//
// - titleWidget (optional): widget to use for a title.
//
func (self *HeaderBar) SetTitleWidget(titleWidget gtk.Widgetter) {
var _arg0 *C.AdwHeaderBar // out
var _arg1 *C.GtkWidget // out
_arg0 = (*C.AdwHeaderBar)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if titleWidget != nil {
_arg1 = (*C.GtkWidget)(unsafe.Pointer(coreglib.InternObject(titleWidget).Native()))
}
C.adw_header_bar_set_title_widget(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(titleWidget)
}
// HeaderBarClass: instance of this type is always passed by reference.
type HeaderBarClass struct {
*headerBarClass
}
// headerBarClass is the struct that's finalized.
type headerBarClass struct {
native *C.AdwHeaderBarClass
}
func (h *HeaderBarClass) ParentClass() *gtk.WidgetClass {
valptr := &h.native.parent_class
var _v *gtk.WidgetClass // out
_v = (*gtk.WidgetClass)(gextras.NewStructNative(unsafe.Pointer(valptr)))
return _v
}