gtk4/
bookmark_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, BookmarkList};
6
7impl BookmarkList {
8    /// Gets the IO priority to use while loading file.
9    ///
10    /// # Returns
11    ///
12    /// The IO priority.
13    #[doc(alias = "gtk_bookmark_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_bookmark_list_get_io_priority(
18                self.to_glib_none().0,
19            ))
20        }
21    }
22
23    /// Sets the IO priority to use while loading files.
24    ///
25    /// The default IO priority is `G_PRIORITY_DEFAULT`.
26    /// ## `io_priority`
27    /// IO priority to use
28    #[doc(alias = "gtk_bookmark_list_set_io_priority")]
29    pub fn set_io_priority(&self, io_priority: glib::Priority) {
30        unsafe {
31            ffi::gtk_bookmark_list_set_io_priority(self.to_glib_none().0, io_priority.into_glib());
32        }
33    }
34
35    // rustdoc-stripper-ignore-next
36    /// Creates a new builder-pattern struct instance to construct
37    /// [`BookmarkList`] objects.
38    ///
39    /// This method returns an instance of
40    /// [`BookmarkListBuilder`](crate::builders::BookmarkListBuilder) which can
41    /// be used to create [`BookmarkList`] objects.
42    pub fn builder() -> BookmarkListBuilder {
43        BookmarkListBuilder::new()
44    }
45}
46
47// rustdoc-stripper-ignore-next
48/// A [builder-pattern] type to construct [`BookmarkList`] objects.
49///
50/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
51#[must_use = "The builder must be built to be used"]
52pub struct BookmarkListBuilder {
53    builder: glib::object::ObjectBuilder<'static, BookmarkList>,
54}
55
56impl BookmarkListBuilder {
57    fn new() -> Self {
58        Self {
59            builder: glib::object::Object::builder(),
60        }
61    }
62
63    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
64    pub fn build(self) -> BookmarkList {
65        self.builder.build()
66    }
67
68    pub fn attributes(self, attributes: &str) -> Self {
69        Self {
70            builder: self.builder.property("attributes", attributes),
71        }
72    }
73
74    pub fn filename(self, filename: &str) -> Self {
75        Self {
76            builder: self.builder.property("filename", filename),
77        }
78    }
79
80    pub fn io_priority(self, io_priority: glib::Priority) -> Self {
81        Self {
82            builder: self
83                .builder
84                .property("io-priority", io_priority.into_glib()),
85        }
86    }
87}