gtk4/auto/
app_chooser_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, AppChooser, Buildable, ConstraintTarget, Dialog, DialogFlags, Native, Root,
8    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 = "GtkAppChooserDialog")]
19    pub struct AppChooserDialog(Object<ffi::GtkAppChooserDialog>) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, AppChooser;
20
21    match fn {
22        type_ => || ffi::gtk_app_chooser_dialog_get_type(),
23    }
24}
25
26impl AppChooserDialog {
27    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
28    #[allow(deprecated)]
29    #[doc(alias = "gtk_app_chooser_dialog_new")]
30    pub fn new(
31        parent: Option<&impl IsA<Window>>,
32        flags: DialogFlags,
33        file: &impl IsA<gio::File>,
34    ) -> AppChooserDialog {
35        assert_initialized_main_thread!();
36        unsafe {
37            Widget::from_glib_none(ffi::gtk_app_chooser_dialog_new(
38                parent.map(|p| p.as_ref()).to_glib_none().0,
39                flags.into_glib(),
40                file.as_ref().to_glib_none().0,
41            ))
42            .unsafe_cast()
43        }
44    }
45
46    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
47    #[allow(deprecated)]
48    #[doc(alias = "gtk_app_chooser_dialog_new_for_content_type")]
49    #[doc(alias = "new_for_content_type")]
50    pub fn for_content_type(
51        parent: Option<&impl IsA<Window>>,
52        flags: DialogFlags,
53        content_type: &str,
54    ) -> AppChooserDialog {
55        assert_initialized_main_thread!();
56        unsafe {
57            Widget::from_glib_none(ffi::gtk_app_chooser_dialog_new_for_content_type(
58                parent.map(|p| p.as_ref()).to_glib_none().0,
59                flags.into_glib(),
60                content_type.to_glib_none().0,
61            ))
62            .unsafe_cast()
63        }
64    }
65
66    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
67    #[allow(deprecated)]
68    #[doc(alias = "gtk_app_chooser_dialog_get_heading")]
69    #[doc(alias = "get_heading")]
70    pub fn heading(&self) -> Option<glib::GString> {
71        unsafe {
72            from_glib_none(ffi::gtk_app_chooser_dialog_get_heading(
73                self.to_glib_none().0,
74            ))
75        }
76    }
77
78    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
79    #[allow(deprecated)]
80    #[doc(alias = "gtk_app_chooser_dialog_get_widget")]
81    #[doc(alias = "get_widget")]
82    pub fn widget(&self) -> Widget {
83        unsafe {
84            from_glib_none(ffi::gtk_app_chooser_dialog_get_widget(
85                self.to_glib_none().0,
86            ))
87        }
88    }
89
90    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
91    #[allow(deprecated)]
92    #[doc(alias = "gtk_app_chooser_dialog_set_heading")]
93    #[doc(alias = "heading")]
94    pub fn set_heading(&self, heading: &str) {
95        unsafe {
96            ffi::gtk_app_chooser_dialog_set_heading(
97                self.to_glib_none().0,
98                heading.to_glib_none().0,
99            );
100        }
101    }
102
103    pub fn gfile(&self) -> Option<gio::File> {
104        ObjectExt::property(self, "gfile")
105    }
106
107    #[doc(alias = "heading")]
108    pub fn connect_heading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
109        unsafe extern "C" fn notify_heading_trampoline<F: Fn(&AppChooserDialog) + 'static>(
110            this: *mut ffi::GtkAppChooserDialog,
111            _param_spec: glib::ffi::gpointer,
112            f: glib::ffi::gpointer,
113        ) {
114            let f: &F = &*(f as *const F);
115            f(&from_glib_borrow(this))
116        }
117        unsafe {
118            let f: Box_<F> = Box_::new(f);
119            connect_raw(
120                self.as_ptr() as *mut _,
121                c"notify::heading".as_ptr() as *const _,
122                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
123                    notify_heading_trampoline::<F> as *const (),
124                )),
125                Box_::into_raw(f),
126            )
127        }
128    }
129}