gtk/
cell_renderer_pixbuf.rs

1// Copyright 2013-2018, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use glib;
6use glib::object::IsA;
7use glib::translate::*;
8use glib::StaticType;
9use glib::Value;
10use gobject_sys;
11use CellRendererPixbuf;
12use IconSize;
13
14pub trait CellRendererPixbufExtManual: 'static {
15    fn get_property_stock_size(&self) -> IconSize;
16
17    fn set_property_stock_size(&self, stock_size: IconSize);
18}
19
20impl<O: IsA<CellRendererPixbuf> + IsA<glib::object::Object>> CellRendererPixbufExtManual for O {
21    fn get_property_stock_size(&self) -> IconSize {
22        unsafe {
23            let mut value = Value::from_type(<u32 as StaticType>::static_type());
24            gobject_sys::g_object_get_property(
25                self.to_glib_none().0 as *mut _,
26                "stock-size".to_glib_none().0,
27                value.to_glib_none_mut().0,
28            );
29            from_glib(value.get::<u32>().unwrap() as i32)
30        }
31    }
32
33    fn set_property_stock_size(&self, stock_size: IconSize) {
34        unsafe {
35            let value = Value::from(&(stock_size.to_glib() as u32));
36            gobject_sys::g_object_set_property(
37                self.to_glib_none().0 as *mut _,
38                "stock-size".to_glib_none().0,
39                value.to_glib_none().0,
40            );
41        }
42    }
43}