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/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// Class structure for `GtkNativeDialog`.
17type NativeDialogClass struct {
18 _ structs.HostLayout
19
20 ParentClass gobject.ObjectClass
21
22 xResponse uintptr
23
24 xShow uintptr
25
26 xHide uintptr
27
28 xGtkReserved1 uintptr
29
30 xGtkReserved2 uintptr
31
32 xGtkReserved3 uintptr
33
34 xGtkReserved4 uintptr
35}
36
37func (x *NativeDialogClass) GoPointer() uintptr {
38 return uintptr(unsafe.Pointer(x))
39}
40
41// OverrideResponse sets the "response" callback function.
42// class handler for the `GtkNativeDialog::response` signal
43func (x *NativeDialogClass) OverrideResponse(cb func(*NativeDialog, int)) {
44 if cb == nil {
45 x.xResponse = 0
46 } else {
47 x.xResponse = purego.NewCallback(func(SelfVarp uintptr, ResponseIdVarp int) {
48 cb(NativeDialogNewFromInternalPtr(SelfVarp), ResponseIdVarp)
49 })
50 }
51}
52
53// GetResponse gets the "response" callback function.
54// class handler for the `GtkNativeDialog::response` signal
55func (x *NativeDialogClass) GetResponse() func(*NativeDialog, int) {
56 if x.xResponse == 0 {
57 return nil
58 }
59 var rawCallback func(SelfVarp uintptr, ResponseIdVarp int)
60 purego.RegisterFunc(&rawCallback, x.xResponse)
61 return func(SelfVar *NativeDialog, ResponseIdVar int) {
62 rawCallback(SelfVar.GoPointer(), ResponseIdVar)
63 }
64}
65
66// OverrideShow sets the "show" callback function.
67func (x *NativeDialogClass) OverrideShow(cb func(*NativeDialog)) {
68 if cb == nil {
69 x.xShow = 0
70 } else {
71 x.xShow = purego.NewCallback(func(SelfVarp uintptr) {
72 cb(NativeDialogNewFromInternalPtr(SelfVarp))
73 })
74 }
75}
76
77// GetShow gets the "show" callback function.
78func (x *NativeDialogClass) GetShow() func(*NativeDialog) {
79 if x.xShow == 0 {
80 return nil
81 }
82 var rawCallback func(SelfVarp uintptr)
83 purego.RegisterFunc(&rawCallback, x.xShow)
84 return func(SelfVar *NativeDialog) {
85 rawCallback(SelfVar.GoPointer())
86 }
87}
88
89// OverrideHide sets the "hide" callback function.
90func (x *NativeDialogClass) OverrideHide(cb func(*NativeDialog)) {
91 if cb == nil {
92 x.xHide = 0
93 } else {
94 x.xHide = purego.NewCallback(func(SelfVarp uintptr) {
95 cb(NativeDialogNewFromInternalPtr(SelfVarp))
96 })
97 }
98}
99
100// GetHide gets the "hide" callback function.
101func (x *NativeDialogClass) GetHide() func(*NativeDialog) {
102 if x.xHide == 0 {
103 return nil
104 }
105 var rawCallback func(SelfVarp uintptr)
106 purego.RegisterFunc(&rawCallback, x.xHide)
107 return func(SelfVar *NativeDialog) {
108 rawCallback(SelfVar.GoPointer())
109 }
110}
111
112// OverrideGtkReserved1 sets the "_gtk_reserved1" callback function.
113func (x *NativeDialogClass) OverrideGtkReserved1(cb func()) {
114 if cb == nil {
115 x.xGtkReserved1 = 0
116 } else {
117 x.xGtkReserved1 = purego.NewCallback(func() {
118 cb()
119 })
120 }
121}
122
123// GetGtkReserved1 gets the "_gtk_reserved1" callback function.
124func (x *NativeDialogClass) GetGtkReserved1() func() {
125 if x.xGtkReserved1 == 0 {
126 return nil
127 }
128 var rawCallback func()
129 purego.RegisterFunc(&rawCallback, x.xGtkReserved1)
130 return func() {
131 rawCallback()
132 }
133}
134
135// OverrideGtkReserved2 sets the "_gtk_reserved2" callback function.
136func (x *NativeDialogClass) OverrideGtkReserved2(cb func()) {
137 if cb == nil {
138 x.xGtkReserved2 = 0
139 } else {
140 x.xGtkReserved2 = purego.NewCallback(func() {
141 cb()
142 })
143 }
144}
145
146// GetGtkReserved2 gets the "_gtk_reserved2" callback function.
147func (x *NativeDialogClass) GetGtkReserved2() func() {
148 if x.xGtkReserved2 == 0 {
149 return nil
150 }
151 var rawCallback func()
152 purego.RegisterFunc(&rawCallback, x.xGtkReserved2)
153 return func() {
154 rawCallback()
155 }
156}
157
158// OverrideGtkReserved3 sets the "_gtk_reserved3" callback function.
159func (x *NativeDialogClass) OverrideGtkReserved3(cb func()) {
160 if cb == nil {
161 x.xGtkReserved3 = 0
162 } else {
163 x.xGtkReserved3 = purego.NewCallback(func() {
164 cb()
165 })
166 }
167}
168
169// GetGtkReserved3 gets the "_gtk_reserved3" callback function.
170func (x *NativeDialogClass) GetGtkReserved3() func() {
171 if x.xGtkReserved3 == 0 {
172 return nil
173 }
174 var rawCallback func()
175 purego.RegisterFunc(&rawCallback, x.xGtkReserved3)
176 return func() {
177 rawCallback()
178 }
179}
180
181// OverrideGtkReserved4 sets the "_gtk_reserved4" callback function.
182func (x *NativeDialogClass) OverrideGtkReserved4(cb func()) {
183 if cb == nil {
184 x.xGtkReserved4 = 0
185 } else {
186 x.xGtkReserved4 = purego.NewCallback(func() {
187 cb()
188 })
189 }
190}
191
192// GetGtkReserved4 gets the "_gtk_reserved4" callback function.
193func (x *NativeDialogClass) GetGtkReserved4() func() {
194 if x.xGtkReserved4 == 0 {
195 return nil
196 }
197 var rawCallback func()
198 purego.RegisterFunc(&rawCallback, x.xGtkReserved4)
199 return func() {
200 rawCallback()
201 }
202}
203
204// Base class for platform dialogs that don't use `GtkDialog`.
205//
206// Native dialogs are used in order to integrate better with a platform,
207// by looking the same as other native applications and supporting
208// platform specific features.
209//
210// The [class@Gtk.Dialog] functions cannot be used on such objects,
211// but we need a similar API in order to drive them. The `GtkNativeDialog`
212// object is an API that allows you to do this. It allows you to set
213// various common properties on the dialog, as well as show and hide
214// it and get a [signal@Gtk.NativeDialog::response] signal when the user
215// finished with the dialog.
216//
217// Note that unlike `GtkDialog`, `GtkNativeDialog` objects are not
218// toplevel widgets, and GTK does not keep them alive. It is your
219// responsibility to keep a reference until you are done with the
220// object.
221type NativeDialog struct {
222 gobject.Object
223}
224
225var xNativeDialogGLibType func() types.GType
226
227func NativeDialogGLibType() types.GType {
228 return xNativeDialogGLibType()
229}
230
231func NativeDialogNewFromInternalPtr(ptr uintptr) *NativeDialog {
232 cls := &NativeDialog{}
233 cls.Ptr = ptr
234 return cls
235}
236
237var xNativeDialogDestroy func(uintptr)
238
239// Destroys a dialog.
240//
241// When a dialog is destroyed, it will break any references it holds
242// to other objects.
243//
244// If it is visible it will be hidden and any underlying window system
245// resources will be destroyed.
246//
247// Note that this does not release any reference to the object (as opposed
248// to destroying a `GtkWindow`) because there is no reference from the
249// windowing system to the `GtkNativeDialog`.
250func (x *NativeDialog) Destroy() {
251
252 xNativeDialogDestroy(x.GoPointer())
253
254}
255
256var xNativeDialogGetModal func(uintptr) bool
257
258// Returns whether the dialog is modal.
259func (x *NativeDialog) GetModal() bool {
260
261 cret := xNativeDialogGetModal(x.GoPointer())
262 return cret
263}
264
265var xNativeDialogGetTitle func(uintptr) string
266
267// Gets the title of the `GtkNativeDialog`.
268func (x *NativeDialog) GetTitle() string {
269
270 cret := xNativeDialogGetTitle(x.GoPointer())
271 return cret
272}
273
274var xNativeDialogGetTransientFor func(uintptr) uintptr
275
276// Fetches the transient parent for this window.
277func (x *NativeDialog) GetTransientFor() *Window {
278 var cls *Window
279
280 cret := xNativeDialogGetTransientFor(x.GoPointer())
281
282 if cret == 0 {
283 return nil
284 }
285 gobject.IncreaseRef(cret)
286 cls = &Window{}
287 cls.Ptr = cret
288 return cls
289}
290
291var xNativeDialogGetVisible func(uintptr) bool
292
293// Determines whether the dialog is visible.
294func (x *NativeDialog) GetVisible() bool {
295
296 cret := xNativeDialogGetVisible(x.GoPointer())
297 return cret
298}
299
300var xNativeDialogHide func(uintptr)
301
302// Hides the dialog if it is visible, aborting any interaction.
303//
304// Once this is called the [signal@Gtk.NativeDialog::response] signal
305// will *not* be emitted until after the next call to
306// [method@Gtk.NativeDialog.show].
307//
308// If the dialog is not visible this does nothing.
309func (x *NativeDialog) Hide() {
310
311 xNativeDialogHide(x.GoPointer())
312
313}
314
315var xNativeDialogSetModal func(uintptr, bool)
316
317// Sets a dialog modal or non-modal.
318//
319// Modal dialogs prevent interaction with other windows in the same
320// application. To keep modal dialogs on top of main application
321// windows, use [method@Gtk.NativeDialog.set_transient_for] to make
322// the dialog transient for the parent; most window managers will
323// then disallow lowering the dialog below the parent.
324func (x *NativeDialog) SetModal(ModalVar bool) {
325
326 xNativeDialogSetModal(x.GoPointer(), ModalVar)
327
328}
329
330var xNativeDialogSetTitle func(uintptr, string)
331
332// Sets the title of the `GtkNativeDialog.`
333func (x *NativeDialog) SetTitle(TitleVar string) {
334
335 xNativeDialogSetTitle(x.GoPointer(), TitleVar)
336
337}
338
339var xNativeDialogSetTransientFor func(uintptr, uintptr)
340
341// Dialog windows should be set transient for the main application
342// window they were spawned from.
343//
344// This allows window managers to e.g. keep the dialog on top of the
345// main window, or center the dialog over the main window.
346//
347// Passing %NULL for @parent unsets the current transient window.
348func (x *NativeDialog) SetTransientFor(ParentVar *Window) {
349
350 xNativeDialogSetTransientFor(x.GoPointer(), ParentVar.GoPointer())
351
352}
353
354var xNativeDialogShow func(uintptr)
355
356// Shows the dialog on the display.
357//
358// When the user accepts the state of the dialog the dialog will
359// be automatically hidden and the [signal@Gtk.NativeDialog::response]
360// signal will be emitted.
361//
362// Multiple calls while the dialog is visible will be ignored.
363func (x *NativeDialog) Show() {
364
365 xNativeDialogShow(x.GoPointer())
366
367}
368
369func (c *NativeDialog) GoPointer() uintptr {
370 if c == nil {
371 return 0
372 }
373 return c.Ptr
374}
375
376func (c *NativeDialog) SetGoPointer(ptr uintptr) {
377 c.Ptr = ptr
378}
379
380// SetPropertyModal sets the "modal" property.
381// Whether the window should be modal with respect to its transient parent.
382func (x *NativeDialog) SetPropertyModal(value bool) {
383 var v gobject.Value
384 v.Init(gobject.TypeBooleanVal)
385 v.SetBoolean(value)
386 x.SetProperty("modal", &v)
387}
388
389// GetPropertyModal gets the "modal" property.
390// Whether the window should be modal with respect to its transient parent.
391func (x *NativeDialog) GetPropertyModal() bool {
392 var v gobject.Value
393 x.GetProperty("modal", &v)
394 return v.GetBoolean()
395}
396
397// SetPropertyTitle sets the "title" property.
398// The title of the dialog window
399func (x *NativeDialog) SetPropertyTitle(value string) {
400 var v gobject.Value
401 v.Init(gobject.TypeStringVal)
402 v.SetString(&value)
403 x.SetProperty("title", &v)
404}
405
406// GetPropertyTitle gets the "title" property.
407// The title of the dialog window
408func (x *NativeDialog) GetPropertyTitle() string {
409 var v gobject.Value
410 x.GetProperty("title", &v)
411 return v.GetString()
412}
413
414// SetPropertyVisible sets the "visible" property.
415// Whether the window is currently visible.
416func (x *NativeDialog) SetPropertyVisible(value bool) {
417 var v gobject.Value
418 v.Init(gobject.TypeBooleanVal)
419 v.SetBoolean(value)
420 x.SetProperty("visible", &v)
421}
422
423// GetPropertyVisible gets the "visible" property.
424// Whether the window is currently visible.
425func (x *NativeDialog) GetPropertyVisible() bool {
426 var v gobject.Value
427 x.GetProperty("visible", &v)
428 return v.GetBoolean()
429}
430
431// Emitted when the user responds to the dialog.
432//
433// When this is called the dialog has been hidden.
434//
435// If you call [method@Gtk.NativeDialog.hide] before the user
436// responds to the dialog this signal will not be emitted.
437func (x *NativeDialog) ConnectResponse(cb *func(NativeDialog, int)) uint {
438 cbPtr := uintptr(unsafe.Pointer(cb))
439 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
440 handlerID := gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr)
441 glib.SaveHandlerMapping(handlerID, cbPtr)
442 return handlerID
443 }
444
445 fcb := func(clsPtr uintptr, ResponseIdVarp int) {
446 fa := NativeDialog{}
447 fa.Ptr = clsPtr
448 cbFn := *cb
449
450 cbFn(fa, ResponseIdVarp)
451
452 }
453 cbRefPtr := purego.NewCallback(fcb)
454 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
455 handlerID := gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr)
456 glib.SaveHandlerMapping(handlerID, cbPtr)
457 return handlerID
458}
459
460func init() {
461 core.SetPackageName("GTK", "gtk4")
462 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
463 var libs []uintptr
464 for _, libPath := range core.GetPaths("GTK") {
465 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
466 if err != nil {
467 panic(err)
468 }
469 libs = append(libs, lib)
470 }
471
472 core.PuregoSafeRegister(&xNativeDialogGLibType, libs, "gtk_native_dialog_get_type")
473
474 core.PuregoSafeRegister(&xNativeDialogDestroy, libs, "gtk_native_dialog_destroy")
475 core.PuregoSafeRegister(&xNativeDialogGetModal, libs, "gtk_native_dialog_get_modal")
476 core.PuregoSafeRegister(&xNativeDialogGetTitle, libs, "gtk_native_dialog_get_title")
477 core.PuregoSafeRegister(&xNativeDialogGetTransientFor, libs, "gtk_native_dialog_get_transient_for")
478 core.PuregoSafeRegister(&xNativeDialogGetVisible, libs, "gtk_native_dialog_get_visible")
479 core.PuregoSafeRegister(&xNativeDialogHide, libs, "gtk_native_dialog_hide")
480 core.PuregoSafeRegister(&xNativeDialogSetModal, libs, "gtk_native_dialog_set_modal")
481 core.PuregoSafeRegister(&xNativeDialogSetTitle, libs, "gtk_native_dialog_set_title")
482 core.PuregoSafeRegister(&xNativeDialogSetTransientFor, libs, "gtk_native_dialog_set_transient_for")
483 core.PuregoSafeRegister(&xNativeDialogShow, libs, "gtk_native_dialog_show")
484
485}