gtk4/auto/
bookmark_list.rs1use crate::ffi;
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[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 #[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 #[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 #[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 #[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 #[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() as *const _,
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() as *const _,
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() as *const _,
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}