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 
5 use gdk;
6 use glib::object::Cast;
7 use glib::object::IsA;
8 use glib::signal::connect_raw;
9 use glib::signal::SignalHandlerId;
10 use glib::translate::*;
11 use glib::StaticType;
12 use glib::ToValue;
13 use glib::Value;
14 use glib_sys;
15 use gobject_sys;
16 use gtk_sys;
17 use libc;
18 use std::boxed::Box as Box_;
19 use std::fmt;
20 use std::mem::transmute;
21 use CellRenderer;
22 use CellRendererMode;
23 use TreePath;
24 
25 glib_wrapper! {
26     pub struct CellRendererToggle(Object<gtk_sys::GtkCellRendererToggle, gtk_sys::GtkCellRendererToggleClass, CellRendererToggleClass>) @extends CellRenderer;
27 
28     match fn {
29         get_type => || gtk_sys::gtk_cell_renderer_toggle_get_type(),
30     }
31 }
32 
33 impl CellRendererToggle {
new() -> CellRendererToggle34     pub fn new() -> CellRendererToggle {
35         assert_initialized_main_thread!();
36         unsafe {
37             CellRenderer::from_glib_none(gtk_sys::gtk_cell_renderer_toggle_new()).unsafe_cast()
38         }
39     }
40 }
41 
42 impl Default for CellRendererToggle {
default() -> Self43     fn default() -> Self {
44         Self::new()
45     }
46 }
47 
48 pub struct CellRendererToggleBuilder {
49     activatable: Option<bool>,
50     active: Option<bool>,
51     inconsistent: Option<bool>,
52     indicator_size: Option<i32>,
53     radio: Option<bool>,
54     cell_background: Option<String>,
55     cell_background_rgba: Option<gdk::RGBA>,
56     cell_background_set: Option<bool>,
57     height: Option<i32>,
58     is_expanded: Option<bool>,
59     is_expander: Option<bool>,
60     mode: Option<CellRendererMode>,
61     sensitive: Option<bool>,
62     visible: Option<bool>,
63     width: Option<i32>,
64     xalign: Option<f32>,
65     xpad: Option<u32>,
66     yalign: Option<f32>,
67     ypad: Option<u32>,
68 }
69 
70 impl CellRendererToggleBuilder {
new() -> Self71     pub fn new() -> Self {
72         Self {
73             activatable: None,
74             active: None,
75             inconsistent: None,
76             indicator_size: None,
77             radio: None,
78             cell_background: None,
79             cell_background_rgba: None,
80             cell_background_set: None,
81             height: None,
82             is_expanded: None,
83             is_expander: None,
84             mode: None,
85             sensitive: None,
86             visible: None,
87             width: None,
88             xalign: None,
89             xpad: None,
90             yalign: None,
91             ypad: None,
92         }
93     }
94 
build(self) -> CellRendererToggle95     pub fn build(self) -> CellRendererToggle {
96         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
97         if let Some(ref activatable) = self.activatable {
98             properties.push(("activatable", activatable));
99         }
100         if let Some(ref active) = self.active {
101             properties.push(("active", active));
102         }
103         if let Some(ref inconsistent) = self.inconsistent {
104             properties.push(("inconsistent", inconsistent));
105         }
106         if let Some(ref indicator_size) = self.indicator_size {
107             properties.push(("indicator-size", indicator_size));
108         }
109         if let Some(ref radio) = self.radio {
110             properties.push(("radio", radio));
111         }
112         if let Some(ref cell_background) = self.cell_background {
113             properties.push(("cell-background", cell_background));
114         }
115         if let Some(ref cell_background_rgba) = self.cell_background_rgba {
116             properties.push(("cell-background-rgba", cell_background_rgba));
117         }
118         if let Some(ref cell_background_set) = self.cell_background_set {
119             properties.push(("cell-background-set", cell_background_set));
120         }
121         if let Some(ref height) = self.height {
122             properties.push(("height", height));
123         }
124         if let Some(ref is_expanded) = self.is_expanded {
125             properties.push(("is-expanded", is_expanded));
126         }
127         if let Some(ref is_expander) = self.is_expander {
128             properties.push(("is-expander", is_expander));
129         }
130         if let Some(ref mode) = self.mode {
131             properties.push(("mode", mode));
132         }
133         if let Some(ref sensitive) = self.sensitive {
134             properties.push(("sensitive", sensitive));
135         }
136         if let Some(ref visible) = self.visible {
137             properties.push(("visible", visible));
138         }
139         if let Some(ref width) = self.width {
140             properties.push(("width", width));
141         }
142         if let Some(ref xalign) = self.xalign {
143             properties.push(("xalign", xalign));
144         }
145         if let Some(ref xpad) = self.xpad {
146             properties.push(("xpad", xpad));
147         }
148         if let Some(ref yalign) = self.yalign {
149             properties.push(("yalign", yalign));
150         }
151         if let Some(ref ypad) = self.ypad {
152             properties.push(("ypad", ypad));
153         }
154         glib::Object::new(CellRendererToggle::static_type(), &properties)
155             .expect("object new")
156             .downcast()
157             .expect("downcast")
158     }
159 
activatable(mut self, activatable: bool) -> Self160     pub fn activatable(mut self, activatable: bool) -> Self {
161         self.activatable = Some(activatable);
162         self
163     }
164 
active(mut self, active: bool) -> Self165     pub fn active(mut self, active: bool) -> Self {
166         self.active = Some(active);
167         self
168     }
169 
inconsistent(mut self, inconsistent: bool) -> Self170     pub fn inconsistent(mut self, inconsistent: bool) -> Self {
171         self.inconsistent = Some(inconsistent);
172         self
173     }
174 
indicator_size(mut self, indicator_size: i32) -> Self175     pub fn indicator_size(mut self, indicator_size: i32) -> Self {
176         self.indicator_size = Some(indicator_size);
177         self
178     }
179 
radio(mut self, radio: bool) -> Self180     pub fn radio(mut self, radio: bool) -> Self {
181         self.radio = Some(radio);
182         self
183     }
184 
cell_background(mut self, cell_background: &str) -> Self185     pub fn cell_background(mut self, cell_background: &str) -> Self {
186         self.cell_background = Some(cell_background.to_string());
187         self
188     }
189 
cell_background_rgba(mut self, cell_background_rgba: &gdk::RGBA) -> Self190     pub fn cell_background_rgba(mut self, cell_background_rgba: &gdk::RGBA) -> Self {
191         self.cell_background_rgba = Some(cell_background_rgba.clone());
192         self
193     }
194 
cell_background_set(mut self, cell_background_set: bool) -> Self195     pub fn cell_background_set(mut self, cell_background_set: bool) -> Self {
196         self.cell_background_set = Some(cell_background_set);
197         self
198     }
199 
height(mut self, height: i32) -> Self200     pub fn height(mut self, height: i32) -> Self {
201         self.height = Some(height);
202         self
203     }
204 
is_expanded(mut self, is_expanded: bool) -> Self205     pub fn is_expanded(mut self, is_expanded: bool) -> Self {
206         self.is_expanded = Some(is_expanded);
207         self
208     }
209 
is_expander(mut self, is_expander: bool) -> Self210     pub fn is_expander(mut self, is_expander: bool) -> Self {
211         self.is_expander = Some(is_expander);
212         self
213     }
214 
mode(mut self, mode: CellRendererMode) -> Self215     pub fn mode(mut self, mode: CellRendererMode) -> Self {
216         self.mode = Some(mode);
217         self
218     }
219 
sensitive(mut self, sensitive: bool) -> Self220     pub fn sensitive(mut self, sensitive: bool) -> Self {
221         self.sensitive = Some(sensitive);
222         self
223     }
224 
visible(mut self, visible: bool) -> Self225     pub fn visible(mut self, visible: bool) -> Self {
226         self.visible = Some(visible);
227         self
228     }
229 
width(mut self, width: i32) -> Self230     pub fn width(mut self, width: i32) -> Self {
231         self.width = Some(width);
232         self
233     }
234 
xalign(mut self, xalign: f32) -> Self235     pub fn xalign(mut self, xalign: f32) -> Self {
236         self.xalign = Some(xalign);
237         self
238     }
239 
xpad(mut self, xpad: u32) -> Self240     pub fn xpad(mut self, xpad: u32) -> Self {
241         self.xpad = Some(xpad);
242         self
243     }
244 
yalign(mut self, yalign: f32) -> Self245     pub fn yalign(mut self, yalign: f32) -> Self {
246         self.yalign = Some(yalign);
247         self
248     }
249 
ypad(mut self, ypad: u32) -> Self250     pub fn ypad(mut self, ypad: u32) -> Self {
251         self.ypad = Some(ypad);
252         self
253     }
254 }
255 
256 pub const NONE_CELL_RENDERER_TOGGLE: Option<&CellRendererToggle> = None;
257 
258 pub trait CellRendererToggleExt: 'static {
get_activatable(&self) -> bool259     fn get_activatable(&self) -> bool;
260 
get_active(&self) -> bool261     fn get_active(&self) -> bool;
262 
get_radio(&self) -> bool263     fn get_radio(&self) -> bool;
264 
set_activatable(&self, setting: bool)265     fn set_activatable(&self, setting: bool);
266 
set_active(&self, setting: bool)267     fn set_active(&self, setting: bool);
268 
set_radio(&self, radio: bool)269     fn set_radio(&self, radio: bool);
270 
get_property_inconsistent(&self) -> bool271     fn get_property_inconsistent(&self) -> bool;
272 
set_property_inconsistent(&self, inconsistent: bool)273     fn set_property_inconsistent(&self, inconsistent: bool);
274 
get_property_indicator_size(&self) -> i32275     fn get_property_indicator_size(&self) -> i32;
276 
set_property_indicator_size(&self, indicator_size: i32)277     fn set_property_indicator_size(&self, indicator_size: i32);
278 
connect_toggled<F: Fn(&Self, TreePath) + 'static>(&self, f: F) -> SignalHandlerId279     fn connect_toggled<F: Fn(&Self, TreePath) + 'static>(&self, f: F) -> SignalHandlerId;
280 
connect_property_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId281     fn connect_property_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
282 
connect_property_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId283     fn connect_property_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
284 
connect_property_inconsistent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId285     fn connect_property_inconsistent_notify<F: Fn(&Self) + 'static>(&self, f: F)
286         -> SignalHandlerId;
287 
connect_property_indicator_size_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId288     fn connect_property_indicator_size_notify<F: Fn(&Self) + 'static>(
289         &self,
290         f: F,
291     ) -> SignalHandlerId;
292 
connect_property_radio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId293     fn connect_property_radio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
294 }
295 
296 impl<O: IsA<CellRendererToggle>> CellRendererToggleExt for O {
get_activatable(&self) -> bool297     fn get_activatable(&self) -> bool {
298         unsafe {
299             from_glib(gtk_sys::gtk_cell_renderer_toggle_get_activatable(
300                 self.as_ref().to_glib_none().0,
301             ))
302         }
303     }
304 
get_active(&self) -> bool305     fn get_active(&self) -> bool {
306         unsafe {
307             from_glib(gtk_sys::gtk_cell_renderer_toggle_get_active(
308                 self.as_ref().to_glib_none().0,
309             ))
310         }
311     }
312 
get_radio(&self) -> bool313     fn get_radio(&self) -> bool {
314         unsafe {
315             from_glib(gtk_sys::gtk_cell_renderer_toggle_get_radio(
316                 self.as_ref().to_glib_none().0,
317             ))
318         }
319     }
320 
set_activatable(&self, setting: bool)321     fn set_activatable(&self, setting: bool) {
322         unsafe {
323             gtk_sys::gtk_cell_renderer_toggle_set_activatable(
324                 self.as_ref().to_glib_none().0,
325                 setting.to_glib(),
326             );
327         }
328     }
329 
set_active(&self, setting: bool)330     fn set_active(&self, setting: bool) {
331         unsafe {
332             gtk_sys::gtk_cell_renderer_toggle_set_active(
333                 self.as_ref().to_glib_none().0,
334                 setting.to_glib(),
335             );
336         }
337     }
338 
set_radio(&self, radio: bool)339     fn set_radio(&self, radio: bool) {
340         unsafe {
341             gtk_sys::gtk_cell_renderer_toggle_set_radio(
342                 self.as_ref().to_glib_none().0,
343                 radio.to_glib(),
344             );
345         }
346     }
347 
get_property_inconsistent(&self) -> bool348     fn get_property_inconsistent(&self) -> bool {
349         unsafe {
350             let mut value = Value::from_type(<bool as StaticType>::static_type());
351             gobject_sys::g_object_get_property(
352                 self.to_glib_none().0 as *mut gobject_sys::GObject,
353                 b"inconsistent\0".as_ptr() as *const _,
354                 value.to_glib_none_mut().0,
355             );
356             value.get().unwrap()
357         }
358     }
359 
set_property_inconsistent(&self, inconsistent: bool)360     fn set_property_inconsistent(&self, inconsistent: bool) {
361         unsafe {
362             gobject_sys::g_object_set_property(
363                 self.to_glib_none().0 as *mut gobject_sys::GObject,
364                 b"inconsistent\0".as_ptr() as *const _,
365                 Value::from(&inconsistent).to_glib_none().0,
366             );
367         }
368     }
369 
get_property_indicator_size(&self) -> i32370     fn get_property_indicator_size(&self) -> i32 {
371         unsafe {
372             let mut value = Value::from_type(<i32 as StaticType>::static_type());
373             gobject_sys::g_object_get_property(
374                 self.to_glib_none().0 as *mut gobject_sys::GObject,
375                 b"indicator-size\0".as_ptr() as *const _,
376                 value.to_glib_none_mut().0,
377             );
378             value.get().unwrap()
379         }
380     }
381 
set_property_indicator_size(&self, indicator_size: i32)382     fn set_property_indicator_size(&self, indicator_size: i32) {
383         unsafe {
384             gobject_sys::g_object_set_property(
385                 self.to_glib_none().0 as *mut gobject_sys::GObject,
386                 b"indicator-size\0".as_ptr() as *const _,
387                 Value::from(&indicator_size).to_glib_none().0,
388             );
389         }
390     }
391 
connect_toggled<F: Fn(&Self, TreePath) + 'static>(&self, f: F) -> SignalHandlerId392     fn connect_toggled<F: Fn(&Self, TreePath) + 'static>(&self, f: F) -> SignalHandlerId {
393         unsafe extern "C" fn toggled_trampoline<P, F: Fn(&P, TreePath) + 'static>(
394             this: *mut gtk_sys::GtkCellRendererToggle,
395             path: *mut libc::c_char,
396             f: glib_sys::gpointer,
397         ) where
398             P: IsA<CellRendererToggle>,
399         {
400             let f: &F = &*(f as *const F);
401             let path = from_glib_full(gtk_sys::gtk_tree_path_new_from_string(path));
402             f(
403                 &CellRendererToggle::from_glib_borrow(this).unsafe_cast(),
404                 path,
405             )
406         }
407         unsafe {
408             let f: Box_<F> = Box_::new(f);
409             connect_raw(
410                 self.as_ptr() as *mut _,
411                 b"toggled\0".as_ptr() as *const _,
412                 Some(transmute(toggled_trampoline::<Self, F> as usize)),
413                 Box_::into_raw(f),
414             )
415         }
416     }
417 
connect_property_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId418     fn connect_property_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
419         unsafe extern "C" fn notify_activatable_trampoline<P, F: Fn(&P) + 'static>(
420             this: *mut gtk_sys::GtkCellRendererToggle,
421             _param_spec: glib_sys::gpointer,
422             f: glib_sys::gpointer,
423         ) where
424             P: IsA<CellRendererToggle>,
425         {
426             let f: &F = &*(f as *const F);
427             f(&CellRendererToggle::from_glib_borrow(this).unsafe_cast())
428         }
429         unsafe {
430             let f: Box_<F> = Box_::new(f);
431             connect_raw(
432                 self.as_ptr() as *mut _,
433                 b"notify::activatable\0".as_ptr() as *const _,
434                 Some(transmute(notify_activatable_trampoline::<Self, F> as usize)),
435                 Box_::into_raw(f),
436             )
437         }
438     }
439 
connect_property_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId440     fn connect_property_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
441         unsafe extern "C" fn notify_active_trampoline<P, F: Fn(&P) + 'static>(
442             this: *mut gtk_sys::GtkCellRendererToggle,
443             _param_spec: glib_sys::gpointer,
444             f: glib_sys::gpointer,
445         ) where
446             P: IsA<CellRendererToggle>,
447         {
448             let f: &F = &*(f as *const F);
449             f(&CellRendererToggle::from_glib_borrow(this).unsafe_cast())
450         }
451         unsafe {
452             let f: Box_<F> = Box_::new(f);
453             connect_raw(
454                 self.as_ptr() as *mut _,
455                 b"notify::active\0".as_ptr() as *const _,
456                 Some(transmute(notify_active_trampoline::<Self, F> as usize)),
457                 Box_::into_raw(f),
458             )
459         }
460     }
461 
connect_property_inconsistent_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId462     fn connect_property_inconsistent_notify<F: Fn(&Self) + 'static>(
463         &self,
464         f: F,
465     ) -> SignalHandlerId {
466         unsafe extern "C" fn notify_inconsistent_trampoline<P, F: Fn(&P) + 'static>(
467             this: *mut gtk_sys::GtkCellRendererToggle,
468             _param_spec: glib_sys::gpointer,
469             f: glib_sys::gpointer,
470         ) where
471             P: IsA<CellRendererToggle>,
472         {
473             let f: &F = &*(f as *const F);
474             f(&CellRendererToggle::from_glib_borrow(this).unsafe_cast())
475         }
476         unsafe {
477             let f: Box_<F> = Box_::new(f);
478             connect_raw(
479                 self.as_ptr() as *mut _,
480                 b"notify::inconsistent\0".as_ptr() as *const _,
481                 Some(transmute(
482                     notify_inconsistent_trampoline::<Self, F> as usize,
483                 )),
484                 Box_::into_raw(f),
485             )
486         }
487     }
488 
connect_property_indicator_size_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId489     fn connect_property_indicator_size_notify<F: Fn(&Self) + 'static>(
490         &self,
491         f: F,
492     ) -> SignalHandlerId {
493         unsafe extern "C" fn notify_indicator_size_trampoline<P, F: Fn(&P) + 'static>(
494             this: *mut gtk_sys::GtkCellRendererToggle,
495             _param_spec: glib_sys::gpointer,
496             f: glib_sys::gpointer,
497         ) where
498             P: IsA<CellRendererToggle>,
499         {
500             let f: &F = &*(f as *const F);
501             f(&CellRendererToggle::from_glib_borrow(this).unsafe_cast())
502         }
503         unsafe {
504             let f: Box_<F> = Box_::new(f);
505             connect_raw(
506                 self.as_ptr() as *mut _,
507                 b"notify::indicator-size\0".as_ptr() as *const _,
508                 Some(transmute(
509                     notify_indicator_size_trampoline::<Self, F> as usize,
510                 )),
511                 Box_::into_raw(f),
512             )
513         }
514     }
515 
connect_property_radio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId516     fn connect_property_radio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
517         unsafe extern "C" fn notify_radio_trampoline<P, F: Fn(&P) + 'static>(
518             this: *mut gtk_sys::GtkCellRendererToggle,
519             _param_spec: glib_sys::gpointer,
520             f: glib_sys::gpointer,
521         ) where
522             P: IsA<CellRendererToggle>,
523         {
524             let f: &F = &*(f as *const F);
525             f(&CellRendererToggle::from_glib_borrow(this).unsafe_cast())
526         }
527         unsafe {
528             let f: Box_<F> = Box_::new(f);
529             connect_raw(
530                 self.as_ptr() as *mut _,
531                 b"notify::radio\0".as_ptr() as *const _,
532                 Some(transmute(notify_radio_trampoline::<Self, F> as usize)),
533                 Box_::into_raw(f),
534             )
535         }
536     }
537 }
538 
539 impl fmt::Display for CellRendererToggle {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result540     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
541         write!(f, "CellRendererToggle")
542     }
543 }
544