gio/auto/
property_action.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use gio_sys;
6use glib;
7use glib::object::IsA;
8use glib::object::ObjectType as ObjectType_;
9use glib::signal::connect_raw;
10use glib::signal::SignalHandlerId;
11use glib::translate::*;
12#[cfg(any(feature = "v2_46", feature = "dox"))]
13use glib::StaticType;
14#[cfg(any(feature = "v2_46", feature = "dox"))]
15use glib::Value;
16use glib_sys;
17#[cfg(any(feature = "v2_46", feature = "dox"))]
18use gobject_sys;
19use std::boxed::Box as Box_;
20use std::fmt;
21use std::mem::transmute;
22use Action;
23
24glib_wrapper! {
25    pub struct PropertyAction(Object<gio_sys::GPropertyAction, PropertyActionClass>) @implements Action;
26
27    match fn {
28        get_type => || gio_sys::g_property_action_get_type(),
29    }
30}
31
32impl PropertyAction {
33    pub fn new<P: IsA<glib::Object>>(
34        name: &str,
35        object: &P,
36        property_name: &str,
37    ) -> PropertyAction {
38        unsafe {
39            from_glib_full(gio_sys::g_property_action_new(
40                name.to_glib_none().0,
41                object.as_ref().to_glib_none().0,
42                property_name.to_glib_none().0,
43            ))
44        }
45    }
46
47    #[cfg(any(feature = "v2_46", feature = "dox"))]
48    pub fn get_property_invert_boolean(&self) -> bool {
49        unsafe {
50            let mut value = Value::from_type(<bool as StaticType>::static_type());
51            gobject_sys::g_object_get_property(
52                self.as_ptr() as *mut gobject_sys::GObject,
53                b"invert-boolean\0".as_ptr() as *const _,
54                value.to_glib_none_mut().0,
55            );
56            value.get().unwrap()
57        }
58    }
59
60    pub fn connect_property_enabled_notify<F: Fn(&PropertyAction) + 'static>(
61        &self,
62        f: F,
63    ) -> SignalHandlerId {
64        unsafe extern "C" fn notify_enabled_trampoline<F: Fn(&PropertyAction) + 'static>(
65            this: *mut gio_sys::GPropertyAction,
66            _param_spec: glib_sys::gpointer,
67            f: glib_sys::gpointer,
68        ) {
69            let f: &F = &*(f as *const F);
70            f(&from_glib_borrow(this))
71        }
72        unsafe {
73            let f: Box_<F> = Box_::new(f);
74            connect_raw(
75                self.as_ptr() as *mut _,
76                b"notify::enabled\0".as_ptr() as *const _,
77                Some(transmute(notify_enabled_trampoline::<F> as usize)),
78                Box_::into_raw(f),
79            )
80        }
81    }
82
83    pub fn connect_property_parameter_type_notify<F: Fn(&PropertyAction) + 'static>(
84        &self,
85        f: F,
86    ) -> SignalHandlerId {
87        unsafe extern "C" fn notify_parameter_type_trampoline<F: Fn(&PropertyAction) + 'static>(
88            this: *mut gio_sys::GPropertyAction,
89            _param_spec: glib_sys::gpointer,
90            f: glib_sys::gpointer,
91        ) {
92            let f: &F = &*(f as *const F);
93            f(&from_glib_borrow(this))
94        }
95        unsafe {
96            let f: Box_<F> = Box_::new(f);
97            connect_raw(
98                self.as_ptr() as *mut _,
99                b"notify::parameter-type\0".as_ptr() as *const _,
100                Some(transmute(notify_parameter_type_trampoline::<F> as usize)),
101                Box_::into_raw(f),
102            )
103        }
104    }
105
106    pub fn connect_property_state_notify<F: Fn(&PropertyAction) + 'static>(
107        &self,
108        f: F,
109    ) -> SignalHandlerId {
110        unsafe extern "C" fn notify_state_trampoline<F: Fn(&PropertyAction) + 'static>(
111            this: *mut gio_sys::GPropertyAction,
112            _param_spec: glib_sys::gpointer,
113            f: glib_sys::gpointer,
114        ) {
115            let f: &F = &*(f as *const F);
116            f(&from_glib_borrow(this))
117        }
118        unsafe {
119            let f: Box_<F> = Box_::new(f);
120            connect_raw(
121                self.as_ptr() as *mut _,
122                b"notify::state\0".as_ptr() as *const _,
123                Some(transmute(notify_state_trampoline::<F> as usize)),
124                Box_::into_raw(f),
125            )
126        }
127    }
128
129    pub fn connect_property_state_type_notify<F: Fn(&PropertyAction) + 'static>(
130        &self,
131        f: F,
132    ) -> SignalHandlerId {
133        unsafe extern "C" fn notify_state_type_trampoline<F: Fn(&PropertyAction) + 'static>(
134            this: *mut gio_sys::GPropertyAction,
135            _param_spec: glib_sys::gpointer,
136            f: glib_sys::gpointer,
137        ) {
138            let f: &F = &*(f as *const F);
139            f(&from_glib_borrow(this))
140        }
141        unsafe {
142            let f: Box_<F> = Box_::new(f);
143            connect_raw(
144                self.as_ptr() as *mut _,
145                b"notify::state-type\0".as_ptr() as *const _,
146                Some(transmute(notify_state_type_trampoline::<F> as usize)),
147                Box_::into_raw(f),
148            )
149        }
150    }
151}
152
153impl fmt::Display for PropertyAction {
154    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
155        write!(f, "PropertyAction")
156    }
157}