1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2013-2018, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use glib;
use glib::object::IsA;
use glib::translate::*;
use glib::StaticType;
use glib::Value;
use gobject_sys;
use CellRendererPixbuf;
use IconSize;

pub trait CellRendererPixbufExtManual: 'static {
    /// The `IconSize` value that specifies the size of the rendered icon.
    fn get_property_stock_size(&self) -> IconSize;

    /// The `IconSize` value that specifies the size of the rendered icon.
    fn set_property_stock_size(&self, stock_size: IconSize);
}

impl<O: IsA<CellRendererPixbuf> + IsA<glib::object::Object>> CellRendererPixbufExtManual for O {
    fn get_property_stock_size(&self) -> IconSize {
        unsafe {
            let mut value = Value::from_type(<u32 as StaticType>::static_type());
            gobject_sys::g_object_get_property(
                self.to_glib_none().0 as *mut _,
                "stock-size".to_glib_none().0,
                value.to_glib_none_mut().0,
            );
            from_glib(
                value
                    .get::<u32>()
                    .expect("Return Value for property `stock_size` getter")
                    .unwrap() as i32,
            )
        }
    }

    fn set_property_stock_size(&self, stock_size: IconSize) {
        unsafe {
            let value = Value::from(&(stock_size.to_glib() as u32));
            gobject_sys::g_object_set_property(
                self.to_glib_none().0 as *mut _,
                "stock-size".to_glib_none().0,
                value.to_glib_none().0,
            );
        }
    }
}