1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use BindingFlags;
use Object;
use gobject_ffi as ffi;
use ffi as glib_ffi;
use gobject_ffi;
use signal::SignalHandlerId;
use signal::connect;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
use translate::*;

glib_wrapper! {
    pub struct Binding(Object<ffi::GBinding>);

    match fn {
        get_type => || ffi::g_binding_get_type(),
    }
}

impl Binding {
    pub fn get_flags(&self) -> BindingFlags {
        unsafe {
            from_glib(ffi::g_binding_get_flags(self.to_glib_none().0))
        }
    }

    pub fn get_source(&self) -> Option<Object> {
        unsafe {
            from_glib_none(ffi::g_binding_get_source(self.to_glib_none().0))
        }
    }

    pub fn get_source_property(&self) -> Option<String> {
        unsafe {
            from_glib_none(ffi::g_binding_get_source_property(self.to_glib_none().0))
        }
    }

    pub fn get_target(&self) -> Option<Object> {
        unsafe {
            from_glib_none(ffi::g_binding_get_target(self.to_glib_none().0))
        }
    }

    pub fn get_target_property(&self) -> Option<String> {
        unsafe {
            from_glib_none(ffi::g_binding_get_target_property(self.to_glib_none().0))
        }
    }

    #[cfg(any(feature = "v2_38", feature = "dox"))]
    pub fn unbind(&self) {
        unsafe {
            ffi::g_binding_unbind(self.to_glib_full());
        }
    }

    pub fn connect_property_flags_notify<F: Fn(&Binding) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Binding) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::flags",
                transmute(notify_flags_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

    pub fn connect_property_source_notify<F: Fn(&Binding) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Binding) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::source",
                transmute(notify_source_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

    pub fn connect_property_source_property_notify<F: Fn(&Binding) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Binding) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::source-property",
                transmute(notify_source_property_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

    pub fn connect_property_target_notify<F: Fn(&Binding) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Binding) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::target",
                transmute(notify_target_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

    pub fn connect_property_target_property_notify<F: Fn(&Binding) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Binding) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::target-property",
                transmute(notify_target_property_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe impl Send for Binding {}
unsafe impl Sync for Binding {}

unsafe extern "C" fn notify_flags_trampoline(this: *mut gobject_ffi::GBinding, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    let f: &&(Fn(&Binding) + Send + Sync + 'static) = transmute(f);
    f(&from_glib_borrow(this))
}

unsafe extern "C" fn notify_source_trampoline(this: *mut gobject_ffi::GBinding, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    let f: &&(Fn(&Binding) + Send + Sync + 'static) = transmute(f);
    f(&from_glib_borrow(this))
}

unsafe extern "C" fn notify_source_property_trampoline(this: *mut gobject_ffi::GBinding, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    let f: &&(Fn(&Binding) + Send + Sync + 'static) = transmute(f);
    f(&from_glib_borrow(this))
}

unsafe extern "C" fn notify_target_trampoline(this: *mut gobject_ffi::GBinding, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    let f: &&(Fn(&Binding) + Send + Sync + 'static) = transmute(f);
    f(&from_glib_borrow(this))
}

unsafe extern "C" fn notify_target_property_trampoline(this: *mut gobject_ffi::GBinding, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    let f: &&(Fn(&Binding) + Send + Sync + 'static) = transmute(f);
    f(&from_glib_borrow(this))
}