libadwaita/auto/
application_window.rs

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