use Drive;
use Mount;
use Volume;
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct VolumeMonitor(Object<ffi::GVolumeMonitor, ffi::GVolumeMonitorClass>);
match fn {
get_type => || ffi::g_volume_monitor_get_type(),
}
}
impl VolumeMonitor {
#[deprecated]
pub fn adopt_orphan_mount<P: IsA<Mount>>(mount: &P) -> Option<Volume> {
unsafe {
from_glib_full(ffi::g_volume_monitor_adopt_orphan_mount(mount.to_glib_none().0))
}
}
pub fn get() -> Option<VolumeMonitor> {
unsafe {
from_glib_full(ffi::g_volume_monitor_get())
}
}
}
pub trait VolumeMonitorExt {
fn get_connected_drives(&self) -> Vec<Drive>;
fn get_mount_for_uuid(&self, uuid: &str) -> Option<Mount>;
fn get_mounts(&self) -> Vec<Mount>;
fn get_volume_for_uuid(&self, uuid: &str) -> Option<Volume>;
fn get_volumes(&self) -> Vec<Volume>;
fn connect_drive_changed<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_drive_connected<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_drive_disconnected<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_drive_eject_button<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_drive_stop_button<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_mount_added<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_mount_changed<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_mount_pre_unmount<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_mount_removed<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_volume_added<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_volume_changed<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_volume_removed<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<VolumeMonitor> + IsA<glib::object::Object>> VolumeMonitorExt for O {
fn get_connected_drives(&self) -> Vec<Drive> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_connected_drives(self.to_glib_none().0))
}
}
fn get_mount_for_uuid(&self, uuid: &str) -> Option<Mount> {
unsafe {
from_glib_full(ffi::g_volume_monitor_get_mount_for_uuid(self.to_glib_none().0, uuid.to_glib_none().0))
}
}
fn get_mounts(&self) -> Vec<Mount> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_mounts(self.to_glib_none().0))
}
}
fn get_volume_for_uuid(&self, uuid: &str) -> Option<Volume> {
unsafe {
from_glib_full(ffi::g_volume_monitor_get_volume_for_uuid(self.to_glib_none().0, uuid.to_glib_none().0))
}
}
fn get_volumes(&self) -> Vec<Volume> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_volumes(self.to_glib_none().0))
}
}
fn connect_drive_changed<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Drive) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "drive-changed",
transmute(drive_changed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_drive_connected<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Drive) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "drive-connected",
transmute(drive_connected_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_drive_disconnected<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Drive) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "drive-disconnected",
transmute(drive_disconnected_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_drive_eject_button<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Drive) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "drive-eject-button",
transmute(drive_eject_button_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_drive_stop_button<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Drive) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "drive-stop-button",
transmute(drive_stop_button_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_mount_added<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Mount) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "mount-added",
transmute(mount_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_mount_changed<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Mount) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "mount-changed",
transmute(mount_changed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_mount_pre_unmount<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Mount) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "mount-pre-unmount",
transmute(mount_pre_unmount_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_mount_removed<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Mount) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "mount-removed",
transmute(mount_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_volume_added<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Volume) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "volume-added",
transmute(volume_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_volume_changed<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Volume) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "volume-changed",
transmute(volume_changed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_volume_removed<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &Volume) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "volume-removed",
transmute(volume_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn drive_changed_trampoline<P>(this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Drive) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(drive))
}
unsafe extern "C" fn drive_connected_trampoline<P>(this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Drive) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(drive))
}
unsafe extern "C" fn drive_disconnected_trampoline<P>(this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Drive) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(drive))
}
unsafe extern "C" fn drive_eject_button_trampoline<P>(this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Drive) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(drive))
}
unsafe extern "C" fn drive_stop_button_trampoline<P>(this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Drive) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(drive))
}
unsafe extern "C" fn mount_added_trampoline<P>(this: *mut ffi::GVolumeMonitor, mount: *mut ffi::GMount, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Mount) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(mount))
}
unsafe extern "C" fn mount_changed_trampoline<P>(this: *mut ffi::GVolumeMonitor, mount: *mut ffi::GMount, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Mount) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(mount))
}
unsafe extern "C" fn mount_pre_unmount_trampoline<P>(this: *mut ffi::GVolumeMonitor, mount: *mut ffi::GMount, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Mount) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(mount))
}
unsafe extern "C" fn mount_removed_trampoline<P>(this: *mut ffi::GVolumeMonitor, mount: *mut ffi::GMount, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Mount) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(mount))
}
unsafe extern "C" fn volume_added_trampoline<P>(this: *mut ffi::GVolumeMonitor, volume: *mut ffi::GVolume, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Volume) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(volume))
}
unsafe extern "C" fn volume_changed_trampoline<P>(this: *mut ffi::GVolumeMonitor, volume: *mut ffi::GVolume, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Volume) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(volume))
}
unsafe extern "C" fn volume_removed_trampoline<P>(this: *mut ffi::GVolumeMonitor, volume: *mut ffi::GVolume, f: glib_ffi::gpointer)
where P: IsA<VolumeMonitor> {
let f: &&(Fn(&P, &Volume) + 'static) = transmute(f);
f(&VolumeMonitor::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(volume))
}