Skip to main content

tracker/auto/
endpoint.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, SparqlConnection};
7#[cfg(feature = "v3_7")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v3_7")))]
9use glib::signal::{connect_raw, SignalHandlerId};
10use glib::{prelude::*, translate::*};
11#[cfg(feature = "v3_7")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v3_7")))]
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "TrackerEndpoint")]
17    pub struct Endpoint(Object<ffi::TrackerEndpoint, ffi::TrackerEndpointClass>);
18
19    match fn {
20        type_ => || ffi::tracker_endpoint_get_type(),
21    }
22}
23
24impl Endpoint {
25    pub const NONE: Option<&'static Endpoint> = None;
26}
27
28pub trait EndpointExt: IsA<Endpoint> + 'static {
29    #[cfg(feature = "v3_7")]
30    #[cfg_attr(docsrs, doc(cfg(feature = "v3_7")))]
31    #[doc(alias = "tracker_endpoint_get_readonly")]
32    #[doc(alias = "get_readonly")]
33    #[doc(alias = "readonly")]
34    fn is_readonly(&self) -> bool {
35        unsafe {
36            from_glib(ffi::tracker_endpoint_get_readonly(
37                self.as_ref().to_glib_none().0,
38            ))
39        }
40    }
41
42    #[doc(alias = "tracker_endpoint_get_sparql_connection")]
43    #[doc(alias = "get_sparql_connection")]
44    #[doc(alias = "sparql-connection")]
45    fn sparql_connection(&self) -> Option<SparqlConnection> {
46        unsafe {
47            from_glib_none(ffi::tracker_endpoint_get_sparql_connection(
48                self.as_ref().to_glib_none().0,
49            ))
50        }
51    }
52
53    #[cfg(feature = "v3_7")]
54    #[cfg_attr(docsrs, doc(cfg(feature = "v3_7")))]
55    #[doc(alias = "tracker_endpoint_set_readonly")]
56    #[doc(alias = "readonly")]
57    fn set_readonly(&self, readonly: bool) {
58        unsafe {
59            ffi::tracker_endpoint_set_readonly(
60                self.as_ref().to_glib_none().0,
61                readonly.into_glib(),
62            );
63        }
64    }
65
66    #[cfg(feature = "v3_7")]
67    #[cfg_attr(docsrs, doc(cfg(feature = "v3_7")))]
68    #[doc(alias = "allowed-graphs")]
69    fn connect_allowed_graphs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
70        unsafe extern "C" fn notify_allowed_graphs_trampoline<
71            P: IsA<Endpoint>,
72            F: Fn(&P) + 'static,
73        >(
74            this: *mut ffi::TrackerEndpoint,
75            _param_spec: glib::ffi::gpointer,
76            f: glib::ffi::gpointer,
77        ) {
78            unsafe {
79                let f: &F = &*(f as *const F);
80                f(Endpoint::from_glib_borrow(this).unsafe_cast_ref())
81            }
82        }
83        unsafe {
84            let f: Box_<F> = Box_::new(f);
85            connect_raw(
86                self.as_ptr() as *mut _,
87                c"notify::allowed-graphs".as_ptr(),
88                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
89                    notify_allowed_graphs_trampoline::<Self, F> as *const (),
90                )),
91                Box_::into_raw(f),
92            )
93        }
94    }
95
96    #[cfg(feature = "v3_7")]
97    #[cfg_attr(docsrs, doc(cfg(feature = "v3_7")))]
98    #[doc(alias = "allowed-services")]
99    fn connect_allowed_services_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
100        unsafe extern "C" fn notify_allowed_services_trampoline<
101            P: IsA<Endpoint>,
102            F: Fn(&P) + 'static,
103        >(
104            this: *mut ffi::TrackerEndpoint,
105            _param_spec: glib::ffi::gpointer,
106            f: glib::ffi::gpointer,
107        ) {
108            unsafe {
109                let f: &F = &*(f as *const F);
110                f(Endpoint::from_glib_borrow(this).unsafe_cast_ref())
111            }
112        }
113        unsafe {
114            let f: Box_<F> = Box_::new(f);
115            connect_raw(
116                self.as_ptr() as *mut _,
117                c"notify::allowed-services".as_ptr(),
118                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
119                    notify_allowed_services_trampoline::<Self, F> as *const (),
120                )),
121                Box_::into_raw(f),
122            )
123        }
124    }
125
126    #[cfg(feature = "v3_7")]
127    #[cfg_attr(docsrs, doc(cfg(feature = "v3_7")))]
128    #[doc(alias = "readonly")]
129    fn connect_readonly_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
130        unsafe extern "C" fn notify_readonly_trampoline<P: IsA<Endpoint>, F: Fn(&P) + 'static>(
131            this: *mut ffi::TrackerEndpoint,
132            _param_spec: glib::ffi::gpointer,
133            f: glib::ffi::gpointer,
134        ) {
135            unsafe {
136                let f: &F = &*(f as *const F);
137                f(Endpoint::from_glib_borrow(this).unsafe_cast_ref())
138            }
139        }
140        unsafe {
141            let f: Box_<F> = Box_::new(f);
142            connect_raw(
143                self.as_ptr() as *mut _,
144                c"notify::readonly".as_ptr(),
145                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
146                    notify_readonly_trampoline::<Self, F> as *const (),
147                )),
148                Box_::into_raw(f),
149            )
150        }
151    }
152}
153
154impl<O: IsA<Endpoint>> EndpointExt for O {}