use crate::SparqlConnection;
use glib::object::Cast;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::fmt;
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::default()
}
#[doc(alias = "tracker_notifier_signal_subscribe")]
pub fn signal_subscribe(
&self,
connection: &gio::DBusConnection,
service: &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> {
unsafe {
let mut value = glib::Value::from_type(<SparqlConnection as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"connection\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `connection` getter")
}
}
}
#[derive(Clone, Default)]
pub struct NotifierBuilder {
connection: Option<SparqlConnection>,
}
impl NotifierBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn build(self) -> Notifier {
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
if let Some(ref connection) = self.connection {
properties.push(("connection", connection));
}
glib::Object::new::<Notifier>(&properties)
.expect("Failed to create an instance of Notifier")
}
pub fn connection(mut self, connection: &SparqlConnection) -> Self {
self.connection = Some(connection.clone());
self
}
}
impl fmt::Display for Notifier {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Notifier")
}
}