[go: up one dir, main page]

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