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/gio"
12 "github.com/bnema/puregotk/v4/glib"
13 "github.com/bnema/puregotk/v4/gobject"
14 "github.com/bnema/puregotk/v4/gobject/types"
15)
16
17type AlertDialogClass struct {
18 _ structs.HostLayout
19
20 ParentClass gobject.ObjectClass
21}
22
23func (x *AlertDialogClass) GoPointer() uintptr {
24 return uintptr(unsafe.Pointer(x))
25}
26
27// Collects the arguments that are needed to present a message to the user.
28//
29// The message is shown with the [method@Gtk.AlertDialog.choose]
30// function.
31//
32// If you don't need to wait for a button to be clicked, you can use
33// [method@Gtk.AlertDialog.show].
34type AlertDialog struct {
35 gobject.Object
36}
37
38var xAlertDialogGLibType func() types.GType
39
40func AlertDialogGLibType() types.GType {
41 return xAlertDialogGLibType()
42}
43
44func AlertDialogNewFromInternalPtr(ptr uintptr) *AlertDialog {
45 cls := &AlertDialog{}
46 cls.Ptr = ptr
47 return cls
48}
49
50var xNewAlertDialog func(string, ...interface{}) uintptr
51
52// Creates a new `GtkAlertDialog` object.
53//
54// The message will be set to the formatted string
55// resulting from the arguments.
56func NewAlertDialog(FormatVar string, varArgs ...interface{}) *AlertDialog {
57 var cls *AlertDialog
58
59 cret := xNewAlertDialog(FormatVar, varArgs...)
60
61 if cret == 0 {
62 return nil
63 }
64 cls = &AlertDialog{}
65 cls.Ptr = cret
66 return cls
67}
68
69var xAlertDialogChoose func(uintptr, uintptr, uintptr, uintptr, uintptr)
70
71// Shows the alert to the user.
72//
73// It is ok to pass `NULL` for the callback if the alert
74// does not have more than one button. A simpler API for
75// this case is [method@Gtk.AlertDialog.show].
76func (x *AlertDialog) Choose(ParentVar *Window, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
77
78 var CallbackVarRef uintptr
79 if CallbackVar != nil {
80 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
81 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
82 CallbackVarRef = cbRefPtr
83 } else {
84 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
85 cbFn := *CallbackVar
86 cbFn(arg0, arg1, arg2)
87 }
88 CallbackVarRef = purego.NewCallback(fcb)
89 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
90 }
91 }
92
93 xAlertDialogChoose(x.GoPointer(), ParentVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
94
95}
96
97var xAlertDialogChooseFinish func(uintptr, uintptr, **glib.Error) int
98
99// Finishes the [method@Gtk.AlertDialog.choose] call.
100func (x *AlertDialog) ChooseFinish(ResultVar gio.AsyncResult) (int, error) {
101 var cerr *glib.Error
102
103 cret := xAlertDialogChooseFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
104 if cerr == nil {
105 return cret, nil
106 }
107 return cret, cerr
108
109}
110
111var xAlertDialogGetButtons func(uintptr) []string
112
113// Returns the button labels for the alert.
114func (x *AlertDialog) GetButtons() []string {
115
116 cret := xAlertDialogGetButtons(x.GoPointer())
117 return cret
118}
119
120var xAlertDialogGetCancelButton func(uintptr) int
121
122// Returns the index of the cancel button.
123func (x *AlertDialog) GetCancelButton() int {
124
125 cret := xAlertDialogGetCancelButton(x.GoPointer())
126 return cret
127}
128
129var xAlertDialogGetDefaultButton func(uintptr) int
130
131// Returns the index of the default button.
132func (x *AlertDialog) GetDefaultButton() int {
133
134 cret := xAlertDialogGetDefaultButton(x.GoPointer())
135 return cret
136}
137
138var xAlertDialogGetDetail func(uintptr) string
139
140// Returns the detail text that will be shown in the alert.
141func (x *AlertDialog) GetDetail() string {
142
143 cret := xAlertDialogGetDetail(x.GoPointer())
144 return cret
145}
146
147var xAlertDialogGetMessage func(uintptr) string
148
149// Returns the message that will be shown in the alert.
150func (x *AlertDialog) GetMessage() string {
151
152 cret := xAlertDialogGetMessage(x.GoPointer())
153 return cret
154}
155
156var xAlertDialogGetModal func(uintptr) bool
157
158// Returns whether the alert blocks interaction
159// with the parent window while it is presented.
160func (x *AlertDialog) GetModal() bool {
161
162 cret := xAlertDialogGetModal(x.GoPointer())
163 return cret
164}
165
166var xAlertDialogSetButtons func(uintptr, []string)
167
168// Sets the button labels for the alert.
169func (x *AlertDialog) SetButtons(LabelsVar []string) {
170
171 xAlertDialogSetButtons(x.GoPointer(), LabelsVar)
172
173}
174
175var xAlertDialogSetCancelButton func(uintptr, int)
176
177// Sets the index of the cancel button.
178//
179// See [property@Gtk.AlertDialog:cancel-button] for
180// details of how this value is used.
181func (x *AlertDialog) SetCancelButton(ButtonVar int) {
182
183 xAlertDialogSetCancelButton(x.GoPointer(), ButtonVar)
184
185}
186
187var xAlertDialogSetDefaultButton func(uintptr, int)
188
189// Sets the index of the default button.
190//
191// See [property@Gtk.AlertDialog:default-button] for
192// details of how this value is used.
193func (x *AlertDialog) SetDefaultButton(ButtonVar int) {
194
195 xAlertDialogSetDefaultButton(x.GoPointer(), ButtonVar)
196
197}
198
199var xAlertDialogSetDetail func(uintptr, string)
200
201// Sets the detail text that will be shown in the alert.
202func (x *AlertDialog) SetDetail(DetailVar string) {
203
204 xAlertDialogSetDetail(x.GoPointer(), DetailVar)
205
206}
207
208var xAlertDialogSetMessage func(uintptr, string)
209
210// Sets the message that will be shown in the alert.
211func (x *AlertDialog) SetMessage(MessageVar string) {
212
213 xAlertDialogSetMessage(x.GoPointer(), MessageVar)
214
215}
216
217var xAlertDialogSetModal func(uintptr, bool)
218
219// Sets whether the alert blocks interaction
220// with the parent window while it is presented.
221func (x *AlertDialog) SetModal(ModalVar bool) {
222
223 xAlertDialogSetModal(x.GoPointer(), ModalVar)
224
225}
226
227var xAlertDialogShow func(uintptr, uintptr)
228
229// Shows the alert to the user.
230//
231// This function is a simpler version of [method@Gtk.AlertDialog.choose]
232// intended for dialogs with a single button.
233//
234// If you want to cancel the dialog or if the alert has more than one
235// button, you should use that function instead and provide it with a
236// [class@Gio.Cancellable] and callback respectively.
237func (x *AlertDialog) Show(ParentVar *Window) {
238
239 xAlertDialogShow(x.GoPointer(), ParentVar.GoPointer())
240
241}
242
243func (c *AlertDialog) GoPointer() uintptr {
244 if c == nil {
245 return 0
246 }
247 return c.Ptr
248}
249
250func (c *AlertDialog) SetGoPointer(ptr uintptr) {
251 c.Ptr = ptr
252}
253
254// SetPropertyButtons sets the "buttons" property.
255// Labels for buttons to show in the alert.
256//
257// The labels should be translated and may contain
258// a `_` character to indicate the mnemonic character.
259//
260// If this property is not set, then a 'Close' button is
261// automatically created.
262func (x *AlertDialog) SetPropertyButtons(value []string) {
263 var v gobject.Value
264 v.Init(glib.StrvGetType())
265 v.SetBoxed(uintptr(unsafe.Pointer(core.ByteSlice(value))))
266 x.SetProperty("buttons", &v)
267}
268
269// GetPropertyButtons gets the "buttons" property.
270// Labels for buttons to show in the alert.
271//
272// The labels should be translated and may contain
273// a `_` character to indicate the mnemonic character.
274//
275// If this property is not set, then a 'Close' button is
276// automatically created.
277func (x *AlertDialog) GetPropertyButtons() []string {
278 var v gobject.Value
279 x.GetProperty("buttons", &v)
280 return core.GoStringSlice(v.GetBoxed())
281}
282
283// SetPropertyCancelButton sets the "cancel-button" property.
284// Determines what happens when the <kbd>Escape</kbd> key is pressed
285// while the alert is shown.
286//
287// If this property holds the index of a button in [property@Gtk.AlertDialog:buttons],
288// then pressing Escape is treated as if that button was pressed. If it is -1
289// or not a valid index for the `buttons` array, then an error is returned.
290//
291// If `buttons` is `NULL`, then the automatically created 'Close' button
292// is treated as both cancel and default button, so 0 is returned.
293func (x *AlertDialog) SetPropertyCancelButton(value int) {
294 var v gobject.Value
295 v.Init(gobject.TypeIntVal)
296 v.SetInt(value)
297 x.SetProperty("cancel-button", &v)
298}
299
300// GetPropertyCancelButton gets the "cancel-button" property.
301// Determines what happens when the <kbd>Escape</kbd> key is pressed
302// while the alert is shown.
303//
304// If this property holds the index of a button in [property@Gtk.AlertDialog:buttons],
305// then pressing Escape is treated as if that button was pressed. If it is -1
306// or not a valid index for the `buttons` array, then an error is returned.
307//
308// If `buttons` is `NULL`, then the automatically created 'Close' button
309// is treated as both cancel and default button, so 0 is returned.
310func (x *AlertDialog) GetPropertyCancelButton() int {
311 var v gobject.Value
312 x.GetProperty("cancel-button", &v)
313 return v.GetInt()
314}
315
316// SetPropertyDefaultButton sets the "default-button" property.
317// Determines what happens when the <kbd>Return</kbd> key is pressed
318// while the alert is shown.
319//
320// If this property holds the index of a button in [property@Gtk.AlertDialog:buttons],
321// then pressing Return is treated as if that button was pressed. If it is -1
322// or not a valid index for the `buttons` array, then nothing happens.
323//
324// If `buttons` is `NULL`, then the automatically created 'Close' button
325// is treated as both cancel and default button, so 0 is returned.
326func (x *AlertDialog) SetPropertyDefaultButton(value int) {
327 var v gobject.Value
328 v.Init(gobject.TypeIntVal)
329 v.SetInt(value)
330 x.SetProperty("default-button", &v)
331}
332
333// GetPropertyDefaultButton gets the "default-button" property.
334// Determines what happens when the <kbd>Return</kbd> key is pressed
335// while the alert is shown.
336//
337// If this property holds the index of a button in [property@Gtk.AlertDialog:buttons],
338// then pressing Return is treated as if that button was pressed. If it is -1
339// or not a valid index for the `buttons` array, then nothing happens.
340//
341// If `buttons` is `NULL`, then the automatically created 'Close' button
342// is treated as both cancel and default button, so 0 is returned.
343func (x *AlertDialog) GetPropertyDefaultButton() int {
344 var v gobject.Value
345 x.GetProperty("default-button", &v)
346 return v.GetInt()
347}
348
349// SetPropertyDetail sets the "detail" property.
350// The detail text for the alert.
351func (x *AlertDialog) SetPropertyDetail(value string) {
352 var v gobject.Value
353 v.Init(gobject.TypeStringVal)
354 v.SetString(&value)
355 x.SetProperty("detail", &v)
356}
357
358// GetPropertyDetail gets the "detail" property.
359// The detail text for the alert.
360func (x *AlertDialog) GetPropertyDetail() string {
361 var v gobject.Value
362 x.GetProperty("detail", &v)
363 return v.GetString()
364}
365
366// SetPropertyMessage sets the "message" property.
367// The message for the alert.
368func (x *AlertDialog) SetPropertyMessage(value string) {
369 var v gobject.Value
370 v.Init(gobject.TypeStringVal)
371 v.SetString(&value)
372 x.SetProperty("message", &v)
373}
374
375// GetPropertyMessage gets the "message" property.
376// The message for the alert.
377func (x *AlertDialog) GetPropertyMessage() string {
378 var v gobject.Value
379 x.GetProperty("message", &v)
380 return v.GetString()
381}
382
383// SetPropertyModal sets the "modal" property.
384// Whether the alert is modal.
385func (x *AlertDialog) SetPropertyModal(value bool) {
386 var v gobject.Value
387 v.Init(gobject.TypeBooleanVal)
388 v.SetBoolean(value)
389 x.SetProperty("modal", &v)
390}
391
392// GetPropertyModal gets the "modal" property.
393// Whether the alert is modal.
394func (x *AlertDialog) GetPropertyModal() bool {
395 var v gobject.Value
396 x.GetProperty("modal", &v)
397 return v.GetBoolean()
398}
399
400func init() {
401 core.SetPackageName("GTK", "gtk4")
402 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
403 var libs []uintptr
404 for _, libPath := range core.GetPaths("GTK") {
405 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
406 if err != nil {
407 panic(err)
408 }
409 libs = append(libs, lib)
410 }
411
412 core.PuregoSafeRegister(&xAlertDialogGLibType, libs, "gtk_alert_dialog_get_type")
413
414 core.PuregoSafeRegister(&xNewAlertDialog, libs, "gtk_alert_dialog_new")
415
416 core.PuregoSafeRegister(&xAlertDialogChoose, libs, "gtk_alert_dialog_choose")
417 core.PuregoSafeRegister(&xAlertDialogChooseFinish, libs, "gtk_alert_dialog_choose_finish")
418 core.PuregoSafeRegister(&xAlertDialogGetButtons, libs, "gtk_alert_dialog_get_buttons")
419 core.PuregoSafeRegister(&xAlertDialogGetCancelButton, libs, "gtk_alert_dialog_get_cancel_button")
420 core.PuregoSafeRegister(&xAlertDialogGetDefaultButton, libs, "gtk_alert_dialog_get_default_button")
421 core.PuregoSafeRegister(&xAlertDialogGetDetail, libs, "gtk_alert_dialog_get_detail")
422 core.PuregoSafeRegister(&xAlertDialogGetMessage, libs, "gtk_alert_dialog_get_message")
423 core.PuregoSafeRegister(&xAlertDialogGetModal, libs, "gtk_alert_dialog_get_modal")
424 core.PuregoSafeRegister(&xAlertDialogSetButtons, libs, "gtk_alert_dialog_set_buttons")
425 core.PuregoSafeRegister(&xAlertDialogSetCancelButton, libs, "gtk_alert_dialog_set_cancel_button")
426 core.PuregoSafeRegister(&xAlertDialogSetDefaultButton, libs, "gtk_alert_dialog_set_default_button")
427 core.PuregoSafeRegister(&xAlertDialogSetDetail, libs, "gtk_alert_dialog_set_detail")
428 core.PuregoSafeRegister(&xAlertDialogSetMessage, libs, "gtk_alert_dialog_set_message")
429 core.PuregoSafeRegister(&xAlertDialogSetModal, libs, "gtk_alert_dialog_set_modal")
430 core.PuregoSafeRegister(&xAlertDialogShow, libs, "gtk_alert_dialog_show")
431
432}