gtk4/
directory_list.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::translate::*;

use crate::{ffi, prelude::*, DirectoryList};

impl DirectoryList {
    /// Gets the IO priority set via gtk_directory_list_set_io_priority().
    ///
    /// # Returns
    ///
    /// The IO priority.
    #[doc(alias = "gtk_directory_list_get_io_priority")]
    #[doc(alias = "get_io_priority")]
    pub fn io_priority(&self) -> glib::Priority {
        unsafe {
            from_glib(ffi::gtk_directory_list_get_io_priority(
                self.to_glib_none().0,
            ))
        }
    }

    /// Sets the IO priority to use while loading directories.
    ///
    /// Setting the priority while @self is loading will reprioritize the
    /// ongoing load as soon as possible.
    ///
    /// The default IO priority is `G_PRIORITY_DEFAULT`, which is higher than
    /// the GTK redraw priority. If you are loading a lot of directories in
    /// parallel, lowering it to something like `G_PRIORITY_DEFAULT_IDLE`
    /// may increase responsiveness.
    /// ## `io_priority`
    /// IO priority to use
    #[doc(alias = "gtk_directory_list_set_io_priority")]
    pub fn set_io_priority(&self, io_priority: glib::Priority) {
        unsafe {
            ffi::gtk_directory_list_set_io_priority(self.to_glib_none().0, io_priority.into_glib());
        }
    }

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct
    /// [`DirectoryList`] objects.
    ///
    /// This method returns an instance of
    /// [`DirectoryListBuilder`](crate::builders::DirectoryListBuilder) which
    /// can be used to create [`DirectoryList`] objects.
    pub fn builder() -> DirectoryListBuilder {
        DirectoryListBuilder::new()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`DirectoryList`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct DirectoryListBuilder {
    builder: glib::object::ObjectBuilder<'static, DirectoryList>,
}

impl DirectoryListBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> DirectoryList {
        self.builder.build()
    }

    pub fn attributes(self, attributes: &str) -> Self {
        Self {
            builder: self.builder.property("attributes", attributes),
        }
    }

    pub fn file(self, file: &impl IsA<gio::File>) -> Self {
        Self {
            builder: self.builder.property("file", file),
        }
    }

    pub fn io_priority(self, io_priority: glib::Priority) -> Self {
        Self {
            builder: self
                .builder
                .property("io-priority", io_priority.into_glib()),
        }
    }

    pub fn monitored(self, monitored: bool) -> Self {
        Self {
            builder: self.builder.property("monitored", monitored),
        }
    }
}