1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/glib"
11 "github.com/bnema/puregotk/v4/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// Renders a combobox in a cell
16//
17// `GtkCellRendererCombo` renders text in a cell like `GtkCellRendererText` from
18// which it is derived. But while `GtkCellRendererText` offers a simple entry to
19// edit the text, `GtkCellRendererCombo` offers a `GtkComboBox`
20// widget to edit the text. The values to display in the combo box are taken from
21// the tree model specified in the `GtkCellRendererCombo`:model property.
22//
23// The combo cell renderer takes care of adding a text cell renderer to the combo
24// box and sets it to display the column specified by its
25// `GtkCellRendererCombo`:text-column property. Further properties of the combo box
26// can be set in a handler for the `GtkCellRenderer::editing-started` signal.
27type CellRendererCombo struct {
28 CellRendererText
29}
30
31var xCellRendererComboGLibType func() types.GType
32
33func CellRendererComboGLibType() types.GType {
34 return xCellRendererComboGLibType()
35}
36
37func CellRendererComboNewFromInternalPtr(ptr uintptr) *CellRendererCombo {
38 cls := &CellRendererCombo{}
39 cls.Ptr = ptr
40 return cls
41}
42
43var xNewCellRendererCombo func() uintptr
44
45// Creates a new `GtkCellRendererCombo`.
46// Adjust how text is drawn using object properties.
47// Object properties can be set globally (with g_object_set()).
48// Also, with `GtkTreeViewColumn`, you can bind a property to a value
49// in a `GtkTreeModel`. For example, you can bind the “text” property
50// on the cell renderer to a string value in the model, thus rendering
51// a different string in each row of the `GtkTreeView`.
52func NewCellRendererCombo() *CellRendererCombo {
53 var cls *CellRendererCombo
54
55 cret := xNewCellRendererCombo()
56
57 if cret == 0 {
58 return nil
59 }
60 gobject.IncreaseRef(cret)
61 cls = &CellRendererCombo{}
62 cls.Ptr = cret
63 return cls
64}
65
66func (c *CellRendererCombo) GoPointer() uintptr {
67 if c == nil {
68 return 0
69 }
70 return c.Ptr
71}
72
73func (c *CellRendererCombo) SetGoPointer(ptr uintptr) {
74 c.Ptr = ptr
75}
76
77// SetPropertyHasEntry sets the "has-entry" property.
78// If %TRUE, the cell renderer will include an entry and allow to enter
79// values other than the ones in the popup list.
80func (x *CellRendererCombo) SetPropertyHasEntry(value bool) {
81 var v gobject.Value
82 v.Init(gobject.TypeBooleanVal)
83 v.SetBoolean(value)
84 x.SetProperty("has-entry", &v)
85}
86
87// GetPropertyHasEntry gets the "has-entry" property.
88// If %TRUE, the cell renderer will include an entry and allow to enter
89// values other than the ones in the popup list.
90func (x *CellRendererCombo) GetPropertyHasEntry() bool {
91 var v gobject.Value
92 x.GetProperty("has-entry", &v)
93 return v.GetBoolean()
94}
95
96// SetPropertyTextColumn sets the "text-column" property.
97// Specifies the model column which holds the possible values for the
98// combo box.
99//
100// Note that this refers to the model specified in the model property,
101// not the model backing the tree view to which
102// this cell renderer is attached.
103//
104// `GtkCellRendererCombo` automatically adds a text cell renderer for
105// this column to its combo box.
106func (x *CellRendererCombo) SetPropertyTextColumn(value int) {
107 var v gobject.Value
108 v.Init(gobject.TypeIntVal)
109 v.SetInt(value)
110 x.SetProperty("text-column", &v)
111}
112
113// GetPropertyTextColumn gets the "text-column" property.
114// Specifies the model column which holds the possible values for the
115// combo box.
116//
117// Note that this refers to the model specified in the model property,
118// not the model backing the tree view to which
119// this cell renderer is attached.
120//
121// `GtkCellRendererCombo` automatically adds a text cell renderer for
122// this column to its combo box.
123func (x *CellRendererCombo) GetPropertyTextColumn() int {
124 var v gobject.Value
125 x.GetProperty("text-column", &v)
126 return v.GetInt()
127}
128
129// This signal is emitted each time after the user selected an item in
130// the combo box, either by using the mouse or the arrow keys. Contrary
131// to GtkComboBox, GtkCellRendererCombo::changed is not emitted for
132// changes made to a selected item in the entry. The argument @new_iter
133// corresponds to the newly selected item in the combo box and it is relative
134// to the GtkTreeModel set via the model property on GtkCellRendererCombo.
135//
136// Note that as soon as you change the model displayed in the tree view,
137// the tree view will immediately cease the editing operating. This
138// means that you most probably want to refrain from changing the model
139// until the combo cell renderer emits the edited or editing_canceled signal.
140func (x *CellRendererCombo) ConnectChanged(cb *func(CellRendererCombo, string, uintptr)) uint {
141 cbPtr := uintptr(unsafe.Pointer(cb))
142 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
143 handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr)
144 glib.SaveHandlerMapping(handlerID, cbPtr)
145 return handlerID
146 }
147
148 fcb := func(clsPtr uintptr, PathStringVarp uintptr, NewIterVarp uintptr) {
149 fa := CellRendererCombo{}
150 fa.Ptr = clsPtr
151 cbFn := *cb
152
153 cbFn(fa, core.GoString(PathStringVarp), NewIterVarp)
154
155 }
156 cbRefPtr := purego.NewCallback(fcb)
157 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
158 handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr)
159 glib.SaveHandlerMapping(handlerID, cbPtr)
160 return handlerID
161}
162
163func init() {
164 core.SetPackageName("GTK", "gtk4")
165 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
166 var libs []uintptr
167 for _, libPath := range core.GetPaths("GTK") {
168 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
169 if err != nil {
170 panic(err)
171 }
172 libs = append(libs, lib)
173 }
174
175 core.PuregoSafeRegister(&xCellRendererComboGLibType, libs, "gtk_cell_renderer_combo_get_type")
176
177 core.PuregoSafeRegister(&xNewCellRendererCombo, libs, "gtk_cell_renderer_combo_new")
178
179}