// 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 PasswordEntryClass struct { _ structs.HostLayout } func (x *PasswordEntryClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // A single-line text entry widget for entering passwords and other secrets. // // <picture> // // <source srcset="password-entry-dark.png" media="(prefers-color-scheme: dark)"> // <img alt="An example GtkPasswordEntry" src="password-entry.png"> // // </picture> // // It does not show its contents in clear text, does not allow to copy it // to the clipboard, and it shows a warning when Caps Lock is engaged. If // the underlying platform allows it, `GtkPasswordEntry` will also place // the text in a non-pageable memory area, to avoid it being written out // to disk by the operating system. // // Optionally, it can offer a way to reveal the contents in clear text. // // `GtkPasswordEntry` provides only minimal API and should be used with // the [iface@Gtk.Editable] API. // // # CSS Nodes // // ``` // entry.password // ╰── text // // ├── image.caps-lock-indicator // ┊ // // ``` // // `GtkPasswordEntry` has a single CSS node with name entry that carries // a .passwordstyle class. The text Css node below it has a child with // name image and style class .caps-lock-indicator for the Caps Lock // icon, and possibly other children. // // # Accessibility // // `GtkPasswordEntry` uses the [enum@Gtk.AccessibleRole.text_box] role. type PasswordEntry struct { Widget } var xPasswordEntryGLibType func() types.GType func PasswordEntryGLibType() types.GType { return xPasswordEntryGLibType() } func PasswordEntryNewFromInternalPtr(ptr uintptr) *PasswordEntry { cls := &PasswordEntry{} cls.Ptr = ptr return cls } var xNewPasswordEntry func() uintptr // Creates a `GtkPasswordEntry`. func NewPasswordEntry() *PasswordEntry { var cls *PasswordEntry cret := xNewPasswordEntry() if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &PasswordEntry{} cls.Ptr = cret return cls } var xPasswordEntryGetExtraMenu func(uintptr) uintptr // Gets the menu model set with gtk_password_entry_set_extra_menu(). func (x *PasswordEntry) GetExtraMenu() *gio.MenuModel { var cls *gio.MenuModel cret := xPasswordEntryGetExtraMenu(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gio.MenuModel{} cls.Ptr = cret return cls } var xPasswordEntryGetShowPeekIcon func(uintptr) bool // Returns whether the entry is showing an icon to // reveal the contents. func (x *PasswordEntry) GetShowPeekIcon() bool { cret := xPasswordEntryGetShowPeekIcon(x.GoPointer()) return cret } var xPasswordEntrySetExtraMenu func(uintptr, uintptr) // Sets a menu model to add when constructing // the context menu for @entry. func (x *PasswordEntry) SetExtraMenu(ModelVar *gio.MenuModel) { xPasswordEntrySetExtraMenu(x.GoPointer(), ModelVar.GoPointer()) } var xPasswordEntrySetShowPeekIcon func(uintptr, bool) // Sets whether the entry should have a clickable icon // to reveal the contents. // // Setting this to %FALSE also hides the text again. func (x *PasswordEntry) SetShowPeekIcon(ShowPeekIconVar bool) { xPasswordEntrySetShowPeekIcon(x.GoPointer(), ShowPeekIconVar) } func (c *PasswordEntry) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *PasswordEntry) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyActivatesDefault sets the "activates-default" property. // Whether to activate the default widget when Enter is pressed. func (x *PasswordEntry) SetPropertyActivatesDefault(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("activates-default", &v) } // GetPropertyActivatesDefault gets the "activates-default" property. // Whether to activate the default widget when Enter is pressed. func (x *PasswordEntry) GetPropertyActivatesDefault() bool { var v gobject.Value x.GetProperty("activates-default", &v) return v.GetBoolean() } // SetPropertyPlaceholderText sets the "placeholder-text" property. // The text that will be displayed in the `GtkPasswordEntry` // when it is empty and unfocused. func (x *PasswordEntry) SetPropertyPlaceholderText(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("placeholder-text", &v) } // GetPropertyPlaceholderText gets the "placeholder-text" property. // The text that will be displayed in the `GtkPasswordEntry` // when it is empty and unfocused. func (x *PasswordEntry) GetPropertyPlaceholderText() string { var v gobject.Value x.GetProperty("placeholder-text", &v) return v.GetString() } // SetPropertyShowPeekIcon sets the "show-peek-icon" property. // Whether to show an icon for revealing the content. func (x *PasswordEntry) SetPropertyShowPeekIcon(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("show-peek-icon", &v) } // GetPropertyShowPeekIcon gets the "show-peek-icon" property. // Whether to show an icon for revealing the content. func (x *PasswordEntry) GetPropertyShowPeekIcon() bool { var v gobject.Value x.GetProperty("show-peek-icon", &v) return v.GetBoolean() } // Emitted when the entry is activated. // // The keybindings for this signal are all forms of the Enter key. func (x *PasswordEntry) ConnectActivate(cb *func(PasswordEntry)) 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 := PasswordEntry{} 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) GetAccessibleRole() AccessibleRole { cret := XGtkAccessibleGetAccessibleRole(x.GoPointer()) return cret } // Retrieves the implementation for the given accessible object. func (x *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) GetPlatformState(StateVar AccessiblePlatformState) bool { cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar) return cret } // Resets the accessible property to its default value. func (x *PasswordEntry) ResetProperty(PropertyVar AccessibleProperty) { XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar) } // Resets the accessible relation to its default value. func (x *PasswordEntry) ResetRelation(RelationVar AccessibleRelation) { XGtkAccessibleResetRelation(x.GoPointer(), RelationVar) } // Resets the accessible state to its default value. func (x *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) 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 *PasswordEntry) GetBuildableId() string { cret := XGtkBuildableGetBuildableId(x.GoPointer()) return cret } // Retrieves the accessible platform state from the editable delegate. // // This is an helper function to retrieve the accessible state for // `GtkEditable` interface implementations using a delegate pattern. // // You should call this function in your editable widget implementation // of the [vfunc@Gtk.Accessible.get_platform_state] virtual function, for // instance: // // ```c // static void // accessible_interface_init (GtkAccessibleInterface *iface) // // { // iface->get_platform_state = your_editable_get_accessible_platform_state; // } // // static gboolean // your_editable_get_accessible_platform_state (GtkAccessible *accessible, // // GtkAccessiblePlatformState state) // // { // return gtk_editable_delegate_get_accessible_platform_state (GTK_EDITABLE (accessible), state); // } // // ``` // // Note that the widget which is the delegate *must* be a direct child of // this widget, otherwise your implementation of [vfunc@Gtk.Accessible.get_platform_state] // might not even be called, as the platform change will originate from // the parent of the delegate, and, as a result, will not work properly. // // So, if you can't ensure the direct child condition, you should give the // delegate the %GTK_ACCESSIBLE_ROLE_TEXT_BOX role, or you can // change your tree to allow this function to work. func (x *PasswordEntry) DelegateGetAccessiblePlatformState(StateVar AccessiblePlatformState) bool { cret := XGtkEditableDelegateGetAccessiblePlatformState(x.GoPointer(), StateVar) return cret } // Deletes the currently selected text of the editable. // // This call doesn’t do anything if there is no selected text. func (x *PasswordEntry) DeleteSelection() { XGtkEditableDeleteSelection(x.GoPointer()) } // Deletes a sequence of characters. // // The characters that are deleted are those characters at positions // from @start_pos up to, but not including @end_pos. If @end_pos is // negative, then the characters deleted are those from @start_pos to // the end of the text. // // Note that the positions are specified in characters, not bytes. func (x *PasswordEntry) DeleteText(StartPosVar int, EndPosVar int) { XGtkEditableDeleteText(x.GoPointer(), StartPosVar, EndPosVar) } // Undoes the setup done by [method@Gtk.Editable.init_delegate]. // // This is a helper function that should be called from dispose, // before removing the delegate object. func (x *PasswordEntry) FinishDelegate() { XGtkEditableFinishDelegate(x.GoPointer()) } // Gets the alignment of the editable. func (x *PasswordEntry) GetAlignment() float32 { cret := XGtkEditableGetAlignment(x.GoPointer()) return cret } // Retrieves a sequence of characters. // // The characters that are retrieved are those characters at positions // from @start_pos up to, but not including @end_pos. If @end_pos is negative, // then the characters retrieved are those characters from @start_pos to // the end of the text. // // Note that positions are specified in characters, not bytes. func (x *PasswordEntry) GetChars(StartPosVar int, EndPosVar int) string { cret := XGtkEditableGetChars(x.GoPointer(), StartPosVar, EndPosVar) return cret } // Gets the `GtkEditable` that @editable is delegating its // implementation to. // // Typically, the delegate is a [class@Gtk.Text] widget. func (x *PasswordEntry) GetDelegate() *EditableBase { var cls *EditableBase cret := XGtkEditableGetDelegate(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &EditableBase{} cls.Ptr = cret return cls } // Retrieves whether @editable is editable. func (x *PasswordEntry) GetEditable() bool { cret := XGtkEditableGetEditable(x.GoPointer()) return cret } // Gets if undo/redo actions are enabled for @editable func (x *PasswordEntry) GetEnableUndo() bool { cret := XGtkEditableGetEnableUndo(x.GoPointer()) return cret } // Retrieves the desired maximum width of @editable, in characters. func (x *PasswordEntry) GetMaxWidthChars() int { cret := XGtkEditableGetMaxWidthChars(x.GoPointer()) return cret } // Retrieves the current position of the cursor relative // to the start of the content of the editable. // // Note that this position is in characters, not in bytes. func (x *PasswordEntry) GetPosition() int { cret := XGtkEditableGetPosition(x.GoPointer()) return cret } // Retrieves the selection bound of the editable. // // @start_pos will be filled with the start of the selection and // @end_pos with end. If no text was selected both will be identical // and %FALSE will be returned. // // Note that positions are specified in characters, not bytes. func (x *PasswordEntry) GetSelectionBounds(StartPosVar *int, EndPosVar *int) bool { cret := XGtkEditableGetSelectionBounds(x.GoPointer(), StartPosVar, EndPosVar) return cret } // Retrieves the contents of @editable. // // The returned string is owned by GTK and must not be modified or freed. func (x *PasswordEntry) GetText() string { cret := XGtkEditableGetText(x.GoPointer()) return cret } // Gets the number of characters of space reserved // for the contents of the editable. func (x *PasswordEntry) GetWidthChars() int { cret := XGtkEditableGetWidthChars(x.GoPointer()) return cret } // Sets up a delegate for `GtkEditable`. // // This is assuming that the get_delegate vfunc in the `GtkEditable` // interface has been set up for the @editable's type. // // This is a helper function that should be called in instance init, // after creating the delegate object. func (x *PasswordEntry) InitDelegate() { XGtkEditableInitDelegate(x.GoPointer()) } // Inserts @length bytes of @text into the contents of the // widget, at position @position. // // Note that the position is in characters, not in bytes. // The function updates @position to point after the newly // inserted text. func (x *PasswordEntry) InsertText(TextVar string, LengthVar int, PositionVar *int) { XGtkEditableInsertText(x.GoPointer(), TextVar, LengthVar, PositionVar) } // Selects a region of text. // // The characters that are selected are those characters at positions // from @start_pos up to, but not including @end_pos. If @end_pos is // negative, then the characters selected are those characters from // @start_pos to the end of the text. // // Note that positions are specified in characters, not bytes. func (x *PasswordEntry) SelectRegion(StartPosVar int, EndPosVar int) { XGtkEditableSelectRegion(x.GoPointer(), StartPosVar, EndPosVar) } // Sets the alignment for the contents of the editable. // // This controls the horizontal positioning of the contents when // the displayed text is shorter than the width of the editable. func (x *PasswordEntry) SetAlignment(XalignVar float32) { XGtkEditableSetAlignment(x.GoPointer(), XalignVar) } // Determines if the user can edit the text in the editable widget. func (x *PasswordEntry) SetEditable(IsEditableVar bool) { XGtkEditableSetEditable(x.GoPointer(), IsEditableVar) } // If enabled, changes to @editable will be saved for undo/redo // actions. // // This results in an additional copy of text changes and are not // stored in secure memory. As such, undo is forcefully disabled // when [property@Gtk.Text:visibility] is set to %FALSE. func (x *PasswordEntry) SetEnableUndo(EnableUndoVar bool) { XGtkEditableSetEnableUndo(x.GoPointer(), EnableUndoVar) } // Sets the desired maximum width in characters of @editable. func (x *PasswordEntry) SetMaxWidthChars(NCharsVar int) { XGtkEditableSetMaxWidthChars(x.GoPointer(), NCharsVar) } // Sets the cursor position in the editable to the given value. // // The cursor is displayed before the character with the given (base 0) // index in the contents of the editable. The value must be less than // or equal to the number of characters in the editable. A value of -1 // indicates that the position should be set after the last character // of the editable. Note that @position is in characters, not in bytes. func (x *PasswordEntry) SetPosition(PositionVar int) { XGtkEditableSetPosition(x.GoPointer(), PositionVar) } // Sets the text in the editable to the given value. // // This is replacing the current contents. func (x *PasswordEntry) SetText(TextVar string) { XGtkEditableSetText(x.GoPointer(), TextVar) } // Changes the size request of the editable to be about the // right size for @n_chars characters. // // Note that it changes the size request, the size can still // be affected by how you pack the widget into containers. // If @n_chars is -1, the size reverts to the default size. func (x *PasswordEntry) SetWidthChars(NCharsVar int) { XGtkEditableSetWidthChars(x.GoPointer(), NCharsVar) } 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(&xPasswordEntryGLibType, libs, "gtk_password_entry_get_type") core.PuregoSafeRegister(&xNewPasswordEntry, libs, "gtk_password_entry_new") core.PuregoSafeRegister(&xPasswordEntryGetExtraMenu, libs, "gtk_password_entry_get_extra_menu") core.PuregoSafeRegister(&xPasswordEntryGetShowPeekIcon, libs, "gtk_password_entry_get_show_peek_icon") core.PuregoSafeRegister(&xPasswordEntrySetExtraMenu, libs, "gtk_password_entry_set_extra_menu") core.PuregoSafeRegister(&xPasswordEntrySetShowPeekIcon, libs, "gtk_password_entry_set_show_peek_icon") }