Skip to main content

gtk4/auto/
expander.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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9    AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow, Widget, ffi,
10};
11use glib::{
12    object::ObjectType as _,
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19#[cfg(feature = "v4_10")]
20#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
21glib::wrapper! {
22    ///
23    /// ```text
24    ///
25    /// [`Expander`][crate::Expander] has a main node `expander-widget`, and subnode `box` containing
26    /// the title and child widget. The box subnode `title` contains node `expander`,
27    /// i.e. the expand/collapse arrow; then the label widget if any. The arrow of an
28    /// expander that is showing its child gets the `:checked` pseudoclass set on it.
29    ///
30    /// # Accessibility
31    ///
32    /// [`Expander`][crate::Expander] uses the [enum@Gtk.AccessibleRole.button] role.
33    ///
34    /// ## Properties
35    ///
36    ///
37    /// #### `child`
38    ///  The child widget.
39    ///
40    /// Readable | Writable
41    ///
42    ///
43    /// #### `expanded`
44    ///  Whether the expander has been opened to reveal the child.
45    ///
46    /// Readable | Writable | Construct
47    ///
48    ///
49    /// #### `label`
50    ///  The text of the expanders label.
51    ///
52    /// Readable | Writable | Construct
53    ///
54    ///
55    /// #### `label-widget`
56    ///  A widget to display instead of the usual expander label.
57    ///
58    /// Readable | Writable
59    ///
60    ///
61    /// #### `resize-toplevel`
62    ///  When this property is [`true`], the expander will resize the toplevel
63    /// widget containing the expander upon expanding and collapsing.
64    ///
65    /// Readable | Writable
66    ///
67    ///
68    /// #### `use-markup`
69    ///  Whether the text in the label is Pango markup.
70    ///
71    /// Readable | Writable | Construct
72    ///
73    ///
74    /// #### `use-underline`
75    ///  Whether an underline in the text indicates a mnemonic.
76    ///
77    /// Readable | Writable | Construct
78    /// <details><summary><h4>Widget</h4></summary>
79    ///
80    ///
81    /// #### `can-focus`
82    ///  Whether the widget or any of its descendents can accept
83    /// the input focus.
84    ///
85    /// This property is meant to be set by widget implementations,
86    /// typically in their instance init function.
87    ///
88    /// Readable | Writable
89    ///
90    ///
91    /// #### `can-target`
92    ///  Whether the widget can receive pointer events.
93    ///
94    /// Readable | Writable
95    ///
96    ///
97    /// #### `css-classes`
98    ///  A list of css classes applied to this widget.
99    ///
100    /// Readable | Writable
101    ///
102    ///
103    /// #### `css-name`
104    ///  The name of this widget in the CSS tree.
105    ///
106    /// This property is meant to be set by widget implementations,
107    /// typically in their instance init function.
108    ///
109    /// Readable | Writable | Construct Only
110    ///
111    ///
112    /// #### `cursor`
113    ///  The cursor used by @widget.
114    ///
115    /// Readable | Writable
116    ///
117    ///
118    /// #### `focus-on-click`
119    ///  Whether the widget should grab focus when it is clicked with the mouse.
120    ///
121    /// This property is only relevant for widgets that can take focus.
122    ///
123    /// Readable | Writable
124    ///
125    ///
126    /// #### `focusable`
127    ///  Whether this widget itself will accept the input focus.
128    ///
129    /// Readable | Writable
130    ///
131    ///
132    /// #### `halign`
133    ///  How to distribute horizontal space if widget gets extra space.
134    ///
135    /// Readable | Writable
136    ///
137    ///
138    /// #### `has-default`
139    ///  Whether the widget is the default widget.
140    ///
141    /// Readable
142    ///
143    ///
144    /// #### `has-focus`
145    ///  Whether the widget has the input focus.
146    ///
147    /// Readable
148    ///
149    ///
150    /// #### `has-tooltip`
151    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
152    /// signal on @widget.
153    ///
154    /// A true value indicates that @widget can have a tooltip, in this case
155    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
156    /// determine whether it will provide a tooltip or not.
157    ///
158    /// Readable | Writable
159    ///
160    ///
161    /// #### `height-request`
162    ///  Overrides for height request of the widget.
163    ///
164    /// If this is -1, the natural request will be used.
165    ///
166    /// Readable | Writable
167    ///
168    ///
169    /// #### `hexpand`
170    ///  Whether to expand horizontally.
171    ///
172    /// Readable | Writable
173    ///
174    ///
175    /// #### `hexpand-set`
176    ///  Whether to use the `hexpand` property.
177    ///
178    /// Readable | Writable
179    ///
180    ///
181    /// #### `layout-manager`
182    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
183    /// the preferred size of the widget, and allocate its children.
184    ///
185    /// This property is meant to be set by widget implementations,
186    /// typically in their instance init function.
187    ///
188    /// Readable | Writable
189    ///
190    ///
191    /// #### `limit-events`
192    ///  Makes this widget act like a modal dialog, with respect to
193    /// event delivery.
194    ///
195    /// Global event controllers will not handle events with targets
196    /// inside the widget, unless they are set up to ignore propagation
197    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
198    ///
199    /// Readable | Writable
200    ///
201    ///
202    /// #### `margin-bottom`
203    ///  Margin on bottom side of widget.
204    ///
205    /// This property adds margin outside of the widget's normal size
206    /// request, the margin will be added in addition to the size from
207    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
208    ///
209    /// Readable | Writable
210    ///
211    ///
212    /// #### `margin-end`
213    ///  Margin on end of widget, horizontally.
214    ///
215    /// This property supports left-to-right and right-to-left text
216    /// directions.
217    ///
218    /// This property adds margin outside of the widget's normal size
219    /// request, the margin will be added in addition to the size from
220    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
221    ///
222    /// Readable | Writable
223    ///
224    ///
225    /// #### `margin-start`
226    ///  Margin on start of widget, horizontally.
227    ///
228    /// This property supports left-to-right and right-to-left text
229    /// directions.
230    ///
231    /// This property adds margin outside of the widget's normal size
232    /// request, the margin will be added in addition to the size from
233    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
234    ///
235    /// Readable | Writable
236    ///
237    ///
238    /// #### `margin-top`
239    ///  Margin on top side of widget.
240    ///
241    /// This property adds margin outside of the widget's normal size
242    /// request, the margin will be added in addition to the size from
243    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
244    ///
245    /// Readable | Writable
246    ///
247    ///
248    /// #### `name`
249    ///  The name of the widget.
250    ///
251    /// Readable | Writable
252    ///
253    ///
254    /// #### `opacity`
255    ///  The requested opacity of the widget.
256    ///
257    /// Readable | Writable
258    ///
259    ///
260    /// #### `overflow`
261    ///  How content outside the widget's content area is treated.
262    ///
263    /// This property is meant to be set by widget implementations,
264    /// typically in their instance init function.
265    ///
266    /// Readable | Writable
267    ///
268    ///
269    /// #### `parent`
270    ///  The parent widget of this widget.
271    ///
272    /// Readable
273    ///
274    ///
275    /// #### `receives-default`
276    ///  Whether the widget will receive the default action when it is focused.
277    ///
278    /// Readable | Writable
279    ///
280    ///
281    /// #### `root`
282    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
283    ///
284    /// This will be `NULL` if the widget is not contained in a root widget.
285    ///
286    /// Readable
287    ///
288    ///
289    /// #### `scale-factor`
290    ///  The scale factor of the widget.
291    ///
292    /// Readable
293    ///
294    ///
295    /// #### `sensitive`
296    ///  Whether the widget responds to input.
297    ///
298    /// Readable | Writable
299    ///
300    ///
301    /// #### `tooltip-markup`
302    ///  Sets the text of tooltip to be the given string, which is marked up
303    /// with Pango markup.
304    ///
305    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
306    ///
307    /// This is a convenience property which will take care of getting the
308    /// tooltip shown if the given string is not `NULL`:
309    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
310    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
311    /// the default signal handler.
312    ///
313    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
314    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
315    ///
316    /// Readable | Writable
317    ///
318    ///
319    /// #### `tooltip-text`
320    ///  Sets the text of tooltip to be the given string.
321    ///
322    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
323    ///
324    /// This is a convenience property which will take care of getting the
325    /// tooltip shown if the given string is not `NULL`:
326    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
327    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
328    /// the default signal handler.
329    ///
330    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
331    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
332    ///
333    /// Readable | Writable
334    ///
335    ///
336    /// #### `valign`
337    ///  How to distribute vertical space if widget gets extra space.
338    ///
339    /// Readable | Writable
340    ///
341    ///
342    /// #### `vexpand`
343    ///  Whether to expand vertically.
344    ///
345    /// Readable | Writable
346    ///
347    ///
348    /// #### `vexpand-set`
349    ///  Whether to use the `vexpand` property.
350    ///
351    /// Readable | Writable
352    ///
353    ///
354    /// #### `visible`
355    ///  Whether the widget is visible.
356    ///
357    /// Readable | Writable
358    ///
359    ///
360    /// #### `width-request`
361    ///  Overrides for width request of the widget.
362    ///
363    /// If this is -1, the natural request will be used.
364    ///
365    /// Readable | Writable
366    /// </details>
367    /// <details><summary><h4>Accessible</h4></summary>
368    ///
369    ///
370    /// #### `accessible-role`
371    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
372    ///
373    /// The accessible role cannot be changed once set.
374    ///
375    /// Readable | Writable
376    /// </details>
377    ///
378    /// ## Signals
379    ///
380    ///
381    /// #### `activate`
382    ///  Activates the [`Expander`][crate::Expander].
383    ///
384    /// Action
385    /// <details><summary><h4>Widget</h4></summary>
386    ///
387    ///
388    /// #### `destroy`
389    ///  Signals that all holders of a reference to the widget should release
390    /// the reference that they hold.
391    ///
392    /// May result in finalization of the widget if all references are released.
393    ///
394    /// This signal is not suitable for saving widget state.
395    ///
396    ///
397    ///
398    ///
399    /// #### `direction-changed`
400    ///  Emitted when the text direction of a widget changes.
401    ///
402    ///
403    ///
404    ///
405    /// #### `hide`
406    ///  Emitted when @widget is hidden.
407    ///
408    ///
409    ///
410    ///
411    /// #### `keynav-failed`
412    ///  Emitted if keyboard navigation fails.
413    ///
414    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
415    ///
416    ///
417    ///
418    ///
419    /// #### `map`
420    ///  Emitted when @widget is going to be mapped.
421    ///
422    /// A widget is mapped when the widget is visible (which is controlled with
423    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
424    /// are also visible.
425    ///
426    /// The `::map` signal can be used to determine whether a widget will be drawn,
427    /// for instance it can resume an animation that was stopped during the
428    /// emission of [`unmap`][struct@crate::Widget#unmap].
429    ///
430    ///
431    ///
432    ///
433    /// #### `mnemonic-activate`
434    ///  Emitted when a widget is activated via a mnemonic.
435    ///
436    /// The default handler for this signal activates @widget if @group_cycling
437    /// is false, or just makes @widget grab focus if @group_cycling is true.
438    ///
439    ///
440    ///
441    ///
442    /// #### `move-focus`
443    ///   to move backward.
444    ///
445    /// Action
446    ///
447    ///
448    /// #### `query-tooltip`
449    ///  Emitted when the widget’s tooltip is about to be shown.
450    ///
451    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
452    /// is true and the hover timeout has expired with the cursor hovering
453    /// above @widget; or emitted when @widget got focus in keyboard mode.
454    ///
455    /// Using the given coordinates, the signal handler should determine
456    /// whether a tooltip should be shown for @widget. If this is the case
457    /// true should be returned, false otherwise. Note that if @keyboard_mode
458    /// is true, the values of @x and @y are undefined and should not be used.
459    ///
460    /// The signal handler is free to manipulate @tooltip with the therefore
461    /// destined function calls.
462    ///
463    ///
464    ///
465    ///
466    /// #### `realize`
467    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
468    ///
469    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
470    /// or the widget has been mapped (that is, it is going to be drawn).
471    ///
472    ///
473    ///
474    ///
475    /// #### `show`
476    ///  Emitted when @widget is shown.
477    ///
478    ///
479    ///
480    ///
481    /// #### `state-flags-changed`
482    ///  Emitted when the widget state changes.
483    ///
484    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
485    ///
486    ///
487    ///
488    ///
489    /// #### `unmap`
490    ///  Emitted when @widget is going to be unmapped.
491    ///
492    /// A widget is unmapped when either it or any of its parents up to the
493    /// toplevel widget have been set as hidden.
494    ///
495    /// As `::unmap` indicates that a widget will not be shown any longer,
496    /// it can be used to, for example, stop an animation on the widget.
497    ///
498    ///
499    ///
500    ///
501    /// #### `unrealize`
502    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
503    ///
504    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
505    /// or the widget has been unmapped (that is, it is going to be hidden).
506    ///
507    ///
508    /// </details>
509    ///
510    /// # Implements
511    ///
512    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
513    #[doc(alias = "GtkExpander")]
514    pub struct Expander(Object<ffi::GtkExpander>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
515
516    match fn {
517        type_ => || ffi::gtk_expander_get_type(),
518    }
519}
520
521#[cfg(not(feature = "v4_10"))]
522glib::wrapper! {
523    #[doc(alias = "GtkExpander")]
524    pub struct Expander(Object<ffi::GtkExpander>) @extends Widget, @implements Buildable, ConstraintTarget;
525
526    match fn {
527        type_ => || ffi::gtk_expander_get_type(),
528    }
529}
530
531impl Expander {
532    /// Creates a new expander using @label as the text of the label.
533    /// ## `label`
534    /// the text of the label
535    ///
536    /// # Returns
537    ///
538    /// a new [`Expander`][crate::Expander] widget.
539    #[doc(alias = "gtk_expander_new")]
540    pub fn new(label: Option<&str>) -> Expander {
541        assert_initialized_main_thread!();
542        unsafe {
543            Widget::from_glib_none(ffi::gtk_expander_new(label.to_glib_none().0)).unsafe_cast()
544        }
545    }
546
547    /// Creates a new expander using @label as the text of the label.
548    ///
549    /// If characters in @label are preceded by an underscore, they are
550    /// underlined. If you need a literal underscore character in a label,
551    /// use “__” (two underscores). The first underlined character represents
552    /// a keyboard accelerator called a mnemonic.
553    ///
554    /// Pressing Alt and that key activates the button.
555    /// ## `label`
556    /// the text of the label with an underscore
557    ///   in front of the mnemonic character
558    ///
559    /// # Returns
560    ///
561    /// a new [`Expander`][crate::Expander] widget.
562    #[doc(alias = "gtk_expander_new_with_mnemonic")]
563    #[doc(alias = "new_with_mnemonic")]
564    pub fn with_mnemonic(label: &str) -> Expander {
565        assert_initialized_main_thread!();
566        unsafe {
567            Widget::from_glib_none(ffi::gtk_expander_new_with_mnemonic(label.to_glib_none().0))
568                .unsafe_cast()
569        }
570    }
571
572    // rustdoc-stripper-ignore-next
573    /// Creates a new builder-pattern struct instance to construct [`Expander`] objects.
574    ///
575    /// This method returns an instance of [`ExpanderBuilder`](crate::builders::ExpanderBuilder) which can be used to create [`Expander`] objects.
576    pub fn builder() -> ExpanderBuilder {
577        ExpanderBuilder::new()
578    }
579
580    /// Gets the child widget of @self.
581    ///
582    /// # Returns
583    ///
584    /// the child widget of @self
585    #[doc(alias = "gtk_expander_get_child")]
586    #[doc(alias = "get_child")]
587    pub fn child(&self) -> Option<Widget> {
588        unsafe { from_glib_none(ffi::gtk_expander_get_child(self.to_glib_none().0)) }
589    }
590
591    /// Queries a [`Expander`][crate::Expander] and returns its current state.
592    ///
593    /// Returns [`true`] if the child widget is revealed.
594    ///
595    /// # Returns
596    ///
597    /// the current state of the expander
598    #[doc(alias = "gtk_expander_get_expanded")]
599    #[doc(alias = "get_expanded")]
600    #[doc(alias = "expanded")]
601    pub fn is_expanded(&self) -> bool {
602        unsafe { from_glib(ffi::gtk_expander_get_expanded(self.to_glib_none().0)) }
603    }
604
605    /// Fetches the text from a label widget.
606    ///
607    /// This is including any embedded underlines indicating mnemonics and
608    /// Pango markup, as set by [`set_label()`][Self::set_label()]. If the label
609    /// text has not been set the return value will be [`None`]. This will be the
610    /// case if you create an empty button with gtk_button_new() to use as a
611    /// container.
612    ///
613    /// # Returns
614    ///
615    /// The text of the label widget. This string is owned
616    ///   by the widget and must not be modified or freed.
617    #[doc(alias = "gtk_expander_get_label")]
618    #[doc(alias = "get_label")]
619    pub fn label(&self) -> Option<glib::GString> {
620        unsafe { from_glib_none(ffi::gtk_expander_get_label(self.to_glib_none().0)) }
621    }
622
623    /// Retrieves the label widget for the frame.
624    ///
625    /// # Returns
626    ///
627    /// the label widget
628    #[doc(alias = "gtk_expander_get_label_widget")]
629    #[doc(alias = "get_label_widget")]
630    #[doc(alias = "label-widget")]
631    pub fn label_widget(&self) -> Option<Widget> {
632        unsafe { from_glib_none(ffi::gtk_expander_get_label_widget(self.to_glib_none().0)) }
633    }
634
635    /// Returns whether the expander will resize the toplevel widget
636    /// containing the expander upon resizing and collapsing.
637    ///
638    /// # Returns
639    ///
640    /// the “resize toplevel” setting.
641    #[doc(alias = "gtk_expander_get_resize_toplevel")]
642    #[doc(alias = "get_resize_toplevel")]
643    #[doc(alias = "resize-toplevel")]
644    pub fn resizes_toplevel(&self) -> bool {
645        unsafe { from_glib(ffi::gtk_expander_get_resize_toplevel(self.to_glib_none().0)) }
646    }
647
648    /// Returns whether the label’s text is interpreted as Pango markup.
649    ///
650    /// # Returns
651    ///
652    /// [`true`] if the label’s text will be parsed for markup
653    #[doc(alias = "gtk_expander_get_use_markup")]
654    #[doc(alias = "get_use_markup")]
655    #[doc(alias = "use-markup")]
656    pub fn uses_markup(&self) -> bool {
657        unsafe { from_glib(ffi::gtk_expander_get_use_markup(self.to_glib_none().0)) }
658    }
659
660    /// Returns whether an underline in the text indicates a mnemonic.
661    ///
662    /// # Returns
663    ///
664    /// [`true`] if an embedded underline in the expander
665    ///   label indicates the mnemonic accelerator keys
666    #[doc(alias = "gtk_expander_get_use_underline")]
667    #[doc(alias = "get_use_underline")]
668    #[doc(alias = "use-underline")]
669    pub fn uses_underline(&self) -> bool {
670        unsafe { from_glib(ffi::gtk_expander_get_use_underline(self.to_glib_none().0)) }
671    }
672
673    /// Sets the child widget of @self.
674    /// ## `child`
675    /// the child widget
676    #[doc(alias = "gtk_expander_set_child")]
677    #[doc(alias = "child")]
678    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
679        unsafe {
680            ffi::gtk_expander_set_child(
681                self.to_glib_none().0,
682                child.map(|p| p.as_ref()).to_glib_none().0,
683            );
684        }
685    }
686
687    /// Sets the state of the expander.
688    ///
689    /// Set to [`true`], if you want the child widget to be revealed,
690    /// and [`false`] if you want the child widget to be hidden.
691    /// ## `expanded`
692    /// whether the child widget is revealed
693    #[doc(alias = "gtk_expander_set_expanded")]
694    #[doc(alias = "expanded")]
695    pub fn set_expanded(&self, expanded: bool) {
696        unsafe {
697            ffi::gtk_expander_set_expanded(self.to_glib_none().0, expanded.into_glib());
698        }
699    }
700
701    /// Sets the text of the label of the expander to @label.
702    ///
703    /// This will also clear any previously set labels.
704    /// ## `label`
705    /// a string
706    #[doc(alias = "gtk_expander_set_label")]
707    #[doc(alias = "label")]
708    pub fn set_label(&self, label: Option<&str>) {
709        unsafe {
710            ffi::gtk_expander_set_label(self.to_glib_none().0, label.to_glib_none().0);
711        }
712    }
713
714    /// Set the label widget for the expander.
715    ///
716    /// This is the widget that will appear embedded alongside
717    /// the expander arrow.
718    /// ## `label_widget`
719    /// the new label widget
720    #[doc(alias = "gtk_expander_set_label_widget")]
721    #[doc(alias = "label-widget")]
722    pub fn set_label_widget(&self, label_widget: Option<&impl IsA<Widget>>) {
723        unsafe {
724            ffi::gtk_expander_set_label_widget(
725                self.to_glib_none().0,
726                label_widget.map(|p| p.as_ref()).to_glib_none().0,
727            );
728        }
729    }
730
731    /// Sets whether the expander will resize the toplevel widget
732    /// containing the expander upon resizing and collapsing.
733    /// ## `resize_toplevel`
734    /// whether to resize the toplevel
735    #[doc(alias = "gtk_expander_set_resize_toplevel")]
736    #[doc(alias = "resize-toplevel")]
737    pub fn set_resize_toplevel(&self, resize_toplevel: bool) {
738        unsafe {
739            ffi::gtk_expander_set_resize_toplevel(
740                self.to_glib_none().0,
741                resize_toplevel.into_glib(),
742            );
743        }
744    }
745
746    /// Sets whether the text of the label contains Pango markup.
747    /// ## `use_markup`
748    /// [`true`] if the label’s text should be parsed for markup
749    #[doc(alias = "gtk_expander_set_use_markup")]
750    #[doc(alias = "use-markup")]
751    pub fn set_use_markup(&self, use_markup: bool) {
752        unsafe {
753            ffi::gtk_expander_set_use_markup(self.to_glib_none().0, use_markup.into_glib());
754        }
755    }
756
757    /// If true, an underline in the text indicates a mnemonic.
758    /// ## `use_underline`
759    /// [`true`] if underlines in the text indicate mnemonics
760    #[doc(alias = "gtk_expander_set_use_underline")]
761    #[doc(alias = "use-underline")]
762    pub fn set_use_underline(&self, use_underline: bool) {
763        unsafe {
764            ffi::gtk_expander_set_use_underline(self.to_glib_none().0, use_underline.into_glib());
765        }
766    }
767
768    /// Activates the [`Expander`][crate::Expander].
769    #[doc(alias = "activate")]
770    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
771        unsafe extern "C" fn activate_trampoline<F: Fn(&Expander) + 'static>(
772            this: *mut ffi::GtkExpander,
773            f: glib::ffi::gpointer,
774        ) {
775            unsafe {
776                let f: &F = &*(f as *const F);
777                f(&from_glib_borrow(this))
778            }
779        }
780        unsafe {
781            let f: Box_<F> = Box_::new(f);
782            connect_raw(
783                self.as_ptr() as *mut _,
784                c"activate".as_ptr(),
785                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
786                    activate_trampoline::<F> as *const (),
787                )),
788                Box_::into_raw(f),
789            )
790        }
791    }
792
793    pub fn emit_activate(&self) {
794        self.emit_by_name::<()>("activate", &[]);
795    }
796
797    #[doc(alias = "child")]
798    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
799        unsafe extern "C" fn notify_child_trampoline<F: Fn(&Expander) + 'static>(
800            this: *mut ffi::GtkExpander,
801            _param_spec: glib::ffi::gpointer,
802            f: glib::ffi::gpointer,
803        ) {
804            unsafe {
805                let f: &F = &*(f as *const F);
806                f(&from_glib_borrow(this))
807            }
808        }
809        unsafe {
810            let f: Box_<F> = Box_::new(f);
811            connect_raw(
812                self.as_ptr() as *mut _,
813                c"notify::child".as_ptr(),
814                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
815                    notify_child_trampoline::<F> as *const (),
816                )),
817                Box_::into_raw(f),
818            )
819        }
820    }
821
822    #[doc(alias = "expanded")]
823    pub fn connect_expanded_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
824        unsafe extern "C" fn notify_expanded_trampoline<F: Fn(&Expander) + 'static>(
825            this: *mut ffi::GtkExpander,
826            _param_spec: glib::ffi::gpointer,
827            f: glib::ffi::gpointer,
828        ) {
829            unsafe {
830                let f: &F = &*(f as *const F);
831                f(&from_glib_borrow(this))
832            }
833        }
834        unsafe {
835            let f: Box_<F> = Box_::new(f);
836            connect_raw(
837                self.as_ptr() as *mut _,
838                c"notify::expanded".as_ptr(),
839                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
840                    notify_expanded_trampoline::<F> as *const (),
841                )),
842                Box_::into_raw(f),
843            )
844        }
845    }
846
847    #[doc(alias = "label")]
848    pub fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
849        unsafe extern "C" fn notify_label_trampoline<F: Fn(&Expander) + 'static>(
850            this: *mut ffi::GtkExpander,
851            _param_spec: glib::ffi::gpointer,
852            f: glib::ffi::gpointer,
853        ) {
854            unsafe {
855                let f: &F = &*(f as *const F);
856                f(&from_glib_borrow(this))
857            }
858        }
859        unsafe {
860            let f: Box_<F> = Box_::new(f);
861            connect_raw(
862                self.as_ptr() as *mut _,
863                c"notify::label".as_ptr(),
864                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
865                    notify_label_trampoline::<F> as *const (),
866                )),
867                Box_::into_raw(f),
868            )
869        }
870    }
871
872    #[doc(alias = "label-widget")]
873    pub fn connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
874        unsafe extern "C" fn notify_label_widget_trampoline<F: Fn(&Expander) + 'static>(
875            this: *mut ffi::GtkExpander,
876            _param_spec: glib::ffi::gpointer,
877            f: glib::ffi::gpointer,
878        ) {
879            unsafe {
880                let f: &F = &*(f as *const F);
881                f(&from_glib_borrow(this))
882            }
883        }
884        unsafe {
885            let f: Box_<F> = Box_::new(f);
886            connect_raw(
887                self.as_ptr() as *mut _,
888                c"notify::label-widget".as_ptr(),
889                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
890                    notify_label_widget_trampoline::<F> as *const (),
891                )),
892                Box_::into_raw(f),
893            )
894        }
895    }
896
897    #[doc(alias = "resize-toplevel")]
898    pub fn connect_resize_toplevel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
899        unsafe extern "C" fn notify_resize_toplevel_trampoline<F: Fn(&Expander) + 'static>(
900            this: *mut ffi::GtkExpander,
901            _param_spec: glib::ffi::gpointer,
902            f: glib::ffi::gpointer,
903        ) {
904            unsafe {
905                let f: &F = &*(f as *const F);
906                f(&from_glib_borrow(this))
907            }
908        }
909        unsafe {
910            let f: Box_<F> = Box_::new(f);
911            connect_raw(
912                self.as_ptr() as *mut _,
913                c"notify::resize-toplevel".as_ptr(),
914                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
915                    notify_resize_toplevel_trampoline::<F> as *const (),
916                )),
917                Box_::into_raw(f),
918            )
919        }
920    }
921
922    #[doc(alias = "use-markup")]
923    pub fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
924        unsafe extern "C" fn notify_use_markup_trampoline<F: Fn(&Expander) + 'static>(
925            this: *mut ffi::GtkExpander,
926            _param_spec: glib::ffi::gpointer,
927            f: glib::ffi::gpointer,
928        ) {
929            unsafe {
930                let f: &F = &*(f as *const F);
931                f(&from_glib_borrow(this))
932            }
933        }
934        unsafe {
935            let f: Box_<F> = Box_::new(f);
936            connect_raw(
937                self.as_ptr() as *mut _,
938                c"notify::use-markup".as_ptr(),
939                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
940                    notify_use_markup_trampoline::<F> as *const (),
941                )),
942                Box_::into_raw(f),
943            )
944        }
945    }
946
947    #[doc(alias = "use-underline")]
948    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
949        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&Expander) + 'static>(
950            this: *mut ffi::GtkExpander,
951            _param_spec: glib::ffi::gpointer,
952            f: glib::ffi::gpointer,
953        ) {
954            unsafe {
955                let f: &F = &*(f as *const F);
956                f(&from_glib_borrow(this))
957            }
958        }
959        unsafe {
960            let f: Box_<F> = Box_::new(f);
961            connect_raw(
962                self.as_ptr() as *mut _,
963                c"notify::use-underline".as_ptr(),
964                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
965                    notify_use_underline_trampoline::<F> as *const (),
966                )),
967                Box_::into_raw(f),
968            )
969        }
970    }
971}
972
973impl Default for Expander {
974    fn default() -> Self {
975        glib::object::Object::new::<Self>()
976    }
977}
978
979// rustdoc-stripper-ignore-next
980/// A [builder-pattern] type to construct [`Expander`] objects.
981///
982/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
983#[must_use = "The builder must be built to be used"]
984pub struct ExpanderBuilder {
985    builder: glib::object::ObjectBuilder<'static, Expander>,
986}
987
988impl ExpanderBuilder {
989    fn new() -> Self {
990        Self {
991            builder: glib::object::Object::builder(),
992        }
993    }
994
995    /// The child widget.
996    pub fn child(self, child: &impl IsA<Widget>) -> Self {
997        Self {
998            builder: self.builder.property("child", child.clone().upcast()),
999        }
1000    }
1001
1002    /// Whether the expander has been opened to reveal the child.
1003    pub fn expanded(self, expanded: bool) -> Self {
1004        Self {
1005            builder: self.builder.property("expanded", expanded),
1006        }
1007    }
1008
1009    /// The text of the expanders label.
1010    pub fn label(self, label: impl Into<glib::GString>) -> Self {
1011        Self {
1012            builder: self.builder.property("label", label.into()),
1013        }
1014    }
1015
1016    /// A widget to display instead of the usual expander label.
1017    pub fn label_widget(self, label_widget: &impl IsA<Widget>) -> Self {
1018        Self {
1019            builder: self
1020                .builder
1021                .property("label-widget", label_widget.clone().upcast()),
1022        }
1023    }
1024
1025    /// When this property is [`true`], the expander will resize the toplevel
1026    /// widget containing the expander upon expanding and collapsing.
1027    pub fn resize_toplevel(self, resize_toplevel: bool) -> Self {
1028        Self {
1029            builder: self.builder.property("resize-toplevel", resize_toplevel),
1030        }
1031    }
1032
1033    /// Whether the text in the label is Pango markup.
1034    pub fn use_markup(self, use_markup: bool) -> Self {
1035        Self {
1036            builder: self.builder.property("use-markup", use_markup),
1037        }
1038    }
1039
1040    /// Whether an underline in the text indicates a mnemonic.
1041    pub fn use_underline(self, use_underline: bool) -> Self {
1042        Self {
1043            builder: self.builder.property("use-underline", use_underline),
1044        }
1045    }
1046
1047    /// Whether the widget or any of its descendents can accept
1048    /// the input focus.
1049    ///
1050    /// This property is meant to be set by widget implementations,
1051    /// typically in their instance init function.
1052    pub fn can_focus(self, can_focus: bool) -> Self {
1053        Self {
1054            builder: self.builder.property("can-focus", can_focus),
1055        }
1056    }
1057
1058    /// Whether the widget can receive pointer events.
1059    pub fn can_target(self, can_target: bool) -> Self {
1060        Self {
1061            builder: self.builder.property("can-target", can_target),
1062        }
1063    }
1064
1065    /// A list of css classes applied to this widget.
1066    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1067        Self {
1068            builder: self.builder.property("css-classes", css_classes.into()),
1069        }
1070    }
1071
1072    /// The name of this widget in the CSS tree.
1073    ///
1074    /// This property is meant to be set by widget implementations,
1075    /// typically in their instance init function.
1076    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1077        Self {
1078            builder: self.builder.property("css-name", css_name.into()),
1079        }
1080    }
1081
1082    /// The cursor used by @widget.
1083    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1084        Self {
1085            builder: self.builder.property("cursor", cursor.clone()),
1086        }
1087    }
1088
1089    /// Whether the widget should grab focus when it is clicked with the mouse.
1090    ///
1091    /// This property is only relevant for widgets that can take focus.
1092    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1093        Self {
1094            builder: self.builder.property("focus-on-click", focus_on_click),
1095        }
1096    }
1097
1098    /// Whether this widget itself will accept the input focus.
1099    pub fn focusable(self, focusable: bool) -> Self {
1100        Self {
1101            builder: self.builder.property("focusable", focusable),
1102        }
1103    }
1104
1105    /// How to distribute horizontal space if widget gets extra space.
1106    pub fn halign(self, halign: Align) -> Self {
1107        Self {
1108            builder: self.builder.property("halign", halign),
1109        }
1110    }
1111
1112    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1113    /// signal on @widget.
1114    ///
1115    /// A true value indicates that @widget can have a tooltip, in this case
1116    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1117    /// determine whether it will provide a tooltip or not.
1118    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1119        Self {
1120            builder: self.builder.property("has-tooltip", has_tooltip),
1121        }
1122    }
1123
1124    /// Overrides for height request of the widget.
1125    ///
1126    /// If this is -1, the natural request will be used.
1127    pub fn height_request(self, height_request: i32) -> Self {
1128        Self {
1129            builder: self.builder.property("height-request", height_request),
1130        }
1131    }
1132
1133    /// Whether to expand horizontally.
1134    pub fn hexpand(self, hexpand: bool) -> Self {
1135        Self {
1136            builder: self.builder.property("hexpand", hexpand),
1137        }
1138    }
1139
1140    /// Whether to use the `hexpand` property.
1141    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1142        Self {
1143            builder: self.builder.property("hexpand-set", hexpand_set),
1144        }
1145    }
1146
1147    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1148    /// the preferred size of the widget, and allocate its children.
1149    ///
1150    /// This property is meant to be set by widget implementations,
1151    /// typically in their instance init function.
1152    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1153        Self {
1154            builder: self
1155                .builder
1156                .property("layout-manager", layout_manager.clone().upcast()),
1157        }
1158    }
1159
1160    /// Makes this widget act like a modal dialog, with respect to
1161    /// event delivery.
1162    ///
1163    /// Global event controllers will not handle events with targets
1164    /// inside the widget, unless they are set up to ignore propagation
1165    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1166    #[cfg(feature = "v4_18")]
1167    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1168    pub fn limit_events(self, limit_events: bool) -> Self {
1169        Self {
1170            builder: self.builder.property("limit-events", limit_events),
1171        }
1172    }
1173
1174    /// Margin on bottom side of widget.
1175    ///
1176    /// This property adds margin outside of the widget's normal size
1177    /// request, the margin will be added in addition to the size from
1178    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1179    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1180        Self {
1181            builder: self.builder.property("margin-bottom", margin_bottom),
1182        }
1183    }
1184
1185    /// Margin on end of widget, horizontally.
1186    ///
1187    /// This property supports left-to-right and right-to-left text
1188    /// directions.
1189    ///
1190    /// This property adds margin outside of the widget's normal size
1191    /// request, the margin will be added in addition to the size from
1192    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1193    pub fn margin_end(self, margin_end: i32) -> Self {
1194        Self {
1195            builder: self.builder.property("margin-end", margin_end),
1196        }
1197    }
1198
1199    /// Margin on start of widget, horizontally.
1200    ///
1201    /// This property supports left-to-right and right-to-left text
1202    /// directions.
1203    ///
1204    /// This property adds margin outside of the widget's normal size
1205    /// request, the margin will be added in addition to the size from
1206    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1207    pub fn margin_start(self, margin_start: i32) -> Self {
1208        Self {
1209            builder: self.builder.property("margin-start", margin_start),
1210        }
1211    }
1212
1213    /// Margin on top side of widget.
1214    ///
1215    /// This property adds margin outside of the widget's normal size
1216    /// request, the margin will be added in addition to the size from
1217    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1218    pub fn margin_top(self, margin_top: i32) -> Self {
1219        Self {
1220            builder: self.builder.property("margin-top", margin_top),
1221        }
1222    }
1223
1224    /// The name of the widget.
1225    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1226        Self {
1227            builder: self.builder.property("name", name.into()),
1228        }
1229    }
1230
1231    /// The requested opacity of the widget.
1232    pub fn opacity(self, opacity: f64) -> Self {
1233        Self {
1234            builder: self.builder.property("opacity", opacity),
1235        }
1236    }
1237
1238    /// How content outside the widget's content area is treated.
1239    ///
1240    /// This property is meant to be set by widget implementations,
1241    /// typically in their instance init function.
1242    pub fn overflow(self, overflow: Overflow) -> Self {
1243        Self {
1244            builder: self.builder.property("overflow", overflow),
1245        }
1246    }
1247
1248    /// Whether the widget will receive the default action when it is focused.
1249    pub fn receives_default(self, receives_default: bool) -> Self {
1250        Self {
1251            builder: self.builder.property("receives-default", receives_default),
1252        }
1253    }
1254
1255    /// Whether the widget responds to input.
1256    pub fn sensitive(self, sensitive: bool) -> Self {
1257        Self {
1258            builder: self.builder.property("sensitive", sensitive),
1259        }
1260    }
1261
1262    /// Sets the text of tooltip to be the given string, which is marked up
1263    /// with Pango markup.
1264    ///
1265    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1266    ///
1267    /// This is a convenience property which will take care of getting the
1268    /// tooltip shown if the given string is not `NULL`:
1269    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1270    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1271    /// the default signal handler.
1272    ///
1273    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1274    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1275    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1276        Self {
1277            builder: self
1278                .builder
1279                .property("tooltip-markup", tooltip_markup.into()),
1280        }
1281    }
1282
1283    /// Sets the text of tooltip to be the given string.
1284    ///
1285    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1286    ///
1287    /// This is a convenience property which will take care of getting the
1288    /// tooltip shown if the given string is not `NULL`:
1289    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1290    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1291    /// the default signal handler.
1292    ///
1293    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1294    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1295    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1296        Self {
1297            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1298        }
1299    }
1300
1301    /// How to distribute vertical space if widget gets extra space.
1302    pub fn valign(self, valign: Align) -> Self {
1303        Self {
1304            builder: self.builder.property("valign", valign),
1305        }
1306    }
1307
1308    /// Whether to expand vertically.
1309    pub fn vexpand(self, vexpand: bool) -> Self {
1310        Self {
1311            builder: self.builder.property("vexpand", vexpand),
1312        }
1313    }
1314
1315    /// Whether to use the `vexpand` property.
1316    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1317        Self {
1318            builder: self.builder.property("vexpand-set", vexpand_set),
1319        }
1320    }
1321
1322    /// Whether the widget is visible.
1323    pub fn visible(self, visible: bool) -> Self {
1324        Self {
1325            builder: self.builder.property("visible", visible),
1326        }
1327    }
1328
1329    /// Overrides for width request of the widget.
1330    ///
1331    /// If this is -1, the natural request will be used.
1332    pub fn width_request(self, width_request: i32) -> Self {
1333        Self {
1334            builder: self.builder.property("width-request", width_request),
1335        }
1336    }
1337
1338    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1339    ///
1340    /// The accessible role cannot be changed once set.
1341    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1342        Self {
1343            builder: self.builder.property("accessible-role", accessible_role),
1344        }
1345    }
1346
1347    // rustdoc-stripper-ignore-next
1348    /// Build the [`Expander`].
1349    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1350    pub fn build(self) -> Expander {
1351        assert_initialized_main_thread!();
1352        self.builder.build()
1353    }
1354}