1// Package adw was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package adw
3
4import (
5 "fmt"
6 "structs"
7 "unsafe"
8
9 "github.com/ebitengine/purego"
10
11 "github.com/bnema/puregotk/pkg/core"
12 "github.com/bnema/puregotk/v4/gio"
13 "github.com/bnema/puregotk/v4/glib"
14 "github.com/bnema/puregotk/v4/gobject"
15 "github.com/bnema/puregotk/v4/gobject/types"
16 "github.com/bnema/puregotk/v4/gtk"
17)
18
19type AlertDialogClass struct {
20 _ structs.HostLayout
21
22 ParentClass DialogClass
23
24 xResponse uintptr
25
26 Padding [4]uintptr
27}
28
29func (x *AlertDialogClass) GoPointer() uintptr {
30 return uintptr(unsafe.Pointer(x))
31}
32
33// OverrideResponse sets the "response" callback function.
34func (x *AlertDialogClass) OverrideResponse(cb func(*AlertDialog, string)) {
35 if cb == nil {
36 x.xResponse = 0
37 } else {
38 x.xResponse = purego.NewCallback(func(SelfVarp uintptr, ResponseVarp string) {
39 cb(AlertDialogNewFromInternalPtr(SelfVarp), ResponseVarp)
40 })
41 }
42}
43
44// GetResponse gets the "response" callback function.
45func (x *AlertDialogClass) GetResponse() func(*AlertDialog, string) {
46 if x.xResponse == 0 {
47 return nil
48 }
49 var rawCallback func(SelfVarp uintptr, ResponseVarp string)
50 purego.RegisterFunc(&rawCallback, x.xResponse)
51 return func(SelfVar *AlertDialog, ResponseVar string) {
52 rawCallback(SelfVar.GoPointer(), ResponseVar)
53 }
54}
55
56// Describes the possible styles of [class@AlertDialog] response buttons.
57//
58// See [method@AlertDialog.set_response_appearance].
59type ResponseAppearance int
60
61var xResponseAppearanceGLibType func() types.GType
62
63func ResponseAppearanceGLibType() types.GType {
64 return xResponseAppearanceGLibType()
65}
66
67const (
68
69 // the default appearance.
70 ResponseDefaultValue ResponseAppearance = 0
71 // used to denote important responses such as the
72 // affirmative action.
73 ResponseSuggestedValue ResponseAppearance = 1
74 // used to draw attention to the potentially damaging
75 // consequences of using the response. This appearance acts as a warning to
76 // the user.
77 ResponseDestructiveValue ResponseAppearance = 2
78)
79
80// A dialog presenting a message or a question.
81//
82// <picture>
83//
84// <source srcset="alert-dialog-dark.png" media="(prefers-color-scheme: dark)">
85// <img src="alert-dialog.png" alt="alert-dialog">
86//
87// </picture>
88//
89// Alert dialogs have a heading, a body, an optional child widget, and one or
90// multiple responses, each presented as a button.
91//
92// Each response has a unique string ID, and a button label. Additionally, each
93// response can be enabled or disabled, and can have a suggested or destructive
94// appearance.
95//
96// When one of the responses is activated, or the dialog is closed, the
97// [signal@AlertDialog::response] signal will be emitted. This signal is
98// detailed, and the detail, as well as the `response` parameter will be set to
99// the ID of the activated response, or to the value of the
100// [property@AlertDialog:close-response] property if the dialog had been closed
101// without activating any of the responses.
102//
103// Response buttons can be presented horizontally or vertically depending on
104// available space.
105//
106// When a response is activated, `AdwAlertDialog` is closed automatically.
107//
108// An example of using an alert dialog:
109//
110// ```c
111// AdwDialog *dialog;
112//
113// dialog = adw_alert_dialog_new (_("Replace File?"), NULL);
114//
115// adw_alert_dialog_format_body (ADW_ALERT_DIALOG (dialog),
116//
117// _("A file named “%s” already exists. Do you want to replace it?"),
118// filename);
119//
120// adw_alert_dialog_add_responses (ADW_ALERT_DIALOG (dialog),
121//
122// "cancel", _("_Cancel"),
123// "replace", _("_Replace"),
124// NULL);
125//
126// adw_alert_dialog_set_response_appearance (ADW_ALERT_DIALOG (dialog),
127//
128// "replace",
129// ADW_RESPONSE_DESTRUCTIVE);
130//
131// adw_alert_dialog_set_default_response (ADW_ALERT_DIALOG (dialog), "cancel");
132// adw_alert_dialog_set_close_response (ADW_ALERT_DIALOG (dialog), "cancel");
133//
134// g_signal_connect (dialog, "response", G_CALLBACK (response_cb), self);
135//
136// adw_dialog_present (dialog, parent);
137// ```
138//
139// ## Async API
140//
141// `AdwAlertDialog` can also be used via the [method@AlertDialog.choose] method.
142// This API follows the GIO async pattern, for example:
143//
144// ```c
145// static void
146// dialog_cb (AdwAlertDialog *dialog,
147//
148// GAsyncResult *result,
149// MyWindow *self)
150//
151// {
152// const char *response = adw_alert_dialog_choose_finish (dialog, result);
153//
154// // ...
155// }
156//
157// static void
158// show_dialog (MyWindow *self)
159//
160// {
161// AdwDialog *dialog;
162//
163// dialog = adw_alert_dialog_new (_("Replace File?"), NULL);
164//
165// adw_alert_dialog_format_body (ADW_ALERT_DIALOG (dialog),
166// _("A file named “%s” already exists. Do you want to replace it?"),
167// filename);
168//
169// adw_alert_dialog_add_responses (ADW_ALERT_DIALOG (dialog),
170// "cancel", _("_Cancel"),
171// "replace", _("_Replace"),
172// NULL);
173//
174// adw_alert_dialog_set_response_appearance (ADW_ALERT_DIALOG (dialog),
175// "replace",
176// ADW_RESPONSE_DESTRUCTIVE);
177//
178// adw_alert_dialog_set_default_response (ADW_ALERT_DIALOG (dialog), "cancel");
179// adw_alert_dialog_set_close_response (ADW_ALERT_DIALOG (dialog), "cancel");
180//
181// adw_alert_dialog_choose (ADW_ALERT_DIALOG (dialog), GTK_WIDGET (self),
182// NULL, (GAsyncReadyCallback) dialog_cb, self);
183// }
184//
185// ```
186//
187// ## AdwAlertDialog as GtkBuildable
188//
189// `AdwAlertDialog` supports adding responses in UI definitions by via the
190// `<responses>` element that may contain multiple `<response>` elements, each
191// representing a response.
192//
193// Each of the `<response>` elements must have the `id` attribute specifying the
194// response ID. The contents of the element are used as the response label.
195//
196// Response labels can be translated with the usual `translatable`, `context`
197// and `comments` attributes.
198//
199// The `<response>` elements can also have `enabled` and/or `appearance`
200// attributes. See [method@AlertDialog.set_response_enabled] and
201// [method@AlertDialog.set_response_appearance] for details.
202//
203// Example of an `AdwAlertDialog` UI definition:
204//
205// ```xml
206// <object class="AdwAlertDialog" id="dialog">
207//
208// <property name="heading" translatable="yes">Save Changes?</property>
209// <property name="body" translatable="yes">Open documents contain unsaved changes. Changes which are not saved will be permanently lost.</property>
210// <property name="default-response">save</property>
211// <property name="close-response">cancel</property>
212// <signal name="response" handler="response_cb"/>
213// <responses>
214// <response id="cancel" translatable="yes">_Cancel</response>
215// <response id="discard" translatable="yes" appearance="destructive">_Discard</response>
216// <response id="save" translatable="yes" appearance="suggested" enabled="false">_Save</response>
217// </responses>
218//
219// </object>
220// ```
221type AlertDialog struct {
222 Dialog
223}
224
225var xAlertDialogGLibType func() types.GType
226
227func AlertDialogGLibType() types.GType {
228 return xAlertDialogGLibType()
229}
230
231func AlertDialogNewFromInternalPtr(ptr uintptr) *AlertDialog {
232 cls := &AlertDialog{}
233 cls.Ptr = ptr
234 return cls
235}
236
237var xNewAlertDialog func(uintptr, uintptr) uintptr
238
239// Creates a new `AdwAlertDialog`.
240//
241// @heading and @body can be set to `NULL`. This can be useful if they need to
242// be formatted or use markup. In that case, set them to `NULL` and call
243// [method@AlertDialog.format_body] or similar methods afterwards:
244//
245// ```c
246// AdwDialog *dialog;
247//
248// dialog = adw_alert_dialog_new (_("Replace File?"), NULL);
249// adw_alert_dialog_format_body (ADW_ALERT_DIALOG (dialog),
250//
251// _("A file named “%s” already exists. Do you want to replace it?"),
252// filename);
253//
254// ```
255func NewAlertDialog(HeadingVar *string, BodyVar *string) *AlertDialog {
256 var cls *AlertDialog
257
258 HeadingVarPtr := core.GStrdupNullable(HeadingVar)
259 defer core.GFreeNullable(HeadingVarPtr)
260
261 BodyVarPtr := core.GStrdupNullable(BodyVar)
262 defer core.GFreeNullable(BodyVarPtr)
263
264 cret := xNewAlertDialog(HeadingVarPtr, BodyVarPtr)
265
266 if cret == 0 {
267 return nil
268 }
269 gobject.IncreaseRef(cret)
270 cls = &AlertDialog{}
271 cls.Ptr = cret
272 return cls
273}
274
275var xAlertDialogAddResponse func(uintptr, string, string)
276
277// Adds a response with @id and @label to @self.
278//
279// Responses are represented as buttons in the dialog.
280//
281// Response ID must be unique. It will be used in [signal@AlertDialog::response]
282// to tell which response had been activated, as well as to inspect and modify
283// the response later.
284//
285// An embedded underline in @label indicates a mnemonic.
286//
287// [method@AlertDialog.set_response_label] can be used to change the response
288// label after it had been added.
289//
290// [method@AlertDialog.set_response_enabled] and
291// [method@AlertDialog.set_response_appearance] can be used to customize the
292// responses further.
293func (x *AlertDialog) AddResponse(IdVar string, LabelVar string) {
294
295 xAlertDialogAddResponse(x.GoPointer(), IdVar, LabelVar)
296
297}
298
299var xAlertDialogAddResponses func(uintptr, string, ...interface{})
300
301// Adds multiple responses to @self.
302//
303// This is the same as calling [method@AlertDialog.add_response] repeatedly. The
304// variable argument list should be `NULL`-terminated list of response IDs and
305// labels.
306//
307// Example:
308//
309// ```c
310// adw_alert_dialog_add_responses (dialog,
311//
312// "cancel", _("_Cancel"),
313// "discard", _("_Discard"),
314// "save", _("_Save"),
315// NULL);
316//
317// ```
318func (x *AlertDialog) AddResponses(FirstIdVar string, varArgs ...interface{}) {
319
320 xAlertDialogAddResponses(x.GoPointer(), FirstIdVar, varArgs...)
321
322}
323
324var xAlertDialogChoose func(uintptr, uintptr, uintptr, uintptr, uintptr)
325
326// This function shows @self to the user.
327//
328// If the window is an [class@Window] or [class@ApplicationWindow], the dialog
329// will be shown within it. Otherwise, it will be a separate window.
330func (x *AlertDialog) Choose(ParentVar *gtk.Widget, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
331
332 var CallbackVarRef uintptr
333 if CallbackVar != nil {
334 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
335 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
336 CallbackVarRef = cbRefPtr
337 } else {
338 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
339 cbFn := *CallbackVar
340 cbFn(arg0, arg1, arg2)
341 }
342 CallbackVarRef = purego.NewCallback(fcb)
343 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
344 }
345 }
346
347 xAlertDialogChoose(x.GoPointer(), ParentVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
348
349}
350
351var xAlertDialogChooseFinish func(uintptr, uintptr) string
352
353// Finishes the [method@AlertDialog.choose] call and returns the response ID.
354func (x *AlertDialog) ChooseFinish(ResultVar gio.AsyncResult) string {
355
356 cret := xAlertDialogChooseFinish(x.GoPointer(), ResultVar.GoPointer())
357 return cret
358}
359
360var xAlertDialogFormatBody func(uintptr, string, ...interface{})
361
362// Sets the formatted body text of @self.
363//
364// See [property@AlertDialog:body].
365func (x *AlertDialog) FormatBody(FormatVar string, varArgs ...interface{}) {
366
367 xAlertDialogFormatBody(x.GoPointer(), FormatVar, varArgs...)
368
369}
370
371var xAlertDialogFormatBodyMarkup func(uintptr, string, ...interface{})
372
373// Sets the formatted body text of @self with Pango markup.
374//
375// The @format is assumed to contain Pango markup.
376//
377// Special XML characters in the `printf()` arguments passed to this function
378// will automatically be escaped as necessary, see
379// [func@GLib.markup_printf_escaped].
380//
381// See [property@AlertDialog:body].
382func (x *AlertDialog) FormatBodyMarkup(FormatVar string, varArgs ...interface{}) {
383
384 xAlertDialogFormatBodyMarkup(x.GoPointer(), FormatVar, varArgs...)
385
386}
387
388var xAlertDialogFormatHeading func(uintptr, string, ...interface{})
389
390// Sets the formatted heading of @self.
391//
392// See [property@AlertDialog:heading].
393func (x *AlertDialog) FormatHeading(FormatVar string, varArgs ...interface{}) {
394
395 xAlertDialogFormatHeading(x.GoPointer(), FormatVar, varArgs...)
396
397}
398
399var xAlertDialogFormatHeadingMarkup func(uintptr, string, ...interface{})
400
401// Sets the formatted heading of @self with Pango markup.
402//
403// The @format is assumed to contain Pango markup.
404//
405// Special XML characters in the `printf()` arguments passed to this function
406// will automatically be escaped as necessary, see
407// [func@GLib.markup_printf_escaped].
408//
409// See [property@AlertDialog:heading].
410func (x *AlertDialog) FormatHeadingMarkup(FormatVar string, varArgs ...interface{}) {
411
412 xAlertDialogFormatHeadingMarkup(x.GoPointer(), FormatVar, varArgs...)
413
414}
415
416var xAlertDialogGetBody func(uintptr) string
417
418// Gets the body text of @self.
419func (x *AlertDialog) GetBody() string {
420
421 cret := xAlertDialogGetBody(x.GoPointer())
422 return cret
423}
424
425var xAlertDialogGetBodyUseMarkup func(uintptr) bool
426
427// Gets whether the body text of @self includes Pango markup.
428func (x *AlertDialog) GetBodyUseMarkup() bool {
429
430 cret := xAlertDialogGetBodyUseMarkup(x.GoPointer())
431 return cret
432}
433
434var xAlertDialogGetCloseResponse func(uintptr) string
435
436// Gets the ID of the close response of @self.
437func (x *AlertDialog) GetCloseResponse() string {
438
439 cret := xAlertDialogGetCloseResponse(x.GoPointer())
440 return cret
441}
442
443var xAlertDialogGetDefaultResponse func(uintptr) string
444
445// Gets the ID of the default response of @self.
446func (x *AlertDialog) GetDefaultResponse() string {
447
448 cret := xAlertDialogGetDefaultResponse(x.GoPointer())
449 return cret
450}
451
452var xAlertDialogGetExtraChild func(uintptr) uintptr
453
454// Gets the child widget of @self.
455func (x *AlertDialog) GetExtraChild() *gtk.Widget {
456 var cls *gtk.Widget
457
458 cret := xAlertDialogGetExtraChild(x.GoPointer())
459
460 if cret == 0 {
461 return nil
462 }
463 gobject.IncreaseRef(cret)
464 cls = >k.Widget{}
465 cls.Ptr = cret
466 return cls
467}
468
469var xAlertDialogGetHeading func(uintptr) string
470
471// Gets the heading of @self.
472func (x *AlertDialog) GetHeading() string {
473
474 cret := xAlertDialogGetHeading(x.GoPointer())
475 return cret
476}
477
478var xAlertDialogGetHeadingUseMarkup func(uintptr) bool
479
480// Gets whether the heading of @self includes Pango markup.
481func (x *AlertDialog) GetHeadingUseMarkup() bool {
482
483 cret := xAlertDialogGetHeadingUseMarkup(x.GoPointer())
484 return cret
485}
486
487var xAlertDialogGetPreferWideLayout func(uintptr) bool
488
489// Gets whether @self prefers wide layout.
490func (x *AlertDialog) GetPreferWideLayout() bool {
491
492 cret := xAlertDialogGetPreferWideLayout(x.GoPointer())
493 return cret
494}
495
496var xAlertDialogGetResponseAppearance func(uintptr, string) ResponseAppearance
497
498// Gets the appearance of @response.
499//
500// See [method@AlertDialog.set_response_appearance].
501func (x *AlertDialog) GetResponseAppearance(ResponseVar string) ResponseAppearance {
502
503 cret := xAlertDialogGetResponseAppearance(x.GoPointer(), ResponseVar)
504 return cret
505}
506
507var xAlertDialogGetResponseEnabled func(uintptr, string) bool
508
509// Gets whether @response is enabled.
510//
511// See [method@AlertDialog.set_response_enabled].
512func (x *AlertDialog) GetResponseEnabled(ResponseVar string) bool {
513
514 cret := xAlertDialogGetResponseEnabled(x.GoPointer(), ResponseVar)
515 return cret
516}
517
518var xAlertDialogGetResponseLabel func(uintptr, string) string
519
520// Gets the label of @response.
521//
522// See [method@AlertDialog.set_response_label].
523func (x *AlertDialog) GetResponseLabel(ResponseVar string) string {
524
525 cret := xAlertDialogGetResponseLabel(x.GoPointer(), ResponseVar)
526 return cret
527}
528
529var xAlertDialogHasResponse func(uintptr, string) bool
530
531// Gets whether @self has a response with the ID @response.
532func (x *AlertDialog) HasResponse(ResponseVar string) bool {
533
534 cret := xAlertDialogHasResponse(x.GoPointer(), ResponseVar)
535 return cret
536}
537
538var xAlertDialogRemoveResponse func(uintptr, string)
539
540// Removes a response from @self.
541func (x *AlertDialog) RemoveResponse(IdVar string) {
542
543 xAlertDialogRemoveResponse(x.GoPointer(), IdVar)
544
545}
546
547var xAlertDialogSetBody func(uintptr, string)
548
549// Sets the body text of @self.
550func (x *AlertDialog) SetBody(BodyVar string) {
551
552 xAlertDialogSetBody(x.GoPointer(), BodyVar)
553
554}
555
556var xAlertDialogSetBodyUseMarkup func(uintptr, bool)
557
558// Sets whether the body text of @self includes Pango markup.
559//
560// See [func@Pango.parse_markup].
561func (x *AlertDialog) SetBodyUseMarkup(UseMarkupVar bool) {
562
563 xAlertDialogSetBodyUseMarkup(x.GoPointer(), UseMarkupVar)
564
565}
566
567var xAlertDialogSetCloseResponse func(uintptr, string)
568
569// Sets the ID of the close response of @self.
570//
571// It will be passed to [signal@AlertDialog::response] if the dialog is closed
572// by pressing <kbd>Escape</kbd> or with a system action.
573//
574// It doesn't have to correspond to any of the responses in the dialog.
575//
576// The default close response is `close`.
577func (x *AlertDialog) SetCloseResponse(ResponseVar string) {
578
579 xAlertDialogSetCloseResponse(x.GoPointer(), ResponseVar)
580
581}
582
583var xAlertDialogSetDefaultResponse func(uintptr, uintptr)
584
585// Sets the ID of the default response of @self.
586//
587// The button corresponding to this response will be set as the default widget
588// of @self.
589//
590// If not set, the default widget will not be set, and the last added response
591// will be focused by default.
592//
593// See [property@Dialog:default-widget].
594func (x *AlertDialog) SetDefaultResponse(ResponseVar *string) {
595
596 ResponseVarPtr := core.GStrdupNullable(ResponseVar)
597 defer core.GFreeNullable(ResponseVarPtr)
598
599 xAlertDialogSetDefaultResponse(x.GoPointer(), ResponseVarPtr)
600
601}
602
603var xAlertDialogSetExtraChild func(uintptr, uintptr)
604
605// Sets the child widget of @self.
606//
607// The child widget is displayed below the heading and body.
608func (x *AlertDialog) SetExtraChild(ChildVar *gtk.Widget) {
609
610 xAlertDialogSetExtraChild(x.GoPointer(), ChildVar.GoPointer())
611
612}
613
614var xAlertDialogSetHeading func(uintptr, uintptr)
615
616// Sets the heading of @self.
617func (x *AlertDialog) SetHeading(HeadingVar *string) {
618
619 HeadingVarPtr := core.GStrdupNullable(HeadingVar)
620 defer core.GFreeNullable(HeadingVarPtr)
621
622 xAlertDialogSetHeading(x.GoPointer(), HeadingVarPtr)
623
624}
625
626var xAlertDialogSetHeadingUseMarkup func(uintptr, bool)
627
628// Sets whether the heading of @self includes Pango markup.
629//
630// See [func@Pango.parse_markup].
631func (x *AlertDialog) SetHeadingUseMarkup(UseMarkupVar bool) {
632
633 xAlertDialogSetHeadingUseMarkup(x.GoPointer(), UseMarkupVar)
634
635}
636
637var xAlertDialogSetPreferWideLayout func(uintptr, bool)
638
639// Sets whether @self prefers wide layout.
640//
641// Prefer horizontal button layout when possible, and wider dialog width
642// otherwise.
643func (x *AlertDialog) SetPreferWideLayout(PreferWideLayoutVar bool) {
644
645 xAlertDialogSetPreferWideLayout(x.GoPointer(), PreferWideLayoutVar)
646
647}
648
649var xAlertDialogSetResponseAppearance func(uintptr, string, ResponseAppearance)
650
651// Sets the appearance for @response.
652//
653// <picture>
654//
655// <source srcset="alert-dialog-appearance-dark.png" media="(prefers-color-scheme: dark)">
656// <img src="alert-dialog-appearance.png" alt="alert-dialog-appearance">
657//
658// </picture>
659//
660// Use `ADW_RESPONSE_SUGGESTED` to mark important responses such as the
661// affirmative action, like the Save button in the example.
662//
663// Use `ADW_RESPONSE_DESTRUCTIVE` to draw attention to the potentially damaging
664// consequences of using @response. This appearance acts as a warning to the
665// user. The Discard button in the example is using this appearance.
666//
667// The default appearance is `ADW_RESPONSE_DEFAULT`.
668//
669// Negative responses like Cancel or Close should use the default appearance.
670func (x *AlertDialog) SetResponseAppearance(ResponseVar string, AppearanceVar ResponseAppearance) {
671
672 xAlertDialogSetResponseAppearance(x.GoPointer(), ResponseVar, AppearanceVar)
673
674}
675
676var xAlertDialogSetResponseEnabled func(uintptr, string, bool)
677
678// Sets whether @response is enabled.
679//
680// If @response is not enabled, the corresponding button will have
681// [property@Gtk.Widget:sensitive] set to `FALSE` and it can't be activated as
682// a default response.
683//
684// @response can still be used as [property@AlertDialog:close-response] while
685// it's not enabled.
686//
687// Responses are enabled by default.
688func (x *AlertDialog) SetResponseEnabled(ResponseVar string, EnabledVar bool) {
689
690 xAlertDialogSetResponseEnabled(x.GoPointer(), ResponseVar, EnabledVar)
691
692}
693
694var xAlertDialogSetResponseLabel func(uintptr, string, string)
695
696// Sets the label of @response to @label.
697//
698// Labels are displayed on the dialog buttons. An embedded underline in @label
699// indicates a mnemonic.
700func (x *AlertDialog) SetResponseLabel(ResponseVar string, LabelVar string) {
701
702 xAlertDialogSetResponseLabel(x.GoPointer(), ResponseVar, LabelVar)
703
704}
705
706func (c *AlertDialog) GoPointer() uintptr {
707 if c == nil {
708 return 0
709 }
710 return c.Ptr
711}
712
713func (c *AlertDialog) SetGoPointer(ptr uintptr) {
714 c.Ptr = ptr
715}
716
717// SetPropertyBody sets the "body" property.
718// The body text of the dialog.
719func (x *AlertDialog) SetPropertyBody(value string) {
720 var v gobject.Value
721 v.Init(gobject.TypeStringVal)
722 v.SetString(&value)
723 x.SetProperty("body", &v)
724}
725
726// GetPropertyBody gets the "body" property.
727// The body text of the dialog.
728func (x *AlertDialog) GetPropertyBody() string {
729 var v gobject.Value
730 x.GetProperty("body", &v)
731 return v.GetString()
732}
733
734// SetPropertyBodyUseMarkup sets the "body-use-markup" property.
735// Whether the body text includes Pango markup.
736//
737// See [func@Pango.parse_markup].
738func (x *AlertDialog) SetPropertyBodyUseMarkup(value bool) {
739 var v gobject.Value
740 v.Init(gobject.TypeBooleanVal)
741 v.SetBoolean(value)
742 x.SetProperty("body-use-markup", &v)
743}
744
745// GetPropertyBodyUseMarkup gets the "body-use-markup" property.
746// Whether the body text includes Pango markup.
747//
748// See [func@Pango.parse_markup].
749func (x *AlertDialog) GetPropertyBodyUseMarkup() bool {
750 var v gobject.Value
751 x.GetProperty("body-use-markup", &v)
752 return v.GetBoolean()
753}
754
755// SetPropertyCloseResponse sets the "close-response" property.
756// The ID of the close response.
757//
758// It will be passed to [signal@AlertDialog::response] if the dialog is
759// closed by pressing <kbd>Escape</kbd> or with a system action.
760//
761// It doesn't have to correspond to any of the responses in the dialog.
762//
763// The default close response is `close`.
764func (x *AlertDialog) SetPropertyCloseResponse(value string) {
765 var v gobject.Value
766 v.Init(gobject.TypeStringVal)
767 v.SetString(&value)
768 x.SetProperty("close-response", &v)
769}
770
771// GetPropertyCloseResponse gets the "close-response" property.
772// The ID of the close response.
773//
774// It will be passed to [signal@AlertDialog::response] if the dialog is
775// closed by pressing <kbd>Escape</kbd> or with a system action.
776//
777// It doesn't have to correspond to any of the responses in the dialog.
778//
779// The default close response is `close`.
780func (x *AlertDialog) GetPropertyCloseResponse() string {
781 var v gobject.Value
782 x.GetProperty("close-response", &v)
783 return v.GetString()
784}
785
786// SetPropertyDefaultResponse sets the "default-response" property.
787// The response ID of the default response.
788//
789// The button corresponding to this response will be set as the default widget
790// of the dialog.
791//
792// If not set, the default widget will not be set, and the last added response
793// will be focused by default.
794//
795// See [property@Dialog:default-widget].
796func (x *AlertDialog) SetPropertyDefaultResponse(value string) {
797 var v gobject.Value
798 v.Init(gobject.TypeStringVal)
799 v.SetString(&value)
800 x.SetProperty("default-response", &v)
801}
802
803// GetPropertyDefaultResponse gets the "default-response" property.
804// The response ID of the default response.
805//
806// The button corresponding to this response will be set as the default widget
807// of the dialog.
808//
809// If not set, the default widget will not be set, and the last added response
810// will be focused by default.
811//
812// See [property@Dialog:default-widget].
813func (x *AlertDialog) GetPropertyDefaultResponse() string {
814 var v gobject.Value
815 x.GetProperty("default-response", &v)
816 return v.GetString()
817}
818
819// SetPropertyHeading sets the "heading" property.
820// The heading of the dialog.
821func (x *AlertDialog) SetPropertyHeading(value string) {
822 var v gobject.Value
823 v.Init(gobject.TypeStringVal)
824 v.SetString(&value)
825 x.SetProperty("heading", &v)
826}
827
828// GetPropertyHeading gets the "heading" property.
829// The heading of the dialog.
830func (x *AlertDialog) GetPropertyHeading() string {
831 var v gobject.Value
832 x.GetProperty("heading", &v)
833 return v.GetString()
834}
835
836// SetPropertyHeadingUseMarkup sets the "heading-use-markup" property.
837// Whether the heading includes Pango markup.
838//
839// See [func@Pango.parse_markup].
840func (x *AlertDialog) SetPropertyHeadingUseMarkup(value bool) {
841 var v gobject.Value
842 v.Init(gobject.TypeBooleanVal)
843 v.SetBoolean(value)
844 x.SetProperty("heading-use-markup", &v)
845}
846
847// GetPropertyHeadingUseMarkup gets the "heading-use-markup" property.
848// Whether the heading includes Pango markup.
849//
850// See [func@Pango.parse_markup].
851func (x *AlertDialog) GetPropertyHeadingUseMarkup() bool {
852 var v gobject.Value
853 x.GetProperty("heading-use-markup", &v)
854 return v.GetBoolean()
855}
856
857// SetPropertyPreferWideLayout sets the "prefer-wide-layout" property.
858// Whether to prefer wide layout.
859//
860// Prefer horizontal button layout when possible, and wider dialog width
861// otherwise.
862func (x *AlertDialog) SetPropertyPreferWideLayout(value bool) {
863 var v gobject.Value
864 v.Init(gobject.TypeBooleanVal)
865 v.SetBoolean(value)
866 x.SetProperty("prefer-wide-layout", &v)
867}
868
869// GetPropertyPreferWideLayout gets the "prefer-wide-layout" property.
870// Whether to prefer wide layout.
871//
872// Prefer horizontal button layout when possible, and wider dialog width
873// otherwise.
874func (x *AlertDialog) GetPropertyPreferWideLayout() bool {
875 var v gobject.Value
876 x.GetProperty("prefer-wide-layout", &v)
877 return v.GetBoolean()
878}
879
880// This signal is emitted when the dialog is closed.
881//
882// @response will be set to the response ID of the button that had been
883// activated.
884//
885// if the dialog was closed by pressing <kbd>Escape</kbd> or with a system
886// action, @response will be set to the value of
887// [property@AlertDialog:close-response].
888func (x *AlertDialog) ConnectResponse(cb *func(AlertDialog, string)) uint {
889 cbPtr := uintptr(unsafe.Pointer(cb))
890 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
891 handlerID := gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr)
892 glib.SaveHandlerMapping(handlerID, cbPtr)
893 return handlerID
894 }
895
896 fcb := func(clsPtr uintptr, ResponseVarp uintptr) {
897 fa := AlertDialog{}
898 fa.Ptr = clsPtr
899 cbFn := *cb
900
901 cbFn(fa, core.GoString(ResponseVarp))
902
903 }
904 cbRefPtr := purego.NewCallback(fcb)
905 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
906 handlerID := gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr)
907 glib.SaveHandlerMapping(handlerID, cbPtr)
908 return handlerID
909}
910
911// ConnectResponseWithDetail connects to the "response" signal with a detail string.
912// The detail is appended as "response::<detail>".
913func (x *AlertDialog) ConnectResponseWithDetail(detail string, cb *func(AlertDialog, string)) uint {
914 cbPtr := uintptr(unsafe.Pointer(cb))
915 signalName := fmt.Sprintf("response::%s", detail)
916 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
917 handlerID := gobject.SignalConnect(x.GoPointer(), signalName, cbRefPtr)
918 glib.SaveHandlerMapping(handlerID, cbPtr)
919 return handlerID
920 }
921
922 fcb := func(clsPtr uintptr, ResponseVarp uintptr) {
923 fa := AlertDialog{}
924 fa.Ptr = clsPtr
925 cbFn := *cb
926
927 cbFn(fa, core.GoString(ResponseVarp))
928
929 }
930 cbRefPtr := purego.NewCallback(fcb)
931 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
932 handlerID := gobject.SignalConnect(x.GoPointer(), signalName, cbRefPtr)
933 glib.SaveHandlerMapping(handlerID, cbPtr)
934 return handlerID
935}
936
937// Requests the user's screen reader to announce the given message.
938//
939// This kind of notification is useful for messages that
940// either have only a visual representation or that are not
941// exposed visually at all, e.g. a notification about a
942// successful operation.
943//
944// Also, by using this API, you can ensure that the message
945// does not interrupts the user's current screen reader output.
946func (x *AlertDialog) Announce(MessageVar string, PriorityVar gtk.AccessibleAnnouncementPriority) {
947
948 gtk.XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar)
949
950}
951
952// Retrieves the accessible parent for an accessible object.
953//
954// This function returns `NULL` for top level widgets.
955func (x *AlertDialog) GetAccessibleParent() *gtk.AccessibleBase {
956 var cls *gtk.AccessibleBase
957
958 cret := gtk.XGtkAccessibleGetAccessibleParent(x.GoPointer())
959
960 if cret == 0 {
961 return nil
962 }
963 cls = >k.AccessibleBase{}
964 cls.Ptr = cret
965 return cls
966}
967
968// Retrieves the accessible role of an accessible object.
969func (x *AlertDialog) GetAccessibleRole() gtk.AccessibleRole {
970
971 cret := gtk.XGtkAccessibleGetAccessibleRole(x.GoPointer())
972 return cret
973}
974
975// Retrieves the implementation for the given accessible object.
976func (x *AlertDialog) GetAtContext() *gtk.ATContext {
977 var cls *gtk.ATContext
978
979 cret := gtk.XGtkAccessibleGetAtContext(x.GoPointer())
980
981 if cret == 0 {
982 return nil
983 }
984 cls = >k.ATContext{}
985 cls.Ptr = cret
986 return cls
987}
988
989// Queries the coordinates and dimensions of this accessible
990//
991// This functionality can be overridden by `GtkAccessible`
992// implementations, e.g. to get the bounds from an ignored
993// child widget.
994func (x *AlertDialog) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool {
995
996 cret := gtk.XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar)
997 return cret
998}
999
1000// Retrieves the first accessible child of an accessible object.
1001func (x *AlertDialog) GetFirstAccessibleChild() *gtk.AccessibleBase {
1002 var cls *gtk.AccessibleBase
1003
1004 cret := gtk.XGtkAccessibleGetFirstAccessibleChild(x.GoPointer())
1005
1006 if cret == 0 {
1007 return nil
1008 }
1009 cls = >k.AccessibleBase{}
1010 cls.Ptr = cret
1011 return cls
1012}
1013
1014// Retrieves the next accessible sibling of an accessible object
1015func (x *AlertDialog) GetNextAccessibleSibling() *gtk.AccessibleBase {
1016 var cls *gtk.AccessibleBase
1017
1018 cret := gtk.XGtkAccessibleGetNextAccessibleSibling(x.GoPointer())
1019
1020 if cret == 0 {
1021 return nil
1022 }
1023 cls = >k.AccessibleBase{}
1024 cls.Ptr = cret
1025 return cls
1026}
1027
1028// Queries a platform state, such as focus.
1029//
1030// This functionality can be overridden by `GtkAccessible`
1031// implementations, e.g. to get platform state from an ignored
1032// child widget, as is the case for `GtkText` wrappers.
1033func (x *AlertDialog) GetPlatformState(StateVar gtk.AccessiblePlatformState) bool {
1034
1035 cret := gtk.XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar)
1036 return cret
1037}
1038
1039// Resets the accessible property to its default value.
1040func (x *AlertDialog) ResetProperty(PropertyVar gtk.AccessibleProperty) {
1041
1042 gtk.XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar)
1043
1044}
1045
1046// Resets the accessible relation to its default value.
1047func (x *AlertDialog) ResetRelation(RelationVar gtk.AccessibleRelation) {
1048
1049 gtk.XGtkAccessibleResetRelation(x.GoPointer(), RelationVar)
1050
1051}
1052
1053// Resets the accessible state to its default value.
1054func (x *AlertDialog) ResetState(StateVar gtk.AccessibleState) {
1055
1056 gtk.XGtkAccessibleResetState(x.GoPointer(), StateVar)
1057
1058}
1059
1060// Sets the parent and sibling of an accessible object.
1061//
1062// This function is meant to be used by accessible implementations that are
1063// not part of the widget hierarchy, and but act as a logical bridge between
1064// widgets. For instance, if a widget creates an object that holds metadata
1065// for each child, and you want that object to implement the `GtkAccessible`
1066// interface, you will use this function to ensure that the parent of each
1067// child widget is the metadata object, and the parent of each metadata
1068// object is the container widget.
1069func (x *AlertDialog) SetAccessibleParent(ParentVar gtk.Accessible, NextSiblingVar gtk.Accessible) {
1070
1071 gtk.XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer())
1072
1073}
1074
1075// Updates the next accessible sibling.
1076//
1077// That might be useful when a new child of a custom accessible
1078// is created, and it needs to be linked to a previous child.
1079func (x *AlertDialog) UpdateNextAccessibleSibling(NewSiblingVar gtk.Accessible) {
1080
1081 gtk.XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer())
1082
1083}
1084
1085// Informs ATs that the platform state has changed.
1086//
1087// This function should be used by `GtkAccessible` implementations that
1088// have a platform state but are not widgets. Widgets handle platform
1089// states automatically.
1090func (x *AlertDialog) UpdatePlatformState(StateVar gtk.AccessiblePlatformState) {
1091
1092 gtk.XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar)
1093
1094}
1095
1096// Updates a list of accessible properties.
1097//
1098// See the [enum@Gtk.AccessibleProperty] documentation for the
1099// value types of accessible properties.
1100//
1101// This function should be called by `GtkWidget` types whenever
1102// an accessible property change must be communicated to assistive
1103// technologies.
1104//
1105// Example:
1106// ```c
1107// value = gtk_adjustment_get_value (adjustment);
1108// gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button),
1109//
1110// GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
1111// -1);
1112//
1113// ```
1114func (x *AlertDialog) UpdateProperty(FirstPropertyVar gtk.AccessibleProperty, varArgs ...interface{}) {
1115
1116 gtk.XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...)
1117
1118}
1119
1120// Updates an array of accessible properties.
1121//
1122// This function should be called by `GtkWidget` types whenever an accessible
1123// property change must be communicated to assistive technologies.
1124//
1125// This function is meant to be used by language bindings.
1126func (x *AlertDialog) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []gtk.AccessibleProperty, ValuesVar []gobject.Value) {
1127
1128 gtk.XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar)
1129
1130}
1131
1132// Updates a list of accessible relations.
1133//
1134// This function should be called by `GtkWidget` types whenever an accessible
1135// relation change must be communicated to assistive technologies.
1136//
1137// If the [enum@Gtk.AccessibleRelation] requires a list of references,
1138// you should pass each reference individually, followed by `NULL`, e.g.
1139//
1140// ```c
1141// gtk_accessible_update_relation (accessible,
1142//
1143// GTK_ACCESSIBLE_RELATION_CONTROLS,
1144// ref1, NULL,
1145// GTK_ACCESSIBLE_RELATION_LABELLED_BY,
1146// ref1, ref2, ref3, NULL,
1147// -1);
1148//
1149// ```
1150func (x *AlertDialog) UpdateRelation(FirstRelationVar gtk.AccessibleRelation, varArgs ...interface{}) {
1151
1152 gtk.XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...)
1153
1154}
1155
1156// Updates an array of accessible relations.
1157//
1158// This function should be called by `GtkWidget` types whenever an accessible
1159// relation change must be communicated to assistive technologies.
1160//
1161// This function is meant to be used by language bindings.
1162func (x *AlertDialog) UpdateRelationValue(NRelationsVar int, RelationsVar []gtk.AccessibleRelation, ValuesVar []gobject.Value) {
1163
1164 gtk.XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar)
1165
1166}
1167
1168// Updates a list of accessible states.
1169//
1170// See the [enum@Gtk.AccessibleState] documentation for the
1171// value types of accessible states.
1172//
1173// This function should be called by `GtkWidget` types whenever
1174// an accessible state change must be communicated to assistive
1175// technologies.
1176//
1177// Example:
1178//
1179// ```c
1180// value = GTK_ACCESSIBLE_TRISTATE_MIXED;
1181// gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
1182//
1183// GTK_ACCESSIBLE_STATE_CHECKED, value,
1184// -1);
1185//
1186// ```
1187func (x *AlertDialog) UpdateState(FirstStateVar gtk.AccessibleState, varArgs ...interface{}) {
1188
1189 gtk.XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...)
1190
1191}
1192
1193// Updates an array of accessible states.
1194//
1195// This function should be called by `GtkWidget` types whenever an accessible
1196// state change must be communicated to assistive technologies.
1197//
1198// This function is meant to be used by language bindings.
1199func (x *AlertDialog) UpdateStateValue(NStatesVar int, StatesVar []gtk.AccessibleState, ValuesVar []gobject.Value) {
1200
1201 gtk.XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar)
1202
1203}
1204
1205// Gets the ID of the @buildable object.
1206//
1207// `GtkBuilder` sets the name based on the ID attribute
1208// of the `<object>` tag used to construct the @buildable.
1209func (x *AlertDialog) GetBuildableId() string {
1210
1211 cret := gtk.XGtkBuildableGetBuildableId(x.GoPointer())
1212 return cret
1213}
1214
1215func init() {
1216 core.SetPackageName("ADW", "libadwaita-1")
1217 core.SetSharedLibraries("ADW", []string{"libadwaita-1.so.0"})
1218 var libs []uintptr
1219 for _, libPath := range core.GetPaths("ADW") {
1220 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1221 if err != nil {
1222 panic(err)
1223 }
1224 libs = append(libs, lib)
1225 }
1226
1227 core.PuregoSafeRegister(&xResponseAppearanceGLibType, libs, "adw_response_appearance_get_type")
1228
1229 core.PuregoSafeRegister(&xAlertDialogGLibType, libs, "adw_alert_dialog_get_type")
1230
1231 core.PuregoSafeRegister(&xNewAlertDialog, libs, "adw_alert_dialog_new")
1232
1233 core.PuregoSafeRegister(&xAlertDialogAddResponse, libs, "adw_alert_dialog_add_response")
1234 core.PuregoSafeRegister(&xAlertDialogAddResponses, libs, "adw_alert_dialog_add_responses")
1235 core.PuregoSafeRegister(&xAlertDialogChoose, libs, "adw_alert_dialog_choose")
1236 core.PuregoSafeRegister(&xAlertDialogChooseFinish, libs, "adw_alert_dialog_choose_finish")
1237 core.PuregoSafeRegister(&xAlertDialogFormatBody, libs, "adw_alert_dialog_format_body")
1238 core.PuregoSafeRegister(&xAlertDialogFormatBodyMarkup, libs, "adw_alert_dialog_format_body_markup")
1239 core.PuregoSafeRegister(&xAlertDialogFormatHeading, libs, "adw_alert_dialog_format_heading")
1240 core.PuregoSafeRegister(&xAlertDialogFormatHeadingMarkup, libs, "adw_alert_dialog_format_heading_markup")
1241 core.PuregoSafeRegister(&xAlertDialogGetBody, libs, "adw_alert_dialog_get_body")
1242 core.PuregoSafeRegister(&xAlertDialogGetBodyUseMarkup, libs, "adw_alert_dialog_get_body_use_markup")
1243 core.PuregoSafeRegister(&xAlertDialogGetCloseResponse, libs, "adw_alert_dialog_get_close_response")
1244 core.PuregoSafeRegister(&xAlertDialogGetDefaultResponse, libs, "adw_alert_dialog_get_default_response")
1245 core.PuregoSafeRegister(&xAlertDialogGetExtraChild, libs, "adw_alert_dialog_get_extra_child")
1246 core.PuregoSafeRegister(&xAlertDialogGetHeading, libs, "adw_alert_dialog_get_heading")
1247 core.PuregoSafeRegister(&xAlertDialogGetHeadingUseMarkup, libs, "adw_alert_dialog_get_heading_use_markup")
1248 core.PuregoSafeRegister(&xAlertDialogGetPreferWideLayout, libs, "adw_alert_dialog_get_prefer_wide_layout")
1249 core.PuregoSafeRegister(&xAlertDialogGetResponseAppearance, libs, "adw_alert_dialog_get_response_appearance")
1250 core.PuregoSafeRegister(&xAlertDialogGetResponseEnabled, libs, "adw_alert_dialog_get_response_enabled")
1251 core.PuregoSafeRegister(&xAlertDialogGetResponseLabel, libs, "adw_alert_dialog_get_response_label")
1252 core.PuregoSafeRegister(&xAlertDialogHasResponse, libs, "adw_alert_dialog_has_response")
1253 core.PuregoSafeRegister(&xAlertDialogRemoveResponse, libs, "adw_alert_dialog_remove_response")
1254 core.PuregoSafeRegister(&xAlertDialogSetBody, libs, "adw_alert_dialog_set_body")
1255 core.PuregoSafeRegister(&xAlertDialogSetBodyUseMarkup, libs, "adw_alert_dialog_set_body_use_markup")
1256 core.PuregoSafeRegister(&xAlertDialogSetCloseResponse, libs, "adw_alert_dialog_set_close_response")
1257 core.PuregoSafeRegister(&xAlertDialogSetDefaultResponse, libs, "adw_alert_dialog_set_default_response")
1258 core.PuregoSafeRegister(&xAlertDialogSetExtraChild, libs, "adw_alert_dialog_set_extra_child")
1259 core.PuregoSafeRegister(&xAlertDialogSetHeading, libs, "adw_alert_dialog_set_heading")
1260 core.PuregoSafeRegister(&xAlertDialogSetHeadingUseMarkup, libs, "adw_alert_dialog_set_heading_use_markup")
1261 core.PuregoSafeRegister(&xAlertDialogSetPreferWideLayout, libs, "adw_alert_dialog_set_prefer_wide_layout")
1262 core.PuregoSafeRegister(&xAlertDialogSetResponseAppearance, libs, "adw_alert_dialog_set_response_appearance")
1263 core.PuregoSafeRegister(&xAlertDialogSetResponseEnabled, libs, "adw_alert_dialog_set_response_enabled")
1264 core.PuregoSafeRegister(&xAlertDialogSetResponseLabel, libs, "adw_alert_dialog_set_response_label")
1265
1266}