File: button_box.go

package info (click to toggle)
golang-github-gotk3-gotk3 0.6.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,392 kB
  • sloc: ansic: 914; makefile: 4
file content (98 lines) | stat: -rw-r--r-- 2,924 bytes parent folder | download | duplicates (2)
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
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures

package gtk

// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
	"unsafe"

	"github.com/gotk3/gotk3/glib"
)

type ButtonBoxStyle int

const (
	BUTTONBOX_SPREAD ButtonBoxStyle = C.GTK_BUTTONBOX_SPREAD
	BUTTONBOX_EDGE   ButtonBoxStyle = C.GTK_BUTTONBOX_EDGE
	BUTTONBOX_START  ButtonBoxStyle = C.GTK_BUTTONBOX_START
	BUTTONBOX_END    ButtonBoxStyle = C.GTK_BUTTONBOX_END
	BUTTONBOX_CENTER ButtonBoxStyle = C.GTK_BUTTONBOX_CENTER
)

/*
 * GtkButtonBox
 */

// ButtonBox is a representation of GTK's GtkButtonBox.
type ButtonBox struct {
	Box
}

// native returns a pointer to the underlying GtkButtonBox.
func (v *ButtonBox) native() *C.GtkButtonBox {
	if v == nil || v.GObject == nil {
		return nil
	}
	p := unsafe.Pointer(v.GObject)
	return C.toGtkButtonBox(p)
}

func marshalButtonBox(p uintptr) (interface{}, error) {
	c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
	obj := glib.Take(unsafe.Pointer(c))
	return wrapButtonBox(obj), nil
}

func wrapButtonBox(obj *glib.Object) *ButtonBox {
	if obj == nil {
		return nil
	}

	return &ButtonBox{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}

// ButtonBoxNew is a wrapper around gtk_button_box_new().
func ButtonBoxNew(o Orientation) (*ButtonBox, error) {
	c := C.gtk_button_box_new(C.GtkOrientation(o))
	if c == nil {
		return nil, nilPtrErr
	}
	obj := glib.Take(unsafe.Pointer(c))
	return wrapButtonBox(obj), nil
}

// GetLayout() is a wrapper around gtk_button_box_get_layout().
func (v *ButtonBox) GetLayout() ButtonBoxStyle {
	c := C.gtk_button_box_get_layout(v.native())
	return ButtonBoxStyle(c)
}

// GetChildSecondary() is a wrapper around gtk_button_box_get_child_secondary().
func (v *ButtonBox) GetChildSecondary(child IWidget) bool {
	c := C.gtk_button_box_get_child_secondary(v.native(), child.toWidget())
	return gobool(c)
}

// GetChildNonHomogeneous() is a wrapper around gtk_button_box_get_child_non_homogeneous().
func (v *ButtonBox) GetChildNonHomogeneous(child IWidget) bool {
	c := C.gtk_button_box_get_child_non_homogeneous(v.native(), child.toWidget())
	return gobool(c)
}

// SetLayout() is a wrapper around gtk_button_box_set_layout().
func (v *ButtonBox) SetLayout(style ButtonBoxStyle) {
	C.gtk_button_box_set_layout(v.native(), C.GtkButtonBoxStyle(style))
}

// SetChildSecondary() is a wrapper around gtk_button_box_set_child_secondary().
func (v *ButtonBox) SetChildSecondary(child IWidget, isSecondary bool) {
	C.gtk_button_box_set_child_secondary(v.native(), child.toWidget(), gbool(isSecondary))
}

// SetChildNonHomogeneous() is a wrapper around gtk_button_box_set_child_non_homogeneous().
func (v *ButtonBox) SetChildNonHomogeneous(child IWidget, nonHomogeneous bool) {
	C.gtk_button_box_set_child_non_homogeneous(v.native(), child.toWidget(), gbool(nonHomogeneous))
}