gtk4/
directory_list.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, prelude::*, DirectoryList};
6
7impl DirectoryList {
8    /// Gets the IO priority set via gtk_directory_list_set_io_priority().
9    ///
10    /// # Returns
11    ///
12    /// The IO priority.
13    #[doc(alias = "gtk_directory_list_get_io_priority")]
14    #[doc(alias = "get_io_priority")]
15    pub fn io_priority(&self) -> glib::Priority {
16        unsafe {
17            from_glib(ffi::gtk_directory_list_get_io_priority(
18                self.to_glib_none().0,
19            ))
20        }
21    }
22
23    /// Sets the IO priority to use while loading directories.
24    ///
25    /// Setting the priority while @self is loading will reprioritize the
26    /// ongoing load as soon as possible.
27    ///
28    /// The default IO priority is `G_PRIORITY_DEFAULT`, which is higher than
29    /// the GTK redraw priority. If you are loading a lot of directories in
30    /// parallel, lowering it to something like `G_PRIORITY_DEFAULT_IDLE`
31    /// may increase responsiveness.
32    /// ## `io_priority`
33    /// IO priority to use
34    #[doc(alias = "gtk_directory_list_set_io_priority")]
35    pub fn set_io_priority(&self, io_priority: glib::Priority) {
36        unsafe {
37            ffi::gtk_directory_list_set_io_priority(self.to_glib_none().0, io_priority.into_glib());
38        }
39    }
40
41    // rustdoc-stripper-ignore-next
42    /// Creates a new builder-pattern struct instance to construct
43    /// [`DirectoryList`] objects.
44    ///
45    /// This method returns an instance of
46    /// [`DirectoryListBuilder`](crate::builders::DirectoryListBuilder) which
47    /// can be used to create [`DirectoryList`] objects.
48    pub fn builder() -> DirectoryListBuilder {
49        DirectoryListBuilder::new()
50    }
51}
52
53// rustdoc-stripper-ignore-next
54/// A [builder-pattern] type to construct [`DirectoryList`] objects.
55///
56/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
57#[must_use = "The builder must be built to be used"]
58pub struct DirectoryListBuilder {
59    builder: glib::object::ObjectBuilder<'static, DirectoryList>,
60}
61
62impl DirectoryListBuilder {
63    fn new() -> Self {
64        Self {
65            builder: glib::object::Object::builder(),
66        }
67    }
68    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
69    pub fn build(self) -> DirectoryList {
70        self.builder.build()
71    }
72
73    pub fn attributes(self, attributes: &str) -> Self {
74        Self {
75            builder: self.builder.property("attributes", attributes),
76        }
77    }
78
79    pub fn file(self, file: &impl IsA<gio::File>) -> Self {
80        Self {
81            builder: self.builder.property("file", file),
82        }
83    }
84
85    pub fn io_priority(self, io_priority: glib::Priority) -> Self {
86        Self {
87            builder: self
88                .builder
89                .property("io-priority", io_priority.into_glib()),
90        }
91    }
92
93    pub fn monitored(self, monitored: bool) -> Self {
94        Self {
95            builder: self.builder.property("monitored", monitored),
96        }
97    }
98}