gtk4/auto/bookmark_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::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 /// A list model that wraps `GBookmarkFile`.
15 ///
16 /// It presents a `GListModel` and fills it asynchronously with the
17 /// `GFileInfo`s returned from that function.
18 ///
19 /// The `GFileInfo`s in the list have some attributes in the recent namespace
20 /// added: `recent::private` (boolean) and `recent:applications` (stringv). They
21 /// also have the `GFile` referred by the URI in `standard::file` attribute.
22 ///
23 /// ## Properties
24 ///
25 ///
26 /// #### `attributes`
27 /// The attributes to query.
28 ///
29 /// Readable | Writeable
30 ///
31 ///
32 /// #### `filename`
33 /// The bookmark file to load.
34 ///
35 /// Readable | Writeable | Construct Only
36 ///
37 ///
38 /// #### `io-priority`
39 /// Priority used when loading.
40 ///
41 /// Readable | Writeable
42 ///
43 ///
44 /// #### `item-type`
45 /// The type of items. See [`ListModelExtManual::item_type()`][crate::gio::prelude::ListModelExtManual::item_type()].
46 ///
47 /// Readable
48 ///
49 ///
50 /// #### `loading`
51 /// [`true`] if files are being loaded.
52 ///
53 /// Readable
54 ///
55 ///
56 /// #### `n-items`
57 /// The number of items. See [`ListModelExtManual::n_items()`][crate::gio::prelude::ListModelExtManual::n_items()].
58 ///
59 /// Readable
60 ///
61 /// # Implements
62 ///
63 /// [`trait@glib::ObjectExt`], [`trait@gio::prelude::ListModelExt`]
64 #[doc(alias = "GtkBookmarkList")]
65 pub struct BookmarkList(Object<ffi::GtkBookmarkList, ffi::GtkBookmarkListClass>) @implements gio::ListModel;
66
67 match fn {
68 type_ => || ffi::gtk_bookmark_list_get_type(),
69 }
70}
71
72impl BookmarkList {
73 /// Creates a new [`BookmarkList`][crate::BookmarkList] with the given @attributes.
74 /// ## `filename`
75 /// The bookmark file to load
76 /// ## `attributes`
77 /// The attributes to query
78 ///
79 /// # Returns
80 ///
81 /// a new [`BookmarkList`][crate::BookmarkList]
82 #[doc(alias = "gtk_bookmark_list_new")]
83 pub fn new(
84 filename: Option<impl AsRef<std::path::Path>>,
85 attributes: Option<&str>,
86 ) -> BookmarkList {
87 assert_initialized_main_thread!();
88 unsafe {
89 from_glib_full(ffi::gtk_bookmark_list_new(
90 filename.as_ref().map(|p| p.as_ref()).to_glib_none().0,
91 attributes.to_glib_none().0,
92 ))
93 }
94 }
95
96 /// Gets the attributes queried on the children.
97 ///
98 /// # Returns
99 ///
100 /// The queried attributes
101 #[doc(alias = "gtk_bookmark_list_get_attributes")]
102 #[doc(alias = "get_attributes")]
103 pub fn attributes(&self) -> Option<glib::GString> {
104 unsafe { from_glib_none(ffi::gtk_bookmark_list_get_attributes(self.to_glib_none().0)) }
105 }
106
107 /// Returns the filename of the bookmark file that
108 /// this list is loading.
109 ///
110 /// # Returns
111 ///
112 /// the filename of the .xbel file
113 #[doc(alias = "gtk_bookmark_list_get_filename")]
114 #[doc(alias = "get_filename")]
115 pub fn filename(&self) -> std::path::PathBuf {
116 unsafe { from_glib_none(ffi::gtk_bookmark_list_get_filename(self.to_glib_none().0)) }
117 }
118
119 /// Returns [`true`] if the files are currently being loaded.
120 ///
121 /// Files will be added to @self from time to time while loading is
122 /// going on. The order in which are added is undefined and may change
123 /// in between runs.
124 ///
125 /// # Returns
126 ///
127 /// [`true`] if @self is loading
128 #[doc(alias = "gtk_bookmark_list_is_loading")]
129 #[doc(alias = "loading")]
130 pub fn is_loading(&self) -> bool {
131 unsafe { from_glib(ffi::gtk_bookmark_list_is_loading(self.to_glib_none().0)) }
132 }
133
134 /// Sets the @attributes to be enumerated and starts the enumeration.
135 ///
136 /// If @attributes is [`None`], no attributes will be queried, but a list
137 /// of `GFileInfo`s will still be created.
138 /// ## `attributes`
139 /// the attributes to enumerate
140 #[doc(alias = "gtk_bookmark_list_set_attributes")]
141 #[doc(alias = "attributes")]
142 pub fn set_attributes(&self, attributes: Option<&str>) {
143 unsafe {
144 ffi::gtk_bookmark_list_set_attributes(
145 self.to_glib_none().0,
146 attributes.to_glib_none().0,
147 );
148 }
149 }
150
151 #[doc(alias = "attributes")]
152 pub fn connect_attributes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
153 unsafe extern "C" fn notify_attributes_trampoline<F: Fn(&BookmarkList) + 'static>(
154 this: *mut ffi::GtkBookmarkList,
155 _param_spec: glib::ffi::gpointer,
156 f: glib::ffi::gpointer,
157 ) {
158 unsafe {
159 let f: &F = &*(f as *const F);
160 f(&from_glib_borrow(this))
161 }
162 }
163 unsafe {
164 let f: Box_<F> = Box_::new(f);
165 connect_raw(
166 self.as_ptr() as *mut _,
167 c"notify::attributes".as_ptr(),
168 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
169 notify_attributes_trampoline::<F> as *const (),
170 )),
171 Box_::into_raw(f),
172 )
173 }
174 }
175
176 #[doc(alias = "io-priority")]
177 pub fn connect_io_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
178 unsafe extern "C" fn notify_io_priority_trampoline<F: Fn(&BookmarkList) + 'static>(
179 this: *mut ffi::GtkBookmarkList,
180 _param_spec: glib::ffi::gpointer,
181 f: glib::ffi::gpointer,
182 ) {
183 unsafe {
184 let f: &F = &*(f as *const F);
185 f(&from_glib_borrow(this))
186 }
187 }
188 unsafe {
189 let f: Box_<F> = Box_::new(f);
190 connect_raw(
191 self.as_ptr() as *mut _,
192 c"notify::io-priority".as_ptr(),
193 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
194 notify_io_priority_trampoline::<F> as *const (),
195 )),
196 Box_::into_raw(f),
197 )
198 }
199 }
200
201 #[doc(alias = "loading")]
202 pub fn connect_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
203 unsafe extern "C" fn notify_loading_trampoline<F: Fn(&BookmarkList) + 'static>(
204 this: *mut ffi::GtkBookmarkList,
205 _param_spec: glib::ffi::gpointer,
206 f: glib::ffi::gpointer,
207 ) {
208 unsafe {
209 let f: &F = &*(f as *const F);
210 f(&from_glib_borrow(this))
211 }
212 }
213 unsafe {
214 let f: Box_<F> = Box_::new(f);
215 connect_raw(
216 self.as_ptr() as *mut _,
217 c"notify::loading".as_ptr(),
218 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
219 notify_loading_trampoline::<F> as *const (),
220 )),
221 Box_::into_raw(f),
222 )
223 }
224 }
225}