// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/gdk" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) // The `GtkColorButton` allows to open a color chooser dialog to change // the color. // // <picture> // // <source srcset="color-button-dark.png" media="(prefers-color-scheme: dark)"> // <img alt="An example GtkColorButton" src="color-button.png"> // // </picture> // // It is suitable widget for selecting a color in a preference dialog. // // # CSS nodes // // ``` // colorbutton // ╰── button.color // // ╰── [content] // // ``` // // `GtkColorButton` has a single CSS node with name colorbutton which // contains a button node. To differentiate it from a plain `GtkButton`, // it gets the .color style class. type ColorButton struct { Widget } var xColorButtonGLibType func() types.GType func ColorButtonGLibType() types.GType { return xColorButtonGLibType() } func ColorButtonNewFromInternalPtr(ptr uintptr) *ColorButton { cls := &ColorButton{} cls.Ptr = ptr return cls } var xNewColorButton func() uintptr // Creates a new color button. // // This returns a widget in the form of a small button containing // a swatch representing the current selected color. When the button // is clicked, a color chooser dialog will open, allowing the user // to select a color. The swatch will be updated to reflect the new // color when the user finishes. func NewColorButton() *ColorButton { var cls *ColorButton cret := xNewColorButton() if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &ColorButton{} cls.Ptr = cret return cls } var xNewColorButtonWithRgba func(*gdk.RGBA) uintptr // Creates a new color button showing the given color. func NewColorButtonWithRgba(RgbaVar *gdk.RGBA) *ColorButton { var cls *ColorButton cret := xNewColorButtonWithRgba(RgbaVar) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &ColorButton{} cls.Ptr = cret return cls } var xColorButtonGetModal func(uintptr) bool // Gets whether the dialog is modal. func (x *ColorButton) GetModal() bool { cret := xColorButtonGetModal(x.GoPointer()) return cret } var xColorButtonGetTitle func(uintptr) string // Gets the title of the color chooser dialog. func (x *ColorButton) GetTitle() string { cret := xColorButtonGetTitle(x.GoPointer()) return cret } var xColorButtonSetModal func(uintptr, bool) // Sets whether the dialog should be modal. func (x *ColorButton) SetModal(ModalVar bool) { xColorButtonSetModal(x.GoPointer(), ModalVar) } var xColorButtonSetTitle func(uintptr, string) // Sets the title for the color chooser dialog. func (x *ColorButton) SetTitle(TitleVar string) { xColorButtonSetTitle(x.GoPointer(), TitleVar) } func (c *ColorButton) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *ColorButton) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyModal sets the "modal" property. // Whether the color chooser dialog should be modal. func (x *ColorButton) SetPropertyModal(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("modal", &v) } // GetPropertyModal gets the "modal" property. // Whether the color chooser dialog should be modal. func (x *ColorButton) GetPropertyModal() bool { var v gobject.Value x.GetProperty("modal", &v) return v.GetBoolean() } // SetPropertyShowEditor sets the "show-editor" property. // Whether the color chooser should open in editor mode. // // This property should be used in cases where the palette // in the editor would be redundant, such as when the color // button is already part of a palette. func (x *ColorButton) SetPropertyShowEditor(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("show-editor", &v) } // GetPropertyShowEditor gets the "show-editor" property. // Whether the color chooser should open in editor mode. // // This property should be used in cases where the palette // in the editor would be redundant, such as when the color // button is already part of a palette. func (x *ColorButton) GetPropertyShowEditor() bool { var v gobject.Value x.GetProperty("show-editor", &v) return v.GetBoolean() } // SetPropertyTitle sets the "title" property. // The title of the color chooser dialog func (x *ColorButton) SetPropertyTitle(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("title", &v) } // GetPropertyTitle gets the "title" property. // The title of the color chooser dialog func (x *ColorButton) GetPropertyTitle() string { var v gobject.Value x.GetProperty("title", &v) return v.GetString() } // Emitted to when the color button is activated. // // The `::activate` signal on `GtkMenuButton` is an action signal and // emitting it causes the button to pop up its dialog. func (x *ColorButton) ConnectActivate(cb *func(ColorButton)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr) { fa := ColorButton{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Emitted when the user selects a color. // // When handling this signal, use [method@Gtk.ColorChooser.get_rgba] // to find out which color was just selected. // // Note that this signal is only emitted when the user changes the color. // If you need to react to programmatic color changes as well, use // the notify::rgba signal. func (x *ColorButton) ConnectColorSet(cb *func(ColorButton)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "color-set", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr) { fa := ColorButton{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "color-set", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Requests the user's screen reader to announce the given message. // // This kind of notification is useful for messages that // either have only a visual representation or that are not // exposed visually at all, e.g. a notification about a // successful operation. // // Also, by using this API, you can ensure that the message // does not interrupts the user's current screen reader output. func (x *ColorButton) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) { XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar) } // Retrieves the accessible parent for an accessible object. // // This function returns `NULL` for top level widgets. func (x *ColorButton) GetAccessibleParent() *AccessibleBase { var cls *AccessibleBase cret := XGtkAccessibleGetAccessibleParent(x.GoPointer()) if cret == 0 { return nil } cls = &AccessibleBase{} cls.Ptr = cret return cls } // Retrieves the accessible role of an accessible object. func (x *ColorButton) GetAccessibleRole() AccessibleRole { cret := XGtkAccessibleGetAccessibleRole(x.GoPointer()) return cret } // Retrieves the implementation for the given accessible object. func (x *ColorButton) GetAtContext() *ATContext { var cls *ATContext cret := XGtkAccessibleGetAtContext(x.GoPointer()) if cret == 0 { return nil } cls = &ATContext{} cls.Ptr = cret return cls } // Queries the coordinates and dimensions of this accessible // // This functionality can be overridden by `GtkAccessible` // implementations, e.g. to get the bounds from an ignored // child widget. func (x *ColorButton) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool { cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar) return cret } // Retrieves the first accessible child of an accessible object. func (x *ColorButton) GetFirstAccessibleChild() *AccessibleBase { var cls *AccessibleBase cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer()) if cret == 0 { return nil } cls = &AccessibleBase{} cls.Ptr = cret return cls } // Retrieves the next accessible sibling of an accessible object func (x *ColorButton) GetNextAccessibleSibling() *AccessibleBase { var cls *AccessibleBase cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer()) if cret == 0 { return nil } cls = &AccessibleBase{} cls.Ptr = cret return cls } // Queries a platform state, such as focus. // // This functionality can be overridden by `GtkAccessible` // implementations, e.g. to get platform state from an ignored // child widget, as is the case for `GtkText` wrappers. func (x *ColorButton) GetPlatformState(StateVar AccessiblePlatformState) bool { cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar) return cret } // Resets the accessible property to its default value. func (x *ColorButton) ResetProperty(PropertyVar AccessibleProperty) { XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar) } // Resets the accessible relation to its default value. func (x *ColorButton) ResetRelation(RelationVar AccessibleRelation) { XGtkAccessibleResetRelation(x.GoPointer(), RelationVar) } // Resets the accessible state to its default value. func (x *ColorButton) ResetState(StateVar AccessibleState) { XGtkAccessibleResetState(x.GoPointer(), StateVar) } // Sets the parent and sibling of an accessible object. // // This function is meant to be used by accessible implementations that are // not part of the widget hierarchy, and but act as a logical bridge between // widgets. For instance, if a widget creates an object that holds metadata // for each child, and you want that object to implement the `GtkAccessible` // interface, you will use this function to ensure that the parent of each // child widget is the metadata object, and the parent of each metadata // object is the container widget. func (x *ColorButton) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) { XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer()) } // Updates the next accessible sibling. // // That might be useful when a new child of a custom accessible // is created, and it needs to be linked to a previous child. func (x *ColorButton) UpdateNextAccessibleSibling(NewSiblingVar Accessible) { XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer()) } // Informs ATs that the platform state has changed. // // This function should be used by `GtkAccessible` implementations that // have a platform state but are not widgets. Widgets handle platform // states automatically. func (x *ColorButton) UpdatePlatformState(StateVar AccessiblePlatformState) { XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar) } // Updates a list of accessible properties. // // See the [enum@Gtk.AccessibleProperty] documentation for the // value types of accessible properties. // // This function should be called by `GtkWidget` types whenever // an accessible property change must be communicated to assistive // technologies. // // Example: // ```c // value = gtk_adjustment_get_value (adjustment); // gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button), // // GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value, // -1); // // ``` func (x *ColorButton) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) { XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...) } // Updates an array of accessible properties. // // This function should be called by `GtkWidget` types whenever an accessible // property change must be communicated to assistive technologies. // // This function is meant to be used by language bindings. func (x *ColorButton) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) { XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar) } // Updates a list of accessible relations. // // This function should be called by `GtkWidget` types whenever an accessible // relation change must be communicated to assistive technologies. // // If the [enum@Gtk.AccessibleRelation] requires a list of references, // you should pass each reference individually, followed by `NULL`, e.g. // // ```c // gtk_accessible_update_relation (accessible, // // GTK_ACCESSIBLE_RELATION_CONTROLS, // ref1, NULL, // GTK_ACCESSIBLE_RELATION_LABELLED_BY, // ref1, ref2, ref3, NULL, // -1); // // ``` func (x *ColorButton) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) { XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...) } // Updates an array of accessible relations. // // This function should be called by `GtkWidget` types whenever an accessible // relation change must be communicated to assistive technologies. // // This function is meant to be used by language bindings. func (x *ColorButton) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) { XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar) } // Updates a list of accessible states. // // See the [enum@Gtk.AccessibleState] documentation for the // value types of accessible states. // // This function should be called by `GtkWidget` types whenever // an accessible state change must be communicated to assistive // technologies. // // Example: // // ```c // value = GTK_ACCESSIBLE_TRISTATE_MIXED; // gtk_accessible_update_state (GTK_ACCESSIBLE (check_button), // // GTK_ACCESSIBLE_STATE_CHECKED, value, // -1); // // ``` func (x *ColorButton) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) { XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...) } // Updates an array of accessible states. // // This function should be called by `GtkWidget` types whenever an accessible // state change must be communicated to assistive technologies. // // This function is meant to be used by language bindings. func (x *ColorButton) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) { XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar) } // Gets the ID of the @buildable object. // // `GtkBuilder` sets the name based on the ID attribute // of the `<object>` tag used to construct the @buildable. func (x *ColorButton) GetBuildableId() string { cret := XGtkBuildableGetBuildableId(x.GoPointer()) return cret } // Adds a palette to the color chooser. // // If @orientation is horizontal, the colors are grouped in rows, // with @colors_per_line colors in each row. If @horizontal is %FALSE, // the colors are grouped in columns instead. // // The default color palette of [class@Gtk.ColorChooserWidget] has // 45 colors, organized in columns of 5 colors (this includes some // grays). // // The layout of the color chooser widget works best when the // palettes have 9-10 columns. // // Calling this function for the first time has the side effect // of removing the default color palette from the color chooser. // // If @colors is %NULL, removes all previously added palettes. func (x *ColorButton) AddPalette(OrientationVar Orientation, ColorsPerLineVar int, NColorsVar int, ColorsVar []gdk.RGBA) { XGtkColorChooserAddPalette(x.GoPointer(), OrientationVar, ColorsPerLineVar, NColorsVar, ColorsVar) } // Gets the currently-selected color. func (x *ColorButton) GetRgba(ColorVar *gdk.RGBA) { XGtkColorChooserGetRgba(x.GoPointer(), ColorVar) } // Returns whether the color chooser shows the alpha channel. func (x *ColorButton) GetUseAlpha() bool { cret := XGtkColorChooserGetUseAlpha(x.GoPointer()) return cret } // Sets the color. func (x *ColorButton) SetRgba(ColorVar *gdk.RGBA) { XGtkColorChooserSetRgba(x.GoPointer(), ColorVar) } // Sets whether or not the color chooser should use the alpha channel. func (x *ColorButton) SetUseAlpha(UseAlphaVar bool) { XGtkColorChooserSetUseAlpha(x.GoPointer(), UseAlphaVar) } func init() { core.SetPackageName("GTK", "gtk4") core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GTK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xColorButtonGLibType, libs, "gtk_color_button_get_type") core.PuregoSafeRegister(&xNewColorButton, libs, "gtk_color_button_new") core.PuregoSafeRegister(&xNewColorButtonWithRgba, libs, "gtk_color_button_new_with_rgba") core.PuregoSafeRegister(&xColorButtonGetModal, libs, "gtk_color_button_get_modal") core.PuregoSafeRegister(&xColorButtonGetTitle, libs, "gtk_color_button_get_title") core.PuregoSafeRegister(&xColorButtonSetModal, libs, "gtk_color_button_set_modal") core.PuregoSafeRegister(&xColorButtonSetTitle, libs, "gtk_color_button_set_title") }