// 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/gdk" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type StyleContextClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass xChanged uintptr xGtkReserved1 uintptr xGtkReserved2 uintptr xGtkReserved3 uintptr xGtkReserved4 uintptr } func (x *StyleContextClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideChanged sets the "changed" callback function. func (x *StyleContextClass) OverrideChanged(cb func(*StyleContext)) { if cb == nil { x.xChanged = 0 } else { x.xChanged = purego.NewCallback(func(ContextVarp uintptr) { cb(StyleContextNewFromInternalPtr(ContextVarp)) }) } } // GetChanged gets the "changed" callback function. func (x *StyleContextClass) GetChanged() func(*StyleContext) { if x.xChanged == 0 { return nil } var rawCallback func(ContextVarp uintptr) purego.RegisterFunc(&rawCallback, x.xChanged) return func(ContextVar *StyleContext) { rawCallback(ContextVar.GoPointer()) } } // OverrideGtkReserved1 sets the "_gtk_reserved1" callback function. func (x *StyleContextClass) OverrideGtkReserved1(cb func()) { if cb == nil { x.xGtkReserved1 = 0 } else { x.xGtkReserved1 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved1 gets the "_gtk_reserved1" callback function. func (x *StyleContextClass) GetGtkReserved1() func() { if x.xGtkReserved1 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved1) return func() { rawCallback() } } // OverrideGtkReserved2 sets the "_gtk_reserved2" callback function. func (x *StyleContextClass) OverrideGtkReserved2(cb func()) { if cb == nil { x.xGtkReserved2 = 0 } else { x.xGtkReserved2 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved2 gets the "_gtk_reserved2" callback function. func (x *StyleContextClass) GetGtkReserved2() func() { if x.xGtkReserved2 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved2) return func() { rawCallback() } } // OverrideGtkReserved3 sets the "_gtk_reserved3" callback function. func (x *StyleContextClass) OverrideGtkReserved3(cb func()) { if cb == nil { x.xGtkReserved3 = 0 } else { x.xGtkReserved3 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved3 gets the "_gtk_reserved3" callback function. func (x *StyleContextClass) GetGtkReserved3() func() { if x.xGtkReserved3 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved3) return func() { rawCallback() } } // OverrideGtkReserved4 sets the "_gtk_reserved4" callback function. func (x *StyleContextClass) OverrideGtkReserved4(cb func()) { if cb == nil { x.xGtkReserved4 = 0 } else { x.xGtkReserved4 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved4 gets the "_gtk_reserved4" callback function. func (x *StyleContextClass) GetGtkReserved4() func() { if x.xGtkReserved4 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved4) return func() { rawCallback() } } // Flags that modify the behavior of gtk_style_context_to_string(). // // New values may be added to this enumeration. type StyleContextPrintFlags int var xStyleContextPrintFlagsGLibType func() types.GType func StyleContextPrintFlagsGLibType() types.GType { return xStyleContextPrintFlagsGLibType() } const ( // Default value. StyleContextPrintNoneValue StyleContextPrintFlags = 0 // Print the entire tree of // CSS nodes starting at the style context's node StyleContextPrintRecurseValue StyleContextPrintFlags = 1 // Show the values of the // CSS properties for each node StyleContextPrintShowStyleValue StyleContextPrintFlags = 2 // Show information about // what changes affect the styles StyleContextPrintShowChangeValue StyleContextPrintFlags = 4 ) // `GtkStyleContext` stores styling information affecting a widget. // // In order to construct the final style information, `GtkStyleContext` // queries information from all attached `GtkStyleProviders`. Style // providers can be either attached explicitly to the context through // [method@Gtk.StyleContext.add_provider], or to the display through // [func@Gtk.StyleContext.add_provider_for_display]. The resulting // style is a combination of all providers’ information in priority order. // // For GTK widgets, any `GtkStyleContext` returned by // [method@Gtk.Widget.get_style_context] will already have a `GdkDisplay` // and RTL/LTR information set. The style context will also be updated // automatically if any of these settings change on the widget. // // ## Style Classes // // Widgets can add style classes to their context, which can be used to associate // different styles by class. The documentation for individual widgets lists // which style classes it uses itself, and which style classes may be added by // applications to affect their appearance. // // # Custom styling in UI libraries and applications // // If you are developing a library with custom widgets that render differently // than standard components, you may need to add a `GtkStyleProvider` yourself // with the %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority, either a // `GtkCssProvider` or a custom object implementing the `GtkStyleProvider` // interface. This way themes may still attempt to style your UI elements in // a different way if needed so. // // If you are using custom styling on an applications, you probably want then // to make your style information prevail to the theme’s, so you must use // a `GtkStyleProvider` with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION // priority, keep in mind that the user settings in // `XDG_CONFIG_HOME/gtk-4.0/gtk.css` will // still take precedence over your changes, as it uses the // %GTK_STYLE_PROVIDER_PRIORITY_USER priority. type StyleContext struct { gobject.Object } var xStyleContextGLibType func() types.GType func StyleContextGLibType() types.GType { return xStyleContextGLibType() } func StyleContextNewFromInternalPtr(ptr uintptr) *StyleContext { cls := &StyleContext{} cls.Ptr = ptr return cls } var xStyleContextAddClass func(uintptr, string) // Adds a style class to @context, so later uses of the // style context will make use of this new class for styling. // // In the CSS file format, a `GtkEntry` defining a “search” // class, would be matched by: // // ```css // entry.search { ... } // ``` // // While any widget defining a “search” class would be // matched by: // ```css // .search { ... } // ``` func (x *StyleContext) AddClass(ClassNameVar string) { xStyleContextAddClass(x.GoPointer(), ClassNameVar) } var xStyleContextAddProvider func(uintptr, uintptr, uint) // Adds a style provider to @context, to be used in style construction. // // Note that a style provider added by this function only affects // the style of the widget to which @context belongs. If you want // to affect the style of all widgets, use // [func@Gtk.StyleContext.add_provider_for_display]. // // Note: If both priorities are the same, a `GtkStyleProvider` // added through this function takes precedence over another added // through [func@Gtk.StyleContext.add_provider_for_display]. func (x *StyleContext) AddProvider(ProviderVar StyleProvider, PriorityVar uint) { xStyleContextAddProvider(x.GoPointer(), ProviderVar.GoPointer(), PriorityVar) } var xStyleContextGetBorder func(uintptr, *Border) // Gets the border for a given state as a `GtkBorder`. func (x *StyleContext) GetBorder(BorderVar *Border) { xStyleContextGetBorder(x.GoPointer(), BorderVar) } var xStyleContextGetColor func(uintptr, *gdk.RGBA) // Gets the foreground color for a given state. func (x *StyleContext) GetColor(ColorVar *gdk.RGBA) { xStyleContextGetColor(x.GoPointer(), ColorVar) } var xStyleContextGetDisplay func(uintptr) uintptr // Returns the `GdkDisplay` to which @context is attached. func (x *StyleContext) GetDisplay() *gdk.Display { var cls *gdk.Display cret := xStyleContextGetDisplay(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gdk.Display{} cls.Ptr = cret return cls } var xStyleContextGetMargin func(uintptr, *Border) // Gets the margin for a given state as a `GtkBorder`. func (x *StyleContext) GetMargin(MarginVar *Border) { xStyleContextGetMargin(x.GoPointer(), MarginVar) } var xStyleContextGetPadding func(uintptr, *Border) // Gets the padding for a given state as a `GtkBorder`. func (x *StyleContext) GetPadding(PaddingVar *Border) { xStyleContextGetPadding(x.GoPointer(), PaddingVar) } var xStyleContextGetScale func(uintptr) int // Returns the scale used for assets. func (x *StyleContext) GetScale() int { cret := xStyleContextGetScale(x.GoPointer()) return cret } var xStyleContextGetState func(uintptr) StateFlags // Returns the state used for style matching. // // This method should only be used to retrieve the `GtkStateFlags` // to pass to `GtkStyleContext` methods, like // [method@Gtk.StyleContext.get_padding]. // If you need to retrieve the current state of a `GtkWidget`, use // [method@Gtk.Widget.get_state_flags]. func (x *StyleContext) GetState() StateFlags { cret := xStyleContextGetState(x.GoPointer()) return cret } var xStyleContextHasClass func(uintptr, string) bool // Returns %TRUE if @context currently has defined the // given class name. func (x *StyleContext) HasClass(ClassNameVar string) bool { cret := xStyleContextHasClass(x.GoPointer(), ClassNameVar) return cret } var xStyleContextLookupColor func(uintptr, string, *gdk.RGBA) bool // Looks up and resolves a color name in the @context color map. func (x *StyleContext) LookupColor(ColorNameVar string, ColorVar *gdk.RGBA) bool { cret := xStyleContextLookupColor(x.GoPointer(), ColorNameVar, ColorVar) return cret } var xStyleContextRemoveClass func(uintptr, string) // Removes @class_name from @context. func (x *StyleContext) RemoveClass(ClassNameVar string) { xStyleContextRemoveClass(x.GoPointer(), ClassNameVar) } var xStyleContextRemoveProvider func(uintptr, uintptr) // Removes @provider from the style providers list in @context. func (x *StyleContext) RemoveProvider(ProviderVar StyleProvider) { xStyleContextRemoveProvider(x.GoPointer(), ProviderVar.GoPointer()) } var xStyleContextRestore func(uintptr) // Restores @context state to a previous stage. // // See [method@Gtk.StyleContext.save]. func (x *StyleContext) Restore() { xStyleContextRestore(x.GoPointer()) } var xStyleContextSave func(uintptr) // Saves the @context state. // // This allows temporary modifications done through // [method@Gtk.StyleContext.add_class], // [method@Gtk.StyleContext.remove_class], // [method@Gtk.StyleContext.set_state] to be quickly // reverted in one go through [method@Gtk.StyleContext.restore]. // // The matching call to [method@Gtk.StyleContext.restore] // must be done before GTK returns to the main loop. func (x *StyleContext) Save() { xStyleContextSave(x.GoPointer()) } var xStyleContextSetDisplay func(uintptr, uintptr) // Attaches @context to the given display. // // The display is used to add style information from “global” // style providers, such as the display's `GtkSettings` instance. // // If you are using a `GtkStyleContext` returned from // [method@Gtk.Widget.get_style_context], you do not need to // call this yourself. func (x *StyleContext) SetDisplay(DisplayVar *gdk.Display) { xStyleContextSetDisplay(x.GoPointer(), DisplayVar.GoPointer()) } var xStyleContextSetScale func(uintptr, int) // Sets the scale to use when getting image assets for the style. func (x *StyleContext) SetScale(ScaleVar int) { xStyleContextSetScale(x.GoPointer(), ScaleVar) } var xStyleContextSetState func(uintptr, StateFlags) // Sets the state to be used for style matching. func (x *StyleContext) SetState(FlagsVar StateFlags) { xStyleContextSetState(x.GoPointer(), FlagsVar) } var xStyleContextToString func(uintptr, StyleContextPrintFlags) string // Converts the style context into a string representation. // // The string representation always includes information about // the name, state, id, visibility and style classes of the CSS // node that is backing @context. Depending on the flags, more // information may be included. // // This function is intended for testing and debugging of the // CSS implementation in GTK. There are no guarantees about // the format of the returned string, it may change. func (x *StyleContext) ToString(FlagsVar StyleContextPrintFlags) string { cret := xStyleContextToString(x.GoPointer(), FlagsVar) return cret } func (c *StyleContext) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *StyleContext) SetGoPointer(ptr uintptr) { c.Ptr = ptr } var xStyleContextAddProviderForDisplay func(uintptr, uintptr, uint) // Adds a global style provider to @display, which will be used // in style construction for all `GtkStyleContexts` under @display. // // GTK uses this to make styling information from `GtkSettings` // available. // // Note: If both priorities are the same, A `GtkStyleProvider` // added through [method@Gtk.StyleContext.add_provider] takes // precedence over another added through this function. func StyleContextAddProviderForDisplay(DisplayVar *gdk.Display, ProviderVar StyleProvider, PriorityVar uint) { xStyleContextAddProviderForDisplay(DisplayVar.GoPointer(), ProviderVar.GoPointer(), PriorityVar) } var xStyleContextRemoveProviderForDisplay func(uintptr, uintptr) // Removes @provider from the global style providers list in @display. func StyleContextRemoveProviderForDisplay(DisplayVar *gdk.Display, ProviderVar StyleProvider) { xStyleContextRemoveProviderForDisplay(DisplayVar.GoPointer(), ProviderVar.GoPointer()) } 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(&xStyleContextPrintFlagsGLibType, libs, "gtk_style_context_print_flags_get_type") core.PuregoSafeRegister(&xStyleContextGLibType, libs, "gtk_style_context_get_type") core.PuregoSafeRegister(&xStyleContextAddClass, libs, "gtk_style_context_add_class") core.PuregoSafeRegister(&xStyleContextAddProvider, libs, "gtk_style_context_add_provider") core.PuregoSafeRegister(&xStyleContextGetBorder, libs, "gtk_style_context_get_border") core.PuregoSafeRegister(&xStyleContextGetColor, libs, "gtk_style_context_get_color") core.PuregoSafeRegister(&xStyleContextGetDisplay, libs, "gtk_style_context_get_display") core.PuregoSafeRegister(&xStyleContextGetMargin, libs, "gtk_style_context_get_margin") core.PuregoSafeRegister(&xStyleContextGetPadding, libs, "gtk_style_context_get_padding") core.PuregoSafeRegister(&xStyleContextGetScale, libs, "gtk_style_context_get_scale") core.PuregoSafeRegister(&xStyleContextGetState, libs, "gtk_style_context_get_state") core.PuregoSafeRegister(&xStyleContextHasClass, libs, "gtk_style_context_has_class") core.PuregoSafeRegister(&xStyleContextLookupColor, libs, "gtk_style_context_lookup_color") core.PuregoSafeRegister(&xStyleContextRemoveClass, libs, "gtk_style_context_remove_class") core.PuregoSafeRegister(&xStyleContextRemoveProvider, libs, "gtk_style_context_remove_provider") core.PuregoSafeRegister(&xStyleContextRestore, libs, "gtk_style_context_restore") core.PuregoSafeRegister(&xStyleContextSave, libs, "gtk_style_context_save") core.PuregoSafeRegister(&xStyleContextSetDisplay, libs, "gtk_style_context_set_display") core.PuregoSafeRegister(&xStyleContextSetScale, libs, "gtk_style_context_set_scale") core.PuregoSafeRegister(&xStyleContextSetState, libs, "gtk_style_context_set_state") core.PuregoSafeRegister(&xStyleContextToString, libs, "gtk_style_context_to_string") core.PuregoSafeRegister(&xStyleContextAddProviderForDisplay, libs, "gtk_style_context_add_provider_for_display") core.PuregoSafeRegister(&xStyleContextRemoveProviderForDisplay, libs, "gtk_style_context_remove_provider_for_display") }