use Bin;
use Buildable;
use Container;
use Frame;
use Widget;
use ffi;
use glib::StaticType;
use glib::Value;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib_wrapper! {
pub struct AspectFrame(Object<ffi::GtkAspectFrame, ffi::GtkAspectFrameClass, AspectFrameClass>) @extends Frame, Bin, Container, Widget, @implements Buildable;
match fn {
get_type => || ffi::gtk_aspect_frame_get_type(),
}
}
impl AspectFrame {
pub fn new<'a, P: Into<Option<&'a str>>>(label: P, xalign: f32, yalign: f32, ratio: f32, obey_child: bool) -> AspectFrame {
assert_initialized_main_thread!();
let label = label.into();
unsafe {
Widget::from_glib_none(ffi::gtk_aspect_frame_new(label.to_glib_none().0, xalign, yalign, ratio, obey_child.to_glib())).unsafe_cast()
}
}
}
pub const NONE_ASPECT_FRAME: Option<&AspectFrame> = None;
pub trait AspectFrameExt: 'static {
fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool);
fn get_property_obey_child(&self) -> bool;
fn set_property_obey_child(&self, obey_child: bool);
fn get_property_ratio(&self) -> f32;
fn set_property_ratio(&self, ratio: f32);
fn get_property_xalign(&self) -> f32;
fn set_property_xalign(&self, xalign: f32);
fn get_property_yalign(&self) -> f32;
fn set_property_yalign(&self, yalign: f32);
fn connect_property_obey_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_ratio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<AspectFrame>> AspectFrameExt for O {
fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool) {
unsafe {
ffi::gtk_aspect_frame_set(self.as_ref().to_glib_none().0, xalign, yalign, ratio, obey_child.to_glib());
}
}
fn get_property_obey_child(&self) -> bool {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"obey-child\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_property_obey_child(&self, obey_child: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"obey-child\0".as_ptr() as *const _, Value::from(&obey_child).to_glib_none().0);
}
}
fn get_property_ratio(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"ratio\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_property_ratio(&self, ratio: f32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"ratio\0".as_ptr() as *const _, Value::from(&ratio).to_glib_none().0);
}
}
fn get_property_xalign(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"xalign\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_property_xalign(&self, xalign: f32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"xalign\0".as_ptr() as *const _, Value::from(&xalign).to_glib_none().0);
}
}
fn get_property_yalign(&self) -> f32 {
unsafe {
let mut value = Value::from_type(<f32 as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"yalign\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_property_yalign(&self, yalign: f32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"yalign\0".as_ptr() as *const _, Value::from(&yalign).to_glib_none().0);
}
}
fn connect_property_obey_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::obey-child\0".as_ptr() as *const _,
Some(transmute(notify_obey_child_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_ratio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::ratio\0".as_ptr() as *const _,
Some(transmute(notify_ratio_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::xalign\0".as_ptr() as *const _,
Some(transmute(notify_xalign_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::yalign\0".as_ptr() as *const _,
Some(transmute(notify_yalign_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn notify_obey_child_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkAspectFrame, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<AspectFrame> {
let f: &F = transmute(f);
f(&AspectFrame::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_ratio_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkAspectFrame, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<AspectFrame> {
let f: &F = transmute(f);
f(&AspectFrame::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_xalign_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkAspectFrame, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<AspectFrame> {
let f: &F = transmute(f);
f(&AspectFrame::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_yalign_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkAspectFrame, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<AspectFrame> {
let f: &F = transmute(f);
f(&AspectFrame::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for AspectFrame {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "AspectFrame")
}
}