gtk/auto/
cell_renderer_spinner.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 gdk;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::signal::connect_raw;
9use glib::signal::SignalHandlerId;
10use glib::translate::*;
11use glib::StaticType;
12use glib::ToValue;
13use glib::Value;
14use glib_sys;
15use gobject_sys;
16use gtk_sys;
17use std::boxed::Box as Box_;
18use std::fmt;
19use std::mem::transmute;
20use CellRenderer;
21use CellRendererMode;
22use IconSize;
23
24glib_wrapper! {
25    pub struct CellRendererSpinner(Object<gtk_sys::GtkCellRendererSpinner, gtk_sys::GtkCellRendererSpinnerClass, CellRendererSpinnerClass>) @extends CellRenderer;
26
27    match fn {
28        get_type => || gtk_sys::gtk_cell_renderer_spinner_get_type(),
29    }
30}
31
32impl CellRendererSpinner {
33    pub fn new() -> CellRendererSpinner {
34        assert_initialized_main_thread!();
35        unsafe {
36            CellRenderer::from_glib_none(gtk_sys::gtk_cell_renderer_spinner_new()).unsafe_cast()
37        }
38    }
39}
40
41impl Default for CellRendererSpinner {
42    fn default() -> Self {
43        Self::new()
44    }
45}
46
47pub struct CellRendererSpinnerBuilder {
48    active: Option<bool>,
49    pulse: Option<u32>,
50    size: Option<IconSize>,
51    cell_background: Option<String>,
52    cell_background_rgba: Option<gdk::RGBA>,
53    cell_background_set: Option<bool>,
54    height: Option<i32>,
55    is_expanded: Option<bool>,
56    is_expander: Option<bool>,
57    mode: Option<CellRendererMode>,
58    sensitive: Option<bool>,
59    visible: Option<bool>,
60    width: Option<i32>,
61    xalign: Option<f32>,
62    xpad: Option<u32>,
63    yalign: Option<f32>,
64    ypad: Option<u32>,
65}
66
67impl CellRendererSpinnerBuilder {
68    pub fn new() -> Self {
69        Self {
70            active: None,
71            pulse: None,
72            size: None,
73            cell_background: None,
74            cell_background_rgba: None,
75            cell_background_set: None,
76            height: None,
77            is_expanded: None,
78            is_expander: None,
79            mode: None,
80            sensitive: None,
81            visible: None,
82            width: None,
83            xalign: None,
84            xpad: None,
85            yalign: None,
86            ypad: None,
87        }
88    }
89
90    pub fn build(self) -> CellRendererSpinner {
91        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
92        if let Some(ref active) = self.active {
93            properties.push(("active", active));
94        }
95        if let Some(ref pulse) = self.pulse {
96            properties.push(("pulse", pulse));
97        }
98        if let Some(ref size) = self.size {
99            properties.push(("size", size));
100        }
101        if let Some(ref cell_background) = self.cell_background {
102            properties.push(("cell-background", cell_background));
103        }
104        if let Some(ref cell_background_rgba) = self.cell_background_rgba {
105            properties.push(("cell-background-rgba", cell_background_rgba));
106        }
107        if let Some(ref cell_background_set) = self.cell_background_set {
108            properties.push(("cell-background-set", cell_background_set));
109        }
110        if let Some(ref height) = self.height {
111            properties.push(("height", height));
112        }
113        if let Some(ref is_expanded) = self.is_expanded {
114            properties.push(("is-expanded", is_expanded));
115        }
116        if let Some(ref is_expander) = self.is_expander {
117            properties.push(("is-expander", is_expander));
118        }
119        if let Some(ref mode) = self.mode {
120            properties.push(("mode", mode));
121        }
122        if let Some(ref sensitive) = self.sensitive {
123            properties.push(("sensitive", sensitive));
124        }
125        if let Some(ref visible) = self.visible {
126            properties.push(("visible", visible));
127        }
128        if let Some(ref width) = self.width {
129            properties.push(("width", width));
130        }
131        if let Some(ref xalign) = self.xalign {
132            properties.push(("xalign", xalign));
133        }
134        if let Some(ref xpad) = self.xpad {
135            properties.push(("xpad", xpad));
136        }
137        if let Some(ref yalign) = self.yalign {
138            properties.push(("yalign", yalign));
139        }
140        if let Some(ref ypad) = self.ypad {
141            properties.push(("ypad", ypad));
142        }
143        glib::Object::new(CellRendererSpinner::static_type(), &properties)
144            .expect("object new")
145            .downcast()
146            .expect("downcast")
147    }
148
149    pub fn active(mut self, active: bool) -> Self {
150        self.active = Some(active);
151        self
152    }
153
154    pub fn pulse(mut self, pulse: u32) -> Self {
155        self.pulse = Some(pulse);
156        self
157    }
158
159    pub fn size(mut self, size: IconSize) -> Self {
160        self.size = Some(size);
161        self
162    }
163
164    pub fn cell_background(mut self, cell_background: &str) -> Self {
165        self.cell_background = Some(cell_background.to_string());
166        self
167    }
168
169    pub fn cell_background_rgba(mut self, cell_background_rgba: &gdk::RGBA) -> Self {
170        self.cell_background_rgba = Some(cell_background_rgba.clone());
171        self
172    }
173
174    pub fn cell_background_set(mut self, cell_background_set: bool) -> Self {
175        self.cell_background_set = Some(cell_background_set);
176        self
177    }
178
179    pub fn height(mut self, height: i32) -> Self {
180        self.height = Some(height);
181        self
182    }
183
184    pub fn is_expanded(mut self, is_expanded: bool) -> Self {
185        self.is_expanded = Some(is_expanded);
186        self
187    }
188
189    pub fn is_expander(mut self, is_expander: bool) -> Self {
190        self.is_expander = Some(is_expander);
191        self
192    }
193
194    pub fn mode(mut self, mode: CellRendererMode) -> Self {
195        self.mode = Some(mode);
196        self
197    }
198
199    pub fn sensitive(mut self, sensitive: bool) -> Self {
200        self.sensitive = Some(sensitive);
201        self
202    }
203
204    pub fn visible(mut self, visible: bool) -> Self {
205        self.visible = Some(visible);
206        self
207    }
208
209    pub fn width(mut self, width: i32) -> Self {
210        self.width = Some(width);
211        self
212    }
213
214    pub fn xalign(mut self, xalign: f32) -> Self {
215        self.xalign = Some(xalign);
216        self
217    }
218
219    pub fn xpad(mut self, xpad: u32) -> Self {
220        self.xpad = Some(xpad);
221        self
222    }
223
224    pub fn yalign(mut self, yalign: f32) -> Self {
225        self.yalign = Some(yalign);
226        self
227    }
228
229    pub fn ypad(mut self, ypad: u32) -> Self {
230        self.ypad = Some(ypad);
231        self
232    }
233}
234
235pub const NONE_CELL_RENDERER_SPINNER: Option<&CellRendererSpinner> = None;
236
237pub trait CellRendererSpinnerExt: 'static {
238    fn get_property_active(&self) -> bool;
239
240    fn set_property_active(&self, active: bool);
241
242    fn get_property_pulse(&self) -> u32;
243
244    fn set_property_pulse(&self, pulse: u32);
245
246    fn get_property_size(&self) -> IconSize;
247
248    fn set_property_size(&self, size: IconSize);
249
250    fn connect_property_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
251
252    fn connect_property_pulse_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
253
254    fn connect_property_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
255}
256
257impl<O: IsA<CellRendererSpinner>> CellRendererSpinnerExt for O {
258    fn get_property_active(&self) -> bool {
259        unsafe {
260            let mut value = Value::from_type(<bool as StaticType>::static_type());
261            gobject_sys::g_object_get_property(
262                self.to_glib_none().0 as *mut gobject_sys::GObject,
263                b"active\0".as_ptr() as *const _,
264                value.to_glib_none_mut().0,
265            );
266            value.get().unwrap()
267        }
268    }
269
270    fn set_property_active(&self, active: bool) {
271        unsafe {
272            gobject_sys::g_object_set_property(
273                self.to_glib_none().0 as *mut gobject_sys::GObject,
274                b"active\0".as_ptr() as *const _,
275                Value::from(&active).to_glib_none().0,
276            );
277        }
278    }
279
280    fn get_property_pulse(&self) -> u32 {
281        unsafe {
282            let mut value = Value::from_type(<u32 as StaticType>::static_type());
283            gobject_sys::g_object_get_property(
284                self.to_glib_none().0 as *mut gobject_sys::GObject,
285                b"pulse\0".as_ptr() as *const _,
286                value.to_glib_none_mut().0,
287            );
288            value.get().unwrap()
289        }
290    }
291
292    fn set_property_pulse(&self, pulse: u32) {
293        unsafe {
294            gobject_sys::g_object_set_property(
295                self.to_glib_none().0 as *mut gobject_sys::GObject,
296                b"pulse\0".as_ptr() as *const _,
297                Value::from(&pulse).to_glib_none().0,
298            );
299        }
300    }
301
302    fn get_property_size(&self) -> IconSize {
303        unsafe {
304            let mut value = Value::from_type(<IconSize as StaticType>::static_type());
305            gobject_sys::g_object_get_property(
306                self.to_glib_none().0 as *mut gobject_sys::GObject,
307                b"size\0".as_ptr() as *const _,
308                value.to_glib_none_mut().0,
309            );
310            value.get().unwrap()
311        }
312    }
313
314    fn set_property_size(&self, size: IconSize) {
315        unsafe {
316            gobject_sys::g_object_set_property(
317                self.to_glib_none().0 as *mut gobject_sys::GObject,
318                b"size\0".as_ptr() as *const _,
319                Value::from(&size).to_glib_none().0,
320            );
321        }
322    }
323
324    fn connect_property_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
325        unsafe extern "C" fn notify_active_trampoline<P, F: Fn(&P) + 'static>(
326            this: *mut gtk_sys::GtkCellRendererSpinner,
327            _param_spec: glib_sys::gpointer,
328            f: glib_sys::gpointer,
329        ) where
330            P: IsA<CellRendererSpinner>,
331        {
332            let f: &F = &*(f as *const F);
333            f(&CellRendererSpinner::from_glib_borrow(this).unsafe_cast())
334        }
335        unsafe {
336            let f: Box_<F> = Box_::new(f);
337            connect_raw(
338                self.as_ptr() as *mut _,
339                b"notify::active\0".as_ptr() as *const _,
340                Some(transmute(notify_active_trampoline::<Self, F> as usize)),
341                Box_::into_raw(f),
342            )
343        }
344    }
345
346    fn connect_property_pulse_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
347        unsafe extern "C" fn notify_pulse_trampoline<P, F: Fn(&P) + 'static>(
348            this: *mut gtk_sys::GtkCellRendererSpinner,
349            _param_spec: glib_sys::gpointer,
350            f: glib_sys::gpointer,
351        ) where
352            P: IsA<CellRendererSpinner>,
353        {
354            let f: &F = &*(f as *const F);
355            f(&CellRendererSpinner::from_glib_borrow(this).unsafe_cast())
356        }
357        unsafe {
358            let f: Box_<F> = Box_::new(f);
359            connect_raw(
360                self.as_ptr() as *mut _,
361                b"notify::pulse\0".as_ptr() as *const _,
362                Some(transmute(notify_pulse_trampoline::<Self, F> as usize)),
363                Box_::into_raw(f),
364            )
365        }
366    }
367
368    fn connect_property_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
369        unsafe extern "C" fn notify_size_trampoline<P, F: Fn(&P) + 'static>(
370            this: *mut gtk_sys::GtkCellRendererSpinner,
371            _param_spec: glib_sys::gpointer,
372            f: glib_sys::gpointer,
373        ) where
374            P: IsA<CellRendererSpinner>,
375        {
376            let f: &F = &*(f as *const F);
377            f(&CellRendererSpinner::from_glib_borrow(this).unsafe_cast())
378        }
379        unsafe {
380            let f: Box_<F> = Box_::new(f);
381            connect_raw(
382                self.as_ptr() as *mut _,
383                b"notify::size\0".as_ptr() as *const _,
384                Some(transmute(notify_size_trampoline::<Self, F> as usize)),
385                Box_::into_raw(f),
386            )
387        }
388    }
389}
390
391impl fmt::Display for CellRendererSpinner {
392    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
393        write!(f, "CellRendererSpinner")
394    }
395}