// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/gio" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type DropDownClass struct { _ structs.HostLayout ParentClass WidgetClass } func (x *DropDownClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // Allows the user to choose an item from a list of options. // // <picture> // // <source srcset="drop-down-dark.png" media="(prefers-color-scheme: dark)"> // <img alt="An example GtkDropDown" src="drop-down.png"> // // </picture> // // The `GtkDropDown` displays the [selected][property@Gtk.DropDown:selected] // choice. // // The options are given to `GtkDropDown` in the form of `GListModel` // and how the individual options are represented is determined by // a [class@Gtk.ListItemFactory]. The default factory displays simple strings, // and adds a checkmark to the selected item in the popup. // // To set your own factory, use [method@Gtk.DropDown.set_factory]. It is // possible to use a separate factory for the items in the popup, with // [method@Gtk.DropDown.set_list_factory]. // // `GtkDropDown` knows how to obtain strings from the items in a // [class@Gtk.StringList]; for other models, you have to provide an expression // to find the strings via [method@Gtk.DropDown.set_expression]. // // `GtkDropDown` can optionally allow search in the popup, which is // useful if the list of options is long. To enable the search entry, // use [method@Gtk.DropDown.set_enable_search]. // // Here is a UI definition example for `GtkDropDown` with a simple model: // // ```xml // <object class="GtkDropDown"> // // <property name="model"> // <object class="GtkStringList"> // <items> // <item translatable="yes">Factory</item> // <item translatable="yes">Home</item> // <item translatable="yes">Subway</item> // </items> // </object> // </property> // // </object> // ``` // // If a `GtkDropDown` is created in this manner, or with // [ctor@Gtk.DropDown.new_from_strings], for instance, the object returned from // [method@Gtk.DropDown.get_selected_item] will be a [class@Gtk.StringObject]. // // To learn more about the list widget framework, see the // [overview](section-list-widget.html). // // ## CSS nodes // // `GtkDropDown` has a single CSS node with name dropdown, // with the button and popover nodes as children. // // ## Accessibility // // `GtkDropDown` uses the [enum@Gtk.AccessibleRole.combo_box] role. type DropDown struct { Widget } var xDropDownGLibType func() types.GType func DropDownGLibType() types.GType { return xDropDownGLibType() } func DropDownNewFromInternalPtr(ptr uintptr) *DropDown { cls := &DropDown{} cls.Ptr = ptr return cls } var xNewDropDown func(uintptr, uintptr) uintptr // Creates a new `GtkDropDown`. // // You may want to call [method@Gtk.DropDown.set_factory] // to set up a way to map its items to widgets. func NewDropDown(ModelVar gio.ListModel, ExpressionVar *Expression) *DropDown { var cls *DropDown cret := xNewDropDown(ModelVar.GoPointer(), ExpressionVar.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &DropDown{} cls.Ptr = cret return cls } var xNewDropDownFromStrings func([]string) uintptr // Creates a new `GtkDropDown` that is populated with // the strings. func NewDropDownFromStrings(StringsVar []string) *DropDown { var cls *DropDown cret := xNewDropDownFromStrings(StringsVar) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &DropDown{} cls.Ptr = cret return cls } var xDropDownGetEnableSearch func(uintptr) bool // Returns whether search is enabled. func (x *DropDown) GetEnableSearch() bool { cret := xDropDownGetEnableSearch(x.GoPointer()) return cret } var xDropDownGetExpression func(uintptr) uintptr // Gets the expression set that is used to obtain strings from items. // // See [method@Gtk.DropDown.set_expression]. func (x *DropDown) GetExpression() *Expression { var cls *Expression cret := xDropDownGetExpression(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Expression{} cls.Ptr = cret return cls } var xDropDownGetFactory func(uintptr) uintptr // Gets the factory that's currently used to populate list items. // // The factory returned by this function is always used for the // item in the button. It is also used for items in the popup // if [property@Gtk.DropDown:list-factory] is not set. func (x *DropDown) GetFactory() *ListItemFactory { var cls *ListItemFactory cret := xDropDownGetFactory(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &ListItemFactory{} cls.Ptr = cret return cls } var xDropDownGetHeaderFactory func(uintptr) uintptr // Gets the factory that's currently used to create header widgets for the popup. func (x *DropDown) GetHeaderFactory() *ListItemFactory { var cls *ListItemFactory cret := xDropDownGetHeaderFactory(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &ListItemFactory{} cls.Ptr = cret return cls } var xDropDownGetListFactory func(uintptr) uintptr // Gets the factory that's currently used to populate list items in the popup. func (x *DropDown) GetListFactory() *ListItemFactory { var cls *ListItemFactory cret := xDropDownGetListFactory(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &ListItemFactory{} cls.Ptr = cret return cls } var xDropDownGetModel func(uintptr) uintptr // Gets the model that provides the displayed items. func (x *DropDown) GetModel() *gio.ListModelBase { var cls *gio.ListModelBase cret := xDropDownGetModel(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gio.ListModelBase{} cls.Ptr = cret return cls } var xDropDownGetSearchMatchMode func(uintptr) StringFilterMatchMode // Returns the match mode that the search filter is using. func (x *DropDown) GetSearchMatchMode() StringFilterMatchMode { cret := xDropDownGetSearchMatchMode(x.GoPointer()) return cret } var xDropDownGetSelected func(uintptr) uint // Gets the position of the selected item. func (x *DropDown) GetSelected() uint { cret := xDropDownGetSelected(x.GoPointer()) return cret } var xDropDownGetSelectedItem func(uintptr) uintptr // Gets the selected item. If no item is selected, %NULL is returned. func (x *DropDown) GetSelectedItem() *gobject.Object { var cls *gobject.Object cret := xDropDownGetSelectedItem(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gobject.Object{} cls.Ptr = cret return cls } var xDropDownGetShowArrow func(uintptr) bool // Returns whether to show an arrow within the widget. func (x *DropDown) GetShowArrow() bool { cret := xDropDownGetShowArrow(x.GoPointer()) return cret } var xDropDownSetEnableSearch func(uintptr, bool) // Sets whether a search entry will be shown in the popup that // allows to search for items in the list. // // Note that [property@Gtk.DropDown:expression] must be set for // search to work. func (x *DropDown) SetEnableSearch(EnableSearchVar bool) { xDropDownSetEnableSearch(x.GoPointer(), EnableSearchVar) } var xDropDownSetExpression func(uintptr, uintptr) // Sets the expression that gets evaluated to obtain strings from items. // // This is used for search in the popup. The expression must have // a value type of %G_TYPE_STRING. func (x *DropDown) SetExpression(ExpressionVar *Expression) { xDropDownSetExpression(x.GoPointer(), ExpressionVar.GoPointer()) } var xDropDownSetFactory func(uintptr, uintptr) // Sets the `GtkListItemFactory` to use for populating list items. func (x *DropDown) SetFactory(FactoryVar *ListItemFactory) { xDropDownSetFactory(x.GoPointer(), FactoryVar.GoPointer()) } var xDropDownSetHeaderFactory func(uintptr, uintptr) // Sets the `GtkListItemFactory` to use for creating header widgets for the popup. func (x *DropDown) SetHeaderFactory(FactoryVar *ListItemFactory) { xDropDownSetHeaderFactory(x.GoPointer(), FactoryVar.GoPointer()) } var xDropDownSetListFactory func(uintptr, uintptr) // Sets the `GtkListItemFactory` to use for populating list items in the popup. func (x *DropDown) SetListFactory(FactoryVar *ListItemFactory) { xDropDownSetListFactory(x.GoPointer(), FactoryVar.GoPointer()) } var xDropDownSetModel func(uintptr, uintptr) // Sets the `GListModel` to use. func (x *DropDown) SetModel(ModelVar gio.ListModel) { xDropDownSetModel(x.GoPointer(), ModelVar.GoPointer()) } var xDropDownSetSearchMatchMode func(uintptr, StringFilterMatchMode) // Sets the match mode for the search filter. func (x *DropDown) SetSearchMatchMode(SearchMatchModeVar StringFilterMatchMode) { xDropDownSetSearchMatchMode(x.GoPointer(), SearchMatchModeVar) } var xDropDownSetSelected func(uintptr, uint) // Selects the item at the given position. func (x *DropDown) SetSelected(PositionVar uint) { xDropDownSetSelected(x.GoPointer(), PositionVar) } var xDropDownSetShowArrow func(uintptr, bool) // Sets whether an arrow will be displayed within the widget. func (x *DropDown) SetShowArrow(ShowArrowVar bool) { xDropDownSetShowArrow(x.GoPointer(), ShowArrowVar) } func (c *DropDown) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *DropDown) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyEnableSearch sets the "enable-search" property. // Whether to show a search entry in the popup. // // Note that search requires [property@Gtk.DropDown:expression] // to be set. func (x *DropDown) SetPropertyEnableSearch(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("enable-search", &v) } // GetPropertyEnableSearch gets the "enable-search" property. // Whether to show a search entry in the popup. // // Note that search requires [property@Gtk.DropDown:expression] // to be set. func (x *DropDown) GetPropertyEnableSearch() bool { var v gobject.Value x.GetProperty("enable-search", &v) return v.GetBoolean() } // SetPropertySelected sets the "selected" property. // The position of the selected item. // // If no item is selected, the property has the value // %GTK_INVALID_LIST_POSITION. func (x *DropDown) SetPropertySelected(value uint) { var v gobject.Value v.Init(gobject.TypeUintVal) v.SetUint(value) x.SetProperty("selected", &v) } // GetPropertySelected gets the "selected" property. // The position of the selected item. // // If no item is selected, the property has the value // %GTK_INVALID_LIST_POSITION. func (x *DropDown) GetPropertySelected() uint { var v gobject.Value x.GetProperty("selected", &v) return v.GetUint() } // SetPropertyShowArrow sets the "show-arrow" property. // Whether to show an arrow within the GtkDropDown widget. func (x *DropDown) SetPropertyShowArrow(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("show-arrow", &v) } // GetPropertyShowArrow gets the "show-arrow" property. // Whether to show an arrow within the GtkDropDown widget. func (x *DropDown) GetPropertyShowArrow() bool { var v gobject.Value x.GetProperty("show-arrow", &v) return v.GetBoolean() } // Emitted to when the drop down is activated. // // The `::activate` signal on `GtkDropDown` is an action signal and // emitting it causes the drop down to pop up its dropdown. func (x *DropDown) ConnectActivate(cb *func(DropDown)) 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 := DropDown{} 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 } // 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 *DropDown) 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 *DropDown) 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 *DropDown) GetAccessibleRole() AccessibleRole { cret := XGtkAccessibleGetAccessibleRole(x.GoPointer()) return cret } // Retrieves the implementation for the given accessible object. func (x *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) GetPlatformState(StateVar AccessiblePlatformState) bool { cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar) return cret } // Resets the accessible property to its default value. func (x *DropDown) ResetProperty(PropertyVar AccessibleProperty) { XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar) } // Resets the accessible relation to its default value. func (x *DropDown) ResetRelation(RelationVar AccessibleRelation) { XGtkAccessibleResetRelation(x.GoPointer(), RelationVar) } // Resets the accessible state to its default value. func (x *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) 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 *DropDown) GetBuildableId() string { cret := XGtkBuildableGetBuildableId(x.GoPointer()) return cret } 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(&xDropDownGLibType, libs, "gtk_drop_down_get_type") core.PuregoSafeRegister(&xNewDropDown, libs, "gtk_drop_down_new") core.PuregoSafeRegister(&xNewDropDownFromStrings, libs, "gtk_drop_down_new_from_strings") core.PuregoSafeRegister(&xDropDownGetEnableSearch, libs, "gtk_drop_down_get_enable_search") core.PuregoSafeRegister(&xDropDownGetExpression, libs, "gtk_drop_down_get_expression") core.PuregoSafeRegister(&xDropDownGetFactory, libs, "gtk_drop_down_get_factory") core.PuregoSafeRegister(&xDropDownGetHeaderFactory, libs, "gtk_drop_down_get_header_factory") core.PuregoSafeRegister(&xDropDownGetListFactory, libs, "gtk_drop_down_get_list_factory") core.PuregoSafeRegister(&xDropDownGetModel, libs, "gtk_drop_down_get_model") core.PuregoSafeRegister(&xDropDownGetSearchMatchMode, libs, "gtk_drop_down_get_search_match_mode") core.PuregoSafeRegister(&xDropDownGetSelected, libs, "gtk_drop_down_get_selected") core.PuregoSafeRegister(&xDropDownGetSelectedItem, libs, "gtk_drop_down_get_selected_item") core.PuregoSafeRegister(&xDropDownGetShowArrow, libs, "gtk_drop_down_get_show_arrow") core.PuregoSafeRegister(&xDropDownSetEnableSearch, libs, "gtk_drop_down_set_enable_search") core.PuregoSafeRegister(&xDropDownSetExpression, libs, "gtk_drop_down_set_expression") core.PuregoSafeRegister(&xDropDownSetFactory, libs, "gtk_drop_down_set_factory") core.PuregoSafeRegister(&xDropDownSetHeaderFactory, libs, "gtk_drop_down_set_header_factory") core.PuregoSafeRegister(&xDropDownSetListFactory, libs, "gtk_drop_down_set_list_factory") core.PuregoSafeRegister(&xDropDownSetModel, libs, "gtk_drop_down_set_model") core.PuregoSafeRegister(&xDropDownSetSearchMatchMode, libs, "gtk_drop_down_set_search_match_mode") core.PuregoSafeRegister(&xDropDownSetSelected, libs, "gtk_drop_down_set_selected") core.PuregoSafeRegister(&xDropDownSetShowArrow, libs, "gtk_drop_down_set_show_arrow") }