[go: up one dir, main page]

gtk4/auto/
directory_list.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
5use crate::ffi;
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkDirectoryList")]
15    pub struct DirectoryList(Object<ffi::GtkDirectoryList, ffi::GtkDirectoryListClass>) @implements gio::ListModel;
16
17    match fn {
18        type_ => || ffi::gtk_directory_list_get_type(),
19    }
20}
21
22impl DirectoryList {
23    #[doc(alias = "gtk_directory_list_new")]
24    pub fn new(attributes: Option<&str>, file: Option<&impl IsA<gio::File>>) -> DirectoryList {
25        assert_initialized_main_thread!();
26        unsafe {
27            from_glib_full(ffi::gtk_directory_list_new(
28                attributes.to_glib_none().0,
29                file.map(|p| p.as_ref()).to_glib_none().0,
30            ))
31        }
32    }
33
34    #[doc(alias = "gtk_directory_list_get_attributes")]
35    #[doc(alias = "get_attributes")]
36    pub fn attributes(&self) -> Option<glib::GString> {
37        unsafe {
38            from_glib_none(ffi::gtk_directory_list_get_attributes(
39                self.to_glib_none().0,
40            ))
41        }
42    }
43
44    #[doc(alias = "gtk_directory_list_get_error")]
45    #[doc(alias = "get_error")]
46    pub fn error(&self) -> Option<glib::Error> {
47        unsafe { from_glib_none(ffi::gtk_directory_list_get_error(self.to_glib_none().0)) }
48    }
49
50    #[doc(alias = "gtk_directory_list_get_file")]
51    #[doc(alias = "get_file")]
52    pub fn file(&self) -> Option<gio::File> {
53        unsafe { from_glib_none(ffi::gtk_directory_list_get_file(self.to_glib_none().0)) }
54    }
55
56    #[doc(alias = "gtk_directory_list_get_monitored")]
57    #[doc(alias = "get_monitored")]
58    #[doc(alias = "monitored")]
59    pub fn is_monitored(&self) -> bool {
60        unsafe { from_glib(ffi::gtk_directory_list_get_monitored(self.to_glib_none().0)) }
61    }
62
63    #[doc(alias = "gtk_directory_list_is_loading")]
64    #[doc(alias = "loading")]
65    pub fn is_loading(&self) -> bool {
66        unsafe { from_glib(ffi::gtk_directory_list_is_loading(self.to_glib_none().0)) }
67    }
68
69    #[doc(alias = "gtk_directory_list_set_attributes")]
70    #[doc(alias = "attributes")]
71    pub fn set_attributes(&self, attributes: Option<&str>) {
72        unsafe {
73            ffi::gtk_directory_list_set_attributes(
74                self.to_glib_none().0,
75                attributes.to_glib_none().0,
76            );
77        }
78    }
79
80    #[doc(alias = "gtk_directory_list_set_file")]
81    #[doc(alias = "file")]
82    pub fn set_file(&self, file: Option<&impl IsA<gio::File>>) {
83        unsafe {
84            ffi::gtk_directory_list_set_file(
85                self.to_glib_none().0,
86                file.map(|p| p.as_ref()).to_glib_none().0,
87            );
88        }
89    }
90
91    #[doc(alias = "gtk_directory_list_set_monitored")]
92    #[doc(alias = "monitored")]
93    pub fn set_monitored(&self, monitored: bool) {
94        unsafe {
95            ffi::gtk_directory_list_set_monitored(self.to_glib_none().0, monitored.into_glib());
96        }
97    }
98
99    #[doc(alias = "attributes")]
100    pub fn connect_attributes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
101        unsafe extern "C" fn notify_attributes_trampoline<F: Fn(&DirectoryList) + 'static>(
102            this: *mut ffi::GtkDirectoryList,
103            _param_spec: glib::ffi::gpointer,
104            f: glib::ffi::gpointer,
105        ) {
106            let f: &F = &*(f as *const F);
107            f(&from_glib_borrow(this))
108        }
109        unsafe {
110            let f: Box_<F> = Box_::new(f);
111            connect_raw(
112                self.as_ptr() as *mut _,
113                c"notify::attributes".as_ptr() as *const _,
114                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
115                    notify_attributes_trampoline::<F> as *const (),
116                )),
117                Box_::into_raw(f),
118            )
119        }
120    }
121
122    #[doc(alias = "error")]
123    pub fn connect_error_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
124        unsafe extern "C" fn notify_error_trampoline<F: Fn(&DirectoryList) + 'static>(
125            this: *mut ffi::GtkDirectoryList,
126            _param_spec: glib::ffi::gpointer,
127            f: glib::ffi::gpointer,
128        ) {
129            let f: &F = &*(f as *const F);
130            f(&from_glib_borrow(this))
131        }
132        unsafe {
133            let f: Box_<F> = Box_::new(f);
134            connect_raw(
135                self.as_ptr() as *mut _,
136                c"notify::error".as_ptr() as *const _,
137                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
138                    notify_error_trampoline::<F> as *const (),
139                )),
140                Box_::into_raw(f),
141            )
142        }
143    }
144
145    #[doc(alias = "file")]
146    pub fn connect_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
147        unsafe extern "C" fn notify_file_trampoline<F: Fn(&DirectoryList) + 'static>(
148            this: *mut ffi::GtkDirectoryList,
149            _param_spec: glib::ffi::gpointer,
150            f: glib::ffi::gpointer,
151        ) {
152            let f: &F = &*(f as *const F);
153            f(&from_glib_borrow(this))
154        }
155        unsafe {
156            let f: Box_<F> = Box_::new(f);
157            connect_raw(
158                self.as_ptr() as *mut _,
159                c"notify::file".as_ptr() as *const _,
160                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
161                    notify_file_trampoline::<F> as *const (),
162                )),
163                Box_::into_raw(f),
164            )
165        }
166    }
167
168    #[doc(alias = "io-priority")]
169    pub fn connect_io_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
170        unsafe extern "C" fn notify_io_priority_trampoline<F: Fn(&DirectoryList) + 'static>(
171            this: *mut ffi::GtkDirectoryList,
172            _param_spec: glib::ffi::gpointer,
173            f: glib::ffi::gpointer,
174        ) {
175            let f: &F = &*(f as *const F);
176            f(&from_glib_borrow(this))
177        }
178        unsafe {
179            let f: Box_<F> = Box_::new(f);
180            connect_raw(
181                self.as_ptr() as *mut _,
182                c"notify::io-priority".as_ptr() as *const _,
183                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
184                    notify_io_priority_trampoline::<F> as *const (),
185                )),
186                Box_::into_raw(f),
187            )
188        }
189    }
190
191    #[doc(alias = "loading")]
192    pub fn connect_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
193        unsafe extern "C" fn notify_loading_trampoline<F: Fn(&DirectoryList) + 'static>(
194            this: *mut ffi::GtkDirectoryList,
195            _param_spec: glib::ffi::gpointer,
196            f: glib::ffi::gpointer,
197        ) {
198            let f: &F = &*(f as *const F);
199            f(&from_glib_borrow(this))
200        }
201        unsafe {
202            let f: Box_<F> = Box_::new(f);
203            connect_raw(
204                self.as_ptr() as *mut _,
205                c"notify::loading".as_ptr() as *const _,
206                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
207                    notify_loading_trampoline::<F> as *const (),
208                )),
209                Box_::into_raw(f),
210            )
211        }
212    }
213
214    #[doc(alias = "monitored")]
215    pub fn connect_monitored_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
216        unsafe extern "C" fn notify_monitored_trampoline<F: Fn(&DirectoryList) + 'static>(
217            this: *mut ffi::GtkDirectoryList,
218            _param_spec: glib::ffi::gpointer,
219            f: glib::ffi::gpointer,
220        ) {
221            let f: &F = &*(f as *const F);
222            f(&from_glib_borrow(this))
223        }
224        unsafe {
225            let f: Box_<F> = Box_::new(f);
226            connect_raw(
227                self.as_ptr() as *mut _,
228                c"notify::monitored".as_ptr() as *const _,
229                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
230                    notify_monitored_trampoline::<F> as *const (),
231                )),
232                Box_::into_raw(f),
233            )
234        }
235    }
236}