// 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" ) // A function which should set the value of @cell_layout’s cell renderer(s) // as appropriate. type CellLayoutDataFunc func(uintptr, uintptr, uintptr, *TreeIter, uintptr) type CellLayoutIface struct { _ structs.HostLayout GIface uintptr xPackStart uintptr xPackEnd uintptr xClear uintptr xAddAttribute uintptr xSetCellDataFunc uintptr xClearAttributes uintptr xReorder uintptr xGetCells uintptr xGetArea uintptr } func (x *CellLayoutIface) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverridePackStart sets the "pack_start" callback function. // Packs the cell into the beginning of cell_layout. func (x *CellLayoutIface) OverridePackStart(cb func(CellLayout, *CellRenderer, bool)) { if cb == nil { x.xPackStart = 0 } else { x.xPackStart = purego.NewCallback(func(CellLayoutVarp uintptr, CellVarp uintptr, ExpandVarp bool) { cb(&CellLayoutBase{Ptr: CellLayoutVarp}, CellRendererNewFromInternalPtr(CellVarp), ExpandVarp) }) } } // GetPackStart gets the "pack_start" callback function. // Packs the cell into the beginning of cell_layout. func (x *CellLayoutIface) GetPackStart() func(CellLayout, *CellRenderer, bool) { if x.xPackStart == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr, CellVarp uintptr, ExpandVarp bool) purego.RegisterFunc(&rawCallback, x.xPackStart) return func(CellLayoutVar CellLayout, CellVar *CellRenderer, ExpandVar bool) { rawCallback(CellLayoutVar.GoPointer(), CellVar.GoPointer(), ExpandVar) } } // OverridePackEnd sets the "pack_end" callback function. // Adds the cell to the end of cell_layout. func (x *CellLayoutIface) OverridePackEnd(cb func(CellLayout, *CellRenderer, bool)) { if cb == nil { x.xPackEnd = 0 } else { x.xPackEnd = purego.NewCallback(func(CellLayoutVarp uintptr, CellVarp uintptr, ExpandVarp bool) { cb(&CellLayoutBase{Ptr: CellLayoutVarp}, CellRendererNewFromInternalPtr(CellVarp), ExpandVarp) }) } } // GetPackEnd gets the "pack_end" callback function. // Adds the cell to the end of cell_layout. func (x *CellLayoutIface) GetPackEnd() func(CellLayout, *CellRenderer, bool) { if x.xPackEnd == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr, CellVarp uintptr, ExpandVarp bool) purego.RegisterFunc(&rawCallback, x.xPackEnd) return func(CellLayoutVar CellLayout, CellVar *CellRenderer, ExpandVar bool) { rawCallback(CellLayoutVar.GoPointer(), CellVar.GoPointer(), ExpandVar) } } // OverrideClear sets the "clear" callback function. // Unsets all the mappings on all renderers on cell_layout and // // removes all renderers from cell_layout. func (x *CellLayoutIface) OverrideClear(cb func(CellLayout)) { if cb == nil { x.xClear = 0 } else { x.xClear = purego.NewCallback(func(CellLayoutVarp uintptr) { cb(&CellLayoutBase{Ptr: CellLayoutVarp}) }) } } // GetClear gets the "clear" callback function. // Unsets all the mappings on all renderers on cell_layout and // // removes all renderers from cell_layout. func (x *CellLayoutIface) GetClear() func(CellLayout) { if x.xClear == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr) purego.RegisterFunc(&rawCallback, x.xClear) return func(CellLayoutVar CellLayout) { rawCallback(CellLayoutVar.GoPointer()) } } // OverrideAddAttribute sets the "add_attribute" callback function. // Adds an attribute mapping to the list in // // cell_layout. func (x *CellLayoutIface) OverrideAddAttribute(cb func(CellLayout, *CellRenderer, string, int)) { if cb == nil { x.xAddAttribute = 0 } else { x.xAddAttribute = purego.NewCallback(func(CellLayoutVarp uintptr, CellVarp uintptr, AttributeVarp string, ColumnVarp int) { cb(&CellLayoutBase{Ptr: CellLayoutVarp}, CellRendererNewFromInternalPtr(CellVarp), AttributeVarp, ColumnVarp) }) } } // GetAddAttribute gets the "add_attribute" callback function. // Adds an attribute mapping to the list in // // cell_layout. func (x *CellLayoutIface) GetAddAttribute() func(CellLayout, *CellRenderer, string, int) { if x.xAddAttribute == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr, CellVarp uintptr, AttributeVarp string, ColumnVarp int) purego.RegisterFunc(&rawCallback, x.xAddAttribute) return func(CellLayoutVar CellLayout, CellVar *CellRenderer, AttributeVar string, ColumnVar int) { rawCallback(CellLayoutVar.GoPointer(), CellVar.GoPointer(), AttributeVar, ColumnVar) } } // OverrideSetCellDataFunc sets the "set_cell_data_func" callback function. // Sets the `GtkCellLayout`DataFunc to use for // // cell_layout. func (x *CellLayoutIface) OverrideSetCellDataFunc(cb func(CellLayout, *CellRenderer, *CellLayoutDataFunc, uintptr, *glib.DestroyNotify)) { if cb == nil { x.xSetCellDataFunc = 0 } else { x.xSetCellDataFunc = purego.NewCallback(func(CellLayoutVarp uintptr, CellVarp uintptr, FuncVarp uintptr, FuncDataVarp uintptr, DestroyVarp uintptr) { cb(&CellLayoutBase{Ptr: CellLayoutVarp}, CellRendererNewFromInternalPtr(CellVarp), (*CellLayoutDataFunc)(unsafe.Pointer(FuncVarp)), FuncDataVarp, (*glib.DestroyNotify)(unsafe.Pointer(DestroyVarp))) }) } } // GetSetCellDataFunc gets the "set_cell_data_func" callback function. // Sets the `GtkCellLayout`DataFunc to use for // // cell_layout. func (x *CellLayoutIface) GetSetCellDataFunc() func(CellLayout, *CellRenderer, *CellLayoutDataFunc, uintptr, *glib.DestroyNotify) { if x.xSetCellDataFunc == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr, CellVarp uintptr, FuncVarp uintptr, FuncDataVarp uintptr, DestroyVarp uintptr) purego.RegisterFunc(&rawCallback, x.xSetCellDataFunc) return func(CellLayoutVar CellLayout, CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { rawCallback(CellLayoutVar.GoPointer(), CellVar.GoPointer(), glib.NewCallbackNullable(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) } } // OverrideClearAttributes sets the "clear_attributes" callback function. // Clears all existing attributes previously set // // with gtk_cell_layout_set_attributes(). func (x *CellLayoutIface) OverrideClearAttributes(cb func(CellLayout, *CellRenderer)) { if cb == nil { x.xClearAttributes = 0 } else { x.xClearAttributes = purego.NewCallback(func(CellLayoutVarp uintptr, CellVarp uintptr) { cb(&CellLayoutBase{Ptr: CellLayoutVarp}, CellRendererNewFromInternalPtr(CellVarp)) }) } } // GetClearAttributes gets the "clear_attributes" callback function. // Clears all existing attributes previously set // // with gtk_cell_layout_set_attributes(). func (x *CellLayoutIface) GetClearAttributes() func(CellLayout, *CellRenderer) { if x.xClearAttributes == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr, CellVarp uintptr) purego.RegisterFunc(&rawCallback, x.xClearAttributes) return func(CellLayoutVar CellLayout, CellVar *CellRenderer) { rawCallback(CellLayoutVar.GoPointer(), CellVar.GoPointer()) } } // OverrideReorder sets the "reorder" callback function. // Re-inserts cell at position. func (x *CellLayoutIface) OverrideReorder(cb func(CellLayout, *CellRenderer, int)) { if cb == nil { x.xReorder = 0 } else { x.xReorder = purego.NewCallback(func(CellLayoutVarp uintptr, CellVarp uintptr, PositionVarp int) { cb(&CellLayoutBase{Ptr: CellLayoutVarp}, CellRendererNewFromInternalPtr(CellVarp), PositionVarp) }) } } // GetReorder gets the "reorder" callback function. // Re-inserts cell at position. func (x *CellLayoutIface) GetReorder() func(CellLayout, *CellRenderer, int) { if x.xReorder == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr, CellVarp uintptr, PositionVarp int) purego.RegisterFunc(&rawCallback, x.xReorder) return func(CellLayoutVar CellLayout, CellVar *CellRenderer, PositionVar int) { rawCallback(CellLayoutVar.GoPointer(), CellVar.GoPointer(), PositionVar) } } // OverrideGetCells sets the "get_cells" callback function. // Get the cell renderers which have been added to // // cell_layout. func (x *CellLayoutIface) OverrideGetCells(cb func(CellLayout) *glib.List) { if cb == nil { x.xGetCells = 0 } else { x.xGetCells = purego.NewCallback(func(CellLayoutVarp uintptr) *glib.List { return cb(&CellLayoutBase{Ptr: CellLayoutVarp}) }) } } // GetGetCells gets the "get_cells" callback function. // Get the cell renderers which have been added to // // cell_layout. func (x *CellLayoutIface) GetGetCells() func(CellLayout) *glib.List { if x.xGetCells == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr) *glib.List purego.RegisterFunc(&rawCallback, x.xGetCells) return func(CellLayoutVar CellLayout) *glib.List { return rawCallback(CellLayoutVar.GoPointer()) } } // OverrideGetArea sets the "get_area" callback function. // Get the underlying `GtkCellArea` which might be // // cell_layout if called on a `GtkCellArea` or might be NULL if no // `GtkCellArea` is used by cell_layout. func (x *CellLayoutIface) OverrideGetArea(cb func(CellLayout) *CellArea) { if cb == nil { x.xGetArea = 0 } else { x.xGetArea = purego.NewCallback(func(CellLayoutVarp uintptr) uintptr { ret := cb(&CellLayoutBase{Ptr: CellLayoutVarp}) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetGetArea gets the "get_area" callback function. // Get the underlying `GtkCellArea` which might be // // cell_layout if called on a `GtkCellArea` or might be NULL if no // `GtkCellArea` is used by cell_layout. func (x *CellLayoutIface) GetGetArea() func(CellLayout) *CellArea { if x.xGetArea == 0 { return nil } var rawCallback func(CellLayoutVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xGetArea) return func(CellLayoutVar CellLayout) *CellArea { rawRet := rawCallback(CellLayoutVar.GoPointer()) if rawRet == 0 { return nil } ret := &CellArea{} ret.Ptr = rawRet return ret } } // An interface for packing cells // // `GtkCellLayout` is an interface to be implemented by all objects which // want to provide a `GtkTreeViewColumn` like API for packing cells, // setting attributes and data funcs. // // One of the notable features provided by implementations of // `GtkCellLayout` are attributes. Attributes let you set the properties // in flexible ways. They can just be set to constant values like regular // properties. But they can also be mapped to a column of the underlying // tree model with gtk_cell_layout_set_attributes(), which means that the value // of the attribute can change from cell to cell as they are rendered by // the cell renderer. Finally, it is possible to specify a function with // gtk_cell_layout_set_cell_data_func() that is called to determine the // value of the attribute for each cell that is rendered. // // ## GtkCellLayouts as GtkBuildable // // Implementations of GtkCellLayout which also implement the GtkBuildable // interface (`GtkCellView`, `GtkIconView`, `GtkComboBox`, // `GtkEntryCompletion`, `GtkTreeViewColumn`) accept `GtkCellRenderer` objects // as `<child>` elements in UI definitions. They support a custom `<attributes>` // element for their children, which can contain multiple `<attribute>` // elements. Each `<attribute>` element has a name attribute which specifies // a property of the cell renderer; the content of the element is the // attribute value. // // This is an example of a UI definition fragment specifying attributes: // // ```xml // <object class="GtkCellView"> // // <child> // <object class="GtkCellRendererText"/> // <attributes> // <attribute name="text">0</attribute> // </attributes> // </child> // // </object> // ``` // // Furthermore for implementations of `GtkCellLayout` that use a `GtkCellArea` // to lay out cells (all `GtkCellLayout`s in GTK use a `GtkCellArea`) // [cell properties](class.CellArea.html#cell-properties) can also be defined // in the format by specifying the custom `<cell-packing>` attribute which can // contain multiple `<property>` elements. // // Here is a UI definition fragment specifying cell properties: // // ```xml // <object class="GtkTreeViewColumn"> // // <child> // <object class="GtkCellRendererText"/> // <cell-packing> // <property name="align">True</property> // <property name="expand">False</property> // </cell-packing> // </child> // // </object> // ``` // // ## Subclassing GtkCellLayout implementations // // When subclassing a widget that implements `GtkCellLayout` like // `GtkIconView` or `GtkComboBox`, there are some considerations related // to the fact that these widgets internally use a `GtkCellArea`. // The cell area is exposed as a construct-only property by these // widgets. This means that it is possible to e.g. do // // ```c // GtkWIdget *combo = // // g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL); // // ``` // // to use a custom cell area with a combo box. But construct properties // are only initialized after instance `init()` // functions have run, which means that using functions which rely on // the existence of the cell area in your subclass `init()` function will // cause the default cell area to be instantiated. In this case, a provided // construct property value will be ignored (with a warning, to alert // you to the problem). // // ```c // static void // my_combo_box_init (MyComboBox *b) // // { // GtkCellRenderer *cell; // // cell = gtk_cell_renderer_pixbuf_new (); // // // The following call causes the default cell area for combo boxes, // // a GtkCellAreaBox, to be instantiated // gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (b), cell, FALSE); // ... // } // // GtkWidget * // my_combo_box_new (GtkCellArea *area) // // { // // This call is going to cause a warning about area being ignored // return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL); // } // // ``` // // If supporting alternative cell areas with your derived widget is // not important, then this does not have to concern you. If you want // to support alternative cell areas, you can do so by moving the // problematic calls out of `init()` and into a `constructor()` // for your class. type CellLayout interface { GoPointer() uintptr SetGoPointer(uintptr) AddAttribute(CellVar *CellRenderer, AttributeVar string, ColumnVar int) Clear() ClearAttributes(CellVar *CellRenderer) GetArea() *CellArea GetCells() *glib.List PackEnd(CellVar *CellRenderer, ExpandVar bool) PackStart(CellVar *CellRenderer, ExpandVar bool) Reorder(CellVar *CellRenderer, PositionVar int) SetAttributes(CellVar *CellRenderer, varArgs ...interface{}) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) } var xCellLayoutGLibType func() types.GType func CellLayoutGLibType() types.GType { return xCellLayoutGLibType() } type CellLayoutBase struct { Ptr uintptr } func (x *CellLayoutBase) GoPointer() uintptr { if x == nil { return 0 } return x.Ptr } func (x *CellLayoutBase) SetGoPointer(ptr uintptr) { x.Ptr = ptr } // Adds an attribute mapping to the list in @cell_layout. // // The @column is the column of the model to get a value from, and the // @attribute is the property on @cell to be set from that value. So for // example if column 2 of the model contains strings, you could have the // “text” attribute of a `GtkCellRendererText` get its values from column 2. // In this context "attribute" and "property" are used interchangeably. func (x *CellLayoutBase) AddAttribute(CellVar *CellRenderer, AttributeVar string, ColumnVar int) { XGtkCellLayoutAddAttribute(x.GoPointer(), CellVar.GoPointer(), AttributeVar, ColumnVar) } // Unsets all the mappings on all renderers on @cell_layout and // removes all renderers from @cell_layout. func (x *CellLayoutBase) Clear() { XGtkCellLayoutClear(x.GoPointer()) } // Clears all existing attributes previously set with // gtk_cell_layout_set_attributes(). func (x *CellLayoutBase) ClearAttributes(CellVar *CellRenderer) { XGtkCellLayoutClearAttributes(x.GoPointer(), CellVar.GoPointer()) } // Returns the underlying `GtkCellArea` which might be @cell_layout // if called on a `GtkCellArea` or might be %NULL if no `GtkCellArea` // is used by @cell_layout. func (x *CellLayoutBase) GetArea() *CellArea { var cls *CellArea cret := XGtkCellLayoutGetArea(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &CellArea{} cls.Ptr = cret return cls } // Returns the cell renderers which have been added to @cell_layout. func (x *CellLayoutBase) GetCells() *glib.List { cret := XGtkCellLayoutGetCells(x.GoPointer()) return cret } // Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the // @cell is allocated no more space than it needs. Any unused space is // divided evenly between cells for which @expand is %TRUE. // // Note that reusing the same cell renderer is not supported. func (x *CellLayoutBase) PackEnd(CellVar *CellRenderer, ExpandVar bool) { XGtkCellLayoutPackEnd(x.GoPointer(), CellVar.GoPointer(), ExpandVar) } // Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE, // then the @cell is allocated no more space than it needs. Any unused space // is divided evenly between cells for which @expand is %TRUE. // // Note that reusing the same cell renderer is not supported. func (x *CellLayoutBase) PackStart(CellVar *CellRenderer, ExpandVar bool) { XGtkCellLayoutPackStart(x.GoPointer(), CellVar.GoPointer(), ExpandVar) } // Re-inserts @cell at @position. // // Note that @cell has already to be packed into @cell_layout // for this to function properly. func (x *CellLayoutBase) Reorder(CellVar *CellRenderer, PositionVar int) { XGtkCellLayoutReorder(x.GoPointer(), CellVar.GoPointer(), PositionVar) } // Sets the attributes in the parameter list as the attributes // of @cell_layout. // // See [method@Gtk.CellLayout.add_attribute] for more details. // // The attributes should be in attribute/column order, as in // gtk_cell_layout_add_attribute(). All existing attributes are // removed, and replaced with the new attributes. func (x *CellLayoutBase) SetAttributes(CellVar *CellRenderer, varArgs ...interface{}) { XGtkCellLayoutSetAttributes(x.GoPointer(), CellVar.GoPointer(), varArgs...) } // Sets the `GtkCellLayout`DataFunc to use for @cell_layout. // // This function is used instead of the standard attributes mapping // for setting the column value, and should set the value of @cell_layout’s // cell renderer(s) as appropriate. // // @func may be %NULL to remove a previously set function. func (x *CellLayoutBase) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallbackNullable(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) } var XGtkCellLayoutAddAttribute func(uintptr, uintptr, string, int) var XGtkCellLayoutClear func(uintptr) var XGtkCellLayoutClearAttributes func(uintptr, uintptr) var XGtkCellLayoutGetArea func(uintptr) uintptr var XGtkCellLayoutGetCells func(uintptr) *glib.List var XGtkCellLayoutPackEnd func(uintptr, uintptr, bool) var XGtkCellLayoutPackStart func(uintptr, uintptr, bool) var XGtkCellLayoutReorder func(uintptr, uintptr, int) var XGtkCellLayoutSetAttributes func(uintptr, uintptr, ...interface{}) var XGtkCellLayoutSetCellDataFunc func(uintptr, uintptr, uintptr, uintptr, uintptr) 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(&xCellLayoutGLibType, libs, "gtk_cell_layout_get_type") core.PuregoSafeRegister(&XGtkCellLayoutAddAttribute, libs, "gtk_cell_layout_add_attribute") core.PuregoSafeRegister(&XGtkCellLayoutClear, libs, "gtk_cell_layout_clear") core.PuregoSafeRegister(&XGtkCellLayoutClearAttributes, libs, "gtk_cell_layout_clear_attributes") core.PuregoSafeRegister(&XGtkCellLayoutGetArea, libs, "gtk_cell_layout_get_area") core.PuregoSafeRegister(&XGtkCellLayoutGetCells, libs, "gtk_cell_layout_get_cells") core.PuregoSafeRegister(&XGtkCellLayoutPackEnd, libs, "gtk_cell_layout_pack_end") core.PuregoSafeRegister(&XGtkCellLayoutPackStart, libs, "gtk_cell_layout_pack_start") core.PuregoSafeRegister(&XGtkCellLayoutReorder, libs, "gtk_cell_layout_reorder") core.PuregoSafeRegister(&XGtkCellLayoutSetAttributes, libs, "gtk_cell_layout_set_attributes") core.PuregoSafeRegister(&XGtkCellLayoutSetCellDataFunc, libs, "gtk_cell_layout_set_cell_data_func") }