gtk4/auto/
message_dialog.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4#![allow(deprecated)]
5
6use crate::{
7    ffi, Accessible, AccessibleRole, Align, Application, Buildable, ButtonsType, ConstraintTarget,
8    Dialog, LayoutManager, MessageType, Native, Overflow, Root, ShortcutManager, Widget, Window,
9};
10use glib::{
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    #[doc(alias = "GtkMessageDialog")]
19    pub struct MessageDialog(Object<ffi::GtkMessageDialog, ffi::GtkMessageDialogClass>) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager;
20
21    match fn {
22        type_ => || ffi::gtk_message_dialog_get_type(),
23    }
24}
25
26impl MessageDialog {
27    // rustdoc-stripper-ignore-next
28    /// Creates a new builder-pattern struct instance to construct [`MessageDialog`] objects.
29    ///
30    /// This method returns an instance of [`MessageDialogBuilder`](crate::builders::MessageDialogBuilder) which can be used to create [`MessageDialog`] objects.
31    pub fn builder() -> MessageDialogBuilder {
32        MessageDialogBuilder::new()
33    }
34
35    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
36    #[allow(deprecated)]
37    #[doc(alias = "gtk_message_dialog_get_message_area")]
38    #[doc(alias = "get_message_area")]
39    #[doc(alias = "message-area")]
40    pub fn message_area(&self) -> Widget {
41        unsafe {
42            from_glib_none(ffi::gtk_message_dialog_get_message_area(
43                self.to_glib_none().0,
44            ))
45        }
46    }
47
48    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
49    #[allow(deprecated)]
50    #[doc(alias = "gtk_message_dialog_set_markup")]
51    pub fn set_markup(&self, str: &str) {
52        unsafe {
53            ffi::gtk_message_dialog_set_markup(self.to_glib_none().0, str.to_glib_none().0);
54        }
55    }
56
57    #[doc(alias = "message-type")]
58    pub fn message_type(&self) -> MessageType {
59        ObjectExt::property(self, "message-type")
60    }
61
62    #[doc(alias = "message-type")]
63    pub fn set_message_type(&self, message_type: MessageType) {
64        ObjectExt::set_property(self, "message-type", message_type)
65    }
66
67    #[doc(alias = "secondary-text")]
68    pub fn secondary_text(&self) -> Option<glib::GString> {
69        ObjectExt::property(self, "secondary-text")
70    }
71
72    #[doc(alias = "secondary-text")]
73    pub fn set_secondary_text(&self, secondary_text: Option<&str>) {
74        ObjectExt::set_property(self, "secondary-text", secondary_text)
75    }
76
77    #[doc(alias = "secondary-use-markup")]
78    pub fn is_secondary_use_markup(&self) -> bool {
79        ObjectExt::property(self, "secondary-use-markup")
80    }
81
82    #[doc(alias = "secondary-use-markup")]
83    pub fn set_secondary_use_markup(&self, secondary_use_markup: bool) {
84        ObjectExt::set_property(self, "secondary-use-markup", secondary_use_markup)
85    }
86
87    pub fn text(&self) -> Option<glib::GString> {
88        ObjectExt::property(self, "text")
89    }
90
91    pub fn set_text(&self, text: Option<&str>) {
92        ObjectExt::set_property(self, "text", text)
93    }
94
95    #[doc(alias = "use-markup")]
96    pub fn uses_markup(&self) -> bool {
97        ObjectExt::property(self, "use-markup")
98    }
99
100    #[doc(alias = "use-markup")]
101    pub fn set_use_markup(&self, use_markup: bool) {
102        ObjectExt::set_property(self, "use-markup", use_markup)
103    }
104
105    #[doc(alias = "message-area")]
106    pub fn connect_message_area_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
107        unsafe extern "C" fn notify_message_area_trampoline<F: Fn(&MessageDialog) + 'static>(
108            this: *mut ffi::GtkMessageDialog,
109            _param_spec: glib::ffi::gpointer,
110            f: glib::ffi::gpointer,
111        ) {
112            let f: &F = &*(f as *const F);
113            f(&from_glib_borrow(this))
114        }
115        unsafe {
116            let f: Box_<F> = Box_::new(f);
117            connect_raw(
118                self.as_ptr() as *mut _,
119                b"notify::message-area\0".as_ptr() as *const _,
120                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
121                    notify_message_area_trampoline::<F> as *const (),
122                )),
123                Box_::into_raw(f),
124            )
125        }
126    }
127
128    #[doc(alias = "message-type")]
129    pub fn connect_message_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
130        unsafe extern "C" fn notify_message_type_trampoline<F: Fn(&MessageDialog) + 'static>(
131            this: *mut ffi::GtkMessageDialog,
132            _param_spec: glib::ffi::gpointer,
133            f: glib::ffi::gpointer,
134        ) {
135            let f: &F = &*(f as *const F);
136            f(&from_glib_borrow(this))
137        }
138        unsafe {
139            let f: Box_<F> = Box_::new(f);
140            connect_raw(
141                self.as_ptr() as *mut _,
142                b"notify::message-type\0".as_ptr() as *const _,
143                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
144                    notify_message_type_trampoline::<F> as *const (),
145                )),
146                Box_::into_raw(f),
147            )
148        }
149    }
150
151    #[doc(alias = "secondary-text")]
152    pub fn connect_secondary_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
153        unsafe extern "C" fn notify_secondary_text_trampoline<F: Fn(&MessageDialog) + 'static>(
154            this: *mut ffi::GtkMessageDialog,
155            _param_spec: glib::ffi::gpointer,
156            f: glib::ffi::gpointer,
157        ) {
158            let f: &F = &*(f as *const F);
159            f(&from_glib_borrow(this))
160        }
161        unsafe {
162            let f: Box_<F> = Box_::new(f);
163            connect_raw(
164                self.as_ptr() as *mut _,
165                b"notify::secondary-text\0".as_ptr() as *const _,
166                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
167                    notify_secondary_text_trampoline::<F> as *const (),
168                )),
169                Box_::into_raw(f),
170            )
171        }
172    }
173
174    #[doc(alias = "secondary-use-markup")]
175    pub fn connect_secondary_use_markup_notify<F: Fn(&Self) + 'static>(
176        &self,
177        f: F,
178    ) -> SignalHandlerId {
179        unsafe extern "C" fn notify_secondary_use_markup_trampoline<
180            F: Fn(&MessageDialog) + 'static,
181        >(
182            this: *mut ffi::GtkMessageDialog,
183            _param_spec: glib::ffi::gpointer,
184            f: glib::ffi::gpointer,
185        ) {
186            let f: &F = &*(f as *const F);
187            f(&from_glib_borrow(this))
188        }
189        unsafe {
190            let f: Box_<F> = Box_::new(f);
191            connect_raw(
192                self.as_ptr() as *mut _,
193                b"notify::secondary-use-markup\0".as_ptr() as *const _,
194                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
195                    notify_secondary_use_markup_trampoline::<F> as *const (),
196                )),
197                Box_::into_raw(f),
198            )
199        }
200    }
201
202    #[doc(alias = "text")]
203    pub fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
204        unsafe extern "C" fn notify_text_trampoline<F: Fn(&MessageDialog) + 'static>(
205            this: *mut ffi::GtkMessageDialog,
206            _param_spec: glib::ffi::gpointer,
207            f: glib::ffi::gpointer,
208        ) {
209            let f: &F = &*(f as *const F);
210            f(&from_glib_borrow(this))
211        }
212        unsafe {
213            let f: Box_<F> = Box_::new(f);
214            connect_raw(
215                self.as_ptr() as *mut _,
216                b"notify::text\0".as_ptr() as *const _,
217                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218                    notify_text_trampoline::<F> as *const (),
219                )),
220                Box_::into_raw(f),
221            )
222        }
223    }
224
225    #[doc(alias = "use-markup")]
226    pub fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
227        unsafe extern "C" fn notify_use_markup_trampoline<F: Fn(&MessageDialog) + 'static>(
228            this: *mut ffi::GtkMessageDialog,
229            _param_spec: glib::ffi::gpointer,
230            f: glib::ffi::gpointer,
231        ) {
232            let f: &F = &*(f as *const F);
233            f(&from_glib_borrow(this))
234        }
235        unsafe {
236            let f: Box_<F> = Box_::new(f);
237            connect_raw(
238                self.as_ptr() as *mut _,
239                b"notify::use-markup\0".as_ptr() as *const _,
240                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
241                    notify_use_markup_trampoline::<F> as *const (),
242                )),
243                Box_::into_raw(f),
244            )
245        }
246    }
247}
248
249// rustdoc-stripper-ignore-next
250/// A [builder-pattern] type to construct [`MessageDialog`] objects.
251///
252/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
253#[must_use = "The builder must be built to be used"]
254pub struct MessageDialogBuilder {
255    builder: glib::object::ObjectBuilder<'static, MessageDialog>,
256}
257
258impl MessageDialogBuilder {
259    fn new() -> Self {
260        Self {
261            builder: glib::object::Object::builder(),
262        }
263    }
264
265    pub fn buttons(self, buttons: ButtonsType) -> Self {
266        Self {
267            builder: self.builder.property("buttons", buttons),
268        }
269    }
270
271    pub fn message_type(self, message_type: MessageType) -> Self {
272        Self {
273            builder: self.builder.property("message-type", message_type),
274        }
275    }
276
277    pub fn secondary_text(self, secondary_text: impl Into<glib::GString>) -> Self {
278        Self {
279            builder: self
280                .builder
281                .property("secondary-text", secondary_text.into()),
282        }
283    }
284
285    pub fn secondary_use_markup(self, secondary_use_markup: bool) -> Self {
286        Self {
287            builder: self
288                .builder
289                .property("secondary-use-markup", secondary_use_markup),
290        }
291    }
292
293    pub fn text(self, text: impl Into<glib::GString>) -> Self {
294        Self {
295            builder: self.builder.property("text", text.into()),
296        }
297    }
298
299    pub fn use_markup(self, use_markup: bool) -> Self {
300        Self {
301            builder: self.builder.property("use-markup", use_markup),
302        }
303    }
304
305    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
306    pub fn use_header_bar(self, use_header_bar: i32) -> Self {
307        Self {
308            builder: self.builder.property("use-header-bar", use_header_bar),
309        }
310    }
311
312    pub fn application(self, application: &impl IsA<Application>) -> Self {
313        Self {
314            builder: self
315                .builder
316                .property("application", application.clone().upcast()),
317        }
318    }
319
320    pub fn child(self, child: &impl IsA<Widget>) -> Self {
321        Self {
322            builder: self.builder.property("child", child.clone().upcast()),
323        }
324    }
325
326    pub fn decorated(self, decorated: bool) -> Self {
327        Self {
328            builder: self.builder.property("decorated", decorated),
329        }
330    }
331
332    pub fn default_height(self, default_height: i32) -> Self {
333        Self {
334            builder: self.builder.property("default-height", default_height),
335        }
336    }
337
338    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
339        Self {
340            builder: self
341                .builder
342                .property("default-widget", default_widget.clone().upcast()),
343        }
344    }
345
346    pub fn default_width(self, default_width: i32) -> Self {
347        Self {
348            builder: self.builder.property("default-width", default_width),
349        }
350    }
351
352    pub fn deletable(self, deletable: bool) -> Self {
353        Self {
354            builder: self.builder.property("deletable", deletable),
355        }
356    }
357
358    pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
359        Self {
360            builder: self
361                .builder
362                .property("destroy-with-parent", destroy_with_parent),
363        }
364    }
365
366    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
367        Self {
368            builder: self.builder.property("display", display.clone().upcast()),
369        }
370    }
371
372    pub fn focus_visible(self, focus_visible: bool) -> Self {
373        Self {
374            builder: self.builder.property("focus-visible", focus_visible),
375        }
376    }
377
378    pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
379        Self {
380            builder: self
381                .builder
382                .property("focus-widget", focus_widget.clone().upcast()),
383        }
384    }
385
386    pub fn fullscreened(self, fullscreened: bool) -> Self {
387        Self {
388            builder: self.builder.property("fullscreened", fullscreened),
389        }
390    }
391
392    #[cfg(feature = "v4_2")]
393    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
394    pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
395        Self {
396            builder: self
397                .builder
398                .property("handle-menubar-accel", handle_menubar_accel),
399        }
400    }
401
402    pub fn hide_on_close(self, hide_on_close: bool) -> Self {
403        Self {
404            builder: self.builder.property("hide-on-close", hide_on_close),
405        }
406    }
407
408    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
409        Self {
410            builder: self.builder.property("icon-name", icon_name.into()),
411        }
412    }
413
414    pub fn maximized(self, maximized: bool) -> Self {
415        Self {
416            builder: self.builder.property("maximized", maximized),
417        }
418    }
419
420    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
421        Self {
422            builder: self
423                .builder
424                .property("mnemonics-visible", mnemonics_visible),
425        }
426    }
427
428    pub fn modal(self, modal: bool) -> Self {
429        Self {
430            builder: self.builder.property("modal", modal),
431        }
432    }
433
434    pub fn resizable(self, resizable: bool) -> Self {
435        Self {
436            builder: self.builder.property("resizable", resizable),
437        }
438    }
439
440    pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
441        Self {
442            builder: self.builder.property("startup-id", startup_id.into()),
443        }
444    }
445
446    pub fn title(self, title: impl Into<glib::GString>) -> Self {
447        Self {
448            builder: self.builder.property("title", title.into()),
449        }
450    }
451
452    #[cfg(feature = "v4_6")]
453    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
454    pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
455        Self {
456            builder: self.builder.property("titlebar", titlebar.clone().upcast()),
457        }
458    }
459
460    pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
461        Self {
462            builder: self
463                .builder
464                .property("transient-for", transient_for.clone().upcast()),
465        }
466    }
467
468    pub fn can_focus(self, can_focus: bool) -> Self {
469        Self {
470            builder: self.builder.property("can-focus", can_focus),
471        }
472    }
473
474    pub fn can_target(self, can_target: bool) -> Self {
475        Self {
476            builder: self.builder.property("can-target", can_target),
477        }
478    }
479
480    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
481        Self {
482            builder: self.builder.property("css-classes", css_classes.into()),
483        }
484    }
485
486    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
487        Self {
488            builder: self.builder.property("css-name", css_name.into()),
489        }
490    }
491
492    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
493        Self {
494            builder: self.builder.property("cursor", cursor.clone()),
495        }
496    }
497
498    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
499        Self {
500            builder: self.builder.property("focus-on-click", focus_on_click),
501        }
502    }
503
504    pub fn focusable(self, focusable: bool) -> Self {
505        Self {
506            builder: self.builder.property("focusable", focusable),
507        }
508    }
509
510    pub fn halign(self, halign: Align) -> Self {
511        Self {
512            builder: self.builder.property("halign", halign),
513        }
514    }
515
516    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
517        Self {
518            builder: self.builder.property("has-tooltip", has_tooltip),
519        }
520    }
521
522    pub fn height_request(self, height_request: i32) -> Self {
523        Self {
524            builder: self.builder.property("height-request", height_request),
525        }
526    }
527
528    pub fn hexpand(self, hexpand: bool) -> Self {
529        Self {
530            builder: self.builder.property("hexpand", hexpand),
531        }
532    }
533
534    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
535        Self {
536            builder: self.builder.property("hexpand-set", hexpand_set),
537        }
538    }
539
540    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
541        Self {
542            builder: self
543                .builder
544                .property("layout-manager", layout_manager.clone().upcast()),
545        }
546    }
547
548    #[cfg(feature = "v4_18")]
549    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
550    pub fn limit_events(self, limit_events: bool) -> Self {
551        Self {
552            builder: self.builder.property("limit-events", limit_events),
553        }
554    }
555
556    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
557        Self {
558            builder: self.builder.property("margin-bottom", margin_bottom),
559        }
560    }
561
562    pub fn margin_end(self, margin_end: i32) -> Self {
563        Self {
564            builder: self.builder.property("margin-end", margin_end),
565        }
566    }
567
568    pub fn margin_start(self, margin_start: i32) -> Self {
569        Self {
570            builder: self.builder.property("margin-start", margin_start),
571        }
572    }
573
574    pub fn margin_top(self, margin_top: i32) -> Self {
575        Self {
576            builder: self.builder.property("margin-top", margin_top),
577        }
578    }
579
580    pub fn name(self, name: impl Into<glib::GString>) -> Self {
581        Self {
582            builder: self.builder.property("name", name.into()),
583        }
584    }
585
586    pub fn opacity(self, opacity: f64) -> Self {
587        Self {
588            builder: self.builder.property("opacity", opacity),
589        }
590    }
591
592    pub fn overflow(self, overflow: Overflow) -> Self {
593        Self {
594            builder: self.builder.property("overflow", overflow),
595        }
596    }
597
598    pub fn receives_default(self, receives_default: bool) -> Self {
599        Self {
600            builder: self.builder.property("receives-default", receives_default),
601        }
602    }
603
604    pub fn sensitive(self, sensitive: bool) -> Self {
605        Self {
606            builder: self.builder.property("sensitive", sensitive),
607        }
608    }
609
610    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
611        Self {
612            builder: self
613                .builder
614                .property("tooltip-markup", tooltip_markup.into()),
615        }
616    }
617
618    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
619        Self {
620            builder: self.builder.property("tooltip-text", tooltip_text.into()),
621        }
622    }
623
624    pub fn valign(self, valign: Align) -> Self {
625        Self {
626            builder: self.builder.property("valign", valign),
627        }
628    }
629
630    pub fn vexpand(self, vexpand: bool) -> Self {
631        Self {
632            builder: self.builder.property("vexpand", vexpand),
633        }
634    }
635
636    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
637        Self {
638            builder: self.builder.property("vexpand-set", vexpand_set),
639        }
640    }
641
642    pub fn visible(self, visible: bool) -> Self {
643        Self {
644            builder: self.builder.property("visible", visible),
645        }
646    }
647
648    pub fn width_request(self, width_request: i32) -> Self {
649        Self {
650            builder: self.builder.property("width-request", width_request),
651        }
652    }
653
654    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
655        Self {
656            builder: self.builder.property("accessible-role", accessible_role),
657        }
658    }
659
660    // rustdoc-stripper-ignore-next
661    /// Build the [`MessageDialog`].
662    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
663    pub fn build(self) -> MessageDialog {
664        assert_initialized_main_thread!();
665        self.builder.build()
666    }
667}