1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gdk"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type ColorChooserInterface struct {
17 _ structs.HostLayout
18
19 BaseInterface uintptr
20
21 xGetRgba uintptr
22
23 xSetRgba uintptr
24
25 xAddPalette uintptr
26
27 xColorActivated uintptr
28
29 Padding [12]uintptr
30}
31
32func (x *ColorChooserInterface) GoPointer() uintptr {
33 return uintptr(unsafe.Pointer(x))
34}
35
36// OverrideGetRgba sets the "get_rgba" callback function.
37func (x *ColorChooserInterface) OverrideGetRgba(cb func(ColorChooser, *gdk.RGBA)) {
38 if cb == nil {
39 x.xGetRgba = 0
40 } else {
41 x.xGetRgba = purego.NewCallback(func(ChooserVarp uintptr, ColorVarp *gdk.RGBA) {
42 cb(&ColorChooserBase{Ptr: ChooserVarp}, ColorVarp)
43 })
44 }
45}
46
47// GetGetRgba gets the "get_rgba" callback function.
48func (x *ColorChooserInterface) GetGetRgba() func(ColorChooser, *gdk.RGBA) {
49 if x.xGetRgba == 0 {
50 return nil
51 }
52 var rawCallback func(ChooserVarp uintptr, ColorVarp *gdk.RGBA)
53 purego.RegisterFunc(&rawCallback, x.xGetRgba)
54 return func(ChooserVar ColorChooser, ColorVar *gdk.RGBA) {
55 rawCallback(ChooserVar.GoPointer(), ColorVar)
56 }
57}
58
59// OverrideSetRgba sets the "set_rgba" callback function.
60func (x *ColorChooserInterface) OverrideSetRgba(cb func(ColorChooser, *gdk.RGBA)) {
61 if cb == nil {
62 x.xSetRgba = 0
63 } else {
64 x.xSetRgba = purego.NewCallback(func(ChooserVarp uintptr, ColorVarp *gdk.RGBA) {
65 cb(&ColorChooserBase{Ptr: ChooserVarp}, ColorVarp)
66 })
67 }
68}
69
70// GetSetRgba gets the "set_rgba" callback function.
71func (x *ColorChooserInterface) GetSetRgba() func(ColorChooser, *gdk.RGBA) {
72 if x.xSetRgba == 0 {
73 return nil
74 }
75 var rawCallback func(ChooserVarp uintptr, ColorVarp *gdk.RGBA)
76 purego.RegisterFunc(&rawCallback, x.xSetRgba)
77 return func(ChooserVar ColorChooser, ColorVar *gdk.RGBA) {
78 rawCallback(ChooserVar.GoPointer(), ColorVar)
79 }
80}
81
82// OverrideAddPalette sets the "add_palette" callback function.
83func (x *ColorChooserInterface) OverrideAddPalette(cb func(ColorChooser, Orientation, int, int, []gdk.RGBA)) {
84 if cb == nil {
85 x.xAddPalette = 0
86 } else {
87 x.xAddPalette = purego.NewCallback(func(ChooserVarp uintptr, OrientationVarp Orientation, ColorsPerLineVarp int, NColorsVarp int, ColorsVarp []gdk.RGBA) {
88 cb(&ColorChooserBase{Ptr: ChooserVarp}, OrientationVarp, ColorsPerLineVarp, NColorsVarp, ColorsVarp)
89 })
90 }
91}
92
93// GetAddPalette gets the "add_palette" callback function.
94func (x *ColorChooserInterface) GetAddPalette() func(ColorChooser, Orientation, int, int, []gdk.RGBA) {
95 if x.xAddPalette == 0 {
96 return nil
97 }
98 var rawCallback func(ChooserVarp uintptr, OrientationVarp Orientation, ColorsPerLineVarp int, NColorsVarp int, ColorsVarp []gdk.RGBA)
99 purego.RegisterFunc(&rawCallback, x.xAddPalette)
100 return func(ChooserVar ColorChooser, OrientationVar Orientation, ColorsPerLineVar int, NColorsVar int, ColorsVar []gdk.RGBA) {
101 rawCallback(ChooserVar.GoPointer(), OrientationVar, ColorsPerLineVar, NColorsVar, ColorsVar)
102 }
103}
104
105// OverrideColorActivated sets the "color_activated" callback function.
106func (x *ColorChooserInterface) OverrideColorActivated(cb func(ColorChooser, *gdk.RGBA)) {
107 if cb == nil {
108 x.xColorActivated = 0
109 } else {
110 x.xColorActivated = purego.NewCallback(func(ChooserVarp uintptr, ColorVarp *gdk.RGBA) {
111 cb(&ColorChooserBase{Ptr: ChooserVarp}, ColorVarp)
112 })
113 }
114}
115
116// GetColorActivated gets the "color_activated" callback function.
117func (x *ColorChooserInterface) GetColorActivated() func(ColorChooser, *gdk.RGBA) {
118 if x.xColorActivated == 0 {
119 return nil
120 }
121 var rawCallback func(ChooserVarp uintptr, ColorVarp *gdk.RGBA)
122 purego.RegisterFunc(&rawCallback, x.xColorActivated)
123 return func(ChooserVar ColorChooser, ColorVar *gdk.RGBA) {
124 rawCallback(ChooserVar.GoPointer(), ColorVar)
125 }
126}
127
128// `GtkColorChooser` is an interface that is implemented by widgets
129// for choosing colors.
130//
131// Depending on the situation, colors may be allowed to have alpha (translucency).
132//
133// In GTK, the main widgets that implement this interface are
134// [class@Gtk.ColorChooserWidget], [class@Gtk.ColorChooserDialog] and
135// [class@Gtk.ColorButton].
136type ColorChooser interface {
137 GoPointer() uintptr
138 SetGoPointer(uintptr)
139 AddPalette(OrientationVar Orientation, ColorsPerLineVar int, NColorsVar int, ColorsVar []gdk.RGBA)
140 GetRgba(ColorVar *gdk.RGBA)
141 GetUseAlpha() bool
142 SetRgba(ColorVar *gdk.RGBA)
143 SetUseAlpha(UseAlphaVar bool)
144}
145
146var xColorChooserGLibType func() types.GType
147
148func ColorChooserGLibType() types.GType {
149 return xColorChooserGLibType()
150}
151
152type ColorChooserBase struct {
153 Ptr uintptr
154}
155
156func (x *ColorChooserBase) GoPointer() uintptr {
157 if x == nil {
158 return 0
159 }
160 return x.Ptr
161}
162
163func (x *ColorChooserBase) SetGoPointer(ptr uintptr) {
164 x.Ptr = ptr
165}
166
167// Adds a palette to the color chooser.
168//
169// If @orientation is horizontal, the colors are grouped in rows,
170// with @colors_per_line colors in each row. If @horizontal is %FALSE,
171// the colors are grouped in columns instead.
172//
173// The default color palette of [class@Gtk.ColorChooserWidget] has
174// 45 colors, organized in columns of 5 colors (this includes some
175// grays).
176//
177// The layout of the color chooser widget works best when the
178// palettes have 9-10 columns.
179//
180// Calling this function for the first time has the side effect
181// of removing the default color palette from the color chooser.
182//
183// If @colors is %NULL, removes all previously added palettes.
184func (x *ColorChooserBase) AddPalette(OrientationVar Orientation, ColorsPerLineVar int, NColorsVar int, ColorsVar []gdk.RGBA) {
185
186 XGtkColorChooserAddPalette(x.GoPointer(), OrientationVar, ColorsPerLineVar, NColorsVar, ColorsVar)
187
188}
189
190// Gets the currently-selected color.
191func (x *ColorChooserBase) GetRgba(ColorVar *gdk.RGBA) {
192
193 XGtkColorChooserGetRgba(x.GoPointer(), ColorVar)
194
195}
196
197// Returns whether the color chooser shows the alpha channel.
198func (x *ColorChooserBase) GetUseAlpha() bool {
199
200 cret := XGtkColorChooserGetUseAlpha(x.GoPointer())
201 return cret
202}
203
204// Sets the color.
205func (x *ColorChooserBase) SetRgba(ColorVar *gdk.RGBA) {
206
207 XGtkColorChooserSetRgba(x.GoPointer(), ColorVar)
208
209}
210
211// Sets whether or not the color chooser should use the alpha channel.
212func (x *ColorChooserBase) SetUseAlpha(UseAlphaVar bool) {
213
214 XGtkColorChooserSetUseAlpha(x.GoPointer(), UseAlphaVar)
215
216}
217
218// SetPropertyRgba sets the "rgba" property.
219// The currently selected color, as a `GdkRGBA` struct.
220//
221// The property can be set to change the current selection
222// programmatically.
223func (x *ColorChooserBase) SetPropertyRgba(value uintptr) {
224 obj := gobject.Object{}
225 obj.Ptr = x.GoPointer()
226 var v gobject.Value
227 v.Init(gobject.TypePointerVal)
228 v.SetPointer(value)
229 obj.SetProperty("rgba", &v)
230}
231
232// GetPropertyRgba gets the "rgba" property.
233// The currently selected color, as a `GdkRGBA` struct.
234//
235// The property can be set to change the current selection
236// programmatically.
237func (x *ColorChooserBase) GetPropertyRgba() uintptr {
238 obj := gobject.Object{}
239 obj.Ptr = x.GoPointer()
240 var v gobject.Value
241 obj.GetProperty("rgba", &v)
242 return v.GetPointer()
243}
244
245// SetPropertyUseAlpha sets the "use-alpha" property.
246// Whether colors may have alpha (translucency).
247//
248// When ::use-alpha is %FALSE, the `GdkRGBA` struct obtained
249// via the [property@Gtk.ColorChooser:rgba] property will be
250// forced to have alpha == 1.
251//
252// Implementations are expected to show alpha by rendering the color
253// over a non-uniform background (like a checkerboard pattern).
254func (x *ColorChooserBase) SetPropertyUseAlpha(value bool) {
255 obj := gobject.Object{}
256 obj.Ptr = x.GoPointer()
257 var v gobject.Value
258 v.Init(gobject.TypeBooleanVal)
259 v.SetBoolean(value)
260 obj.SetProperty("use-alpha", &v)
261}
262
263// GetPropertyUseAlpha gets the "use-alpha" property.
264// Whether colors may have alpha (translucency).
265//
266// When ::use-alpha is %FALSE, the `GdkRGBA` struct obtained
267// via the [property@Gtk.ColorChooser:rgba] property will be
268// forced to have alpha == 1.
269//
270// Implementations are expected to show alpha by rendering the color
271// over a non-uniform background (like a checkerboard pattern).
272func (x *ColorChooserBase) GetPropertyUseAlpha() bool {
273 obj := gobject.Object{}
274 obj.Ptr = x.GoPointer()
275 var v gobject.Value
276 obj.GetProperty("use-alpha", &v)
277 return v.GetBoolean()
278}
279
280var XGtkColorChooserAddPalette func(uintptr, Orientation, int, int, []gdk.RGBA)
281var XGtkColorChooserGetRgba func(uintptr, *gdk.RGBA)
282var XGtkColorChooserGetUseAlpha func(uintptr) bool
283var XGtkColorChooserSetRgba func(uintptr, *gdk.RGBA)
284var XGtkColorChooserSetUseAlpha func(uintptr, bool)
285
286func init() {
287 core.SetPackageName("GTK", "gtk4")
288 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
289 var libs []uintptr
290 for _, libPath := range core.GetPaths("GTK") {
291 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
292 if err != nil {
293 panic(err)
294 }
295 libs = append(libs, lib)
296 }
297
298 core.PuregoSafeRegister(&xColorChooserGLibType, libs, "gtk_color_chooser_get_type")
299
300 core.PuregoSafeRegister(&XGtkColorChooserAddPalette, libs, "gtk_color_chooser_add_palette")
301 core.PuregoSafeRegister(&XGtkColorChooserGetRgba, libs, "gtk_color_chooser_get_rgba")
302 core.PuregoSafeRegister(&XGtkColorChooserGetUseAlpha, libs, "gtk_color_chooser_get_use_alpha")
303 core.PuregoSafeRegister(&XGtkColorChooserSetRgba, libs, "gtk_color_chooser_set_rgba")
304 core.PuregoSafeRegister(&XGtkColorChooserSetUseAlpha, libs, "gtk_color_chooser_set_use_alpha")
305
306}