[go: up one dir, main page]

gtk 0.4.1

Rust bindings for the GTK+ 3 library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
// DO NOT EDIT

use Adjustment;
use Buildable;
use ResizeMode;
use Widget;
use WidgetPath;
use cairo;
use ffi;
use glib;
use glib::Value;
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 Container(Object<ffi::GtkContainer, ffi::GtkContainerClass>): Widget, Buildable;

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

pub trait ContainerExt {
    fn add<P: IsA<Widget>>(&self, widget: &P);

    //fn add_with_properties<P: IsA<Widget>>(&self, widget: &P, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    fn check_resize(&self);

    //fn child_get<P: IsA<Widget>>(&self, child: &P, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    //fn child_get_valist<P: IsA<Widget>>(&self, child: &P, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported);

    fn child_notify<P: IsA<Widget>>(&self, child: &P, child_property: &str);

    //#[cfg(any(feature = "v3_18", feature = "dox"))]
    //fn child_notify_by_pspec<P: IsA<Widget>, Q: IsA</*Ignored*/glib::ParamSpec>>(&self, child: &P, pspec: &Q);

    //fn child_set<P: IsA<Widget>>(&self, child: &P, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    //fn child_set_valist<P: IsA<Widget>>(&self, child: &P, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported);

    fn child_type(&self) -> glib::types::Type;

    //fn forall<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, callback: /*Unknown conversion*//*Unimplemented*/Callback, callback_data: P);

    //fn foreach<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, callback: /*Unknown conversion*//*Unimplemented*/Callback, callback_data: P);

    fn get_border_width(&self) -> u32;

    fn get_children(&self) -> Vec<Widget>;

    //fn get_focus_chain(&self, focusable_widgets: /*Unimplemented*/Vec<Widget>) -> bool;

    fn get_focus_child(&self) -> Option<Widget>;

    fn get_focus_hadjustment(&self) -> Option<Adjustment>;

    fn get_focus_vadjustment(&self) -> Option<Adjustment>;

    fn get_path_for_child<P: IsA<Widget>>(&self, child: &P) -> Option<WidgetPath>;

    #[cfg_attr(feature = "v3_12", deprecated)]
    fn get_resize_mode(&self) -> ResizeMode;

    fn propagate_draw<P: IsA<Widget>>(&self, child: &P, cr: &cairo::Context);

    fn remove<P: IsA<Widget>>(&self, widget: &P);

    #[cfg_attr(feature = "v3_10", deprecated)]
    fn resize_children(&self);

    fn set_border_width(&self, border_width: u32);

    fn set_focus_chain(&self, focusable_widgets: &[Widget]);

    fn set_focus_child<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, child: Q);

    fn set_focus_hadjustment(&self, adjustment: &Adjustment);

    fn set_focus_vadjustment(&self, adjustment: &Adjustment);

    #[cfg_attr(feature = "v3_14", deprecated)]
    fn set_reallocate_redraws(&self, needs_redraws: bool);

    #[cfg_attr(feature = "v3_12", deprecated)]
    fn set_resize_mode(&self, resize_mode: ResizeMode);

    fn unset_focus_chain(&self);

    fn set_property_child<P: IsA<Widget> + IsA<glib::object::Object> + glib::value::SetValueOptional>(&self, child: Option<&P>);

    fn connect_add<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_check_resize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_remove<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_set_focus_child<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_border_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_resize_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<Container> + IsA<glib::object::Object>> ContainerExt for O {
    fn add<P: IsA<Widget>>(&self, widget: &P) {
        unsafe {
            ffi::gtk_container_add(self.to_glib_none().0, widget.to_glib_none().0);
        }
    }

    //fn add_with_properties<P: IsA<Widget>>(&self, widget: &P, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi::gtk_container_add_with_properties() }
    //}

    fn check_resize(&self) {
        unsafe {
            ffi::gtk_container_check_resize(self.to_glib_none().0);
        }
    }

    //fn child_get<P: IsA<Widget>>(&self, child: &P, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi::gtk_container_child_get() }
    //}

    //fn child_get_valist<P: IsA<Widget>>(&self, child: &P, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call ffi::gtk_container_child_get_valist() }
    //}

    fn child_notify<P: IsA<Widget>>(&self, child: &P, child_property: &str) {
        unsafe {
            ffi::gtk_container_child_notify(self.to_glib_none().0, child.to_glib_none().0, child_property.to_glib_none().0);
        }
    }

    //#[cfg(any(feature = "v3_18", feature = "dox"))]
    //fn child_notify_by_pspec<P: IsA<Widget>, Q: IsA</*Ignored*/glib::ParamSpec>>(&self, child: &P, pspec: &Q) {
    //    unsafe { TODO: call ffi::gtk_container_child_notify_by_pspec() }
    //}

    //fn child_set<P: IsA<Widget>>(&self, child: &P, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi::gtk_container_child_set() }
    //}

    //fn child_set_valist<P: IsA<Widget>>(&self, child: &P, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call ffi::gtk_container_child_set_valist() }
    //}

    fn child_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::gtk_container_child_type(self.to_glib_none().0))
        }
    }

    //fn forall<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, callback: /*Unknown conversion*//*Unimplemented*/Callback, callback_data: P) {
    //    unsafe { TODO: call ffi::gtk_container_forall() }
    //}

    //fn foreach<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, callback: /*Unknown conversion*//*Unimplemented*/Callback, callback_data: P) {
    //    unsafe { TODO: call ffi::gtk_container_foreach() }
    //}

    fn get_border_width(&self) -> u32 {
        unsafe {
            ffi::gtk_container_get_border_width(self.to_glib_none().0)
        }
    }

    fn get_children(&self) -> Vec<Widget> {
        unsafe {
            FromGlibPtrContainer::from_glib_container(ffi::gtk_container_get_children(self.to_glib_none().0))
        }
    }

    //fn get_focus_chain(&self, focusable_widgets: /*Unimplemented*/Vec<Widget>) -> bool {
    //    unsafe { TODO: call ffi::gtk_container_get_focus_chain() }
    //}

    fn get_focus_child(&self) -> Option<Widget> {
        unsafe {
            from_glib_none(ffi::gtk_container_get_focus_child(self.to_glib_none().0))
        }
    }

    fn get_focus_hadjustment(&self) -> Option<Adjustment> {
        unsafe {
            from_glib_none(ffi::gtk_container_get_focus_hadjustment(self.to_glib_none().0))
        }
    }

    fn get_focus_vadjustment(&self) -> Option<Adjustment> {
        unsafe {
            from_glib_none(ffi::gtk_container_get_focus_vadjustment(self.to_glib_none().0))
        }
    }

    fn get_path_for_child<P: IsA<Widget>>(&self, child: &P) -> Option<WidgetPath> {
        unsafe {
            from_glib_full(ffi::gtk_container_get_path_for_child(self.to_glib_none().0, child.to_glib_none().0))
        }
    }

    fn get_resize_mode(&self) -> ResizeMode {
        unsafe {
            from_glib(ffi::gtk_container_get_resize_mode(self.to_glib_none().0))
        }
    }

    fn propagate_draw<P: IsA<Widget>>(&self, child: &P, cr: &cairo::Context) {
        unsafe {
            ffi::gtk_container_propagate_draw(self.to_glib_none().0, child.to_glib_none().0, mut_override(cr.to_glib_none().0));
        }
    }

    fn remove<P: IsA<Widget>>(&self, widget: &P) {
        unsafe {
            ffi::gtk_container_remove(self.to_glib_none().0, widget.to_glib_none().0);
        }
    }

    fn resize_children(&self) {
        unsafe {
            ffi::gtk_container_resize_children(self.to_glib_none().0);
        }
    }

    fn set_border_width(&self, border_width: u32) {
        unsafe {
            ffi::gtk_container_set_border_width(self.to_glib_none().0, border_width);
        }
    }

    fn set_focus_chain(&self, focusable_widgets: &[Widget]) {
        unsafe {
            ffi::gtk_container_set_focus_chain(self.to_glib_none().0, focusable_widgets.to_glib_none().0);
        }
    }

    fn set_focus_child<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, child: Q) {
        let child = child.into();
        let child = child.to_glib_none();
        unsafe {
            ffi::gtk_container_set_focus_child(self.to_glib_none().0, child.0);
        }
    }

    fn set_focus_hadjustment(&self, adjustment: &Adjustment) {
        unsafe {
            ffi::gtk_container_set_focus_hadjustment(self.to_glib_none().0, adjustment.to_glib_none().0);
        }
    }

    fn set_focus_vadjustment(&self, adjustment: &Adjustment) {
        unsafe {
            ffi::gtk_container_set_focus_vadjustment(self.to_glib_none().0, adjustment.to_glib_none().0);
        }
    }

    fn set_reallocate_redraws(&self, needs_redraws: bool) {
        unsafe {
            ffi::gtk_container_set_reallocate_redraws(self.to_glib_none().0, needs_redraws.to_glib());
        }
    }

    fn set_resize_mode(&self, resize_mode: ResizeMode) {
        unsafe {
            ffi::gtk_container_set_resize_mode(self.to_glib_none().0, resize_mode.to_glib());
        }
    }

    fn unset_focus_chain(&self) {
        unsafe {
            ffi::gtk_container_unset_focus_chain(self.to_glib_none().0);
        }
    }

    fn set_property_child<P: IsA<Widget> + IsA<glib::object::Object> + glib::value::SetValueOptional>(&self, child: Option<&P>) {
        unsafe {
            gobject_ffi::g_object_set_property(self.to_glib_none().0, "child".to_glib_none().0, Value::from(child).to_glib_none().0);
        }
    }

    fn connect_add<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &Widget) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "add",
                transmute(add_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_check_resize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "check-resize",
                transmute(check_resize_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_remove<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &Widget) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "remove",
                transmute(remove_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_set_focus_child<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &Widget) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "set-focus-child",
                transmute(set_focus_child_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_border_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::border-width",
                transmute(notify_border_width_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::child",
                transmute(notify_child_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_resize_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::resize-mode",
                transmute(notify_resize_mode_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn add_trampoline<P>(this: *mut ffi::GtkContainer, object: *mut ffi::GtkWidget, f: glib_ffi::gpointer)
where P: IsA<Container> {
    callback_guard!();
    let f: &&(Fn(&P, &Widget) + 'static) = transmute(f);
    f(&Container::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(object))
}

unsafe extern "C" fn check_resize_trampoline<P>(this: *mut ffi::GtkContainer, f: glib_ffi::gpointer)
where P: IsA<Container> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&Container::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn remove_trampoline<P>(this: *mut ffi::GtkContainer, object: *mut ffi::GtkWidget, f: glib_ffi::gpointer)
where P: IsA<Container> {
    callback_guard!();
    let f: &&(Fn(&P, &Widget) + 'static) = transmute(f);
    f(&Container::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(object))
}

unsafe extern "C" fn set_focus_child_trampoline<P>(this: *mut ffi::GtkContainer, object: *mut ffi::GtkWidget, f: glib_ffi::gpointer)
where P: IsA<Container> {
    callback_guard!();
    let f: &&(Fn(&P, &Widget) + 'static) = transmute(f);
    f(&Container::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(object))
}

unsafe extern "C" fn notify_border_width_trampoline<P>(this: *mut ffi::GtkContainer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Container> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&Container::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_child_trampoline<P>(this: *mut ffi::GtkContainer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Container> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&Container::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_resize_mode_trampoline<P>(this: *mut ffi::GtkContainer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Container> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&Container::from_glib_borrow(this).downcast_unchecked())
}