// 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 CssProviderClass struct { _ structs.HostLayout } func (x *CssProviderClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } type CssProviderPrivate struct { _ structs.HostLayout } func (x *CssProviderPrivate) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // A style provider for CSS. // // It is able to parse CSS-like input in order to style widgets. // // An application can make GTK parse a specific CSS style sheet by calling // [method@Gtk.CssProvider.load_from_file] or // [method@Gtk.CssProvider.load_from_resource] // and adding the provider with [method@Gtk.StyleContext.add_provider] or // [func@Gtk.StyleContext.add_provider_for_display]. // // In addition, certain files will be read when GTK is initialized. // First, the file `$XDG_CONFIG_HOME/gtk-4.0/gtk.css` is loaded if it // exists. Then, GTK loads the first existing file among // `XDG_DATA_HOME/themes/THEME/gtk-VERSION/gtk-VARIANT.css`, // `$HOME/.themes/THEME/gtk-VERSION/gtk-VARIANT.css`, // `$XDG_DATA_DIRS/themes/THEME/gtk-VERSION/gtk-VARIANT.css` and // `DATADIR/share/themes/THEME/gtk-VERSION/gtk-VARIANT.css`, // where `THEME` is the name of the current theme (see the // [property@Gtk.Settings:gtk-theme-name] setting), `VARIANT` is the // variant to load (see the // [property@Gtk.Settings:gtk-application-prefer-dark-theme] setting), // `DATADIR` is the prefix configured when GTK was compiled (unless // overridden by the `GTK_DATA_PREFIX` environment variable), and // `VERSION` is the GTK version number. If no file is found for the // current version, GTK tries older versions all the way back to 4.0. // // To track errors while loading CSS, connect to the // [signal@Gtk.CssProvider::parsing-error] signal. type CssProvider struct { gobject.Object } var xCssProviderGLibType func() types.GType func CssProviderGLibType() types.GType { return xCssProviderGLibType() } func CssProviderNewFromInternalPtr(ptr uintptr) *CssProvider { cls := &CssProvider{} cls.Ptr = ptr return cls } var xNewCssProvider func() uintptr // Returns a newly created `GtkCssProvider`. func NewCssProvider() *CssProvider { var cls *CssProvider cret := xNewCssProvider() if cret == 0 { return nil } cls = &CssProvider{} cls.Ptr = cret return cls } var xCssProviderLoadFromBytes func(uintptr, *glib.Bytes) // Loads @data into @css_provider. // // This clears any previously loaded information. func (x *CssProvider) LoadFromBytes(DataVar *glib.Bytes) { xCssProviderLoadFromBytes(x.GoPointer(), DataVar) } var xCssProviderLoadFromData func(uintptr, string, int) // Loads @data into @css_provider. // // This clears any previously loaded information. func (x *CssProvider) LoadFromData(DataVar string, LengthVar int) { xCssProviderLoadFromData(x.GoPointer(), DataVar, LengthVar) } var xCssProviderLoadFromFile func(uintptr, uintptr) // Loads the data contained in @file into @css_provider. // // This clears any previously loaded information. func (x *CssProvider) LoadFromFile(FileVar gio.File) { xCssProviderLoadFromFile(x.GoPointer(), FileVar.GoPointer()) } var xCssProviderLoadFromPath func(uintptr, string) // Loads the data contained in @path into @css_provider. // // This clears any previously loaded information. func (x *CssProvider) LoadFromPath(PathVar string) { xCssProviderLoadFromPath(x.GoPointer(), PathVar) } var xCssProviderLoadFromResource func(uintptr, string) // Loads the data contained in the resource at @resource_path into // the @css_provider. // // This clears any previously loaded information. func (x *CssProvider) LoadFromResource(ResourcePathVar string) { xCssProviderLoadFromResource(x.GoPointer(), ResourcePathVar) } var xCssProviderLoadFromString func(uintptr, string) // Loads @string into @css_provider. // // This clears any previously loaded information. func (x *CssProvider) LoadFromString(StringVar string) { xCssProviderLoadFromString(x.GoPointer(), StringVar) } var xCssProviderLoadNamed func(uintptr, string, uintptr) // Loads a theme from the usual theme paths. // // The actual process of finding the theme might change between // releases, but it is guaranteed that this function uses the same // mechanism to load the theme that GTK uses for loading its own theme. func (x *CssProvider) LoadNamed(NameVar string, VariantVar *string) { VariantVarPtr := core.GStrdupNullable(VariantVar) defer core.GFreeNullable(VariantVarPtr) xCssProviderLoadNamed(x.GoPointer(), NameVar, VariantVarPtr) } var xCssProviderToString func(uintptr) string // Converts the @provider into a string representation in CSS // format. // // Using [method@Gtk.CssProvider.load_from_string] with the return // value from this function on a new provider created with // [ctor@Gtk.CssProvider.new] will basically create a duplicate // of this @provider. func (x *CssProvider) ToString() string { cret := xCssProviderToString(x.GoPointer()) return cret } func (c *CssProvider) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *CssProvider) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Signals that a parsing error occurred. // // The expected error values are in the [error@Gtk.CssParserError] // and [enum@Gtk.CssParserWarning] enumerations. // // The @path, @line and @position describe the actual location of // the error as accurately as possible. // // Parsing errors are never fatal, so the parsing will resume after // the error. Errors may however cause parts of the given data or // even all of it to not be parsed at all. So it is a useful idea // to check that the parsing succeeds by connecting to this signal. // // Errors in the [enum@Gtk.CssParserWarning] enumeration should not // be treated as fatal errors. // // Note that this signal may be emitted at any time as the css provider // may opt to defer parsing parts or all of the input to a later time // than when a loading function was called. func (x *CssProvider) ConnectParsingError(cb *func(CssProvider, uintptr, *glib.Error)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "parsing-error", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, SectionVarp uintptr, ErrorVarp uintptr) { fa := CssProvider{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, SectionVarp, (*glib.Error)(unsafe.Pointer(ErrorVarp))) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "parsing-error", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } 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(&xCssProviderGLibType, libs, "gtk_css_provider_get_type") core.PuregoSafeRegister(&xNewCssProvider, libs, "gtk_css_provider_new") core.PuregoSafeRegister(&xCssProviderLoadFromBytes, libs, "gtk_css_provider_load_from_bytes") core.PuregoSafeRegister(&xCssProviderLoadFromData, libs, "gtk_css_provider_load_from_data") core.PuregoSafeRegister(&xCssProviderLoadFromFile, libs, "gtk_css_provider_load_from_file") core.PuregoSafeRegister(&xCssProviderLoadFromPath, libs, "gtk_css_provider_load_from_path") core.PuregoSafeRegister(&xCssProviderLoadFromResource, libs, "gtk_css_provider_load_from_resource") core.PuregoSafeRegister(&xCssProviderLoadFromString, libs, "gtk_css_provider_load_from_string") core.PuregoSafeRegister(&xCssProviderLoadNamed, libs, "gtk_css_provider_load_named") core.PuregoSafeRegister(&xCssProviderToString, libs, "gtk_css_provider_to_string") }