1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/gdk"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// The `GtkColorButton` allows to open a color chooser dialog to change
17// the color.
18//
19// <picture>
20//
21// <source srcset="color-button-dark.png" media="(prefers-color-scheme: dark)">
22// <img alt="An example GtkColorButton" src="color-button.png">
23//
24// </picture>
25//
26// It is suitable widget for selecting a color in a preference dialog.
27//
28// # CSS nodes
29//
30// ```
31// colorbutton
32// ╰── button.color
33//
34// ╰── [content]
35//
36// ```
37//
38// `GtkColorButton` has a single CSS node with name colorbutton which
39// contains a button node. To differentiate it from a plain `GtkButton`,
40// it gets the .color style class.
41type ColorButton struct {
42 Widget
43}
44
45var xColorButtonGLibType func() types.GType
46
47func ColorButtonGLibType() types.GType {
48 return xColorButtonGLibType()
49}
50
51func ColorButtonNewFromInternalPtr(ptr uintptr) *ColorButton {
52 cls := &ColorButton{}
53 cls.Ptr = ptr
54 return cls
55}
56
57var xNewColorButton func() uintptr
58
59// Creates a new color button.
60//
61// This returns a widget in the form of a small button containing
62// a swatch representing the current selected color. When the button
63// is clicked, a color chooser dialog will open, allowing the user
64// to select a color. The swatch will be updated to reflect the new
65// color when the user finishes.
66func NewColorButton() *ColorButton {
67 var cls *ColorButton
68
69 cret := xNewColorButton()
70
71 if cret == 0 {
72 return nil
73 }
74 gobject.IncreaseRef(cret)
75 cls = &ColorButton{}
76 cls.Ptr = cret
77 return cls
78}
79
80var xNewColorButtonWithRgba func(*gdk.RGBA) uintptr
81
82// Creates a new color button showing the given color.
83func NewColorButtonWithRgba(RgbaVar *gdk.RGBA) *ColorButton {
84 var cls *ColorButton
85
86 cret := xNewColorButtonWithRgba(RgbaVar)
87
88 if cret == 0 {
89 return nil
90 }
91 gobject.IncreaseRef(cret)
92 cls = &ColorButton{}
93 cls.Ptr = cret
94 return cls
95}
96
97var xColorButtonGetModal func(uintptr) bool
98
99// Gets whether the dialog is modal.
100func (x *ColorButton) GetModal() bool {
101
102 cret := xColorButtonGetModal(x.GoPointer())
103 return cret
104}
105
106var xColorButtonGetTitle func(uintptr) string
107
108// Gets the title of the color chooser dialog.
109func (x *ColorButton) GetTitle() string {
110
111 cret := xColorButtonGetTitle(x.GoPointer())
112 return cret
113}
114
115var xColorButtonSetModal func(uintptr, bool)
116
117// Sets whether the dialog should be modal.
118func (x *ColorButton) SetModal(ModalVar bool) {
119
120 xColorButtonSetModal(x.GoPointer(), ModalVar)
121
122}
123
124var xColorButtonSetTitle func(uintptr, string)
125
126// Sets the title for the color chooser dialog.
127func (x *ColorButton) SetTitle(TitleVar string) {
128
129 xColorButtonSetTitle(x.GoPointer(), TitleVar)
130
131}
132
133func (c *ColorButton) GoPointer() uintptr {
134 if c == nil {
135 return 0
136 }
137 return c.Ptr
138}
139
140func (c *ColorButton) SetGoPointer(ptr uintptr) {
141 c.Ptr = ptr
142}
143
144// SetPropertyModal sets the "modal" property.
145// Whether the color chooser dialog should be modal.
146func (x *ColorButton) SetPropertyModal(value bool) {
147 var v gobject.Value
148 v.Init(gobject.TypeBooleanVal)
149 v.SetBoolean(value)
150 x.SetProperty("modal", &v)
151}
152
153// GetPropertyModal gets the "modal" property.
154// Whether the color chooser dialog should be modal.
155func (x *ColorButton) GetPropertyModal() bool {
156 var v gobject.Value
157 x.GetProperty("modal", &v)
158 return v.GetBoolean()
159}
160
161// SetPropertyShowEditor sets the "show-editor" property.
162// Whether the color chooser should open in editor mode.
163//
164// This property should be used in cases where the palette
165// in the editor would be redundant, such as when the color
166// button is already part of a palette.
167func (x *ColorButton) SetPropertyShowEditor(value bool) {
168 var v gobject.Value
169 v.Init(gobject.TypeBooleanVal)
170 v.SetBoolean(value)
171 x.SetProperty("show-editor", &v)
172}
173
174// GetPropertyShowEditor gets the "show-editor" property.
175// Whether the color chooser should open in editor mode.
176//
177// This property should be used in cases where the palette
178// in the editor would be redundant, such as when the color
179// button is already part of a palette.
180func (x *ColorButton) GetPropertyShowEditor() bool {
181 var v gobject.Value
182 x.GetProperty("show-editor", &v)
183 return v.GetBoolean()
184}
185
186// SetPropertyTitle sets the "title" property.
187// The title of the color chooser dialog
188func (x *ColorButton) SetPropertyTitle(value string) {
189 var v gobject.Value
190 v.Init(gobject.TypeStringVal)
191 v.SetString(&value)
192 x.SetProperty("title", &v)
193}
194
195// GetPropertyTitle gets the "title" property.
196// The title of the color chooser dialog
197func (x *ColorButton) GetPropertyTitle() string {
198 var v gobject.Value
199 x.GetProperty("title", &v)
200 return v.GetString()
201}
202
203// Emitted to when the color button is activated.
204//
205// The `::activate` signal on `GtkMenuButton` is an action signal and
206// emitting it causes the button to pop up its dialog.
207func (x *ColorButton) ConnectActivate(cb *func(ColorButton)) uint {
208 cbPtr := uintptr(unsafe.Pointer(cb))
209 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
210 handlerID := gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr)
211 glib.SaveHandlerMapping(handlerID, cbPtr)
212 return handlerID
213 }
214
215 fcb := func(clsPtr uintptr) {
216 fa := ColorButton{}
217 fa.Ptr = clsPtr
218 cbFn := *cb
219
220 cbFn(fa)
221
222 }
223 cbRefPtr := purego.NewCallback(fcb)
224 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
225 handlerID := gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr)
226 glib.SaveHandlerMapping(handlerID, cbPtr)
227 return handlerID
228}
229
230// Emitted when the user selects a color.
231//
232// When handling this signal, use [method@Gtk.ColorChooser.get_rgba]
233// to find out which color was just selected.
234//
235// Note that this signal is only emitted when the user changes the color.
236// If you need to react to programmatic color changes as well, use
237// the notify::rgba signal.
238func (x *ColorButton) ConnectColorSet(cb *func(ColorButton)) uint {
239 cbPtr := uintptr(unsafe.Pointer(cb))
240 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
241 handlerID := gobject.SignalConnect(x.GoPointer(), "color-set", cbRefPtr)
242 glib.SaveHandlerMapping(handlerID, cbPtr)
243 return handlerID
244 }
245
246 fcb := func(clsPtr uintptr) {
247 fa := ColorButton{}
248 fa.Ptr = clsPtr
249 cbFn := *cb
250
251 cbFn(fa)
252
253 }
254 cbRefPtr := purego.NewCallback(fcb)
255 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
256 handlerID := gobject.SignalConnect(x.GoPointer(), "color-set", cbRefPtr)
257 glib.SaveHandlerMapping(handlerID, cbPtr)
258 return handlerID
259}
260
261// Requests the user's screen reader to announce the given message.
262//
263// This kind of notification is useful for messages that
264// either have only a visual representation or that are not
265// exposed visually at all, e.g. a notification about a
266// successful operation.
267//
268// Also, by using this API, you can ensure that the message
269// does not interrupts the user's current screen reader output.
270func (x *ColorButton) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) {
271
272 XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar)
273
274}
275
276// Retrieves the accessible parent for an accessible object.
277//
278// This function returns `NULL` for top level widgets.
279func (x *ColorButton) GetAccessibleParent() *AccessibleBase {
280 var cls *AccessibleBase
281
282 cret := XGtkAccessibleGetAccessibleParent(x.GoPointer())
283
284 if cret == 0 {
285 return nil
286 }
287 cls = &AccessibleBase{}
288 cls.Ptr = cret
289 return cls
290}
291
292// Retrieves the accessible role of an accessible object.
293func (x *ColorButton) GetAccessibleRole() AccessibleRole {
294
295 cret := XGtkAccessibleGetAccessibleRole(x.GoPointer())
296 return cret
297}
298
299// Retrieves the implementation for the given accessible object.
300func (x *ColorButton) GetAtContext() *ATContext {
301 var cls *ATContext
302
303 cret := XGtkAccessibleGetAtContext(x.GoPointer())
304
305 if cret == 0 {
306 return nil
307 }
308 cls = &ATContext{}
309 cls.Ptr = cret
310 return cls
311}
312
313// Queries the coordinates and dimensions of this accessible
314//
315// This functionality can be overridden by `GtkAccessible`
316// implementations, e.g. to get the bounds from an ignored
317// child widget.
318func (x *ColorButton) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool {
319
320 cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar)
321 return cret
322}
323
324// Retrieves the first accessible child of an accessible object.
325func (x *ColorButton) GetFirstAccessibleChild() *AccessibleBase {
326 var cls *AccessibleBase
327
328 cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer())
329
330 if cret == 0 {
331 return nil
332 }
333 cls = &AccessibleBase{}
334 cls.Ptr = cret
335 return cls
336}
337
338// Retrieves the next accessible sibling of an accessible object
339func (x *ColorButton) GetNextAccessibleSibling() *AccessibleBase {
340 var cls *AccessibleBase
341
342 cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer())
343
344 if cret == 0 {
345 return nil
346 }
347 cls = &AccessibleBase{}
348 cls.Ptr = cret
349 return cls
350}
351
352// Queries a platform state, such as focus.
353//
354// This functionality can be overridden by `GtkAccessible`
355// implementations, e.g. to get platform state from an ignored
356// child widget, as is the case for `GtkText` wrappers.
357func (x *ColorButton) GetPlatformState(StateVar AccessiblePlatformState) bool {
358
359 cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar)
360 return cret
361}
362
363// Resets the accessible property to its default value.
364func (x *ColorButton) ResetProperty(PropertyVar AccessibleProperty) {
365
366 XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar)
367
368}
369
370// Resets the accessible relation to its default value.
371func (x *ColorButton) ResetRelation(RelationVar AccessibleRelation) {
372
373 XGtkAccessibleResetRelation(x.GoPointer(), RelationVar)
374
375}
376
377// Resets the accessible state to its default value.
378func (x *ColorButton) ResetState(StateVar AccessibleState) {
379
380 XGtkAccessibleResetState(x.GoPointer(), StateVar)
381
382}
383
384// Sets the parent and sibling of an accessible object.
385//
386// This function is meant to be used by accessible implementations that are
387// not part of the widget hierarchy, and but act as a logical bridge between
388// widgets. For instance, if a widget creates an object that holds metadata
389// for each child, and you want that object to implement the `GtkAccessible`
390// interface, you will use this function to ensure that the parent of each
391// child widget is the metadata object, and the parent of each metadata
392// object is the container widget.
393func (x *ColorButton) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) {
394
395 XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer())
396
397}
398
399// Updates the next accessible sibling.
400//
401// That might be useful when a new child of a custom accessible
402// is created, and it needs to be linked to a previous child.
403func (x *ColorButton) UpdateNextAccessibleSibling(NewSiblingVar Accessible) {
404
405 XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer())
406
407}
408
409// Informs ATs that the platform state has changed.
410//
411// This function should be used by `GtkAccessible` implementations that
412// have a platform state but are not widgets. Widgets handle platform
413// states automatically.
414func (x *ColorButton) UpdatePlatformState(StateVar AccessiblePlatformState) {
415
416 XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar)
417
418}
419
420// Updates a list of accessible properties.
421//
422// See the [enum@Gtk.AccessibleProperty] documentation for the
423// value types of accessible properties.
424//
425// This function should be called by `GtkWidget` types whenever
426// an accessible property change must be communicated to assistive
427// technologies.
428//
429// Example:
430// ```c
431// value = gtk_adjustment_get_value (adjustment);
432// gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button),
433//
434// GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
435// -1);
436//
437// ```
438func (x *ColorButton) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) {
439
440 XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...)
441
442}
443
444// Updates an array of accessible properties.
445//
446// This function should be called by `GtkWidget` types whenever an accessible
447// property change must be communicated to assistive technologies.
448//
449// This function is meant to be used by language bindings.
450func (x *ColorButton) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) {
451
452 XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar)
453
454}
455
456// Updates a list of accessible relations.
457//
458// This function should be called by `GtkWidget` types whenever an accessible
459// relation change must be communicated to assistive technologies.
460//
461// If the [enum@Gtk.AccessibleRelation] requires a list of references,
462// you should pass each reference individually, followed by `NULL`, e.g.
463//
464// ```c
465// gtk_accessible_update_relation (accessible,
466//
467// GTK_ACCESSIBLE_RELATION_CONTROLS,
468// ref1, NULL,
469// GTK_ACCESSIBLE_RELATION_LABELLED_BY,
470// ref1, ref2, ref3, NULL,
471// -1);
472//
473// ```
474func (x *ColorButton) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) {
475
476 XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...)
477
478}
479
480// Updates an array of accessible relations.
481//
482// This function should be called by `GtkWidget` types whenever an accessible
483// relation change must be communicated to assistive technologies.
484//
485// This function is meant to be used by language bindings.
486func (x *ColorButton) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) {
487
488 XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar)
489
490}
491
492// Updates a list of accessible states.
493//
494// See the [enum@Gtk.AccessibleState] documentation for the
495// value types of accessible states.
496//
497// This function should be called by `GtkWidget` types whenever
498// an accessible state change must be communicated to assistive
499// technologies.
500//
501// Example:
502//
503// ```c
504// value = GTK_ACCESSIBLE_TRISTATE_MIXED;
505// gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
506//
507// GTK_ACCESSIBLE_STATE_CHECKED, value,
508// -1);
509//
510// ```
511func (x *ColorButton) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) {
512
513 XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...)
514
515}
516
517// Updates an array of accessible states.
518//
519// This function should be called by `GtkWidget` types whenever an accessible
520// state change must be communicated to assistive technologies.
521//
522// This function is meant to be used by language bindings.
523func (x *ColorButton) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) {
524
525 XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar)
526
527}
528
529// Gets the ID of the @buildable object.
530//
531// `GtkBuilder` sets the name based on the ID attribute
532// of the `<object>` tag used to construct the @buildable.
533func (x *ColorButton) GetBuildableId() string {
534
535 cret := XGtkBuildableGetBuildableId(x.GoPointer())
536 return cret
537}
538
539// Adds a palette to the color chooser.
540//
541// If @orientation is horizontal, the colors are grouped in rows,
542// with @colors_per_line colors in each row. If @horizontal is %FALSE,
543// the colors are grouped in columns instead.
544//
545// The default color palette of [class@Gtk.ColorChooserWidget] has
546// 45 colors, organized in columns of 5 colors (this includes some
547// grays).
548//
549// The layout of the color chooser widget works best when the
550// palettes have 9-10 columns.
551//
552// Calling this function for the first time has the side effect
553// of removing the default color palette from the color chooser.
554//
555// If @colors is %NULL, removes all previously added palettes.
556func (x *ColorButton) AddPalette(OrientationVar Orientation, ColorsPerLineVar int, NColorsVar int, ColorsVar []gdk.RGBA) {
557
558 XGtkColorChooserAddPalette(x.GoPointer(), OrientationVar, ColorsPerLineVar, NColorsVar, ColorsVar)
559
560}
561
562// Gets the currently-selected color.
563func (x *ColorButton) GetRgba(ColorVar *gdk.RGBA) {
564
565 XGtkColorChooserGetRgba(x.GoPointer(), ColorVar)
566
567}
568
569// Returns whether the color chooser shows the alpha channel.
570func (x *ColorButton) GetUseAlpha() bool {
571
572 cret := XGtkColorChooserGetUseAlpha(x.GoPointer())
573 return cret
574}
575
576// Sets the color.
577func (x *ColorButton) SetRgba(ColorVar *gdk.RGBA) {
578
579 XGtkColorChooserSetRgba(x.GoPointer(), ColorVar)
580
581}
582
583// Sets whether or not the color chooser should use the alpha channel.
584func (x *ColorButton) SetUseAlpha(UseAlphaVar bool) {
585
586 XGtkColorChooserSetUseAlpha(x.GoPointer(), UseAlphaVar)
587
588}
589
590func init() {
591 core.SetPackageName("GTK", "gtk4")
592 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
593 var libs []uintptr
594 for _, libPath := range core.GetPaths("GTK") {
595 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
596 if err != nil {
597 panic(err)
598 }
599 libs = append(libs, lib)
600 }
601
602 core.PuregoSafeRegister(&xColorButtonGLibType, libs, "gtk_color_button_get_type")
603
604 core.PuregoSafeRegister(&xNewColorButton, libs, "gtk_color_button_new")
605 core.PuregoSafeRegister(&xNewColorButtonWithRgba, libs, "gtk_color_button_new_with_rgba")
606
607 core.PuregoSafeRegister(&xColorButtonGetModal, libs, "gtk_color_button_get_modal")
608 core.PuregoSafeRegister(&xColorButtonGetTitle, libs, "gtk_color_button_get_title")
609 core.PuregoSafeRegister(&xColorButtonSetModal, libs, "gtk_color_button_set_modal")
610 core.PuregoSafeRegister(&xColorButtonSetTitle, libs, "gtk_color_button_set_title")
611
612}