gtk/auto/
stack_sidebar.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 Align;
21use Bin;
22use Buildable;
23use Container;
24use ResizeMode;
25use Stack;
26use Widget;
27
28glib_wrapper! {
29    pub struct StackSidebar(Object<gtk_sys::GtkStackSidebar, gtk_sys::GtkStackSidebarClass, StackSidebarClass>) @extends Bin, Container, Widget, @implements Buildable;
30
31    match fn {
32        get_type => || gtk_sys::gtk_stack_sidebar_get_type(),
33    }
34}
35
36impl StackSidebar {
37    #[cfg(any(feature = "v3_16", feature = "dox"))]
38    pub fn new() -> StackSidebar {
39        assert_initialized_main_thread!();
40        unsafe { Widget::from_glib_none(gtk_sys::gtk_stack_sidebar_new()).unsafe_cast() }
41    }
42}
43
44#[cfg(any(feature = "v3_16", feature = "dox"))]
45impl Default for StackSidebar {
46    fn default() -> Self {
47        Self::new()
48    }
49}
50
51pub struct StackSidebarBuilder {
52    stack: Option<Stack>,
53    border_width: Option<u32>,
54    child: Option<Widget>,
55    resize_mode: Option<ResizeMode>,
56    app_paintable: Option<bool>,
57    can_default: Option<bool>,
58    can_focus: Option<bool>,
59    events: Option<gdk::EventMask>,
60    expand: Option<bool>,
61    #[cfg(any(feature = "v3_20", feature = "dox"))]
62    focus_on_click: Option<bool>,
63    halign: Option<Align>,
64    has_default: Option<bool>,
65    has_focus: Option<bool>,
66    has_tooltip: Option<bool>,
67    height_request: Option<i32>,
68    hexpand: Option<bool>,
69    hexpand_set: Option<bool>,
70    is_focus: Option<bool>,
71    margin: Option<i32>,
72    margin_bottom: Option<i32>,
73    margin_end: Option<i32>,
74    margin_start: Option<i32>,
75    margin_top: Option<i32>,
76    name: Option<String>,
77    no_show_all: Option<bool>,
78    opacity: Option<f64>,
79    parent: Option<Container>,
80    receives_default: Option<bool>,
81    sensitive: Option<bool>,
82    //style: /*Unknown type*/,
83    tooltip_markup: Option<String>,
84    tooltip_text: Option<String>,
85    valign: Option<Align>,
86    vexpand: Option<bool>,
87    vexpand_set: Option<bool>,
88    visible: Option<bool>,
89    width_request: Option<i32>,
90}
91
92impl StackSidebarBuilder {
93    pub fn new() -> Self {
94        Self {
95            stack: None,
96            border_width: None,
97            child: None,
98            resize_mode: None,
99            app_paintable: None,
100            can_default: None,
101            can_focus: None,
102            events: None,
103            expand: None,
104            #[cfg(any(feature = "v3_20", feature = "dox"))]
105            focus_on_click: None,
106            halign: None,
107            has_default: None,
108            has_focus: None,
109            has_tooltip: None,
110            height_request: None,
111            hexpand: None,
112            hexpand_set: None,
113            is_focus: None,
114            margin: None,
115            margin_bottom: None,
116            margin_end: None,
117            margin_start: None,
118            margin_top: None,
119            name: None,
120            no_show_all: None,
121            opacity: None,
122            parent: None,
123            receives_default: None,
124            sensitive: None,
125            tooltip_markup: None,
126            tooltip_text: None,
127            valign: None,
128            vexpand: None,
129            vexpand_set: None,
130            visible: None,
131            width_request: None,
132        }
133    }
134
135    pub fn build(self) -> StackSidebar {
136        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
137        if let Some(ref stack) = self.stack {
138            properties.push(("stack", stack));
139        }
140        if let Some(ref border_width) = self.border_width {
141            properties.push(("border-width", border_width));
142        }
143        if let Some(ref child) = self.child {
144            properties.push(("child", child));
145        }
146        if let Some(ref resize_mode) = self.resize_mode {
147            properties.push(("resize-mode", resize_mode));
148        }
149        if let Some(ref app_paintable) = self.app_paintable {
150            properties.push(("app-paintable", app_paintable));
151        }
152        if let Some(ref can_default) = self.can_default {
153            properties.push(("can-default", can_default));
154        }
155        if let Some(ref can_focus) = self.can_focus {
156            properties.push(("can-focus", can_focus));
157        }
158        if let Some(ref events) = self.events {
159            properties.push(("events", events));
160        }
161        if let Some(ref expand) = self.expand {
162            properties.push(("expand", expand));
163        }
164        #[cfg(any(feature = "v3_20", feature = "dox"))]
165        {
166            if let Some(ref focus_on_click) = self.focus_on_click {
167                properties.push(("focus-on-click", focus_on_click));
168            }
169        }
170        if let Some(ref halign) = self.halign {
171            properties.push(("halign", halign));
172        }
173        if let Some(ref has_default) = self.has_default {
174            properties.push(("has-default", has_default));
175        }
176        if let Some(ref has_focus) = self.has_focus {
177            properties.push(("has-focus", has_focus));
178        }
179        if let Some(ref has_tooltip) = self.has_tooltip {
180            properties.push(("has-tooltip", has_tooltip));
181        }
182        if let Some(ref height_request) = self.height_request {
183            properties.push(("height-request", height_request));
184        }
185        if let Some(ref hexpand) = self.hexpand {
186            properties.push(("hexpand", hexpand));
187        }
188        if let Some(ref hexpand_set) = self.hexpand_set {
189            properties.push(("hexpand-set", hexpand_set));
190        }
191        if let Some(ref is_focus) = self.is_focus {
192            properties.push(("is-focus", is_focus));
193        }
194        if let Some(ref margin) = self.margin {
195            properties.push(("margin", margin));
196        }
197        if let Some(ref margin_bottom) = self.margin_bottom {
198            properties.push(("margin-bottom", margin_bottom));
199        }
200        if let Some(ref margin_end) = self.margin_end {
201            properties.push(("margin-end", margin_end));
202        }
203        if let Some(ref margin_start) = self.margin_start {
204            properties.push(("margin-start", margin_start));
205        }
206        if let Some(ref margin_top) = self.margin_top {
207            properties.push(("margin-top", margin_top));
208        }
209        if let Some(ref name) = self.name {
210            properties.push(("name", name));
211        }
212        if let Some(ref no_show_all) = self.no_show_all {
213            properties.push(("no-show-all", no_show_all));
214        }
215        if let Some(ref opacity) = self.opacity {
216            properties.push(("opacity", opacity));
217        }
218        if let Some(ref parent) = self.parent {
219            properties.push(("parent", parent));
220        }
221        if let Some(ref receives_default) = self.receives_default {
222            properties.push(("receives-default", receives_default));
223        }
224        if let Some(ref sensitive) = self.sensitive {
225            properties.push(("sensitive", sensitive));
226        }
227        if let Some(ref tooltip_markup) = self.tooltip_markup {
228            properties.push(("tooltip-markup", tooltip_markup));
229        }
230        if let Some(ref tooltip_text) = self.tooltip_text {
231            properties.push(("tooltip-text", tooltip_text));
232        }
233        if let Some(ref valign) = self.valign {
234            properties.push(("valign", valign));
235        }
236        if let Some(ref vexpand) = self.vexpand {
237            properties.push(("vexpand", vexpand));
238        }
239        if let Some(ref vexpand_set) = self.vexpand_set {
240            properties.push(("vexpand-set", vexpand_set));
241        }
242        if let Some(ref visible) = self.visible {
243            properties.push(("visible", visible));
244        }
245        if let Some(ref width_request) = self.width_request {
246            properties.push(("width-request", width_request));
247        }
248        glib::Object::new(StackSidebar::static_type(), &properties)
249            .expect("object new")
250            .downcast()
251            .expect("downcast")
252    }
253
254    pub fn stack(mut self, stack: &Stack) -> Self {
255        self.stack = Some(stack.clone());
256        self
257    }
258
259    pub fn border_width(mut self, border_width: u32) -> Self {
260        self.border_width = Some(border_width);
261        self
262    }
263
264    pub fn child(mut self, child: &Widget) -> Self {
265        self.child = Some(child.clone());
266        self
267    }
268
269    pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
270        self.resize_mode = Some(resize_mode);
271        self
272    }
273
274    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
275        self.app_paintable = Some(app_paintable);
276        self
277    }
278
279    pub fn can_default(mut self, can_default: bool) -> Self {
280        self.can_default = Some(can_default);
281        self
282    }
283
284    pub fn can_focus(mut self, can_focus: bool) -> Self {
285        self.can_focus = Some(can_focus);
286        self
287    }
288
289    pub fn events(mut self, events: gdk::EventMask) -> Self {
290        self.events = Some(events);
291        self
292    }
293
294    pub fn expand(mut self, expand: bool) -> Self {
295        self.expand = Some(expand);
296        self
297    }
298
299    #[cfg(any(feature = "v3_20", feature = "dox"))]
300    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
301        self.focus_on_click = Some(focus_on_click);
302        self
303    }
304
305    pub fn halign(mut self, halign: Align) -> Self {
306        self.halign = Some(halign);
307        self
308    }
309
310    pub fn has_default(mut self, has_default: bool) -> Self {
311        self.has_default = Some(has_default);
312        self
313    }
314
315    pub fn has_focus(mut self, has_focus: bool) -> Self {
316        self.has_focus = Some(has_focus);
317        self
318    }
319
320    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
321        self.has_tooltip = Some(has_tooltip);
322        self
323    }
324
325    pub fn height_request(mut self, height_request: i32) -> Self {
326        self.height_request = Some(height_request);
327        self
328    }
329
330    pub fn hexpand(mut self, hexpand: bool) -> Self {
331        self.hexpand = Some(hexpand);
332        self
333    }
334
335    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
336        self.hexpand_set = Some(hexpand_set);
337        self
338    }
339
340    pub fn is_focus(mut self, is_focus: bool) -> Self {
341        self.is_focus = Some(is_focus);
342        self
343    }
344
345    pub fn margin(mut self, margin: i32) -> Self {
346        self.margin = Some(margin);
347        self
348    }
349
350    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
351        self.margin_bottom = Some(margin_bottom);
352        self
353    }
354
355    pub fn margin_end(mut self, margin_end: i32) -> Self {
356        self.margin_end = Some(margin_end);
357        self
358    }
359
360    pub fn margin_start(mut self, margin_start: i32) -> Self {
361        self.margin_start = Some(margin_start);
362        self
363    }
364
365    pub fn margin_top(mut self, margin_top: i32) -> Self {
366        self.margin_top = Some(margin_top);
367        self
368    }
369
370    pub fn name(mut self, name: &str) -> Self {
371        self.name = Some(name.to_string());
372        self
373    }
374
375    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
376        self.no_show_all = Some(no_show_all);
377        self
378    }
379
380    pub fn opacity(mut self, opacity: f64) -> Self {
381        self.opacity = Some(opacity);
382        self
383    }
384
385    pub fn parent(mut self, parent: &Container) -> Self {
386        self.parent = Some(parent.clone());
387        self
388    }
389
390    pub fn receives_default(mut self, receives_default: bool) -> Self {
391        self.receives_default = Some(receives_default);
392        self
393    }
394
395    pub fn sensitive(mut self, sensitive: bool) -> Self {
396        self.sensitive = Some(sensitive);
397        self
398    }
399
400    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
401        self.tooltip_markup = Some(tooltip_markup.to_string());
402        self
403    }
404
405    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
406        self.tooltip_text = Some(tooltip_text.to_string());
407        self
408    }
409
410    pub fn valign(mut self, valign: Align) -> Self {
411        self.valign = Some(valign);
412        self
413    }
414
415    pub fn vexpand(mut self, vexpand: bool) -> Self {
416        self.vexpand = Some(vexpand);
417        self
418    }
419
420    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
421        self.vexpand_set = Some(vexpand_set);
422        self
423    }
424
425    pub fn visible(mut self, visible: bool) -> Self {
426        self.visible = Some(visible);
427        self
428    }
429
430    pub fn width_request(mut self, width_request: i32) -> Self {
431        self.width_request = Some(width_request);
432        self
433    }
434}
435
436pub const NONE_STACK_SIDEBAR: Option<&StackSidebar> = None;
437
438pub trait StackSidebarExt: 'static {
439    #[cfg(any(feature = "v3_16", feature = "dox"))]
440    fn get_stack(&self) -> Option<Stack>;
441
442    #[cfg(any(feature = "v3_16", feature = "dox"))]
443    fn set_stack<P: IsA<Stack>>(&self, stack: &P);
444
445    fn get_property_stack(&self) -> Option<Stack>;
446
447    fn set_property_stack(&self, stack: Option<&Stack>);
448
449    fn connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
450}
451
452impl<O: IsA<StackSidebar>> StackSidebarExt for O {
453    #[cfg(any(feature = "v3_16", feature = "dox"))]
454    fn get_stack(&self) -> Option<Stack> {
455        unsafe {
456            from_glib_none(gtk_sys::gtk_stack_sidebar_get_stack(
457                self.as_ref().to_glib_none().0,
458            ))
459        }
460    }
461
462    #[cfg(any(feature = "v3_16", feature = "dox"))]
463    fn set_stack<P: IsA<Stack>>(&self, stack: &P) {
464        unsafe {
465            gtk_sys::gtk_stack_sidebar_set_stack(
466                self.as_ref().to_glib_none().0,
467                stack.as_ref().to_glib_none().0,
468            );
469        }
470    }
471
472    fn get_property_stack(&self) -> Option<Stack> {
473        unsafe {
474            let mut value = Value::from_type(<Stack as StaticType>::static_type());
475            gobject_sys::g_object_get_property(
476                self.to_glib_none().0 as *mut gobject_sys::GObject,
477                b"stack\0".as_ptr() as *const _,
478                value.to_glib_none_mut().0,
479            );
480            value.get()
481        }
482    }
483
484    fn set_property_stack(&self, stack: Option<&Stack>) {
485        unsafe {
486            gobject_sys::g_object_set_property(
487                self.to_glib_none().0 as *mut gobject_sys::GObject,
488                b"stack\0".as_ptr() as *const _,
489                Value::from(stack).to_glib_none().0,
490            );
491        }
492    }
493
494    fn connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
495        unsafe extern "C" fn notify_stack_trampoline<P, F: Fn(&P) + 'static>(
496            this: *mut gtk_sys::GtkStackSidebar,
497            _param_spec: glib_sys::gpointer,
498            f: glib_sys::gpointer,
499        ) where
500            P: IsA<StackSidebar>,
501        {
502            let f: &F = &*(f as *const F);
503            f(&StackSidebar::from_glib_borrow(this).unsafe_cast())
504        }
505        unsafe {
506            let f: Box_<F> = Box_::new(f);
507            connect_raw(
508                self.as_ptr() as *mut _,
509                b"notify::stack\0".as_ptr() as *const _,
510                Some(transmute(notify_stack_trampoline::<Self, F> as usize)),
511                Box_::into_raw(f),
512            )
513        }
514    }
515}
516
517impl fmt::Display for StackSidebar {
518    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
519        write!(f, "StackSidebar")
520    }
521}