[go: up one dir, main page]

gtk 0.6.0

Rust bindings for the GTK+ 3 library
Documentation
// 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 Actionable;
use Bin;
use Buildable;
use Container;
use Widget;
use ffi;
use glib;
use glib::object::Cast;
use glib::object::IsA;
use glib::object::ObjectExt;
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 ListBoxRow(Object<ffi::GtkListBoxRow, ffi::GtkListBoxRowClass, ListBoxRowClass>) @extends Bin, Container, Widget, @implements Buildable, Actionable;

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

impl ListBoxRow {
    pub fn new() -> ListBoxRow {
        assert_initialized_main_thread!();
        unsafe {
            Widget::from_glib_none(ffi::gtk_list_box_row_new()).unsafe_cast()
        }
    }
}

impl Default for ListBoxRow {
    fn default() -> Self {
        Self::new()
    }
}

pub const NONE_LIST_BOX_ROW: Option<&ListBoxRow> = None;

pub trait ListBoxRowExt: 'static {
    fn changed(&self);

    fn get_activatable(&self) -> bool;

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

    fn get_index(&self) -> i32;

    fn get_selectable(&self) -> bool;

    fn is_selected(&self) -> bool;

    fn set_activatable(&self, activatable: bool);

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

    fn set_selectable(&self, selectable: bool);

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

    fn emit_activate(&self);

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

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

impl<O: IsA<ListBoxRow>> ListBoxRowExt for O {
    fn changed(&self) {
        unsafe {
            ffi::gtk_list_box_row_changed(self.as_ref().to_glib_none().0);
        }
    }

    fn get_activatable(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_list_box_row_get_activatable(self.as_ref().to_glib_none().0))
        }
    }

    fn get_header(&self) -> Option<Widget> {
        unsafe {
            from_glib_none(ffi::gtk_list_box_row_get_header(self.as_ref().to_glib_none().0))
        }
    }

    fn get_index(&self) -> i32 {
        unsafe {
            ffi::gtk_list_box_row_get_index(self.as_ref().to_glib_none().0)
        }
    }

    fn get_selectable(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_list_box_row_get_selectable(self.as_ref().to_glib_none().0))
        }
    }

    fn is_selected(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_list_box_row_is_selected(self.as_ref().to_glib_none().0))
        }
    }

    fn set_activatable(&self, activatable: bool) {
        unsafe {
            ffi::gtk_list_box_row_set_activatable(self.as_ref().to_glib_none().0, activatable.to_glib());
        }
    }

    fn set_header<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, header: Q) {
        let header = header.into();
        unsafe {
            ffi::gtk_list_box_row_set_header(self.as_ref().to_glib_none().0, header.map(|p| p.as_ref()).to_glib_none().0);
        }
    }

    fn set_selectable(&self, selectable: bool) {
        unsafe {
            ffi::gtk_list_box_row_set_selectable(self.as_ref().to_glib_none().0, selectable.to_glib());
        }
    }

    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"activate\0".as_ptr() as *const _,
                Some(transmute(activate_trampoline::<Self, F> as usize)), Box_::into_raw(f))
        }
    }

    fn emit_activate(&self) {
        let _ = unsafe { glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_ffi::GObject).emit("activate", &[]).unwrap() };
    }

    fn connect_property_activatable_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::activatable\0".as_ptr() as *const _,
                Some(transmute(notify_activatable_trampoline::<Self, F> as usize)), Box_::into_raw(f))
        }
    }

    fn connect_property_selectable_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::selectable\0".as_ptr() as *const _,
                Some(transmute(notify_selectable_trampoline::<Self, F> as usize)), Box_::into_raw(f))
        }
    }
}

unsafe extern "C" fn activate_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkListBoxRow, f: glib_ffi::gpointer)
where P: IsA<ListBoxRow> {
    let f: &F = transmute(f);
    f(&ListBoxRow::from_glib_borrow(this).unsafe_cast())
}

unsafe extern "C" fn notify_activatable_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkListBoxRow, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<ListBoxRow> {
    let f: &F = transmute(f);
    f(&ListBoxRow::from_glib_borrow(this).unsafe_cast())
}

unsafe extern "C" fn notify_selectable_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkListBoxRow, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<ListBoxRow> {
    let f: &F = transmute(f);
    f(&ListBoxRow::from_glib_borrow(this).unsafe_cast())
}

impl fmt::Display for ListBoxRow {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "ListBoxRow")
    }
}