// 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/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" "github.com/bnema/puregotk/v4/pango" ) // The `GtkFontButton` allows to open a font chooser dialog to change // the font. // // <picture> // // <source srcset="font-button-dark.png" media="(prefers-color-scheme: dark)"> // <img alt="An example GtkFontButton" src="font-button.png"> // // </picture> // // It is suitable widget for selecting a font in a preference dialog. // // # CSS nodes // // ``` // fontbutton // ╰── button.font // // ╰── [content] // // ``` // // `GtkFontButton` has a single CSS node with name fontbutton which // contains a button node with the .font style class. type FontButton struct { Widget } var xFontButtonGLibType func() types.GType func FontButtonGLibType() types.GType { return xFontButtonGLibType() } func FontButtonNewFromInternalPtr(ptr uintptr) *FontButton { cls := &FontButton{} cls.Ptr = ptr return cls } var xNewFontButton func() uintptr // Creates a new font picker widget. func NewFontButton() *FontButton { var cls *FontButton cret := xNewFontButton() if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &FontButton{} cls.Ptr = cret return cls } var xNewFontButtonWithFont func(string) uintptr // Creates a new font picker widget showing the given font. func NewFontButtonWithFont(FontnameVar string) *FontButton { var cls *FontButton cret := xNewFontButtonWithFont(FontnameVar) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &FontButton{} cls.Ptr = cret return cls } var xFontButtonGetModal func(uintptr) bool // Gets whether the dialog is modal. func (x *FontButton) GetModal() bool { cret := xFontButtonGetModal(x.GoPointer()) return cret } var xFontButtonGetTitle func(uintptr) string // Retrieves the title of the font chooser dialog. func (x *FontButton) GetTitle() string { cret := xFontButtonGetTitle(x.GoPointer()) return cret } var xFontButtonGetUseFont func(uintptr) bool // Returns whether the selected font is used in the label. func (x *FontButton) GetUseFont() bool { cret := xFontButtonGetUseFont(x.GoPointer()) return cret } var xFontButtonGetUseSize func(uintptr) bool // Returns whether the selected size is used in the label. func (x *FontButton) GetUseSize() bool { cret := xFontButtonGetUseSize(x.GoPointer()) return cret } var xFontButtonSetModal func(uintptr, bool) // Sets whether the dialog should be modal. func (x *FontButton) SetModal(ModalVar bool) { xFontButtonSetModal(x.GoPointer(), ModalVar) } var xFontButtonSetTitle func(uintptr, string) // Sets the title for the font chooser dialog. func (x *FontButton) SetTitle(TitleVar string) { xFontButtonSetTitle(x.GoPointer(), TitleVar) } var xFontButtonSetUseFont func(uintptr, bool) // If @use_font is %TRUE, the font name will be written // using the selected font. func (x *FontButton) SetUseFont(UseFontVar bool) { xFontButtonSetUseFont(x.GoPointer(), UseFontVar) } var xFontButtonSetUseSize func(uintptr, bool) // If @use_size is %TRUE, the font name will be written using // the selected size. func (x *FontButton) SetUseSize(UseSizeVar bool) { xFontButtonSetUseSize(x.GoPointer(), UseSizeVar) } func (c *FontButton) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *FontButton) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyModal sets the "modal" property. // Whether the font chooser dialog should be modal. func (x *FontButton) 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 font chooser dialog should be modal. func (x *FontButton) GetPropertyModal() bool { var v gobject.Value x.GetProperty("modal", &v) return v.GetBoolean() } // SetPropertyTitle sets the "title" property. // The title of the font chooser dialog. func (x *FontButton) 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 font chooser dialog. func (x *FontButton) GetPropertyTitle() string { var v gobject.Value x.GetProperty("title", &v) return v.GetString() } // SetPropertyUseFont sets the "use-font" property. // Whether the buttons label will be drawn in the selected font. func (x *FontButton) SetPropertyUseFont(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("use-font", &v) } // GetPropertyUseFont gets the "use-font" property. // Whether the buttons label will be drawn in the selected font. func (x *FontButton) GetPropertyUseFont() bool { var v gobject.Value x.GetProperty("use-font", &v) return v.GetBoolean() } // SetPropertyUseSize sets the "use-size" property. // Whether the buttons label will use the selected font size. func (x *FontButton) SetPropertyUseSize(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("use-size", &v) } // GetPropertyUseSize gets the "use-size" property. // Whether the buttons label will use the selected font size. func (x *FontButton) GetPropertyUseSize() bool { var v gobject.Value x.GetProperty("use-size", &v) return v.GetBoolean() } // Emitted to when the font button is activated. // // The `::activate` signal on `GtkFontButton` is an action signal and // emitting it causes the button to present its dialog. func (x *FontButton) ConnectActivate(cb *func(FontButton)) 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 := FontButton{} 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 font. // // When handling this signal, use [method@Gtk.FontChooser.get_font] // to find out which font was just selected. // // Note that this signal is only emitted when the user changes the font. // If you need to react to programmatic font changes as well, use // the notify::font signal. func (x *FontButton) ConnectFontSet(cb *func(FontButton)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "font-set", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr) { fa := FontButton{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "font-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 *FontButton) 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 *FontButton) 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 *FontButton) GetAccessibleRole() AccessibleRole { cret := XGtkAccessibleGetAccessibleRole(x.GoPointer()) return cret } // Retrieves the implementation for the given accessible object. func (x *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) GetPlatformState(StateVar AccessiblePlatformState) bool { cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar) return cret } // Resets the accessible property to its default value. func (x *FontButton) ResetProperty(PropertyVar AccessibleProperty) { XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar) } // Resets the accessible relation to its default value. func (x *FontButton) ResetRelation(RelationVar AccessibleRelation) { XGtkAccessibleResetRelation(x.GoPointer(), RelationVar) } // Resets the accessible state to its default value. func (x *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) 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 *FontButton) GetBuildableId() string { cret := XGtkBuildableGetBuildableId(x.GoPointer()) return cret } // Gets the currently-selected font name. // // Note that this can be a different string than what you set with // [method@Gtk.FontChooser.set_font], as the font chooser widget may // normalize font names and thus return a string with a different // structure. For example, “Helvetica Italic Bold 12” could be // normalized to “Helvetica Bold Italic 12”. // // Use [method@Pango.FontDescription.equal] if you want to compare two // font descriptions. func (x *FontButton) GetFont() string { cret := XGtkFontChooserGetFont(x.GoPointer()) return cret } // Gets the currently-selected font. // // Note that this can be a different string than what you set with // [method@Gtk.FontChooser.set_font], as the font chooser widget may // normalize font names and thus return a string with a different // structure. For example, “Helvetica Italic Bold 12” could be // normalized to “Helvetica Bold Italic 12”. // // Use [method@Pango.FontDescription.equal] if you want to compare two // font descriptions. func (x *FontButton) GetFontDesc() *pango.FontDescription { cret := XGtkFontChooserGetFontDesc(x.GoPointer()) return cret } // Gets the `PangoFontFace` representing the selected font group // details (i.e. family, slant, weight, width, etc). // // If the selected font is not installed, returns %NULL. func (x *FontButton) GetFontFace() *pango.FontFace { var cls *pango.FontFace cret := XGtkFontChooserGetFontFace(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &pango.FontFace{} cls.Ptr = cret return cls } // Gets the `PangoFontFamily` representing the selected font family. // // Font families are a collection of font faces. // // If the selected font is not installed, returns %NULL. func (x *FontButton) GetFontFamily() *pango.FontFamily { var cls *pango.FontFamily cret := XGtkFontChooserGetFontFamily(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &pango.FontFamily{} cls.Ptr = cret return cls } // Gets the currently-selected font features. // // The format of the returned string is compatible with the // [CSS font-feature-settings property](https://www.w3.org/TR/css-fonts-4/#font-rend-desc). // It can be passed to [func@Pango.AttrFontFeatures.new]. func (x *FontButton) GetFontFeatures() string { cret := XGtkFontChooserGetFontFeatures(x.GoPointer()) return cret } // Gets the custom font map of this font chooser widget, // or %NULL if it does not have one. func (x *FontButton) GetFontMap() *pango.FontMap { var cls *pango.FontMap cret := XGtkFontChooserGetFontMap(x.GoPointer()) if cret == 0 { return nil } cls = &pango.FontMap{} cls.Ptr = cret return cls } // The selected font size. func (x *FontButton) GetFontSize() int { cret := XGtkFontChooserGetFontSize(x.GoPointer()) return cret } // Gets the language that is used for font features. func (x *FontButton) GetLanguage() string { cret := XGtkFontChooserGetLanguage(x.GoPointer()) return cret } // Returns the current level of granularity for selecting fonts. func (x *FontButton) GetLevel() FontChooserLevel { cret := XGtkFontChooserGetLevel(x.GoPointer()) return cret } // Gets the text displayed in the preview area. func (x *FontButton) GetPreviewText() string { cret := XGtkFontChooserGetPreviewText(x.GoPointer()) return cret } // Returns whether the preview entry is shown or not. func (x *FontButton) GetShowPreviewEntry() bool { cret := XGtkFontChooserGetShowPreviewEntry(x.GoPointer()) return cret } // Adds a filter function that decides which fonts to display // in the font chooser. func (x *FontButton) SetFilterFunc(FilterVar *FontFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { XGtkFontChooserSetFilterFunc(x.GoPointer(), glib.NewCallbackNullable(FilterVar), UserDataVar, glib.NewCallback(DestroyVar)) } // Sets the currently-selected font. func (x *FontButton) SetFont(FontnameVar string) { XGtkFontChooserSetFont(x.GoPointer(), FontnameVar) } // Sets the currently-selected font from @font_desc. func (x *FontButton) SetFontDesc(FontDescVar *pango.FontDescription) { XGtkFontChooserSetFontDesc(x.GoPointer(), FontDescVar) } // Sets a custom font map to use for this font chooser widget. // // A custom font map can be used to present application-specific // fonts instead of or in addition to the normal system fonts. // // ```c // FcConfig *config; // PangoFontMap *fontmap; // // config = FcInitLoadConfigAndFonts (); // FcConfigAppFontAddFile (config, my_app_font_file); // // fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); // pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config); // // gtk_font_chooser_set_font_map (font_chooser, fontmap); // ``` // // Note that other GTK widgets will only be able to use the // application-specific font if it is present in the font map they use: // // ```c // context = gtk_widget_get_pango_context (label); // pango_context_set_font_map (context, fontmap); // ``` func (x *FontButton) SetFontMap(FontmapVar *pango.FontMap) { XGtkFontChooserSetFontMap(x.GoPointer(), FontmapVar.GoPointer()) } // Sets the language to use for font features. func (x *FontButton) SetLanguage(LanguageVar string) { XGtkFontChooserSetLanguage(x.GoPointer(), LanguageVar) } // Sets the desired level of granularity for selecting fonts. func (x *FontButton) SetLevel(LevelVar FontChooserLevel) { XGtkFontChooserSetLevel(x.GoPointer(), LevelVar) } // Sets the text displayed in the preview area. // // The @text is used to show how the selected font looks. func (x *FontButton) SetPreviewText(TextVar string) { XGtkFontChooserSetPreviewText(x.GoPointer(), TextVar) } // Shows or hides the editable preview entry. func (x *FontButton) SetShowPreviewEntry(ShowPreviewEntryVar bool) { XGtkFontChooserSetShowPreviewEntry(x.GoPointer(), ShowPreviewEntryVar) } 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(&xFontButtonGLibType, libs, "gtk_font_button_get_type") core.PuregoSafeRegister(&xNewFontButton, libs, "gtk_font_button_new") core.PuregoSafeRegister(&xNewFontButtonWithFont, libs, "gtk_font_button_new_with_font") core.PuregoSafeRegister(&xFontButtonGetModal, libs, "gtk_font_button_get_modal") core.PuregoSafeRegister(&xFontButtonGetTitle, libs, "gtk_font_button_get_title") core.PuregoSafeRegister(&xFontButtonGetUseFont, libs, "gtk_font_button_get_use_font") core.PuregoSafeRegister(&xFontButtonGetUseSize, libs, "gtk_font_button_get_use_size") core.PuregoSafeRegister(&xFontButtonSetModal, libs, "gtk_font_button_set_modal") core.PuregoSafeRegister(&xFontButtonSetTitle, libs, "gtk_font_button_set_title") core.PuregoSafeRegister(&xFontButtonSetUseFont, libs, "gtk_font_button_set_use_font") core.PuregoSafeRegister(&xFontButtonSetUseSize, libs, "gtk_font_button_set_use_size") }