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 #[cfg(any(feature = "v3_20", feature = "dox"))]
14 use glib::Value;
15 use glib_sys;
16 #[cfg(any(feature = "v3_20", feature = "dox"))]
17 use gobject_sys;
18 use gtk_sys;
19 use std::boxed::Box as Box_;
20 use std::fmt;
21 use std::mem::transmute;
22 use Align;
23 use BaselinePosition;
24 use Box;
25 use Buildable;
26 use Container;
27 use Orientable;
28 use Orientation;
29 use ResizeMode;
30 use Stack;
31 use Widget;
32 
33 glib_wrapper! {
34     pub struct StackSwitcher(Object<gtk_sys::GtkStackSwitcher, gtk_sys::GtkStackSwitcherClass, StackSwitcherClass>) @extends Box, Container, Widget, @implements Buildable, Orientable;
35 
36     match fn {
37         get_type => || gtk_sys::gtk_stack_switcher_get_type(),
38     }
39 }
40 
41 impl StackSwitcher {
new() -> StackSwitcher42     pub fn new() -> StackSwitcher {
43         assert_initialized_main_thread!();
44         unsafe { Widget::from_glib_none(gtk_sys::gtk_stack_switcher_new()).unsafe_cast() }
45     }
46 }
47 
48 impl Default for StackSwitcher {
default() -> Self49     fn default() -> Self {
50         Self::new()
51     }
52 }
53 
54 #[derive(Clone, Default)]
55 pub struct StackSwitcherBuilder {
56     #[cfg(any(feature = "v3_20", feature = "dox"))]
57     icon_size: Option<i32>,
58     stack: Option<Stack>,
59     baseline_position: Option<BaselinePosition>,
60     homogeneous: Option<bool>,
61     spacing: Option<i32>,
62     border_width: Option<u32>,
63     child: Option<Widget>,
64     resize_mode: Option<ResizeMode>,
65     app_paintable: Option<bool>,
66     can_default: Option<bool>,
67     can_focus: Option<bool>,
68     events: Option<gdk::EventMask>,
69     expand: Option<bool>,
70     #[cfg(any(feature = "v3_20", feature = "dox"))]
71     focus_on_click: Option<bool>,
72     halign: Option<Align>,
73     has_default: Option<bool>,
74     has_focus: Option<bool>,
75     has_tooltip: Option<bool>,
76     height_request: Option<i32>,
77     hexpand: Option<bool>,
78     hexpand_set: Option<bool>,
79     is_focus: Option<bool>,
80     margin: Option<i32>,
81     margin_bottom: Option<i32>,
82     margin_end: Option<i32>,
83     margin_start: Option<i32>,
84     margin_top: Option<i32>,
85     name: Option<String>,
86     no_show_all: Option<bool>,
87     opacity: Option<f64>,
88     parent: Option<Container>,
89     receives_default: Option<bool>,
90     sensitive: Option<bool>,
91     tooltip_markup: Option<String>,
92     tooltip_text: Option<String>,
93     valign: Option<Align>,
94     vexpand: Option<bool>,
95     vexpand_set: Option<bool>,
96     visible: Option<bool>,
97     width_request: Option<i32>,
98     orientation: Option<Orientation>,
99 }
100 
101 impl StackSwitcherBuilder {
new() -> Self102     pub fn new() -> Self {
103         Self::default()
104     }
105 
build(self) -> StackSwitcher106     pub fn build(self) -> StackSwitcher {
107         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
108         #[cfg(any(feature = "v3_20", feature = "dox"))]
109         {
110             if let Some(ref icon_size) = self.icon_size {
111                 properties.push(("icon-size", icon_size));
112             }
113         }
114         if let Some(ref stack) = self.stack {
115             properties.push(("stack", stack));
116         }
117         if let Some(ref baseline_position) = self.baseline_position {
118             properties.push(("baseline-position", baseline_position));
119         }
120         if let Some(ref homogeneous) = self.homogeneous {
121             properties.push(("homogeneous", homogeneous));
122         }
123         if let Some(ref spacing) = self.spacing {
124             properties.push(("spacing", spacing));
125         }
126         if let Some(ref border_width) = self.border_width {
127             properties.push(("border-width", border_width));
128         }
129         if let Some(ref child) = self.child {
130             properties.push(("child", child));
131         }
132         if let Some(ref resize_mode) = self.resize_mode {
133             properties.push(("resize-mode", resize_mode));
134         }
135         if let Some(ref app_paintable) = self.app_paintable {
136             properties.push(("app-paintable", app_paintable));
137         }
138         if let Some(ref can_default) = self.can_default {
139             properties.push(("can-default", can_default));
140         }
141         if let Some(ref can_focus) = self.can_focus {
142             properties.push(("can-focus", can_focus));
143         }
144         if let Some(ref events) = self.events {
145             properties.push(("events", events));
146         }
147         if let Some(ref expand) = self.expand {
148             properties.push(("expand", expand));
149         }
150         #[cfg(any(feature = "v3_20", feature = "dox"))]
151         {
152             if let Some(ref focus_on_click) = self.focus_on_click {
153                 properties.push(("focus-on-click", focus_on_click));
154             }
155         }
156         if let Some(ref halign) = self.halign {
157             properties.push(("halign", halign));
158         }
159         if let Some(ref has_default) = self.has_default {
160             properties.push(("has-default", has_default));
161         }
162         if let Some(ref has_focus) = self.has_focus {
163             properties.push(("has-focus", has_focus));
164         }
165         if let Some(ref has_tooltip) = self.has_tooltip {
166             properties.push(("has-tooltip", has_tooltip));
167         }
168         if let Some(ref height_request) = self.height_request {
169             properties.push(("height-request", height_request));
170         }
171         if let Some(ref hexpand) = self.hexpand {
172             properties.push(("hexpand", hexpand));
173         }
174         if let Some(ref hexpand_set) = self.hexpand_set {
175             properties.push(("hexpand-set", hexpand_set));
176         }
177         if let Some(ref is_focus) = self.is_focus {
178             properties.push(("is-focus", is_focus));
179         }
180         if let Some(ref margin) = self.margin {
181             properties.push(("margin", margin));
182         }
183         if let Some(ref margin_bottom) = self.margin_bottom {
184             properties.push(("margin-bottom", margin_bottom));
185         }
186         if let Some(ref margin_end) = self.margin_end {
187             properties.push(("margin-end", margin_end));
188         }
189         if let Some(ref margin_start) = self.margin_start {
190             properties.push(("margin-start", margin_start));
191         }
192         if let Some(ref margin_top) = self.margin_top {
193             properties.push(("margin-top", margin_top));
194         }
195         if let Some(ref name) = self.name {
196             properties.push(("name", name));
197         }
198         if let Some(ref no_show_all) = self.no_show_all {
199             properties.push(("no-show-all", no_show_all));
200         }
201         if let Some(ref opacity) = self.opacity {
202             properties.push(("opacity", opacity));
203         }
204         if let Some(ref parent) = self.parent {
205             properties.push(("parent", parent));
206         }
207         if let Some(ref receives_default) = self.receives_default {
208             properties.push(("receives-default", receives_default));
209         }
210         if let Some(ref sensitive) = self.sensitive {
211             properties.push(("sensitive", sensitive));
212         }
213         if let Some(ref tooltip_markup) = self.tooltip_markup {
214             properties.push(("tooltip-markup", tooltip_markup));
215         }
216         if let Some(ref tooltip_text) = self.tooltip_text {
217             properties.push(("tooltip-text", tooltip_text));
218         }
219         if let Some(ref valign) = self.valign {
220             properties.push(("valign", valign));
221         }
222         if let Some(ref vexpand) = self.vexpand {
223             properties.push(("vexpand", vexpand));
224         }
225         if let Some(ref vexpand_set) = self.vexpand_set {
226             properties.push(("vexpand-set", vexpand_set));
227         }
228         if let Some(ref visible) = self.visible {
229             properties.push(("visible", visible));
230         }
231         if let Some(ref width_request) = self.width_request {
232             properties.push(("width-request", width_request));
233         }
234         if let Some(ref orientation) = self.orientation {
235             properties.push(("orientation", orientation));
236         }
237         glib::Object::new(StackSwitcher::static_type(), &properties)
238             .expect("object new")
239             .downcast()
240             .expect("downcast")
241     }
242 
243     #[cfg(any(feature = "v3_20", feature = "dox"))]
icon_size(mut self, icon_size: i32) -> Self244     pub fn icon_size(mut self, icon_size: i32) -> Self {
245         self.icon_size = Some(icon_size);
246         self
247     }
248 
stack<P: IsA<Stack>>(mut self, stack: &P) -> Self249     pub fn stack<P: IsA<Stack>>(mut self, stack: &P) -> Self {
250         self.stack = Some(stack.clone().upcast());
251         self
252     }
253 
baseline_position(mut self, baseline_position: BaselinePosition) -> Self254     pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self {
255         self.baseline_position = Some(baseline_position);
256         self
257     }
258 
homogeneous(mut self, homogeneous: bool) -> Self259     pub fn homogeneous(mut self, homogeneous: bool) -> Self {
260         self.homogeneous = Some(homogeneous);
261         self
262     }
263 
spacing(mut self, spacing: i32) -> Self264     pub fn spacing(mut self, spacing: i32) -> Self {
265         self.spacing = Some(spacing);
266         self
267     }
268 
border_width(mut self, border_width: u32) -> Self269     pub fn border_width(mut self, border_width: u32) -> Self {
270         self.border_width = Some(border_width);
271         self
272     }
273 
child<P: IsA<Widget>>(mut self, child: &P) -> Self274     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
275         self.child = Some(child.clone().upcast());
276         self
277     }
278 
resize_mode(mut self, resize_mode: ResizeMode) -> Self279     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
280         self.resize_mode = Some(resize_mode);
281         self
282     }
283 
app_paintable(mut self, app_paintable: bool) -> Self284     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
285         self.app_paintable = Some(app_paintable);
286         self
287     }
288 
can_default(mut self, can_default: bool) -> Self289     pub fn can_default(mut self, can_default: bool) -> Self {
290         self.can_default = Some(can_default);
291         self
292     }
293 
can_focus(mut self, can_focus: bool) -> Self294     pub fn can_focus(mut self, can_focus: bool) -> Self {
295         self.can_focus = Some(can_focus);
296         self
297     }
298 
events(mut self, events: gdk::EventMask) -> Self299     pub fn events(mut self, events: gdk::EventMask) -> Self {
300         self.events = Some(events);
301         self
302     }
303 
expand(mut self, expand: bool) -> Self304     pub fn expand(mut self, expand: bool) -> Self {
305         self.expand = Some(expand);
306         self
307     }
308 
309     #[cfg(any(feature = "v3_20", feature = "dox"))]
focus_on_click(mut self, focus_on_click: bool) -> Self310     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
311         self.focus_on_click = Some(focus_on_click);
312         self
313     }
314 
halign(mut self, halign: Align) -> Self315     pub fn halign(mut self, halign: Align) -> Self {
316         self.halign = Some(halign);
317         self
318     }
319 
has_default(mut self, has_default: bool) -> Self320     pub fn has_default(mut self, has_default: bool) -> Self {
321         self.has_default = Some(has_default);
322         self
323     }
324 
has_focus(mut self, has_focus: bool) -> Self325     pub fn has_focus(mut self, has_focus: bool) -> Self {
326         self.has_focus = Some(has_focus);
327         self
328     }
329 
has_tooltip(mut self, has_tooltip: bool) -> Self330     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
331         self.has_tooltip = Some(has_tooltip);
332         self
333     }
334 
height_request(mut self, height_request: i32) -> Self335     pub fn height_request(mut self, height_request: i32) -> Self {
336         self.height_request = Some(height_request);
337         self
338     }
339 
hexpand(mut self, hexpand: bool) -> Self340     pub fn hexpand(mut self, hexpand: bool) -> Self {
341         self.hexpand = Some(hexpand);
342         self
343     }
344 
hexpand_set(mut self, hexpand_set: bool) -> Self345     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
346         self.hexpand_set = Some(hexpand_set);
347         self
348     }
349 
is_focus(mut self, is_focus: bool) -> Self350     pub fn is_focus(mut self, is_focus: bool) -> Self {
351         self.is_focus = Some(is_focus);
352         self
353     }
354 
margin(mut self, margin: i32) -> Self355     pub fn margin(mut self, margin: i32) -> Self {
356         self.margin = Some(margin);
357         self
358     }
359 
margin_bottom(mut self, margin_bottom: i32) -> Self360     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
361         self.margin_bottom = Some(margin_bottom);
362         self
363     }
364 
margin_end(mut self, margin_end: i32) -> Self365     pub fn margin_end(mut self, margin_end: i32) -> Self {
366         self.margin_end = Some(margin_end);
367         self
368     }
369 
margin_start(mut self, margin_start: i32) -> Self370     pub fn margin_start(mut self, margin_start: i32) -> Self {
371         self.margin_start = Some(margin_start);
372         self
373     }
374 
margin_top(mut self, margin_top: i32) -> Self375     pub fn margin_top(mut self, margin_top: i32) -> Self {
376         self.margin_top = Some(margin_top);
377         self
378     }
379 
name(mut self, name: &str) -> Self380     pub fn name(mut self, name: &str) -> Self {
381         self.name = Some(name.to_string());
382         self
383     }
384 
no_show_all(mut self, no_show_all: bool) -> Self385     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
386         self.no_show_all = Some(no_show_all);
387         self
388     }
389 
opacity(mut self, opacity: f64) -> Self390     pub fn opacity(mut self, opacity: f64) -> Self {
391         self.opacity = Some(opacity);
392         self
393     }
394 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self395     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
396         self.parent = Some(parent.clone().upcast());
397         self
398     }
399 
receives_default(mut self, receives_default: bool) -> Self400     pub fn receives_default(mut self, receives_default: bool) -> Self {
401         self.receives_default = Some(receives_default);
402         self
403     }
404 
sensitive(mut self, sensitive: bool) -> Self405     pub fn sensitive(mut self, sensitive: bool) -> Self {
406         self.sensitive = Some(sensitive);
407         self
408     }
409 
tooltip_markup(mut self, tooltip_markup: &str) -> Self410     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
411         self.tooltip_markup = Some(tooltip_markup.to_string());
412         self
413     }
414 
tooltip_text(mut self, tooltip_text: &str) -> Self415     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
416         self.tooltip_text = Some(tooltip_text.to_string());
417         self
418     }
419 
valign(mut self, valign: Align) -> Self420     pub fn valign(mut self, valign: Align) -> Self {
421         self.valign = Some(valign);
422         self
423     }
424 
vexpand(mut self, vexpand: bool) -> Self425     pub fn vexpand(mut self, vexpand: bool) -> Self {
426         self.vexpand = Some(vexpand);
427         self
428     }
429 
vexpand_set(mut self, vexpand_set: bool) -> Self430     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
431         self.vexpand_set = Some(vexpand_set);
432         self
433     }
434 
visible(mut self, visible: bool) -> Self435     pub fn visible(mut self, visible: bool) -> Self {
436         self.visible = Some(visible);
437         self
438     }
439 
width_request(mut self, width_request: i32) -> Self440     pub fn width_request(mut self, width_request: i32) -> Self {
441         self.width_request = Some(width_request);
442         self
443     }
444 
orientation(mut self, orientation: Orientation) -> Self445     pub fn orientation(mut self, orientation: Orientation) -> Self {
446         self.orientation = Some(orientation);
447         self
448     }
449 }
450 
451 pub const NONE_STACK_SWITCHER: Option<&StackSwitcher> = None;
452 
453 pub trait StackSwitcherExt: 'static {
get_stack(&self) -> Option<Stack>454     fn get_stack(&self) -> Option<Stack>;
455 
set_stack<P: IsA<Stack>>(&self, stack: Option<&P>)456     fn set_stack<P: IsA<Stack>>(&self, stack: Option<&P>);
457 
458     #[cfg(any(feature = "v3_20", feature = "dox"))]
get_property_icon_size(&self) -> i32459     fn get_property_icon_size(&self) -> i32;
460 
461     #[cfg(any(feature = "v3_20", feature = "dox"))]
set_property_icon_size(&self, icon_size: i32)462     fn set_property_icon_size(&self, icon_size: i32);
463 
464     #[cfg(any(feature = "v3_20", feature = "dox"))]
connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId465     fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
466 
connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId467     fn connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
468 }
469 
470 impl<O: IsA<StackSwitcher>> StackSwitcherExt for O {
get_stack(&self) -> Option<Stack>471     fn get_stack(&self) -> Option<Stack> {
472         unsafe {
473             from_glib_none(gtk_sys::gtk_stack_switcher_get_stack(
474                 self.as_ref().to_glib_none().0,
475             ))
476         }
477     }
478 
set_stack<P: IsA<Stack>>(&self, stack: Option<&P>)479     fn set_stack<P: IsA<Stack>>(&self, stack: Option<&P>) {
480         unsafe {
481             gtk_sys::gtk_stack_switcher_set_stack(
482                 self.as_ref().to_glib_none().0,
483                 stack.map(|p| p.as_ref()).to_glib_none().0,
484             );
485         }
486     }
487 
488     #[cfg(any(feature = "v3_20", feature = "dox"))]
get_property_icon_size(&self) -> i32489     fn get_property_icon_size(&self) -> i32 {
490         unsafe {
491             let mut value = Value::from_type(<i32 as StaticType>::static_type());
492             gobject_sys::g_object_get_property(
493                 self.to_glib_none().0 as *mut gobject_sys::GObject,
494                 b"icon-size\0".as_ptr() as *const _,
495                 value.to_glib_none_mut().0,
496             );
497             value
498                 .get()
499                 .expect("Return Value for property `icon-size` getter")
500                 .unwrap()
501         }
502     }
503 
504     #[cfg(any(feature = "v3_20", feature = "dox"))]
set_property_icon_size(&self, icon_size: i32)505     fn set_property_icon_size(&self, icon_size: i32) {
506         unsafe {
507             gobject_sys::g_object_set_property(
508                 self.to_glib_none().0 as *mut gobject_sys::GObject,
509                 b"icon-size\0".as_ptr() as *const _,
510                 Value::from(&icon_size).to_glib_none().0,
511             );
512         }
513     }
514 
515     #[cfg(any(feature = "v3_20", feature = "dox"))]
connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId516     fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
517         unsafe extern "C" fn notify_icon_size_trampoline<P, F: Fn(&P) + 'static>(
518             this: *mut gtk_sys::GtkStackSwitcher,
519             _param_spec: glib_sys::gpointer,
520             f: glib_sys::gpointer,
521         ) where
522             P: IsA<StackSwitcher>,
523         {
524             let f: &F = &*(f as *const F);
525             f(&StackSwitcher::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::icon-size\0".as_ptr() as *const _,
532                 Some(transmute(notify_icon_size_trampoline::<Self, F> as usize)),
533                 Box_::into_raw(f),
534             )
535         }
536     }
537 
connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId538     fn connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
539         unsafe extern "C" fn notify_stack_trampoline<P, F: Fn(&P) + 'static>(
540             this: *mut gtk_sys::GtkStackSwitcher,
541             _param_spec: glib_sys::gpointer,
542             f: glib_sys::gpointer,
543         ) where
544             P: IsA<StackSwitcher>,
545         {
546             let f: &F = &*(f as *const F);
547             f(&StackSwitcher::from_glib_borrow(this).unsafe_cast())
548         }
549         unsafe {
550             let f: Box_<F> = Box_::new(f);
551             connect_raw(
552                 self.as_ptr() as *mut _,
553                 b"notify::stack\0".as_ptr() as *const _,
554                 Some(transmute(notify_stack_trampoline::<Self, F> as usize)),
555                 Box_::into_raw(f),
556             )
557         }
558     }
559 }
560 
561 impl fmt::Display for StackSwitcher {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result562     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
563         write!(f, "StackSwitcher")
564     }
565 }
566