1use crate::{ffi, SparqlConnection};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 #[doc(alias = "TrackerNotifier")]
11 pub struct Notifier(Object<ffi::TrackerNotifier, ffi::TrackerNotifierClass>);
12
13 match fn {
14 type_ => || ffi::tracker_notifier_get_type(),
15 }
16}
17
18impl Notifier {
19 pub fn builder() -> NotifierBuilder {
24 NotifierBuilder::new()
25 }
26
27 #[doc(alias = "tracker_notifier_signal_subscribe")]
28 pub fn signal_subscribe(
29 &self,
30 connection: &gio::DBusConnection,
31 service: Option<&str>,
32 object_path: Option<&str>,
33 graph: Option<&str>,
34 ) -> u32 {
35 unsafe {
36 ffi::tracker_notifier_signal_subscribe(
37 self.to_glib_none().0,
38 connection.to_glib_none().0,
39 service.to_glib_none().0,
40 object_path.to_glib_none().0,
41 graph.to_glib_none().0,
42 )
43 }
44 }
45
46 #[doc(alias = "tracker_notifier_signal_unsubscribe")]
47 pub fn signal_unsubscribe(&self, handler_id: u32) {
48 unsafe {
49 ffi::tracker_notifier_signal_unsubscribe(self.to_glib_none().0, handler_id);
50 }
51 }
52
53 pub fn connection(&self) -> Option<SparqlConnection> {
54 ObjectExt::property(self, "connection")
55 }
56
57 }
62
63#[must_use = "The builder must be built to be used"]
68pub struct NotifierBuilder {
69 builder: glib::object::ObjectBuilder<'static, Notifier>,
70}
71
72impl NotifierBuilder {
73 fn new() -> Self {
74 Self {
75 builder: glib::object::Object::builder(),
76 }
77 }
78
79 pub fn connection(self, connection: &SparqlConnection) -> Self {
80 Self {
81 builder: self.builder.property("connection", connection.clone()),
82 }
83 }
84
85 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
88 pub fn build(self) -> Notifier {
89 assert_initialized_main_thread!();
90 self.builder.build()
91 }
92}