// 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/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" "github.com/bnema/puregotk/v4/pango" ) // The type of function that is used for deciding what fonts get // shown in a `GtkFontChooser`. // // See [method@Gtk.FontChooser.set_filter_func]. type FontFilterFunc func(uintptr, uintptr, uintptr) bool type FontChooserIface struct { _ structs.HostLayout BaseIface uintptr xGetFontFamily uintptr xGetFontFace uintptr xGetFontSize uintptr xSetFilterFunc uintptr xFontActivated uintptr xSetFontMap uintptr xGetFontMap uintptr Padding [10]uintptr } func (x *FontChooserIface) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideGetFontFamily sets the "get_font_family" callback function. func (x *FontChooserIface) OverrideGetFontFamily(cb func(FontChooser) *pango.FontFamily) { if cb == nil { x.xGetFontFamily = 0 } else { x.xGetFontFamily = purego.NewCallback(func(FontchooserVarp uintptr) uintptr { ret := cb(&FontChooserBase{Ptr: FontchooserVarp}) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetGetFontFamily gets the "get_font_family" callback function. func (x *FontChooserIface) GetGetFontFamily() func(FontChooser) *pango.FontFamily { if x.xGetFontFamily == 0 { return nil } var rawCallback func(FontchooserVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xGetFontFamily) return func(FontchooserVar FontChooser) *pango.FontFamily { rawRet := rawCallback(FontchooserVar.GoPointer()) if rawRet == 0 { return nil } ret := &pango.FontFamily{} ret.Ptr = rawRet return ret } } // OverrideGetFontFace sets the "get_font_face" callback function. func (x *FontChooserIface) OverrideGetFontFace(cb func(FontChooser) *pango.FontFace) { if cb == nil { x.xGetFontFace = 0 } else { x.xGetFontFace = purego.NewCallback(func(FontchooserVarp uintptr) uintptr { ret := cb(&FontChooserBase{Ptr: FontchooserVarp}) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetGetFontFace gets the "get_font_face" callback function. func (x *FontChooserIface) GetGetFontFace() func(FontChooser) *pango.FontFace { if x.xGetFontFace == 0 { return nil } var rawCallback func(FontchooserVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xGetFontFace) return func(FontchooserVar FontChooser) *pango.FontFace { rawRet := rawCallback(FontchooserVar.GoPointer()) if rawRet == 0 { return nil } ret := &pango.FontFace{} ret.Ptr = rawRet return ret } } // OverrideGetFontSize sets the "get_font_size" callback function. func (x *FontChooserIface) OverrideGetFontSize(cb func(FontChooser) int) { if cb == nil { x.xGetFontSize = 0 } else { x.xGetFontSize = purego.NewCallback(func(FontchooserVarp uintptr) int { return cb(&FontChooserBase{Ptr: FontchooserVarp}) }) } } // GetGetFontSize gets the "get_font_size" callback function. func (x *FontChooserIface) GetGetFontSize() func(FontChooser) int { if x.xGetFontSize == 0 { return nil } var rawCallback func(FontchooserVarp uintptr) int purego.RegisterFunc(&rawCallback, x.xGetFontSize) return func(FontchooserVar FontChooser) int { return rawCallback(FontchooserVar.GoPointer()) } } // OverrideSetFilterFunc sets the "set_filter_func" callback function. func (x *FontChooserIface) OverrideSetFilterFunc(cb func(FontChooser, *FontFilterFunc, uintptr, *glib.DestroyNotify)) { if cb == nil { x.xSetFilterFunc = 0 } else { x.xSetFilterFunc = purego.NewCallback(func(FontchooserVarp uintptr, FilterVarp uintptr, UserDataVarp uintptr, DestroyVarp uintptr) { cb(&FontChooserBase{Ptr: FontchooserVarp}, (*FontFilterFunc)(unsafe.Pointer(FilterVarp)), UserDataVarp, (*glib.DestroyNotify)(unsafe.Pointer(DestroyVarp))) }) } } // GetSetFilterFunc gets the "set_filter_func" callback function. func (x *FontChooserIface) GetSetFilterFunc() func(FontChooser, *FontFilterFunc, uintptr, *glib.DestroyNotify) { if x.xSetFilterFunc == 0 { return nil } var rawCallback func(FontchooserVarp uintptr, FilterVarp uintptr, UserDataVarp uintptr, DestroyVarp uintptr) purego.RegisterFunc(&rawCallback, x.xSetFilterFunc) return func(FontchooserVar FontChooser, FilterVar *FontFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { rawCallback(FontchooserVar.GoPointer(), glib.NewCallbackNullable(FilterVar), UserDataVar, glib.NewCallback(DestroyVar)) } } // OverrideFontActivated sets the "font_activated" callback function. func (x *FontChooserIface) OverrideFontActivated(cb func(FontChooser, string)) { if cb == nil { x.xFontActivated = 0 } else { x.xFontActivated = purego.NewCallback(func(ChooserVarp uintptr, FontnameVarp string) { cb(&FontChooserBase{Ptr: ChooserVarp}, FontnameVarp) }) } } // GetFontActivated gets the "font_activated" callback function. func (x *FontChooserIface) GetFontActivated() func(FontChooser, string) { if x.xFontActivated == 0 { return nil } var rawCallback func(ChooserVarp uintptr, FontnameVarp string) purego.RegisterFunc(&rawCallback, x.xFontActivated) return func(ChooserVar FontChooser, FontnameVar string) { rawCallback(ChooserVar.GoPointer(), FontnameVar) } } // OverrideSetFontMap sets the "set_font_map" callback function. func (x *FontChooserIface) OverrideSetFontMap(cb func(FontChooser, *pango.FontMap)) { if cb == nil { x.xSetFontMap = 0 } else { x.xSetFontMap = purego.NewCallback(func(FontchooserVarp uintptr, FontmapVarp uintptr) { cb(&FontChooserBase{Ptr: FontchooserVarp}, pango.FontMapNewFromInternalPtr(FontmapVarp)) }) } } // GetSetFontMap gets the "set_font_map" callback function. func (x *FontChooserIface) GetSetFontMap() func(FontChooser, *pango.FontMap) { if x.xSetFontMap == 0 { return nil } var rawCallback func(FontchooserVarp uintptr, FontmapVarp uintptr) purego.RegisterFunc(&rawCallback, x.xSetFontMap) return func(FontchooserVar FontChooser, FontmapVar *pango.FontMap) { rawCallback(FontchooserVar.GoPointer(), FontmapVar.GoPointer()) } } // OverrideGetFontMap sets the "get_font_map" callback function. func (x *FontChooserIface) OverrideGetFontMap(cb func(FontChooser) *pango.FontMap) { if cb == nil { x.xGetFontMap = 0 } else { x.xGetFontMap = purego.NewCallback(func(FontchooserVarp uintptr) uintptr { ret := cb(&FontChooserBase{Ptr: FontchooserVarp}) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetGetFontMap gets the "get_font_map" callback function. func (x *FontChooserIface) GetGetFontMap() func(FontChooser) *pango.FontMap { if x.xGetFontMap == 0 { return nil } var rawCallback func(FontchooserVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xGetFontMap) return func(FontchooserVar FontChooser) *pango.FontMap { rawRet := rawCallback(FontchooserVar.GoPointer()) if rawRet == 0 { return nil } ret := &pango.FontMap{} ret.Ptr = rawRet return ret } } // `GtkFontChooser` is an interface that can be implemented by widgets // for choosing fonts. // // In GTK, the main objects that implement this interface are // [class@Gtk.FontChooserWidget], [class@Gtk.FontChooserDialog] and // [class@Gtk.FontButton]. type FontChooser interface { GoPointer() uintptr SetGoPointer(uintptr) GetFont() string GetFontDesc() *pango.FontDescription GetFontFace() *pango.FontFace GetFontFamily() *pango.FontFamily GetFontFeatures() string GetFontMap() *pango.FontMap GetFontSize() int GetLanguage() string GetLevel() FontChooserLevel GetPreviewText() string GetShowPreviewEntry() bool SetFilterFunc(FilterVar *FontFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) SetFont(FontnameVar string) SetFontDesc(FontDescVar *pango.FontDescription) SetFontMap(FontmapVar *pango.FontMap) SetLanguage(LanguageVar string) SetLevel(LevelVar FontChooserLevel) SetPreviewText(TextVar string) SetShowPreviewEntry(ShowPreviewEntryVar bool) } var xFontChooserGLibType func() types.GType func FontChooserGLibType() types.GType { return xFontChooserGLibType() } type FontChooserBase struct { Ptr uintptr } func (x *FontChooserBase) GoPointer() uintptr { if x == nil { return 0 } return x.Ptr } func (x *FontChooserBase) SetGoPointer(ptr uintptr) { x.Ptr = ptr } // 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 *FontChooserBase) 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 *FontChooserBase) 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 *FontChooserBase) 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 *FontChooserBase) 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 *FontChooserBase) 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 *FontChooserBase) 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 *FontChooserBase) GetFontSize() int { cret := XGtkFontChooserGetFontSize(x.GoPointer()) return cret } // Gets the language that is used for font features. func (x *FontChooserBase) GetLanguage() string { cret := XGtkFontChooserGetLanguage(x.GoPointer()) return cret } // Returns the current level of granularity for selecting fonts. func (x *FontChooserBase) GetLevel() FontChooserLevel { cret := XGtkFontChooserGetLevel(x.GoPointer()) return cret } // Gets the text displayed in the preview area. func (x *FontChooserBase) GetPreviewText() string { cret := XGtkFontChooserGetPreviewText(x.GoPointer()) return cret } // Returns whether the preview entry is shown or not. func (x *FontChooserBase) GetShowPreviewEntry() bool { cret := XGtkFontChooserGetShowPreviewEntry(x.GoPointer()) return cret } // Adds a filter function that decides which fonts to display // in the font chooser. func (x *FontChooserBase) 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 *FontChooserBase) SetFont(FontnameVar string) { XGtkFontChooserSetFont(x.GoPointer(), FontnameVar) } // Sets the currently-selected font from @font_desc. func (x *FontChooserBase) 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 *FontChooserBase) SetFontMap(FontmapVar *pango.FontMap) { XGtkFontChooserSetFontMap(x.GoPointer(), FontmapVar.GoPointer()) } // Sets the language to use for font features. func (x *FontChooserBase) SetLanguage(LanguageVar string) { XGtkFontChooserSetLanguage(x.GoPointer(), LanguageVar) } // Sets the desired level of granularity for selecting fonts. func (x *FontChooserBase) 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 *FontChooserBase) SetPreviewText(TextVar string) { XGtkFontChooserSetPreviewText(x.GoPointer(), TextVar) } // Shows or hides the editable preview entry. func (x *FontChooserBase) SetShowPreviewEntry(ShowPreviewEntryVar bool) { XGtkFontChooserSetShowPreviewEntry(x.GoPointer(), ShowPreviewEntryVar) } // SetPropertyFont sets the "font" property. // The font description as a string, e.g. "Sans Italic 12". func (x *FontChooserBase) SetPropertyFont(value string) { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) obj.SetProperty("font", &v) } // GetPropertyFont gets the "font" property. // The font description as a string, e.g. "Sans Italic 12". func (x *FontChooserBase) GetPropertyFont() string { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value obj.GetProperty("font", &v) return v.GetString() } // SetPropertyFontDesc sets the "font-desc" property. // The font description as a `PangoFontDescription`. func (x *FontChooserBase) SetPropertyFontDesc(value uintptr) { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value v.Init(gobject.TypePointerVal) v.SetPointer(value) obj.SetProperty("font-desc", &v) } // GetPropertyFontDesc gets the "font-desc" property. // The font description as a `PangoFontDescription`. func (x *FontChooserBase) GetPropertyFontDesc() uintptr { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value obj.GetProperty("font-desc", &v) return v.GetPointer() } // GetPropertyFontFeatures gets the "font-features" property. // The selected font features. // // The format of the string is compatible with // CSS and with Pango attributes. func (x *FontChooserBase) GetPropertyFontFeatures() string { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value obj.GetProperty("font-features", &v) return v.GetString() } // SetPropertyLanguage sets the "language" property. // The language for which the font features were selected. func (x *FontChooserBase) SetPropertyLanguage(value string) { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) obj.SetProperty("language", &v) } // GetPropertyLanguage gets the "language" property. // The language for which the font features were selected. func (x *FontChooserBase) GetPropertyLanguage() string { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value obj.GetProperty("language", &v) return v.GetString() } // SetPropertyPreviewText sets the "preview-text" property. // The string with which to preview the font. func (x *FontChooserBase) SetPropertyPreviewText(value string) { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) obj.SetProperty("preview-text", &v) } // GetPropertyPreviewText gets the "preview-text" property. // The string with which to preview the font. func (x *FontChooserBase) GetPropertyPreviewText() string { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value obj.GetProperty("preview-text", &v) return v.GetString() } // SetPropertyShowPreviewEntry sets the "show-preview-entry" property. // Whether to show an entry to change the preview text. func (x *FontChooserBase) SetPropertyShowPreviewEntry(value bool) { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) obj.SetProperty("show-preview-entry", &v) } // GetPropertyShowPreviewEntry gets the "show-preview-entry" property. // Whether to show an entry to change the preview text. func (x *FontChooserBase) GetPropertyShowPreviewEntry() bool { obj := gobject.Object{} obj.Ptr = x.GoPointer() var v gobject.Value obj.GetProperty("show-preview-entry", &v) return v.GetBoolean() } var XGtkFontChooserGetFont func(uintptr) string var XGtkFontChooserGetFontDesc func(uintptr) *pango.FontDescription var XGtkFontChooserGetFontFace func(uintptr) uintptr var XGtkFontChooserGetFontFamily func(uintptr) uintptr var XGtkFontChooserGetFontFeatures func(uintptr) string var XGtkFontChooserGetFontMap func(uintptr) uintptr var XGtkFontChooserGetFontSize func(uintptr) int var XGtkFontChooserGetLanguage func(uintptr) string var XGtkFontChooserGetLevel func(uintptr) FontChooserLevel var XGtkFontChooserGetPreviewText func(uintptr) string var XGtkFontChooserGetShowPreviewEntry func(uintptr) bool var XGtkFontChooserSetFilterFunc func(uintptr, uintptr, uintptr, uintptr) var XGtkFontChooserSetFont func(uintptr, string) var XGtkFontChooserSetFontDesc func(uintptr, *pango.FontDescription) var XGtkFontChooserSetFontMap func(uintptr, uintptr) var XGtkFontChooserSetLanguage func(uintptr, string) var XGtkFontChooserSetLevel func(uintptr, FontChooserLevel) var XGtkFontChooserSetPreviewText func(uintptr, string) var XGtkFontChooserSetShowPreviewEntry func(uintptr, bool) // Specifies the granularity of font selection // that is desired in a `GtkFontChooser`. // // This enumeration may be extended in the future; applications should // ignore unknown values. type FontChooserLevel int var xFontChooserLevelGLibType func() types.GType func FontChooserLevelGLibType() types.GType { return xFontChooserLevelGLibType() } const ( // Allow selecting a font family FontChooserLevelFamilyValue FontChooserLevel = 0 // Allow selecting a specific font face FontChooserLevelStyleValue FontChooserLevel = 1 // Allow selecting a specific font size FontChooserLevelSizeValue FontChooserLevel = 2 // Allow changing OpenType font variation axes FontChooserLevelVariationsValue FontChooserLevel = 4 // Allow selecting specific OpenType font features FontChooserLevelFeaturesValue FontChooserLevel = 8 ) 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(&xFontChooserLevelGLibType, libs, "gtk_font_chooser_level_get_type") core.PuregoSafeRegister(&xFontChooserGLibType, libs, "gtk_font_chooser_get_type") core.PuregoSafeRegister(&XGtkFontChooserGetFont, libs, "gtk_font_chooser_get_font") core.PuregoSafeRegister(&XGtkFontChooserGetFontDesc, libs, "gtk_font_chooser_get_font_desc") core.PuregoSafeRegister(&XGtkFontChooserGetFontFace, libs, "gtk_font_chooser_get_font_face") core.PuregoSafeRegister(&XGtkFontChooserGetFontFamily, libs, "gtk_font_chooser_get_font_family") core.PuregoSafeRegister(&XGtkFontChooserGetFontFeatures, libs, "gtk_font_chooser_get_font_features") core.PuregoSafeRegister(&XGtkFontChooserGetFontMap, libs, "gtk_font_chooser_get_font_map") core.PuregoSafeRegister(&XGtkFontChooserGetFontSize, libs, "gtk_font_chooser_get_font_size") core.PuregoSafeRegister(&XGtkFontChooserGetLanguage, libs, "gtk_font_chooser_get_language") core.PuregoSafeRegister(&XGtkFontChooserGetLevel, libs, "gtk_font_chooser_get_level") core.PuregoSafeRegister(&XGtkFontChooserGetPreviewText, libs, "gtk_font_chooser_get_preview_text") core.PuregoSafeRegister(&XGtkFontChooserGetShowPreviewEntry, libs, "gtk_font_chooser_get_show_preview_entry") core.PuregoSafeRegister(&XGtkFontChooserSetFilterFunc, libs, "gtk_font_chooser_set_filter_func") core.PuregoSafeRegister(&XGtkFontChooserSetFont, libs, "gtk_font_chooser_set_font") core.PuregoSafeRegister(&XGtkFontChooserSetFontDesc, libs, "gtk_font_chooser_set_font_desc") core.PuregoSafeRegister(&XGtkFontChooserSetFontMap, libs, "gtk_font_chooser_set_font_map") core.PuregoSafeRegister(&XGtkFontChooserSetLanguage, libs, "gtk_font_chooser_set_language") core.PuregoSafeRegister(&XGtkFontChooserSetLevel, libs, "gtk_font_chooser_set_level") core.PuregoSafeRegister(&XGtkFontChooserSetPreviewText, libs, "gtk_font_chooser_set_preview_text") core.PuregoSafeRegister(&XGtkFontChooserSetShowPreviewEntry, libs, "gtk_font_chooser_set_show_preview_entry") }