1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gdk"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type CellEditableIface struct {
17 _ structs.HostLayout
18
19 GIface uintptr
20
21 xEditingDone uintptr
22
23 xRemoveWidget uintptr
24
25 xStartEditing uintptr
26}
27
28func (x *CellEditableIface) GoPointer() uintptr {
29 return uintptr(unsafe.Pointer(x))
30}
31
32// OverrideEditingDone sets the "editing_done" callback function.
33// Signal is a sign for the cell renderer to update its
34//
35// value from the cell_editable.
36func (x *CellEditableIface) OverrideEditingDone(cb func(CellEditable)) {
37 if cb == nil {
38 x.xEditingDone = 0
39 } else {
40 x.xEditingDone = purego.NewCallback(func(CellEditableVarp uintptr) {
41 cb(&CellEditableBase{Ptr: CellEditableVarp})
42 })
43 }
44}
45
46// GetEditingDone gets the "editing_done" callback function.
47// Signal is a sign for the cell renderer to update its
48//
49// value from the cell_editable.
50func (x *CellEditableIface) GetEditingDone() func(CellEditable) {
51 if x.xEditingDone == 0 {
52 return nil
53 }
54 var rawCallback func(CellEditableVarp uintptr)
55 purego.RegisterFunc(&rawCallback, x.xEditingDone)
56 return func(CellEditableVar CellEditable) {
57 rawCallback(CellEditableVar.GoPointer())
58 }
59}
60
61// OverrideRemoveWidget sets the "remove_widget" callback function.
62// Signal is meant to indicate that the cell is
63//
64// finished editing, and the widget may now be destroyed.
65func (x *CellEditableIface) OverrideRemoveWidget(cb func(CellEditable)) {
66 if cb == nil {
67 x.xRemoveWidget = 0
68 } else {
69 x.xRemoveWidget = purego.NewCallback(func(CellEditableVarp uintptr) {
70 cb(&CellEditableBase{Ptr: CellEditableVarp})
71 })
72 }
73}
74
75// GetRemoveWidget gets the "remove_widget" callback function.
76// Signal is meant to indicate that the cell is
77//
78// finished editing, and the widget may now be destroyed.
79func (x *CellEditableIface) GetRemoveWidget() func(CellEditable) {
80 if x.xRemoveWidget == 0 {
81 return nil
82 }
83 var rawCallback func(CellEditableVarp uintptr)
84 purego.RegisterFunc(&rawCallback, x.xRemoveWidget)
85 return func(CellEditableVar CellEditable) {
86 rawCallback(CellEditableVar.GoPointer())
87 }
88}
89
90// OverrideStartEditing sets the "start_editing" callback function.
91// Begins editing on a cell_editable.
92func (x *CellEditableIface) OverrideStartEditing(cb func(CellEditable, *gdk.Event)) {
93 if cb == nil {
94 x.xStartEditing = 0
95 } else {
96 x.xStartEditing = purego.NewCallback(func(CellEditableVarp uintptr, EventVarp uintptr) {
97 cb(&CellEditableBase{Ptr: CellEditableVarp}, gdk.EventNewFromInternalPtr(EventVarp))
98 })
99 }
100}
101
102// GetStartEditing gets the "start_editing" callback function.
103// Begins editing on a cell_editable.
104func (x *CellEditableIface) GetStartEditing() func(CellEditable, *gdk.Event) {
105 if x.xStartEditing == 0 {
106 return nil
107 }
108 var rawCallback func(CellEditableVarp uintptr, EventVarp uintptr)
109 purego.RegisterFunc(&rawCallback, x.xStartEditing)
110 return func(CellEditableVar CellEditable, EventVar *gdk.Event) {
111 rawCallback(CellEditableVar.GoPointer(), EventVar.GoPointer())
112 }
113}
114
115// Interface for widgets that can be used for editing cells
116//
117// The `GtkCellEditable` interface must be implemented for widgets to be usable
118// to edit the contents of a `GtkTreeView` cell. It provides a way to specify how
119// temporary widgets should be configured for editing, get the new value, etc.
120type CellEditable interface {
121 GoPointer() uintptr
122 SetGoPointer(uintptr)
123 EditingDone()
124 RemoveWidget()
125 StartEditing(EventVar *gdk.Event)
126}
127
128var xCellEditableGLibType func() types.GType
129
130func CellEditableGLibType() types.GType {
131 return xCellEditableGLibType()
132}
133
134type CellEditableBase struct {
135 Ptr uintptr
136}
137
138func (x *CellEditableBase) GoPointer() uintptr {
139 if x == nil {
140 return 0
141 }
142 return x.Ptr
143}
144
145func (x *CellEditableBase) SetGoPointer(ptr uintptr) {
146 x.Ptr = ptr
147}
148
149// Emits the `GtkCellEditable::editing-done` signal.
150func (x *CellEditableBase) EditingDone() {
151
152 XGtkCellEditableEditingDone(x.GoPointer())
153
154}
155
156// Emits the `GtkCellEditable::remove-widget` signal.
157func (x *CellEditableBase) RemoveWidget() {
158
159 XGtkCellEditableRemoveWidget(x.GoPointer())
160
161}
162
163// Begins editing on a @cell_editable.
164//
165// The `GtkCellRenderer` for the cell creates and returns a `GtkCellEditable` from
166// gtk_cell_renderer_start_editing(), configured for the `GtkCellRenderer` type.
167//
168// gtk_cell_editable_start_editing() can then set up @cell_editable suitably for
169// editing a cell, e.g. making the Esc key emit `GtkCellEditable::editing-done`.
170//
171// Note that the @cell_editable is created on-demand for the current edit; its
172// lifetime is temporary and does not persist across other edits and/or cells.
173func (x *CellEditableBase) StartEditing(EventVar *gdk.Event) {
174
175 XGtkCellEditableStartEditing(x.GoPointer(), EventVar.GoPointer())
176
177}
178
179// SetPropertyEditingCanceled sets the "editing-canceled" property.
180// Indicates whether editing on the cell has been canceled.
181func (x *CellEditableBase) SetPropertyEditingCanceled(value bool) {
182 obj := gobject.Object{}
183 obj.Ptr = x.GoPointer()
184 var v gobject.Value
185 v.Init(gobject.TypeBooleanVal)
186 v.SetBoolean(value)
187 obj.SetProperty("editing-canceled", &v)
188}
189
190// GetPropertyEditingCanceled gets the "editing-canceled" property.
191// Indicates whether editing on the cell has been canceled.
192func (x *CellEditableBase) GetPropertyEditingCanceled() bool {
193 obj := gobject.Object{}
194 obj.Ptr = x.GoPointer()
195 var v gobject.Value
196 obj.GetProperty("editing-canceled", &v)
197 return v.GetBoolean()
198}
199
200var XGtkCellEditableEditingDone func(uintptr)
201var XGtkCellEditableRemoveWidget func(uintptr)
202var XGtkCellEditableStartEditing func(uintptr, uintptr)
203
204func init() {
205 core.SetPackageName("GTK", "gtk4")
206 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
207 var libs []uintptr
208 for _, libPath := range core.GetPaths("GTK") {
209 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
210 if err != nil {
211 panic(err)
212 }
213 libs = append(libs, lib)
214 }
215
216 core.PuregoSafeRegister(&xCellEditableGLibType, libs, "gtk_cell_editable_get_type")
217
218 core.PuregoSafeRegister(&XGtkCellEditableEditingDone, libs, "gtk_cell_editable_editing_done")
219 core.PuregoSafeRegister(&XGtkCellEditableRemoveWidget, libs, "gtk_cell_editable_remove_widget")
220 core.PuregoSafeRegister(&XGtkCellEditableStartEditing, libs, "gtk_cell_editable_start_editing")
221
222}