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    ///  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    ///  (two underscores). The first underlined character represents
548    /// a keyboard accelerator called a mnemonic.
549    ///
550    /// Pressing Alt and that key activates the button.
551    /// ## `label`
552    /// the text of the label with an underscore
553    ///   in front of the mnemonic character
554    ///
555    /// # Returns
556    ///
557    /// a new [`Expander`][crate::Expander] widget.
558    #[doc(alias = "gtk_expander_new_with_mnemonic")]
559    #[doc(alias = "new_with_mnemonic")]
560    pub fn with_mnemonic(label: &str) -> Expander {
561        assert_initialized_main_thread!();
562        unsafe {
563            Widget::from_glib_none(ffi::gtk_expander_new_with_mnemonic(label.to_glib_none().0))
564                .unsafe_cast()
565        }
566    }
567
568    // rustdoc-stripper-ignore-next
569    /// Creates a new builder-pattern struct instance to construct [`Expander`] objects.
570    ///
571    /// This method returns an instance of [`ExpanderBuilder`](crate::builders::ExpanderBuilder) which can be used to create [`Expander`] objects.
572    pub fn builder() -> ExpanderBuilder {
573        ExpanderBuilder::new()
574    }
575
576    /// Gets the child widget of @self.
577    ///
578    /// # Returns
579    ///
580    /// the child widget of @self
581    #[doc(alias = "gtk_expander_get_child")]
582    #[doc(alias = "get_child")]
583    pub fn child(&self) -> Option<Widget> {
584        unsafe { from_glib_none(ffi::gtk_expander_get_child(self.to_glib_none().0)) }
585    }
586
587    /// Queries a [`Expander`][crate::Expander] and returns its current state.
588    ///
589    /// Returns [`true`] if the child widget is revealed.
590    ///
591    /// # Returns
592    ///
593    /// the current state of the expander
594    #[doc(alias = "gtk_expander_get_expanded")]
595    #[doc(alias = "get_expanded")]
596    #[doc(alias = "expanded")]
597    pub fn is_expanded(&self) -> bool {
598        unsafe { from_glib(ffi::gtk_expander_get_expanded(self.to_glib_none().0)) }
599    }
600
601    /// Fetches the text from a label widget.
602    ///
603    /// This is including any embedded underlines indicating mnemonics and
604    /// Pango markup, as set by [`set_label()`][Self::set_label()]. If the label
605    /// text has not been set the return value will be [`None`]. This will be the
606    /// case if you create an empty button with gtk_button_new() to use as a
607    /// container.
608    ///
609    /// # Returns
610    ///
611    /// The text of the label widget. This string is owned
612    ///   by the widget and must not be modified or freed.
613    #[doc(alias = "gtk_expander_get_label")]
614    #[doc(alias = "get_label")]
615    pub fn label(&self) -> Option<glib::GString> {
616        unsafe { from_glib_none(ffi::gtk_expander_get_label(self.to_glib_none().0)) }
617    }
618
619    /// Retrieves the label widget for the frame.
620    ///
621    /// # Returns
622    ///
623    /// the label widget
624    #[doc(alias = "gtk_expander_get_label_widget")]
625    #[doc(alias = "get_label_widget")]
626    #[doc(alias = "label-widget")]
627    pub fn label_widget(&self) -> Option<Widget> {
628        unsafe { from_glib_none(ffi::gtk_expander_get_label_widget(self.to_glib_none().0)) }
629    }
630
631    /// Returns whether the expander will resize the toplevel widget
632    /// containing the expander upon resizing and collapsing.
633    ///
634    /// # Returns
635    ///
636    ///  setting.
637    #[doc(alias = "gtk_expander_get_resize_toplevel")]
638    #[doc(alias = "get_resize_toplevel")]
639    #[doc(alias = "resize-toplevel")]
640    pub fn resizes_toplevel(&self) -> bool {
641        unsafe { from_glib(ffi::gtk_expander_get_resize_toplevel(self.to_glib_none().0)) }
642    }
643
644    /// s text is interpreted as Pango markup.
645    ///
646    /// # Returns
647    ///
648    /// s text will be parsed for markup
649    #[doc(alias = "gtk_expander_get_use_markup")]
650    #[doc(alias = "get_use_markup")]
651    #[doc(alias = "use-markup")]
652    pub fn uses_markup(&self) -> bool {
653        unsafe { from_glib(ffi::gtk_expander_get_use_markup(self.to_glib_none().0)) }
654    }
655
656    /// Returns whether an underline in the text indicates a mnemonic.
657    ///
658    /// # Returns
659    ///
660    /// [`true`] if an embedded underline in the expander
661    ///   label indicates the mnemonic accelerator keys
662    #[doc(alias = "gtk_expander_get_use_underline")]
663    #[doc(alias = "get_use_underline")]
664    #[doc(alias = "use-underline")]
665    pub fn uses_underline(&self) -> bool {
666        unsafe { from_glib(ffi::gtk_expander_get_use_underline(self.to_glib_none().0)) }
667    }
668
669    /// Sets the child widget of @self.
670    /// ## `child`
671    /// the child widget
672    #[doc(alias = "gtk_expander_set_child")]
673    #[doc(alias = "child")]
674    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
675        unsafe {
676            ffi::gtk_expander_set_child(
677                self.to_glib_none().0,
678                child.map(|p| p.as_ref()).to_glib_none().0,
679            );
680        }
681    }
682
683    /// Sets the state of the expander.
684    ///
685    /// Set to [`true`], if you want the child widget to be revealed,
686    /// and [`false`] if you want the child widget to be hidden.
687    /// ## `expanded`
688    /// whether the child widget is revealed
689    #[doc(alias = "gtk_expander_set_expanded")]
690    #[doc(alias = "expanded")]
691    pub fn set_expanded(&self, expanded: bool) {
692        unsafe {
693            ffi::gtk_expander_set_expanded(self.to_glib_none().0, expanded.into_glib());
694        }
695    }
696
697    /// Sets the text of the label of the expander to @label.
698    ///
699    /// This will also clear any previously set labels.
700    /// ## `label`
701    /// a string
702    #[doc(alias = "gtk_expander_set_label")]
703    #[doc(alias = "label")]
704    pub fn set_label(&self, label: Option<&str>) {
705        unsafe {
706            ffi::gtk_expander_set_label(self.to_glib_none().0, label.to_glib_none().0);
707        }
708    }
709
710    /// Set the label widget for the expander.
711    ///
712    /// This is the widget that will appear embedded alongside
713    /// the expander arrow.
714    /// ## `label_widget`
715    /// the new label widget
716    #[doc(alias = "gtk_expander_set_label_widget")]
717    #[doc(alias = "label-widget")]
718    pub fn set_label_widget(&self, label_widget: Option<&impl IsA<Widget>>) {
719        unsafe {
720            ffi::gtk_expander_set_label_widget(
721                self.to_glib_none().0,
722                label_widget.map(|p| p.as_ref()).to_glib_none().0,
723            );
724        }
725    }
726
727    /// Sets whether the expander will resize the toplevel widget
728    /// containing the expander upon resizing and collapsing.
729    /// ## `resize_toplevel`
730    /// whether to resize the toplevel
731    #[doc(alias = "gtk_expander_set_resize_toplevel")]
732    #[doc(alias = "resize-toplevel")]
733    pub fn set_resize_toplevel(&self, resize_toplevel: bool) {
734        unsafe {
735            ffi::gtk_expander_set_resize_toplevel(
736                self.to_glib_none().0,
737                resize_toplevel.into_glib(),
738            );
739        }
740    }
741
742    /// Sets whether the text of the label contains Pango markup.
743    /// ## `use_markup`
744    /// s text should be parsed for markup
745    #[doc(alias = "gtk_expander_set_use_markup")]
746    #[doc(alias = "use-markup")]
747    pub fn set_use_markup(&self, use_markup: bool) {
748        unsafe {
749            ffi::gtk_expander_set_use_markup(self.to_glib_none().0, use_markup.into_glib());
750        }
751    }
752
753    /// If true, an underline in the text indicates a mnemonic.
754    /// ## `use_underline`
755    /// [`true`] if underlines in the text indicate mnemonics
756    #[doc(alias = "gtk_expander_set_use_underline")]
757    #[doc(alias = "use-underline")]
758    pub fn set_use_underline(&self, use_underline: bool) {
759        unsafe {
760            ffi::gtk_expander_set_use_underline(self.to_glib_none().0, use_underline.into_glib());
761        }
762    }
763
764    /// Activates the [`Expander`][crate::Expander].
765    #[doc(alias = "activate")]
766    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
767        unsafe extern "C" fn activate_trampoline<F: Fn(&Expander) + 'static>(
768            this: *mut ffi::GtkExpander,
769            f: glib::ffi::gpointer,
770        ) {
771            unsafe {
772                let f: &F = &*(f as *const F);
773                f(&from_glib_borrow(this))
774            }
775        }
776        unsafe {
777            let f: Box_<F> = Box_::new(f);
778            connect_raw(
779                self.as_ptr() as *mut _,
780                c"activate".as_ptr(),
781                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
782                    activate_trampoline::<F> as *const (),
783                )),
784                Box_::into_raw(f),
785            )
786        }
787    }
788
789    pub fn emit_activate(&self) {
790        self.emit_by_name::<()>("activate", &[]);
791    }
792
793    #[doc(alias = "child")]
794    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
795        unsafe extern "C" fn notify_child_trampoline<F: Fn(&Expander) + 'static>(
796            this: *mut ffi::GtkExpander,
797            _param_spec: glib::ffi::gpointer,
798            f: glib::ffi::gpointer,
799        ) {
800            unsafe {
801                let f: &F = &*(f as *const F);
802                f(&from_glib_borrow(this))
803            }
804        }
805        unsafe {
806            let f: Box_<F> = Box_::new(f);
807            connect_raw(
808                self.as_ptr() as *mut _,
809                c"notify::child".as_ptr(),
810                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
811                    notify_child_trampoline::<F> as *const (),
812                )),
813                Box_::into_raw(f),
814            )
815        }
816    }
817
818    #[doc(alias = "expanded")]
819    pub fn connect_expanded_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
820        unsafe extern "C" fn notify_expanded_trampoline<F: Fn(&Expander) + 'static>(
821            this: *mut ffi::GtkExpander,
822            _param_spec: glib::ffi::gpointer,
823            f: glib::ffi::gpointer,
824        ) {
825            unsafe {
826                let f: &F = &*(f as *const F);
827                f(&from_glib_borrow(this))
828            }
829        }
830        unsafe {
831            let f: Box_<F> = Box_::new(f);
832            connect_raw(
833                self.as_ptr() as *mut _,
834                c"notify::expanded".as_ptr(),
835                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
836                    notify_expanded_trampoline::<F> as *const (),
837                )),
838                Box_::into_raw(f),
839            )
840        }
841    }
842
843    #[doc(alias = "label")]
844    pub fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
845        unsafe extern "C" fn notify_label_trampoline<F: Fn(&Expander) + 'static>(
846            this: *mut ffi::GtkExpander,
847            _param_spec: glib::ffi::gpointer,
848            f: glib::ffi::gpointer,
849        ) {
850            unsafe {
851                let f: &F = &*(f as *const F);
852                f(&from_glib_borrow(this))
853            }
854        }
855        unsafe {
856            let f: Box_<F> = Box_::new(f);
857            connect_raw(
858                self.as_ptr() as *mut _,
859                c"notify::label".as_ptr(),
860                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
861                    notify_label_trampoline::<F> as *const (),
862                )),
863                Box_::into_raw(f),
864            )
865        }
866    }
867
868    #[doc(alias = "label-widget")]
869    pub fn connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
870        unsafe extern "C" fn notify_label_widget_trampoline<F: Fn(&Expander) + 'static>(
871            this: *mut ffi::GtkExpander,
872            _param_spec: glib::ffi::gpointer,
873            f: glib::ffi::gpointer,
874        ) {
875            unsafe {
876                let f: &F = &*(f as *const F);
877                f(&from_glib_borrow(this))
878            }
879        }
880        unsafe {
881            let f: Box_<F> = Box_::new(f);
882            connect_raw(
883                self.as_ptr() as *mut _,
884                c"notify::label-widget".as_ptr(),
885                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
886                    notify_label_widget_trampoline::<F> as *const (),
887                )),
888                Box_::into_raw(f),
889            )
890        }
891    }
892
893    #[doc(alias = "resize-toplevel")]
894    pub fn connect_resize_toplevel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
895        unsafe extern "C" fn notify_resize_toplevel_trampoline<F: Fn(&Expander) + 'static>(
896            this: *mut ffi::GtkExpander,
897            _param_spec: glib::ffi::gpointer,
898            f: glib::ffi::gpointer,
899        ) {
900            unsafe {
901                let f: &F = &*(f as *const F);
902                f(&from_glib_borrow(this))
903            }
904        }
905        unsafe {
906            let f: Box_<F> = Box_::new(f);
907            connect_raw(
908                self.as_ptr() as *mut _,
909                c"notify::resize-toplevel".as_ptr(),
910                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
911                    notify_resize_toplevel_trampoline::<F> as *const (),
912                )),
913                Box_::into_raw(f),
914            )
915        }
916    }
917
918    #[doc(alias = "use-markup")]
919    pub fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
920        unsafe extern "C" fn notify_use_markup_trampoline<F: Fn(&Expander) + 'static>(
921            this: *mut ffi::GtkExpander,
922            _param_spec: glib::ffi::gpointer,
923            f: glib::ffi::gpointer,
924        ) {
925            unsafe {
926                let f: &F = &*(f as *const F);
927                f(&from_glib_borrow(this))
928            }
929        }
930        unsafe {
931            let f: Box_<F> = Box_::new(f);
932            connect_raw(
933                self.as_ptr() as *mut _,
934                c"notify::use-markup".as_ptr(),
935                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
936                    notify_use_markup_trampoline::<F> as *const (),
937                )),
938                Box_::into_raw(f),
939            )
940        }
941    }
942
943    #[doc(alias = "use-underline")]
944    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
945        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&Expander) + 'static>(
946            this: *mut ffi::GtkExpander,
947            _param_spec: glib::ffi::gpointer,
948            f: glib::ffi::gpointer,
949        ) {
950            unsafe {
951                let f: &F = &*(f as *const F);
952                f(&from_glib_borrow(this))
953            }
954        }
955        unsafe {
956            let f: Box_<F> = Box_::new(f);
957            connect_raw(
958                self.as_ptr() as *mut _,
959                c"notify::use-underline".as_ptr(),
960                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
961                    notify_use_underline_trampoline::<F> as *const (),
962                )),
963                Box_::into_raw(f),
964            )
965        }
966    }
967}
968
969impl Default for Expander {
970    fn default() -> Self {
971        glib::object::Object::new::<Self>()
972    }
973}
974
975// rustdoc-stripper-ignore-next
976/// A [builder-pattern] type to construct [`Expander`] objects.
977///
978/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
979#[must_use = "The builder must be built to be used"]
980pub struct ExpanderBuilder {
981    builder: glib::object::ObjectBuilder<'static, Expander>,
982}
983
984impl ExpanderBuilder {
985    fn new() -> Self {
986        Self {
987            builder: glib::object::Object::builder(),
988        }
989    }
990
991    /// The child widget.
992    pub fn child(self, child: &impl IsA<Widget>) -> Self {
993        Self {
994            builder: self.builder.property("child", child.clone().upcast()),
995        }
996    }
997
998    /// Whether the expander has been opened to reveal the child.
999    pub fn expanded(self, expanded: bool) -> Self {
1000        Self {
1001            builder: self.builder.property("expanded", expanded),
1002        }
1003    }
1004
1005    /// The text of the expanders label.
1006    pub fn label(self, label: impl Into<glib::GString>) -> Self {
1007        Self {
1008            builder: self.builder.property("label", label.into()),
1009        }
1010    }
1011
1012    /// A widget to display instead of the usual expander label.
1013    pub fn label_widget(self, label_widget: &impl IsA<Widget>) -> Self {
1014        Self {
1015            builder: self
1016                .builder
1017                .property("label-widget", label_widget.clone().upcast()),
1018        }
1019    }
1020
1021    /// When this property is [`true`], the expander will resize the toplevel
1022    /// widget containing the expander upon expanding and collapsing.
1023    pub fn resize_toplevel(self, resize_toplevel: bool) -> Self {
1024        Self {
1025            builder: self.builder.property("resize-toplevel", resize_toplevel),
1026        }
1027    }
1028
1029    /// Whether the text in the label is Pango markup.
1030    pub fn use_markup(self, use_markup: bool) -> Self {
1031        Self {
1032            builder: self.builder.property("use-markup", use_markup),
1033        }
1034    }
1035
1036    /// Whether an underline in the text indicates a mnemonic.
1037    pub fn use_underline(self, use_underline: bool) -> Self {
1038        Self {
1039            builder: self.builder.property("use-underline", use_underline),
1040        }
1041    }
1042
1043    /// Whether the widget or any of its descendents can accept
1044    /// the input focus.
1045    ///
1046    /// This property is meant to be set by widget implementations,
1047    /// typically in their instance init function.
1048    pub fn can_focus(self, can_focus: bool) -> Self {
1049        Self {
1050            builder: self.builder.property("can-focus", can_focus),
1051        }
1052    }
1053
1054    /// Whether the widget can receive pointer events.
1055    pub fn can_target(self, can_target: bool) -> Self {
1056        Self {
1057            builder: self.builder.property("can-target", can_target),
1058        }
1059    }
1060
1061    /// A list of css classes applied to this widget.
1062    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1063        Self {
1064            builder: self.builder.property("css-classes", css_classes.into()),
1065        }
1066    }
1067
1068    /// The name of this widget in the CSS tree.
1069    ///
1070    /// This property is meant to be set by widget implementations,
1071    /// typically in their instance init function.
1072    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1073        Self {
1074            builder: self.builder.property("css-name", css_name.into()),
1075        }
1076    }
1077
1078    /// The cursor used by @widget.
1079    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1080        Self {
1081            builder: self.builder.property("cursor", cursor.clone()),
1082        }
1083    }
1084
1085    /// Whether the widget should grab focus when it is clicked with the mouse.
1086    ///
1087    /// This property is only relevant for widgets that can take focus.
1088    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1089        Self {
1090            builder: self.builder.property("focus-on-click", focus_on_click),
1091        }
1092    }
1093
1094    /// Whether this widget itself will accept the input focus.
1095    pub fn focusable(self, focusable: bool) -> Self {
1096        Self {
1097            builder: self.builder.property("focusable", focusable),
1098        }
1099    }
1100
1101    /// How to distribute horizontal space if widget gets extra space.
1102    pub fn halign(self, halign: Align) -> Self {
1103        Self {
1104            builder: self.builder.property("halign", halign),
1105        }
1106    }
1107
1108    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1109    /// signal on @widget.
1110    ///
1111    /// A true value indicates that @widget can have a tooltip, in this case
1112    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1113    /// determine whether it will provide a tooltip or not.
1114    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1115        Self {
1116            builder: self.builder.property("has-tooltip", has_tooltip),
1117        }
1118    }
1119
1120    /// Overrides for height request of the widget.
1121    ///
1122    /// If this is -1, the natural request will be used.
1123    pub fn height_request(self, height_request: i32) -> Self {
1124        Self {
1125            builder: self.builder.property("height-request", height_request),
1126        }
1127    }
1128
1129    /// Whether to expand horizontally.
1130    pub fn hexpand(self, hexpand: bool) -> Self {
1131        Self {
1132            builder: self.builder.property("hexpand", hexpand),
1133        }
1134    }
1135
1136    /// Whether to use the `hexpand` property.
1137    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1138        Self {
1139            builder: self.builder.property("hexpand-set", hexpand_set),
1140        }
1141    }
1142
1143    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1144    /// the preferred size of the widget, and allocate its children.
1145    ///
1146    /// This property is meant to be set by widget implementations,
1147    /// typically in their instance init function.
1148    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1149        Self {
1150            builder: self
1151                .builder
1152                .property("layout-manager", layout_manager.clone().upcast()),
1153        }
1154    }
1155
1156    /// Makes this widget act like a modal dialog, with respect to
1157    /// event delivery.
1158    ///
1159    /// Global event controllers will not handle events with targets
1160    /// inside the widget, unless they are set up to ignore propagation
1161    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1162    #[cfg(feature = "v4_18")]
1163    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1164    pub fn limit_events(self, limit_events: bool) -> Self {
1165        Self {
1166            builder: self.builder.property("limit-events", limit_events),
1167        }
1168    }
1169
1170    /// Margin on bottom side of widget.
1171    ///
1172    /// This property adds margin outside of the widget's normal size
1173    /// request, the margin will be added in addition to the size from
1174    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1175    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1176        Self {
1177            builder: self.builder.property("margin-bottom", margin_bottom),
1178        }
1179    }
1180
1181    /// Margin on end of widget, horizontally.
1182    ///
1183    /// This property supports left-to-right and right-to-left text
1184    /// directions.
1185    ///
1186    /// This property adds margin outside of the widget's normal size
1187    /// request, the margin will be added in addition to the size from
1188    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1189    pub fn margin_end(self, margin_end: i32) -> Self {
1190        Self {
1191            builder: self.builder.property("margin-end", margin_end),
1192        }
1193    }
1194
1195    /// Margin on start of widget, horizontally.
1196    ///
1197    /// This property supports left-to-right and right-to-left text
1198    /// directions.
1199    ///
1200    /// This property adds margin outside of the widget's normal size
1201    /// request, the margin will be added in addition to the size from
1202    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1203    pub fn margin_start(self, margin_start: i32) -> Self {
1204        Self {
1205            builder: self.builder.property("margin-start", margin_start),
1206        }
1207    }
1208
1209    /// Margin on top side of widget.
1210    ///
1211    /// This property adds margin outside of the widget's normal size
1212    /// request, the margin will be added in addition to the size from
1213    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1214    pub fn margin_top(self, margin_top: i32) -> Self {
1215        Self {
1216            builder: self.builder.property("margin-top", margin_top),
1217        }
1218    }
1219
1220    /// The name of the widget.
1221    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1222        Self {
1223            builder: self.builder.property("name", name.into()),
1224        }
1225    }
1226
1227    /// The requested opacity of the widget.
1228    pub fn opacity(self, opacity: f64) -> Self {
1229        Self {
1230            builder: self.builder.property("opacity", opacity),
1231        }
1232    }
1233
1234    /// How content outside the widget's content area is treated.
1235    ///
1236    /// This property is meant to be set by widget implementations,
1237    /// typically in their instance init function.
1238    pub fn overflow(self, overflow: Overflow) -> Self {
1239        Self {
1240            builder: self.builder.property("overflow", overflow),
1241        }
1242    }
1243
1244    /// Whether the widget will receive the default action when it is focused.
1245    pub fn receives_default(self, receives_default: bool) -> Self {
1246        Self {
1247            builder: self.builder.property("receives-default", receives_default),
1248        }
1249    }
1250
1251    /// Whether the widget responds to input.
1252    pub fn sensitive(self, sensitive: bool) -> Self {
1253        Self {
1254            builder: self.builder.property("sensitive", sensitive),
1255        }
1256    }
1257
1258    /// Sets the text of tooltip to be the given string, which is marked up
1259    /// with Pango markup.
1260    ///
1261    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1262    ///
1263    /// This is a convenience property which will take care of getting the
1264    /// tooltip shown if the given string is not `NULL`:
1265    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1266    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1267    /// the default signal handler.
1268    ///
1269    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1270    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1271    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1272        Self {
1273            builder: self
1274                .builder
1275                .property("tooltip-markup", tooltip_markup.into()),
1276        }
1277    }
1278
1279    /// Sets the text of tooltip to be the given string.
1280    ///
1281    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1282    ///
1283    /// This is a convenience property which will take care of getting the
1284    /// tooltip shown if the given string is not `NULL`:
1285    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1286    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1287    /// the default signal handler.
1288    ///
1289    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1290    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1291    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1292        Self {
1293            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1294        }
1295    }
1296
1297    /// How to distribute vertical space if widget gets extra space.
1298    pub fn valign(self, valign: Align) -> Self {
1299        Self {
1300            builder: self.builder.property("valign", valign),
1301        }
1302    }
1303
1304    /// Whether to expand vertically.
1305    pub fn vexpand(self, vexpand: bool) -> Self {
1306        Self {
1307            builder: self.builder.property("vexpand", vexpand),
1308        }
1309    }
1310
1311    /// Whether to use the `vexpand` property.
1312    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1313        Self {
1314            builder: self.builder.property("vexpand-set", vexpand_set),
1315        }
1316    }
1317
1318    /// Whether the widget is visible.
1319    pub fn visible(self, visible: bool) -> Self {
1320        Self {
1321            builder: self.builder.property("visible", visible),
1322        }
1323    }
1324
1325    /// Overrides for width request of the widget.
1326    ///
1327    /// If this is -1, the natural request will be used.
1328    pub fn width_request(self, width_request: i32) -> Self {
1329        Self {
1330            builder: self.builder.property("width-request", width_request),
1331        }
1332    }
1333
1334    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1335    ///
1336    /// The accessible role cannot be changed once set.
1337    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1338        Self {
1339            builder: self.builder.property("accessible-role", accessible_role),
1340        }
1341    }
1342
1343    // rustdoc-stripper-ignore-next
1344    /// Build the [`Expander`].
1345    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1346    pub fn build(self) -> Expander {
1347        assert_initialized_main_thread!();
1348        self.builder.build()
1349    }
1350}