Skip to main content

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 crate::{Align, Bin, Buildable, Container, ResizeMode, Stack, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14    /// A GtkStackSidebar enables you to quickly and easily provide a
15    /// consistent "sidebar" object for your user interface.
16    ///
17    /// In order to use a GtkStackSidebar, you simply use a GtkStack to
18    /// organize your UI flow, and add the sidebar to your sidebar area. You
19    /// can use [`StackSidebarExt::set_stack()`][crate::prelude::StackSidebarExt::set_stack()] to connect the [`StackSidebar`][crate::StackSidebar]
20    /// to the [`Stack`][crate::Stack].
21    ///
22    /// # CSS nodes
23    ///
24    /// GtkStackSidebar has a single CSS node with name stacksidebar and
25    /// style class .sidebar.
26    ///
27    /// When circumstances require it, GtkStackSidebar adds the
28    /// .needs-attention style class to the widgets representing the stack
29    /// pages.
30    ///
31    /// ## Properties
32    ///
33    ///
34    /// #### `stack`
35    ///  Readable | Writeable
36    /// <details><summary><h4>Container</h4></summary>
37    ///
38    ///
39    /// #### `border-width`
40    ///  Readable | Writeable
41    ///
42    ///
43    /// #### `child`
44    ///  Writeable
45    ///
46    ///
47    /// #### `resize-mode`
48    ///  Readable | Writeable
49    /// </details>
50    /// <details><summary><h4>Widget</h4></summary>
51    ///
52    ///
53    /// #### `app-paintable`
54    ///  Readable | Writeable
55    ///
56    ///
57    /// #### `can-default`
58    ///  Readable | Writeable
59    ///
60    ///
61    /// #### `can-focus`
62    ///  Readable | Writeable
63    ///
64    ///
65    /// #### `composite-child`
66    ///  Readable
67    ///
68    ///
69    /// #### `double-buffered`
70    ///  Whether the widget is double buffered.
71    ///
72    /// Readable | Writeable
73    ///
74    ///
75    /// #### `events`
76    ///  Readable | Writeable
77    ///
78    ///
79    /// #### `expand`
80    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
81    ///
82    /// Readable | Writeable
83    ///
84    ///
85    /// #### `focus-on-click`
86    ///  Whether the widget should grab focus when it is clicked with the mouse.
87    ///
88    /// This property is only relevant for widgets that can take focus.
89    ///
90    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
91    /// GtkComboBox) implemented this property individually.
92    ///
93    /// Readable | Writeable
94    ///
95    ///
96    /// #### `halign`
97    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
98    ///
99    /// Readable | Writeable
100    ///
101    ///
102    /// #### `has-default`
103    ///  Readable | Writeable
104    ///
105    ///
106    /// #### `has-focus`
107    ///  Readable | Writeable
108    ///
109    ///
110    /// #### `has-tooltip`
111    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
112    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
113    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
114    /// whether it will provide a tooltip or not.
115    ///
116    /// Note that setting this property to [`true`] for the first time will change
117    /// the event masks of the GdkWindows of this widget to include leave-notify
118    /// and motion-notify events. This cannot and will not be undone when the
119    /// property is set to [`false`] again.
120    ///
121    /// Readable | Writeable
122    ///
123    ///
124    /// #### `height-request`
125    ///  Readable | Writeable
126    ///
127    ///
128    /// #### `hexpand`
129    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
130    ///
131    /// Readable | Writeable
132    ///
133    ///
134    /// #### `hexpand-set`
135    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
136    ///
137    /// Readable | Writeable
138    ///
139    ///
140    /// #### `is-focus`
141    ///  Readable | Writeable
142    ///
143    ///
144    /// #### `margin`
145    ///  Sets all four sides' margin at once. If read, returns max
146    /// margin on any side.
147    ///
148    /// Readable | Writeable
149    ///
150    ///
151    /// #### `margin-bottom`
152    ///  Margin on bottom side of widget.
153    ///
154    /// This property adds margin outside of the widget's normal size
155    /// request, the margin will be added in addition to the size from
156    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
157    ///
158    /// Readable | Writeable
159    ///
160    ///
161    /// #### `margin-end`
162    ///  Margin on end of widget, horizontally. This property supports
163    /// left-to-right and right-to-left text directions.
164    ///
165    /// This property adds margin outside of the widget's normal size
166    /// request, the margin will be added in addition to the size from
167    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
168    ///
169    /// Readable | Writeable
170    ///
171    ///
172    /// #### `margin-left`
173    ///  Margin on left side of widget.
174    ///
175    /// This property adds margin outside of the widget's normal size
176    /// request, the margin will be added in addition to the size from
177    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
178    ///
179    /// Readable | Writeable
180    ///
181    ///
182    /// #### `margin-right`
183    ///  Margin on right side of widget.
184    ///
185    /// This property adds margin outside of the widget's normal size
186    /// request, the margin will be added in addition to the size from
187    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
188    ///
189    /// Readable | Writeable
190    ///
191    ///
192    /// #### `margin-start`
193    ///  Margin on start of widget, horizontally. This property supports
194    /// left-to-right and right-to-left text directions.
195    ///
196    /// This property adds margin outside of the widget's normal size
197    /// request, the margin will be added in addition to the size from
198    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
199    ///
200    /// Readable | Writeable
201    ///
202    ///
203    /// #### `margin-top`
204    ///  Margin on top side of widget.
205    ///
206    /// This property adds margin outside of the widget's normal size
207    /// request, the margin will be added in addition to the size from
208    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
209    ///
210    /// Readable | Writeable
211    ///
212    ///
213    /// #### `name`
214    ///  Readable | Writeable
215    ///
216    ///
217    /// #### `no-show-all`
218    ///  Readable | Writeable
219    ///
220    ///
221    /// #### `opacity`
222    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
223    /// more details about window opacity.
224    ///
225    /// Before 3.8 this was only available in GtkWindow
226    ///
227    /// Readable | Writeable
228    ///
229    ///
230    /// #### `parent`
231    ///  Readable | Writeable
232    ///
233    ///
234    /// #### `receives-default`
235    ///  Readable | Writeable
236    ///
237    ///
238    /// #### `scale-factor`
239    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
240    /// more details about widget scaling.
241    ///
242    /// Readable
243    ///
244    ///
245    /// #### `sensitive`
246    ///  Readable | Writeable
247    ///
248    ///
249    /// #### `style`
250    ///  The style of the widget, which contains information about how it will look (colors, etc).
251    ///
252    /// Readable | Writeable
253    ///
254    ///
255    /// #### `tooltip-markup`
256    ///  Sets the text of tooltip to be the given string, which is marked up
257    /// with the [Pango text markup language][PangoMarkupFormat].
258    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
259    ///
260    /// This is a convenience property which will take care of getting the
261    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
262    /// will automatically be set to [`true`] and there will be taken care of
263    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
264    ///
265    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
266    /// are set, the last one wins.
267    ///
268    /// Readable | Writeable
269    ///
270    ///
271    /// #### `tooltip-text`
272    ///  Sets the text of tooltip to be the given string.
273    ///
274    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
275    ///
276    /// This is a convenience property which will take care of getting the
277    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
278    /// will automatically be set to [`true`] and there will be taken care of
279    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
280    ///
281    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
282    /// are set, the last one wins.
283    ///
284    /// Readable | Writeable
285    ///
286    ///
287    /// #### `valign`
288    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
289    ///
290    /// Readable | Writeable
291    ///
292    ///
293    /// #### `vexpand`
294    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
295    ///
296    /// Readable | Writeable
297    ///
298    ///
299    /// #### `vexpand-set`
300    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
301    ///
302    /// Readable | Writeable
303    ///
304    ///
305    /// #### `visible`
306    ///  Readable | Writeable
307    ///
308    ///
309    /// #### `width-request`
310    ///  Readable | Writeable
311    ///
312    ///
313    /// #### `window`
314    ///  The widget's window if it is realized, [`None`] otherwise.
315    ///
316    /// Readable
317    /// </details>
318    ///
319    /// # Implements
320    ///
321    /// [`StackSidebarExt`][trait@crate::prelude::StackSidebarExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
322    #[doc(alias = "GtkStackSidebar")]
323    pub struct StackSidebar(Object<ffi::GtkStackSidebar, ffi::GtkStackSidebarClass>) @extends Bin, Container, Widget, @implements Buildable;
324
325    match fn {
326        type_ => || ffi::gtk_stack_sidebar_get_type(),
327    }
328}
329
330impl StackSidebar {
331    pub const NONE: Option<&'static StackSidebar> = None;
332
333    /// Creates a new sidebar.
334    ///
335    /// # Returns
336    ///
337    /// the new [`StackSidebar`][crate::StackSidebar]
338    #[doc(alias = "gtk_stack_sidebar_new")]
339    pub fn new() -> StackSidebar {
340        assert_initialized_main_thread!();
341        unsafe { Widget::from_glib_none(ffi::gtk_stack_sidebar_new()).unsafe_cast() }
342    }
343
344    // rustdoc-stripper-ignore-next
345    /// Creates a new builder-pattern struct instance to construct [`StackSidebar`] objects.
346    ///
347    /// This method returns an instance of [`StackSidebarBuilder`](crate::builders::StackSidebarBuilder) which can be used to create [`StackSidebar`] objects.
348    pub fn builder() -> StackSidebarBuilder {
349        StackSidebarBuilder::new()
350    }
351}
352
353impl Default for StackSidebar {
354    fn default() -> Self {
355        Self::new()
356    }
357}
358
359// rustdoc-stripper-ignore-next
360/// A [builder-pattern] type to construct [`StackSidebar`] objects.
361///
362/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
363#[must_use = "The builder must be built to be used"]
364pub struct StackSidebarBuilder {
365    builder: glib::object::ObjectBuilder<'static, StackSidebar>,
366}
367
368impl StackSidebarBuilder {
369    fn new() -> Self {
370        Self {
371            builder: glib::object::Object::builder(),
372        }
373    }
374
375    pub fn stack(self, stack: &impl IsA<Stack>) -> Self {
376        Self {
377            builder: self.builder.property("stack", stack.clone().upcast()),
378        }
379    }
380
381    pub fn border_width(self, border_width: u32) -> Self {
382        Self {
383            builder: self.builder.property("border-width", border_width),
384        }
385    }
386
387    pub fn child(self, child: &impl IsA<Widget>) -> Self {
388        Self {
389            builder: self.builder.property("child", child.clone().upcast()),
390        }
391    }
392
393    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
394        Self {
395            builder: self.builder.property("resize-mode", resize_mode),
396        }
397    }
398
399    pub fn app_paintable(self, app_paintable: bool) -> Self {
400        Self {
401            builder: self.builder.property("app-paintable", app_paintable),
402        }
403    }
404
405    pub fn can_default(self, can_default: bool) -> Self {
406        Self {
407            builder: self.builder.property("can-default", can_default),
408        }
409    }
410
411    pub fn can_focus(self, can_focus: bool) -> Self {
412        Self {
413            builder: self.builder.property("can-focus", can_focus),
414        }
415    }
416
417    pub fn events(self, events: gdk::EventMask) -> Self {
418        Self {
419            builder: self.builder.property("events", events),
420        }
421    }
422
423    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
424    pub fn expand(self, expand: bool) -> Self {
425        Self {
426            builder: self.builder.property("expand", expand),
427        }
428    }
429
430    /// Whether the widget should grab focus when it is clicked with the mouse.
431    ///
432    /// This property is only relevant for widgets that can take focus.
433    ///
434    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
435    /// GtkComboBox) implemented this property individually.
436    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
437        Self {
438            builder: self.builder.property("focus-on-click", focus_on_click),
439        }
440    }
441
442    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
443    pub fn halign(self, halign: Align) -> Self {
444        Self {
445            builder: self.builder.property("halign", halign),
446        }
447    }
448
449    pub fn has_default(self, has_default: bool) -> Self {
450        Self {
451            builder: self.builder.property("has-default", has_default),
452        }
453    }
454
455    pub fn has_focus(self, has_focus: bool) -> Self {
456        Self {
457            builder: self.builder.property("has-focus", has_focus),
458        }
459    }
460
461    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
462    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
463    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
464    /// whether it will provide a tooltip or not.
465    ///
466    /// Note that setting this property to [`true`] for the first time will change
467    /// the event masks of the GdkWindows of this widget to include leave-notify
468    /// and motion-notify events. This cannot and will not be undone when the
469    /// property is set to [`false`] again.
470    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
471        Self {
472            builder: self.builder.property("has-tooltip", has_tooltip),
473        }
474    }
475
476    pub fn height_request(self, height_request: i32) -> Self {
477        Self {
478            builder: self.builder.property("height-request", height_request),
479        }
480    }
481
482    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
483    pub fn hexpand(self, hexpand: bool) -> Self {
484        Self {
485            builder: self.builder.property("hexpand", hexpand),
486        }
487    }
488
489    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
490    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
491        Self {
492            builder: self.builder.property("hexpand-set", hexpand_set),
493        }
494    }
495
496    pub fn is_focus(self, is_focus: bool) -> Self {
497        Self {
498            builder: self.builder.property("is-focus", is_focus),
499        }
500    }
501
502    /// Sets all four sides' margin at once. If read, returns max
503    /// margin on any side.
504    pub fn margin(self, margin: i32) -> Self {
505        Self {
506            builder: self.builder.property("margin", margin),
507        }
508    }
509
510    /// Margin on bottom side of widget.
511    ///
512    /// This property adds margin outside of the widget's normal size
513    /// request, the margin will be added in addition to the size from
514    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
515    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
516        Self {
517            builder: self.builder.property("margin-bottom", margin_bottom),
518        }
519    }
520
521    /// Margin on end of widget, horizontally. This property supports
522    /// left-to-right and right-to-left text directions.
523    ///
524    /// This property adds margin outside of the widget's normal size
525    /// request, the margin will be added in addition to the size from
526    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
527    pub fn margin_end(self, margin_end: i32) -> Self {
528        Self {
529            builder: self.builder.property("margin-end", margin_end),
530        }
531    }
532
533    /// Margin on start of widget, horizontally. This property supports
534    /// left-to-right and right-to-left text directions.
535    ///
536    /// This property adds margin outside of the widget's normal size
537    /// request, the margin will be added in addition to the size from
538    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
539    pub fn margin_start(self, margin_start: i32) -> Self {
540        Self {
541            builder: self.builder.property("margin-start", margin_start),
542        }
543    }
544
545    /// Margin on top side of widget.
546    ///
547    /// This property adds margin outside of the widget's normal size
548    /// request, the margin will be added in addition to the size from
549    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
550    pub fn margin_top(self, margin_top: i32) -> Self {
551        Self {
552            builder: self.builder.property("margin-top", margin_top),
553        }
554    }
555
556    pub fn name(self, name: impl Into<glib::GString>) -> Self {
557        Self {
558            builder: self.builder.property("name", name.into()),
559        }
560    }
561
562    pub fn no_show_all(self, no_show_all: bool) -> Self {
563        Self {
564            builder: self.builder.property("no-show-all", no_show_all),
565        }
566    }
567
568    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
569    /// more details about window opacity.
570    ///
571    /// Before 3.8 this was only available in GtkWindow
572    pub fn opacity(self, opacity: f64) -> Self {
573        Self {
574            builder: self.builder.property("opacity", opacity),
575        }
576    }
577
578    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
579        Self {
580            builder: self.builder.property("parent", parent.clone().upcast()),
581        }
582    }
583
584    pub fn receives_default(self, receives_default: bool) -> Self {
585        Self {
586            builder: self.builder.property("receives-default", receives_default),
587        }
588    }
589
590    pub fn sensitive(self, sensitive: bool) -> Self {
591        Self {
592            builder: self.builder.property("sensitive", sensitive),
593        }
594    }
595
596    /// Sets the text of tooltip to be the given string, which is marked up
597    /// with the [Pango text markup language][PangoMarkupFormat].
598    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
599    ///
600    /// This is a convenience property which will take care of getting the
601    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
602    /// will automatically be set to [`true`] and there will be taken care of
603    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
604    ///
605    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
606    /// are set, the last one wins.
607    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
608        Self {
609            builder: self
610                .builder
611                .property("tooltip-markup", tooltip_markup.into()),
612        }
613    }
614
615    /// Sets the text of tooltip to be the given string.
616    ///
617    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
618    ///
619    /// This is a convenience property which will take care of getting the
620    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
621    /// will automatically be set to [`true`] and there will be taken care of
622    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
623    ///
624    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
625    /// are set, the last one wins.
626    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
627        Self {
628            builder: self.builder.property("tooltip-text", tooltip_text.into()),
629        }
630    }
631
632    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
633    pub fn valign(self, valign: Align) -> Self {
634        Self {
635            builder: self.builder.property("valign", valign),
636        }
637    }
638
639    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
640    pub fn vexpand(self, vexpand: bool) -> Self {
641        Self {
642            builder: self.builder.property("vexpand", vexpand),
643        }
644    }
645
646    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
647    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
648        Self {
649            builder: self.builder.property("vexpand-set", vexpand_set),
650        }
651    }
652
653    pub fn visible(self, visible: bool) -> Self {
654        Self {
655            builder: self.builder.property("visible", visible),
656        }
657    }
658
659    pub fn width_request(self, width_request: i32) -> Self {
660        Self {
661            builder: self.builder.property("width-request", width_request),
662        }
663    }
664
665    // rustdoc-stripper-ignore-next
666    /// Build the [`StackSidebar`].
667    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
668    pub fn build(self) -> StackSidebar {
669        self.builder.build()
670    }
671}
672
673mod sealed {
674    pub trait Sealed {}
675    impl<T: super::IsA<super::StackSidebar>> Sealed for T {}
676}
677
678/// Trait containing all [`struct@StackSidebar`] methods.
679///
680/// # Implementors
681///
682/// [`StackSidebar`][struct@crate::StackSidebar]
683pub trait StackSidebarExt: IsA<StackSidebar> + sealed::Sealed + 'static {
684    /// Retrieves the stack.
685    /// See [`set_stack()`][Self::set_stack()].
686    ///
687    /// # Returns
688    ///
689    /// the associated [`Stack`][crate::Stack] or
690    ///  [`None`] if none has been set explicitly
691    #[doc(alias = "gtk_stack_sidebar_get_stack")]
692    #[doc(alias = "get_stack")]
693    fn stack(&self) -> Option<Stack> {
694        unsafe {
695            from_glib_none(ffi::gtk_stack_sidebar_get_stack(
696                self.as_ref().to_glib_none().0,
697            ))
698        }
699    }
700
701    /// Set the [`Stack`][crate::Stack] associated with this [`StackSidebar`][crate::StackSidebar].
702    ///
703    /// The sidebar widget will automatically update according to the order
704    /// (packing) and items within the given [`Stack`][crate::Stack].
705    /// ## `stack`
706    /// a [`Stack`][crate::Stack]
707    #[doc(alias = "gtk_stack_sidebar_set_stack")]
708    fn set_stack(&self, stack: &impl IsA<Stack>) {
709        unsafe {
710            ffi::gtk_stack_sidebar_set_stack(
711                self.as_ref().to_glib_none().0,
712                stack.as_ref().to_glib_none().0,
713            );
714        }
715    }
716
717    #[doc(alias = "stack")]
718    fn connect_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
719        unsafe extern "C" fn notify_stack_trampoline<P: IsA<StackSidebar>, F: Fn(&P) + 'static>(
720            this: *mut ffi::GtkStackSidebar,
721            _param_spec: glib::ffi::gpointer,
722            f: glib::ffi::gpointer,
723        ) {
724            let f: &F = &*(f as *const F);
725            f(StackSidebar::from_glib_borrow(this).unsafe_cast_ref())
726        }
727        unsafe {
728            let f: Box_<F> = Box_::new(f);
729            connect_raw(
730                self.as_ptr() as *mut _,
731                b"notify::stack\0".as_ptr() as *const _,
732                Some(transmute::<_, unsafe extern "C" fn()>(
733                    notify_stack_trampoline::<Self, F> as *const (),
734                )),
735                Box_::into_raw(f),
736            )
737        }
738    }
739}
740
741impl<O: IsA<StackSidebar>> StackSidebarExt for O {}
742
743impl fmt::Display for StackSidebar {
744    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
745        f.write_str("StackSidebar")
746    }
747}