[go: up one dir, main page]

gvnc 0.3.0

Rust bindings for the GVnc library
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use glib::object::Cast;
use glib::object::ObjectType as ObjectType_;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib::wrapper! {
    #[doc(alias = "VncCursor")]
    pub struct Cursor(Object<ffi::VncCursor, ffi::VncCursorClass>);

    match fn {
        type_ => || ffi::vnc_cursor_get_type(),
    }
}

impl Cursor {
    //#[doc(alias = "vnc_cursor_new")]
    //pub fn new(data: &[u8], hotx: u16, hoty: u16, width: u16, height: u16) -> Cursor {
    //    unsafe { TODO: call ffi:vnc_cursor_new() }
    //}

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`Cursor`] objects.
    ///
    /// This method returns an instance of [`CursorBuilder`](crate::builders::CursorBuilder) which can be used to create [`Cursor`] objects.
    pub fn builder() -> CursorBuilder {
        CursorBuilder::default()
    }

    #[doc(alias = "vnc_cursor_get_height")]
    #[doc(alias = "get_height")]
    pub fn height(&self) -> u16 {
        unsafe { ffi::vnc_cursor_get_height(self.to_glib_none().0) }
    }

    #[doc(alias = "vnc_cursor_get_hotx")]
    #[doc(alias = "get_hotx")]
    pub fn hotx(&self) -> u16 {
        unsafe { ffi::vnc_cursor_get_hotx(self.to_glib_none().0) }
    }

    #[doc(alias = "vnc_cursor_get_hoty")]
    #[doc(alias = "get_hoty")]
    pub fn hoty(&self) -> u16 {
        unsafe { ffi::vnc_cursor_get_hoty(self.to_glib_none().0) }
    }

    #[doc(alias = "vnc_cursor_get_width")]
    #[doc(alias = "get_width")]
    pub fn width(&self) -> u16 {
        unsafe { ffi::vnc_cursor_get_width(self.to_glib_none().0) }
    }

    //pub fn set_data(&self, data: /*Unimplemented*/Basic: Pointer) {
    //    glib::ObjectExt::set_property(self,"data", &data)
    //}

    pub fn set_height(&self, height: i32) {
        glib::ObjectExt::set_property(self, "height", &height)
    }

    pub fn set_hotx(&self, hotx: i32) {
        glib::ObjectExt::set_property(self, "hotx", &hotx)
    }

    pub fn set_hoty(&self, hoty: i32) {
        glib::ObjectExt::set_property(self, "hoty", &hoty)
    }

    pub fn set_width(&self, width: i32) {
        glib::ObjectExt::set_property(self, "width", &width)
    }

    #[doc(alias = "data")]
    pub fn connect_data_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_data_trampoline<F: Fn(&Cursor) + 'static>(
            this: *mut ffi::VncCursor,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::data\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_data_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "height")]
    pub fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_height_trampoline<F: Fn(&Cursor) + 'static>(
            this: *mut ffi::VncCursor,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::height\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_height_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "hotx")]
    pub fn connect_hotx_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_hotx_trampoline<F: Fn(&Cursor) + 'static>(
            this: *mut ffi::VncCursor,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::hotx\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_hotx_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "hoty")]
    pub fn connect_hoty_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_hoty_trampoline<F: Fn(&Cursor) + 'static>(
            this: *mut ffi::VncCursor,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::hoty\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_hoty_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "width")]
    pub fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_width_trampoline<F: Fn(&Cursor) + 'static>(
            this: *mut ffi::VncCursor,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::width\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_width_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl Default for Cursor {
    fn default() -> Self {
        glib::object::Object::new::<Self>(&[])
    }
}

#[derive(Clone, Default)]
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`Cursor`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct CursorBuilder {
    //data: /*Unknown type*/,
    height: Option<i32>,
    hotx: Option<i32>,
    hoty: Option<i32>,
    width: Option<i32>,
}

impl CursorBuilder {
    // rustdoc-stripper-ignore-next
    /// Create a new [`CursorBuilder`].
    pub fn new() -> Self {
        Self::default()
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`Cursor`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> Cursor {
        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
        if let Some(ref height) = self.height {
            properties.push(("height", height));
        }
        if let Some(ref hotx) = self.hotx {
            properties.push(("hotx", hotx));
        }
        if let Some(ref hoty) = self.hoty {
            properties.push(("hoty", hoty));
        }
        if let Some(ref width) = self.width {
            properties.push(("width", width));
        }
        glib::Object::new::<Cursor>(&properties)
    }

    pub fn height(mut self, height: i32) -> Self {
        self.height = Some(height);
        self
    }

    pub fn hotx(mut self, hotx: i32) -> Self {
        self.hotx = Some(hotx);
        self
    }

    pub fn hoty(mut self, hoty: i32) -> Self {
        self.hoty = Some(hoty);
        self
    }

    pub fn width(mut self, width: i32) -> Self {
        self.width = Some(width);
        self
    }
}

impl fmt::Display for Cursor {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Cursor")
    }
}