gtk4/auto/
bookmark_list.rs
1use crate::ffi;
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
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 let f: &F = &*(f as *const F);
159 f(&from_glib_borrow(this))
160 }
161 unsafe {
162 let f: Box_<F> = Box_::new(f);
163 connect_raw(
164 self.as_ptr() as *mut _,
165 b"notify::attributes\0".as_ptr() as *const _,
166 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
167 notify_attributes_trampoline::<F> as *const (),
168 )),
169 Box_::into_raw(f),
170 )
171 }
172 }
173
174 #[doc(alias = "io-priority")]
175 pub fn connect_io_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
176 unsafe extern "C" fn notify_io_priority_trampoline<F: Fn(&BookmarkList) + 'static>(
177 this: *mut ffi::GtkBookmarkList,
178 _param_spec: glib::ffi::gpointer,
179 f: glib::ffi::gpointer,
180 ) {
181 let f: &F = &*(f as *const F);
182 f(&from_glib_borrow(this))
183 }
184 unsafe {
185 let f: Box_<F> = Box_::new(f);
186 connect_raw(
187 self.as_ptr() as *mut _,
188 b"notify::io-priority\0".as_ptr() as *const _,
189 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
190 notify_io_priority_trampoline::<F> as *const (),
191 )),
192 Box_::into_raw(f),
193 )
194 }
195 }
196
197 #[doc(alias = "loading")]
198 pub fn connect_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
199 unsafe extern "C" fn notify_loading_trampoline<F: Fn(&BookmarkList) + 'static>(
200 this: *mut ffi::GtkBookmarkList,
201 _param_spec: glib::ffi::gpointer,
202 f: glib::ffi::gpointer,
203 ) {
204 let f: &F = &*(f as *const F);
205 f(&from_glib_borrow(this))
206 }
207 unsafe {
208 let f: Box_<F> = Box_::new(f);
209 connect_raw(
210 self.as_ptr() as *mut _,
211 b"notify::loading\0".as_ptr() as *const _,
212 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
213 notify_loading_trampoline::<F> as *const (),
214 )),
215 Box_::into_raw(f),
216 )
217 }
218 }
219}