use crate::{ffi, SparqlConnection};
use glib::{prelude::*, translate::*};
glib::wrapper! {
#[doc(alias = "TrackerNotifier")]
pub struct Notifier(Object<ffi::TrackerNotifier, ffi::TrackerNotifierClass>);
match fn {
type_ => || ffi::tracker_notifier_get_type(),
}
}
impl Notifier {
pub fn builder() -> NotifierBuilder {
NotifierBuilder::new()
}
#[doc(alias = "tracker_notifier_signal_subscribe")]
pub fn signal_subscribe(
&self,
connection: &gio::DBusConnection,
service: Option<&str>,
object_path: Option<&str>,
graph: Option<&str>,
) -> u32 {
unsafe {
ffi::tracker_notifier_signal_subscribe(
self.to_glib_none().0,
connection.to_glib_none().0,
service.to_glib_none().0,
object_path.to_glib_none().0,
graph.to_glib_none().0,
)
}
}
#[doc(alias = "tracker_notifier_signal_unsubscribe")]
pub fn signal_unsubscribe(&self, handler_id: u32) {
unsafe {
ffi::tracker_notifier_signal_unsubscribe(self.to_glib_none().0, handler_id);
}
}
pub fn connection(&self) -> Option<SparqlConnection> {
ObjectExt::property(self, "connection")
}
}
#[must_use = "The builder must be built to be used"]
pub struct NotifierBuilder {
builder: glib::object::ObjectBuilder<'static, Notifier>,
}
impl NotifierBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
pub fn connection(self, connection: &SparqlConnection) -> Self {
Self {
builder: self.builder.property("connection", connection.clone()),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> Notifier {
assert_initialized_main_thread!();
self.builder.build()
}
}