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::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkBookmarkList")]
15    pub struct BookmarkList(Object<ffi::GtkBookmarkList, ffi::GtkBookmarkListClass>) @implements gio::ListModel;
16
17    match fn {
18        type_ => || ffi::gtk_bookmark_list_get_type(),
19    }
20}
21
22impl BookmarkList {
23    #[doc(alias = "gtk_bookmark_list_new")]
24    pub fn new(
25        filename: Option<impl AsRef<std::path::Path>>,
26        attributes: Option<&str>,
27    ) -> BookmarkList {
28        assert_initialized_main_thread!();
29        unsafe {
30            from_glib_full(ffi::gtk_bookmark_list_new(
31                filename.as_ref().map(|p| p.as_ref()).to_glib_none().0,
32                attributes.to_glib_none().0,
33            ))
34        }
35    }
36
37    #[doc(alias = "gtk_bookmark_list_get_attributes")]
38    #[doc(alias = "get_attributes")]
39    pub fn attributes(&self) -> Option<glib::GString> {
40        unsafe { from_glib_none(ffi::gtk_bookmark_list_get_attributes(self.to_glib_none().0)) }
41    }
42
43    #[doc(alias = "gtk_bookmark_list_get_filename")]
44    #[doc(alias = "get_filename")]
45    pub fn filename(&self) -> std::path::PathBuf {
46        unsafe { from_glib_none(ffi::gtk_bookmark_list_get_filename(self.to_glib_none().0)) }
47    }
48
49    #[doc(alias = "gtk_bookmark_list_is_loading")]
50    #[doc(alias = "loading")]
51    pub fn is_loading(&self) -> bool {
52        unsafe { from_glib(ffi::gtk_bookmark_list_is_loading(self.to_glib_none().0)) }
53    }
54
55    #[doc(alias = "gtk_bookmark_list_set_attributes")]
56    #[doc(alias = "attributes")]
57    pub fn set_attributes(&self, attributes: Option<&str>) {
58        unsafe {
59            ffi::gtk_bookmark_list_set_attributes(
60                self.to_glib_none().0,
61                attributes.to_glib_none().0,
62            );
63        }
64    }
65
66    #[doc(alias = "attributes")]
67    pub fn connect_attributes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
68        unsafe extern "C" fn notify_attributes_trampoline<F: Fn(&BookmarkList) + 'static>(
69            this: *mut ffi::GtkBookmarkList,
70            _param_spec: glib::ffi::gpointer,
71            f: glib::ffi::gpointer,
72        ) {
73            let f: &F = &*(f as *const F);
74            f(&from_glib_borrow(this))
75        }
76        unsafe {
77            let f: Box_<F> = Box_::new(f);
78            connect_raw(
79                self.as_ptr() as *mut _,
80                c"notify::attributes".as_ptr() as *const _,
81                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
82                    notify_attributes_trampoline::<F> as *const (),
83                )),
84                Box_::into_raw(f),
85            )
86        }
87    }
88
89    #[doc(alias = "io-priority")]
90    pub fn connect_io_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
91        unsafe extern "C" fn notify_io_priority_trampoline<F: Fn(&BookmarkList) + 'static>(
92            this: *mut ffi::GtkBookmarkList,
93            _param_spec: glib::ffi::gpointer,
94            f: glib::ffi::gpointer,
95        ) {
96            let f: &F = &*(f as *const F);
97            f(&from_glib_borrow(this))
98        }
99        unsafe {
100            let f: Box_<F> = Box_::new(f);
101            connect_raw(
102                self.as_ptr() as *mut _,
103                c"notify::io-priority".as_ptr() as *const _,
104                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
105                    notify_io_priority_trampoline::<F> as *const (),
106                )),
107                Box_::into_raw(f),
108            )
109        }
110    }
111
112    #[doc(alias = "loading")]
113    pub fn connect_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
114        unsafe extern "C" fn notify_loading_trampoline<F: Fn(&BookmarkList) + 'static>(
115            this: *mut ffi::GtkBookmarkList,
116            _param_spec: glib::ffi::gpointer,
117            f: glib::ffi::gpointer,
118        ) {
119            let f: &F = &*(f as *const F);
120            f(&from_glib_borrow(this))
121        }
122        unsafe {
123            let f: Box_<F> = Box_::new(f);
124            connect_raw(
125                self.as_ptr() as *mut _,
126                c"notify::loading".as_ptr() as *const _,
127                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
128                    notify_loading_trampoline::<F> as *const (),
129                )),
130                Box_::into_raw(f),
131            )
132        }
133    }
134}