use Buildable;
use CellArea;
use CellAreaContext;
use CellLayout;
use Orientable;
use TreeModel;
use TreePath;
use Widget;
use ffi;
use gdk;
use gdk_pixbuf;
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 CellView(Object<ffi::GtkCellView, ffi::GtkCellViewClass, CellViewClass>) @extends Widget, @implements Buildable, CellLayout, Orientable;
match fn {
get_type => || ffi::gtk_cell_view_get_type(),
}
}
impl CellView {
pub fn new() -> CellView {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_cell_view_new()).unsafe_cast()
}
}
pub fn new_with_context<P: IsA<CellArea>, Q: IsA<CellAreaContext>>(area: &P, context: &Q) -> CellView {
skip_assert_initialized!();
unsafe {
Widget::from_glib_none(ffi::gtk_cell_view_new_with_context(area.as_ref().to_glib_none().0, context.as_ref().to_glib_none().0)).unsafe_cast()
}
}
pub fn new_with_markup(markup: &str) -> CellView {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_cell_view_new_with_markup(markup.to_glib_none().0)).unsafe_cast()
}
}
pub fn new_with_pixbuf(pixbuf: &gdk_pixbuf::Pixbuf) -> CellView {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_cell_view_new_with_pixbuf(pixbuf.to_glib_none().0)).unsafe_cast()
}
}
pub fn new_with_text(text: &str) -> CellView {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_cell_view_new_with_text(text.to_glib_none().0)).unsafe_cast()
}
}
}
impl Default for CellView {
fn default() -> Self {
Self::new()
}
}
pub const NONE_CELL_VIEW: Option<&CellView> = None;
pub trait CellViewExt: 'static {
fn get_displayed_row(&self) -> Option<TreePath>;
fn get_draw_sensitive(&self) -> bool;
fn get_fit_model(&self) -> bool;
fn get_model(&self) -> Option<TreeModel>;
fn set_background_rgba(&self, rgba: &gdk::RGBA);
fn set_displayed_row(&self, path: &mut TreePath);
fn set_draw_sensitive(&self, draw_sensitive: bool);
fn set_fit_model(&self, fit_model: bool);
fn set_model<'a, P: IsA<TreeModel> + 'a, Q: Into<Option<&'a P>>>(&self, model: Q);
fn set_property_background<'a, P: Into<Option<&'a str>>>(&self, background: P);
fn get_property_background_rgba(&self) -> Option<gdk::RGBA>;
fn get_property_background_set(&self) -> bool;
fn set_property_background_set(&self, background_set: bool);
fn get_property_cell_area(&self) -> Option<CellArea>;
fn get_property_cell_area_context(&self) -> Option<CellAreaContext>;
fn connect_property_background_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_background_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_background_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_draw_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_fit_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<CellView>> CellViewExt for O {
fn get_displayed_row(&self) -> Option<TreePath> {
unsafe {
from_glib_full(ffi::gtk_cell_view_get_displayed_row(self.as_ref().to_glib_none().0))
}
}
fn get_draw_sensitive(&self) -> bool {
unsafe {
from_glib(ffi::gtk_cell_view_get_draw_sensitive(self.as_ref().to_glib_none().0))
}
}
fn get_fit_model(&self) -> bool {
unsafe {
from_glib(ffi::gtk_cell_view_get_fit_model(self.as_ref().to_glib_none().0))
}
}
fn get_model(&self) -> Option<TreeModel> {
unsafe {
from_glib_none(ffi::gtk_cell_view_get_model(self.as_ref().to_glib_none().0))
}
}
fn set_background_rgba(&self, rgba: &gdk::RGBA) {
unsafe {
ffi::gtk_cell_view_set_background_rgba(self.as_ref().to_glib_none().0, rgba.to_glib_none().0);
}
}
fn set_displayed_row(&self, path: &mut TreePath) {
unsafe {
ffi::gtk_cell_view_set_displayed_row(self.as_ref().to_glib_none().0, path.to_glib_none_mut().0);
}
}
fn set_draw_sensitive(&self, draw_sensitive: bool) {
unsafe {
ffi::gtk_cell_view_set_draw_sensitive(self.as_ref().to_glib_none().0, draw_sensitive.to_glib());
}
}
fn set_fit_model(&self, fit_model: bool) {
unsafe {
ffi::gtk_cell_view_set_fit_model(self.as_ref().to_glib_none().0, fit_model.to_glib());
}
}
fn set_model<'a, P: IsA<TreeModel> + 'a, Q: Into<Option<&'a P>>>(&self, model: Q) {
let model = model.into();
unsafe {
ffi::gtk_cell_view_set_model(self.as_ref().to_glib_none().0, model.map(|p| p.as_ref()).to_glib_none().0);
}
}
fn set_property_background<'a, P: Into<Option<&'a str>>>(&self, background: P) {
let background = background.into();
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"background\0".as_ptr() as *const _, Value::from(background).to_glib_none().0);
}
}
fn get_property_background_rgba(&self) -> Option<gdk::RGBA> {
unsafe {
let mut value = Value::from_type(<gdk::RGBA as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"background-rgba\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get()
}
}
fn get_property_background_set(&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"background-set\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_property_background_set(&self, background_set: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"background-set\0".as_ptr() as *const _, Value::from(&background_set).to_glib_none().0);
}
}
fn get_property_cell_area(&self) -> Option<CellArea> {
unsafe {
let mut value = Value::from_type(<CellArea as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"cell-area\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get()
}
}
fn get_property_cell_area_context(&self) -> Option<CellAreaContext> {
unsafe {
let mut value = Value::from_type(<CellAreaContext as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"cell-area-context\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get()
}
}
fn connect_property_background_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::background\0".as_ptr() as *const _,
Some(transmute(notify_background_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_background_rgba_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::background-rgba\0".as_ptr() as *const _,
Some(transmute(notify_background_rgba_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_background_set_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::background-set\0".as_ptr() as *const _,
Some(transmute(notify_background_set_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_draw_sensitive_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::draw-sensitive\0".as_ptr() as *const _,
Some(transmute(notify_draw_sensitive_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_fit_model_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::fit-model\0".as_ptr() as *const _,
Some(transmute(notify_fit_model_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_model_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::model\0".as_ptr() as *const _,
Some(transmute(notify_model_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn notify_background_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkCellView, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<CellView> {
let f: &F = transmute(f);
f(&CellView::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_background_rgba_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkCellView, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<CellView> {
let f: &F = transmute(f);
f(&CellView::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_background_set_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkCellView, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<CellView> {
let f: &F = transmute(f);
f(&CellView::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_draw_sensitive_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkCellView, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<CellView> {
let f: &F = transmute(f);
f(&CellView::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_fit_model_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkCellView, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<CellView> {
let f: &F = transmute(f);
f(&CellView::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_model_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkCellView, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<CellView> {
let f: &F = transmute(f);
f(&CellView::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for CellView {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "CellView")
}
}