gtk4/auto/
tree_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
5use crate::{
6    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7    TreeListRow, Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// [`TreeExpander`][crate::TreeExpander] is a widget that provides an expander for a list.
18    ///
19    /// It is typically placed as a bottommost child into a [`ListView`][crate::ListView]
20    /// to allow users to expand and collapse children in a list with a
21    /// [`TreeListModel`][crate::TreeListModel]. [`TreeExpander`][crate::TreeExpander] provides the common UI
22    /// elements, gestures and keybindings for this purpose.
23    ///
24    /// On top of this, the "listitem.expand", "listitem.collapse" and
25    /// "listitem.toggle-expand" actions are provided to allow adding custom
26    /// UI for managing expanded state.
27    ///
28    /// It is important to mention that you want to set the
29    /// [`focusable`][struct@crate::ListItem#focusable] property to FALSE when using this
30    /// widget, as you want the keyboard focus to be in the treexpander, and not
31    /// inside the list to make use of the keybindings.
32    ///
33    /// The [`TreeListModel`][crate::TreeListModel] must be set to not be passthrough. Then it
34    /// will provide [`TreeListRow`][crate::TreeListRow] items which can be set via
35    /// [`set_list_row()`][Self::set_list_row()] on the expander.
36    /// The expander will then watch that row item automatically.
37    /// [`set_child()`][Self::set_child()] sets the widget that displays
38    /// the actual row contents.
39    ///
40    /// [`TreeExpander`][crate::TreeExpander] can be modified with properties such as
41    /// [`indent-for-icon`][struct@crate::TreeExpander#indent-for-icon],
42    /// [`indent-for-depth`][struct@crate::TreeExpander#indent-for-depth], and
43    /// [`hide-expander`][struct@crate::TreeExpander#hide-expander] to achieve a different appearance.
44    /// This can even be done to influence individual rows, for example by binding
45    /// the [`hide-expander`][struct@crate::TreeExpander#hide-expander] property to the item count of
46    /// the model of the treelistrow, to hide the expander for rows without children,
47    /// even if the row is expandable.
48    ///
49    /// ## Shortcuts and Gestures
50    ///
51    /// [`TreeExpander`][crate::TreeExpander] supports the following keyboard shortcuts:
52    ///
53    /// - <kbd>+</kbd> or <kbd>*</kbd> expands the expander.
54    /// - <kbd>-</kbd> or <kbd>/</kbd> collapses the expander.
55    /// - Left and right arrow keys, when combined with <kbd>Shift</kbd> or
56    ///   <kbd>Ctrl</kbd>+<kbd>Shift</kbd>, will expand or collapse, depending on
57    ///   the locale's text direction.
58    /// - <kbd>Ctrl</kbd>+<kbd>␣</kbd> toggles the expander state.
59    ///
60    /// The row can also expand on drag gestures.
61    ///
62    /// ## Actions
63    ///
64    /// [`TreeExpander`][crate::TreeExpander] defines a set of built-in actions:
65    ///
66    /// - `listitem.expand` expands the expander if it can be expanded.
67    /// - `listitem.collapse` collapses the expander.
68    /// - `listitem.toggle-expand` tries to expand the expander if it was collapsed
69    ///   or collapses it if it was expanded.
70    ///
71    /// ## CSS nodes
72    ///
73    /// ```text
74    /// treeexpander
75    /// ├── [indent]*
76    /// ├── [expander]
77    /// ╰── <child>
78    /// ```
79    ///
80    /// [`TreeExpander`][crate::TreeExpander] has zero or one CSS nodes with the name "expander" that
81    /// should display the expander icon. The node will be `:checked` when it
82    /// is expanded. If the node is not expandable, an "indent" node will be
83    /// displayed instead.
84    ///
85    /// For every level of depth, another "indent" node is prepended.
86    ///
87    /// ## Accessibility
88    ///
89    /// Until GTK 4.10, [`TreeExpander`][crate::TreeExpander] used the `GTK_ACCESSIBLE_ROLE_GROUP` role.
90    ///
91    /// Since GTK 4.12, [`TreeExpander`][crate::TreeExpander] uses the `GTK_ACCESSIBLE_ROLE_BUTTON` role.
92    /// Toggling it will change the `GTK_ACCESSIBLE_STATE_EXPANDED` state.
93    ///
94    /// ## Properties
95    ///
96    ///
97    /// #### `child`
98    ///  The child widget with the actual contents.
99    ///
100    /// Readable | Writeable
101    ///
102    ///
103    /// #### `hide-expander`
104    ///  Whether the expander icon should be hidden in a GtkTreeListRow.
105    /// Note that this property simply hides the icon.  The actions and keybinding
106    /// (i.e. collapse and expand) are not affected by this property.
107    ///
108    /// A common use for this property would be to bind to the number of children in a
109    /// GtkTreeListRow's model in order to hide the expander when a row has no children.
110    ///
111    /// Readable | Writeable
112    ///
113    ///
114    /// #### `indent-for-depth`
115    ///  TreeExpander indents the child according to its depth.
116    ///
117    /// Readable | Writeable
118    ///
119    ///
120    /// #### `indent-for-icon`
121    ///  TreeExpander indents the child by the width of an expander-icon if it is not expandable.
122    ///
123    /// Readable | Writeable
124    ///
125    ///
126    /// #### `item`
127    ///  The item held by this expander's row.
128    ///
129    /// Readable
130    ///
131    ///
132    /// #### `list-row`
133    ///  The list row to track for expander state.
134    ///
135    /// Readable | Writeable
136    /// <details><summary><h4>Widget</h4></summary>
137    ///
138    ///
139    /// #### `can-focus`
140    ///  Whether the widget or any of its descendents can accept
141    /// the input focus.
142    ///
143    /// This property is meant to be set by widget implementations,
144    /// typically in their instance init function.
145    ///
146    /// Readable | Writeable
147    ///
148    ///
149    /// #### `can-target`
150    ///  Whether the widget can receive pointer events.
151    ///
152    /// Readable | Writeable
153    ///
154    ///
155    /// #### `css-classes`
156    ///  A list of css classes applied to this widget.
157    ///
158    /// Readable | Writeable
159    ///
160    ///
161    /// #### `css-name`
162    ///  The name of this widget in the CSS tree.
163    ///
164    /// This property is meant to be set by widget implementations,
165    /// typically in their instance init function.
166    ///
167    /// Readable | Writeable | Construct Only
168    ///
169    ///
170    /// #### `cursor`
171    ///  The cursor used by @widget.
172    ///
173    /// Readable | Writeable
174    ///
175    ///
176    /// #### `focus-on-click`
177    ///  Whether the widget should grab focus when it is clicked with the mouse.
178    ///
179    /// This property is only relevant for widgets that can take focus.
180    ///
181    /// Readable | Writeable
182    ///
183    ///
184    /// #### `focusable`
185    ///  Whether this widget itself will accept the input focus.
186    ///
187    /// Readable | Writeable
188    ///
189    ///
190    /// #### `halign`
191    ///  How to distribute horizontal space if widget gets extra space.
192    ///
193    /// Readable | Writeable
194    ///
195    ///
196    /// #### `has-default`
197    ///  Whether the widget is the default widget.
198    ///
199    /// Readable
200    ///
201    ///
202    /// #### `has-focus`
203    ///  Whether the widget has the input focus.
204    ///
205    /// Readable
206    ///
207    ///
208    /// #### `has-tooltip`
209    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
210    /// signal on @widget.
211    ///
212    /// A true value indicates that @widget can have a tooltip, in this case
213    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
214    /// determine whether it will provide a tooltip or not.
215    ///
216    /// Readable | Writeable
217    ///
218    ///
219    /// #### `height-request`
220    ///  Overrides for height request of the widget.
221    ///
222    /// If this is -1, the natural request will be used.
223    ///
224    /// Readable | Writeable
225    ///
226    ///
227    /// #### `hexpand`
228    ///  Whether to expand horizontally.
229    ///
230    /// Readable | Writeable
231    ///
232    ///
233    /// #### `hexpand-set`
234    ///  Whether to use the `hexpand` property.
235    ///
236    /// Readable | Writeable
237    ///
238    ///
239    /// #### `layout-manager`
240    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
241    /// the preferred size of the widget, and allocate its children.
242    ///
243    /// This property is meant to be set by widget implementations,
244    /// typically in their instance init function.
245    ///
246    /// Readable | Writeable
247    ///
248    ///
249    /// #### `limit-events`
250    ///  Makes this widget act like a modal dialog, with respect to
251    /// event delivery.
252    ///
253    /// Global event controllers will not handle events with targets
254    /// inside the widget, unless they are set up to ignore propagation
255    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
256    ///
257    /// Readable | Writeable
258    ///
259    ///
260    /// #### `margin-bottom`
261    ///  Margin on bottom side of widget.
262    ///
263    /// This property adds margin outside of the widget's normal size
264    /// request, the margin will be added in addition to the size from
265    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
266    ///
267    /// Readable | Writeable
268    ///
269    ///
270    /// #### `margin-end`
271    ///  Margin on end of widget, horizontally.
272    ///
273    /// This property supports left-to-right and right-to-left text
274    /// directions.
275    ///
276    /// This property adds margin outside of the widget's normal size
277    /// request, the margin will be added in addition to the size from
278    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
279    ///
280    /// Readable | Writeable
281    ///
282    ///
283    /// #### `margin-start`
284    ///  Margin on start of widget, horizontally.
285    ///
286    /// This property supports left-to-right and right-to-left text
287    /// directions.
288    ///
289    /// This property adds margin outside of the widget's normal size
290    /// request, the margin will be added in addition to the size from
291    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
292    ///
293    /// Readable | Writeable
294    ///
295    ///
296    /// #### `margin-top`
297    ///  Margin on top side of widget.
298    ///
299    /// This property adds margin outside of the widget's normal size
300    /// request, the margin will be added in addition to the size from
301    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
302    ///
303    /// Readable | Writeable
304    ///
305    ///
306    /// #### `name`
307    ///  The name of the widget.
308    ///
309    /// Readable | Writeable
310    ///
311    ///
312    /// #### `opacity`
313    ///  The requested opacity of the widget.
314    ///
315    /// Readable | Writeable
316    ///
317    ///
318    /// #### `overflow`
319    ///  How content outside the widget's content area is treated.
320    ///
321    /// This property is meant to be set by widget implementations,
322    /// typically in their instance init function.
323    ///
324    /// Readable | Writeable
325    ///
326    ///
327    /// #### `parent`
328    ///  The parent widget of this widget.
329    ///
330    /// Readable
331    ///
332    ///
333    /// #### `receives-default`
334    ///  Whether the widget will receive the default action when it is focused.
335    ///
336    /// Readable | Writeable
337    ///
338    ///
339    /// #### `root`
340    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
341    ///
342    /// This will be `NULL` if the widget is not contained in a root widget.
343    ///
344    /// Readable
345    ///
346    ///
347    /// #### `scale-factor`
348    ///  The scale factor of the widget.
349    ///
350    /// Readable
351    ///
352    ///
353    /// #### `sensitive`
354    ///  Whether the widget responds to input.
355    ///
356    /// Readable | Writeable
357    ///
358    ///
359    /// #### `tooltip-markup`
360    ///  Sets the text of tooltip to be the given string, which is marked up
361    /// with Pango markup.
362    ///
363    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
364    ///
365    /// This is a convenience property which will take care of getting the
366    /// tooltip shown if the given string is not `NULL`:
367    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
368    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
369    /// the default signal handler.
370    ///
371    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
372    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
373    ///
374    /// Readable | Writeable
375    ///
376    ///
377    /// #### `tooltip-text`
378    ///  Sets the text of tooltip to be the given string.
379    ///
380    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
381    ///
382    /// This is a convenience property which will take care of getting the
383    /// tooltip shown if the given string is not `NULL`:
384    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
385    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
386    /// the default signal handler.
387    ///
388    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
389    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
390    ///
391    /// Readable | Writeable
392    ///
393    ///
394    /// #### `valign`
395    ///  How to distribute vertical space if widget gets extra space.
396    ///
397    /// Readable | Writeable
398    ///
399    ///
400    /// #### `vexpand`
401    ///  Whether to expand vertically.
402    ///
403    /// Readable | Writeable
404    ///
405    ///
406    /// #### `vexpand-set`
407    ///  Whether to use the `vexpand` property.
408    ///
409    /// Readable | Writeable
410    ///
411    ///
412    /// #### `visible`
413    ///  Whether the widget is visible.
414    ///
415    /// Readable | Writeable
416    ///
417    ///
418    /// #### `width-request`
419    ///  Overrides for width request of the widget.
420    ///
421    /// If this is -1, the natural request will be used.
422    ///
423    /// Readable | Writeable
424    /// </details>
425    /// <details><summary><h4>Accessible</h4></summary>
426    ///
427    ///
428    /// #### `accessible-role`
429    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
430    ///
431    /// The accessible role cannot be changed once set.
432    ///
433    /// Readable | Writeable
434    /// </details>
435    ///
436    /// # Implements
437    ///
438    /// [`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]
439    #[doc(alias = "GtkTreeExpander")]
440    pub struct TreeExpander(Object<ffi::GtkTreeExpander, ffi::GtkTreeExpanderClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
441
442    match fn {
443        type_ => || ffi::gtk_tree_expander_get_type(),
444    }
445}
446
447impl TreeExpander {
448    /// Creates a new [`TreeExpander`][crate::TreeExpander]
449    ///
450    /// # Returns
451    ///
452    /// a new [`TreeExpander`][crate::TreeExpander]
453    #[doc(alias = "gtk_tree_expander_new")]
454    pub fn new() -> TreeExpander {
455        assert_initialized_main_thread!();
456        unsafe { Widget::from_glib_none(ffi::gtk_tree_expander_new()).unsafe_cast() }
457    }
458
459    // rustdoc-stripper-ignore-next
460    /// Creates a new builder-pattern struct instance to construct [`TreeExpander`] objects.
461    ///
462    /// This method returns an instance of [`TreeExpanderBuilder`](crate::builders::TreeExpanderBuilder) which can be used to create [`TreeExpander`] objects.
463    pub fn builder() -> TreeExpanderBuilder {
464        TreeExpanderBuilder::new()
465    }
466
467    /// Gets the child widget displayed by @self.
468    ///
469    /// # Returns
470    ///
471    /// The child displayed by @self
472    #[doc(alias = "gtk_tree_expander_get_child")]
473    #[doc(alias = "get_child")]
474    pub fn child(&self) -> Option<Widget> {
475        unsafe { from_glib_none(ffi::gtk_tree_expander_get_child(self.to_glib_none().0)) }
476    }
477
478    /// Gets whether the TreeExpander should be hidden in a GtkTreeListRow.
479    ///
480    /// # Returns
481    ///
482    /// TRUE if the expander icon should be hidden. Otherwise FALSE.
483    #[cfg(feature = "v4_10")]
484    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
485    #[doc(alias = "gtk_tree_expander_get_hide_expander")]
486    #[doc(alias = "get_hide_expander")]
487    #[doc(alias = "hide-expander")]
488    pub fn hides_expander(&self) -> bool {
489        unsafe {
490            from_glib(ffi::gtk_tree_expander_get_hide_expander(
491                self.to_glib_none().0,
492            ))
493        }
494    }
495
496    /// TreeExpander indents each level of depth with an additional indent.
497    ///
498    /// # Returns
499    ///
500    /// TRUE if the child should be indented . Otherwise FALSE.
501    #[cfg(feature = "v4_10")]
502    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
503    #[doc(alias = "gtk_tree_expander_get_indent_for_depth")]
504    #[doc(alias = "get_indent_for_depth")]
505    #[doc(alias = "indent-for-depth")]
506    pub fn is_indent_for_depth(&self) -> bool {
507        unsafe {
508            from_glib(ffi::gtk_tree_expander_get_indent_for_depth(
509                self.to_glib_none().0,
510            ))
511        }
512    }
513
514    /// TreeExpander indents the child by the width of an expander-icon if it is not expandable.
515    ///
516    /// # Returns
517    ///
518    /// TRUE if the child should be indented when not expandable. Otherwise FALSE.
519    #[cfg(feature = "v4_6")]
520    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
521    #[doc(alias = "gtk_tree_expander_get_indent_for_icon")]
522    #[doc(alias = "get_indent_for_icon")]
523    #[doc(alias = "indent-for-icon")]
524    pub fn is_indent_for_icon(&self) -> bool {
525        unsafe {
526            from_glib(ffi::gtk_tree_expander_get_indent_for_icon(
527                self.to_glib_none().0,
528            ))
529        }
530    }
531
532    /// Forwards the item set on the [`TreeListRow`][crate::TreeListRow] that @self is managing.
533    ///
534    /// This call is essentially equivalent to calling:
535    ///
536    /// **⚠️ The following code is in c ⚠️**
537    ///
538    /// ```c
539    /// gtk_tree_list_row_get_item (gtk_tree_expander_get_list_row (@self));
540    /// ```
541    ///
542    /// # Returns
543    ///
544    /// The item of the row
545    #[doc(alias = "gtk_tree_expander_get_item")]
546    #[doc(alias = "get_item")]
547    pub fn item(&self) -> Option<glib::Object> {
548        unsafe { from_glib_full(ffi::gtk_tree_expander_get_item(self.to_glib_none().0)) }
549    }
550
551    /// Gets the list row managed by @self.
552    ///
553    /// # Returns
554    ///
555    /// The list row displayed by @self
556    #[doc(alias = "gtk_tree_expander_get_list_row")]
557    #[doc(alias = "get_list_row")]
558    #[doc(alias = "list-row")]
559    pub fn list_row(&self) -> Option<TreeListRow> {
560        unsafe { from_glib_none(ffi::gtk_tree_expander_get_list_row(self.to_glib_none().0)) }
561    }
562
563    /// Sets the content widget to display.
564    /// ## `child`
565    /// a [`Widget`][crate::Widget]
566    #[doc(alias = "gtk_tree_expander_set_child")]
567    #[doc(alias = "child")]
568    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
569        unsafe {
570            ffi::gtk_tree_expander_set_child(
571                self.to_glib_none().0,
572                child.map(|p| p.as_ref()).to_glib_none().0,
573            );
574        }
575    }
576
577    /// Sets whether the expander icon should be visible in a GtkTreeListRow.
578    /// ## `hide_expander`
579    /// TRUE if the expander should be hidden. Otherwise FALSE.
580    #[cfg(feature = "v4_10")]
581    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
582    #[doc(alias = "gtk_tree_expander_set_hide_expander")]
583    #[doc(alias = "hide-expander")]
584    pub fn set_hide_expander(&self, hide_expander: bool) {
585        unsafe {
586            ffi::gtk_tree_expander_set_hide_expander(
587                self.to_glib_none().0,
588                hide_expander.into_glib(),
589            );
590        }
591    }
592
593    /// Sets if the TreeExpander should indent the child according to its depth.
594    /// ## `indent_for_depth`
595    /// TRUE if the child should be indented. Otherwise FALSE.
596    #[cfg(feature = "v4_10")]
597    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
598    #[doc(alias = "gtk_tree_expander_set_indent_for_depth")]
599    #[doc(alias = "indent-for-depth")]
600    pub fn set_indent_for_depth(&self, indent_for_depth: bool) {
601        unsafe {
602            ffi::gtk_tree_expander_set_indent_for_depth(
603                self.to_glib_none().0,
604                indent_for_depth.into_glib(),
605            );
606        }
607    }
608
609    /// Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.
610    /// ## `indent_for_icon`
611    /// TRUE if the child should be indented without expander. Otherwise FALSE.
612    #[cfg(feature = "v4_6")]
613    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
614    #[doc(alias = "gtk_tree_expander_set_indent_for_icon")]
615    #[doc(alias = "indent-for-icon")]
616    pub fn set_indent_for_icon(&self, indent_for_icon: bool) {
617        unsafe {
618            ffi::gtk_tree_expander_set_indent_for_icon(
619                self.to_glib_none().0,
620                indent_for_icon.into_glib(),
621            );
622        }
623    }
624
625    /// Sets the tree list row that this expander should manage.
626    /// ## `list_row`
627    /// a [`TreeListRow`][crate::TreeListRow]
628    #[doc(alias = "gtk_tree_expander_set_list_row")]
629    #[doc(alias = "list-row")]
630    pub fn set_list_row(&self, list_row: Option<&TreeListRow>) {
631        unsafe {
632            ffi::gtk_tree_expander_set_list_row(self.to_glib_none().0, list_row.to_glib_none().0);
633        }
634    }
635
636    #[doc(alias = "child")]
637    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
638        unsafe extern "C" fn notify_child_trampoline<F: Fn(&TreeExpander) + 'static>(
639            this: *mut ffi::GtkTreeExpander,
640            _param_spec: glib::ffi::gpointer,
641            f: glib::ffi::gpointer,
642        ) {
643            let f: &F = &*(f as *const F);
644            f(&from_glib_borrow(this))
645        }
646        unsafe {
647            let f: Box_<F> = Box_::new(f);
648            connect_raw(
649                self.as_ptr() as *mut _,
650                c"notify::child".as_ptr() as *const _,
651                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
652                    notify_child_trampoline::<F> as *const (),
653                )),
654                Box_::into_raw(f),
655            )
656        }
657    }
658
659    #[cfg(feature = "v4_10")]
660    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
661    #[doc(alias = "hide-expander")]
662    pub fn connect_hide_expander_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
663        unsafe extern "C" fn notify_hide_expander_trampoline<F: Fn(&TreeExpander) + 'static>(
664            this: *mut ffi::GtkTreeExpander,
665            _param_spec: glib::ffi::gpointer,
666            f: glib::ffi::gpointer,
667        ) {
668            let f: &F = &*(f as *const F);
669            f(&from_glib_borrow(this))
670        }
671        unsafe {
672            let f: Box_<F> = Box_::new(f);
673            connect_raw(
674                self.as_ptr() as *mut _,
675                c"notify::hide-expander".as_ptr() as *const _,
676                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
677                    notify_hide_expander_trampoline::<F> as *const (),
678                )),
679                Box_::into_raw(f),
680            )
681        }
682    }
683
684    #[cfg(feature = "v4_10")]
685    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
686    #[doc(alias = "indent-for-depth")]
687    pub fn connect_indent_for_depth_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
688        unsafe extern "C" fn notify_indent_for_depth_trampoline<F: Fn(&TreeExpander) + 'static>(
689            this: *mut ffi::GtkTreeExpander,
690            _param_spec: glib::ffi::gpointer,
691            f: glib::ffi::gpointer,
692        ) {
693            let f: &F = &*(f as *const F);
694            f(&from_glib_borrow(this))
695        }
696        unsafe {
697            let f: Box_<F> = Box_::new(f);
698            connect_raw(
699                self.as_ptr() as *mut _,
700                c"notify::indent-for-depth".as_ptr() as *const _,
701                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
702                    notify_indent_for_depth_trampoline::<F> as *const (),
703                )),
704                Box_::into_raw(f),
705            )
706        }
707    }
708
709    #[cfg(feature = "v4_6")]
710    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
711    #[doc(alias = "indent-for-icon")]
712    pub fn connect_indent_for_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
713        unsafe extern "C" fn notify_indent_for_icon_trampoline<F: Fn(&TreeExpander) + 'static>(
714            this: *mut ffi::GtkTreeExpander,
715            _param_spec: glib::ffi::gpointer,
716            f: glib::ffi::gpointer,
717        ) {
718            let f: &F = &*(f as *const F);
719            f(&from_glib_borrow(this))
720        }
721        unsafe {
722            let f: Box_<F> = Box_::new(f);
723            connect_raw(
724                self.as_ptr() as *mut _,
725                c"notify::indent-for-icon".as_ptr() as *const _,
726                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
727                    notify_indent_for_icon_trampoline::<F> as *const (),
728                )),
729                Box_::into_raw(f),
730            )
731        }
732    }
733
734    #[doc(alias = "item")]
735    pub fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
736        unsafe extern "C" fn notify_item_trampoline<F: Fn(&TreeExpander) + 'static>(
737            this: *mut ffi::GtkTreeExpander,
738            _param_spec: glib::ffi::gpointer,
739            f: glib::ffi::gpointer,
740        ) {
741            let f: &F = &*(f as *const F);
742            f(&from_glib_borrow(this))
743        }
744        unsafe {
745            let f: Box_<F> = Box_::new(f);
746            connect_raw(
747                self.as_ptr() as *mut _,
748                c"notify::item".as_ptr() as *const _,
749                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
750                    notify_item_trampoline::<F> as *const (),
751                )),
752                Box_::into_raw(f),
753            )
754        }
755    }
756
757    #[doc(alias = "list-row")]
758    pub fn connect_list_row_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
759        unsafe extern "C" fn notify_list_row_trampoline<F: Fn(&TreeExpander) + 'static>(
760            this: *mut ffi::GtkTreeExpander,
761            _param_spec: glib::ffi::gpointer,
762            f: glib::ffi::gpointer,
763        ) {
764            let f: &F = &*(f as *const F);
765            f(&from_glib_borrow(this))
766        }
767        unsafe {
768            let f: Box_<F> = Box_::new(f);
769            connect_raw(
770                self.as_ptr() as *mut _,
771                c"notify::list-row".as_ptr() as *const _,
772                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
773                    notify_list_row_trampoline::<F> as *const (),
774                )),
775                Box_::into_raw(f),
776            )
777        }
778    }
779}
780
781impl Default for TreeExpander {
782    fn default() -> Self {
783        Self::new()
784    }
785}
786
787// rustdoc-stripper-ignore-next
788/// A [builder-pattern] type to construct [`TreeExpander`] objects.
789///
790/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
791#[must_use = "The builder must be built to be used"]
792pub struct TreeExpanderBuilder {
793    builder: glib::object::ObjectBuilder<'static, TreeExpander>,
794}
795
796impl TreeExpanderBuilder {
797    fn new() -> Self {
798        Self {
799            builder: glib::object::Object::builder(),
800        }
801    }
802
803    /// The child widget with the actual contents.
804    pub fn child(self, child: &impl IsA<Widget>) -> Self {
805        Self {
806            builder: self.builder.property("child", child.clone().upcast()),
807        }
808    }
809
810    /// Whether the expander icon should be hidden in a GtkTreeListRow.
811    /// Note that this property simply hides the icon.  The actions and keybinding
812    /// (i.e. collapse and expand) are not affected by this property.
813    ///
814    /// A common use for this property would be to bind to the number of children in a
815    /// GtkTreeListRow's model in order to hide the expander when a row has no children.
816    #[cfg(feature = "v4_10")]
817    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
818    pub fn hide_expander(self, hide_expander: bool) -> Self {
819        Self {
820            builder: self.builder.property("hide-expander", hide_expander),
821        }
822    }
823
824    /// TreeExpander indents the child according to its depth.
825    #[cfg(feature = "v4_10")]
826    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
827    pub fn indent_for_depth(self, indent_for_depth: bool) -> Self {
828        Self {
829            builder: self.builder.property("indent-for-depth", indent_for_depth),
830        }
831    }
832
833    /// TreeExpander indents the child by the width of an expander-icon if it is not expandable.
834    #[cfg(feature = "v4_6")]
835    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
836    pub fn indent_for_icon(self, indent_for_icon: bool) -> Self {
837        Self {
838            builder: self.builder.property("indent-for-icon", indent_for_icon),
839        }
840    }
841
842    /// The list row to track for expander state.
843    pub fn list_row(self, list_row: &TreeListRow) -> Self {
844        Self {
845            builder: self.builder.property("list-row", list_row.clone()),
846        }
847    }
848
849    /// Whether the widget or any of its descendents can accept
850    /// the input focus.
851    ///
852    /// This property is meant to be set by widget implementations,
853    /// typically in their instance init function.
854    pub fn can_focus(self, can_focus: bool) -> Self {
855        Self {
856            builder: self.builder.property("can-focus", can_focus),
857        }
858    }
859
860    /// Whether the widget can receive pointer events.
861    pub fn can_target(self, can_target: bool) -> Self {
862        Self {
863            builder: self.builder.property("can-target", can_target),
864        }
865    }
866
867    /// A list of css classes applied to this widget.
868    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
869        Self {
870            builder: self.builder.property("css-classes", css_classes.into()),
871        }
872    }
873
874    /// The name of this widget in the CSS tree.
875    ///
876    /// This property is meant to be set by widget implementations,
877    /// typically in their instance init function.
878    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
879        Self {
880            builder: self.builder.property("css-name", css_name.into()),
881        }
882    }
883
884    /// The cursor used by @widget.
885    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
886        Self {
887            builder: self.builder.property("cursor", cursor.clone()),
888        }
889    }
890
891    /// Whether the widget should grab focus when it is clicked with the mouse.
892    ///
893    /// This property is only relevant for widgets that can take focus.
894    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
895        Self {
896            builder: self.builder.property("focus-on-click", focus_on_click),
897        }
898    }
899
900    /// Whether this widget itself will accept the input focus.
901    pub fn focusable(self, focusable: bool) -> Self {
902        Self {
903            builder: self.builder.property("focusable", focusable),
904        }
905    }
906
907    /// How to distribute horizontal space if widget gets extra space.
908    pub fn halign(self, halign: Align) -> Self {
909        Self {
910            builder: self.builder.property("halign", halign),
911        }
912    }
913
914    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
915    /// signal on @widget.
916    ///
917    /// A true value indicates that @widget can have a tooltip, in this case
918    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
919    /// determine whether it will provide a tooltip or not.
920    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
921        Self {
922            builder: self.builder.property("has-tooltip", has_tooltip),
923        }
924    }
925
926    /// Overrides for height request of the widget.
927    ///
928    /// If this is -1, the natural request will be used.
929    pub fn height_request(self, height_request: i32) -> Self {
930        Self {
931            builder: self.builder.property("height-request", height_request),
932        }
933    }
934
935    /// Whether to expand horizontally.
936    pub fn hexpand(self, hexpand: bool) -> Self {
937        Self {
938            builder: self.builder.property("hexpand", hexpand),
939        }
940    }
941
942    /// Whether to use the `hexpand` property.
943    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
944        Self {
945            builder: self.builder.property("hexpand-set", hexpand_set),
946        }
947    }
948
949    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
950    /// the preferred size of the widget, and allocate its children.
951    ///
952    /// This property is meant to be set by widget implementations,
953    /// typically in their instance init function.
954    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
955        Self {
956            builder: self
957                .builder
958                .property("layout-manager", layout_manager.clone().upcast()),
959        }
960    }
961
962    /// Makes this widget act like a modal dialog, with respect to
963    /// event delivery.
964    ///
965    /// Global event controllers will not handle events with targets
966    /// inside the widget, unless they are set up to ignore propagation
967    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
968    #[cfg(feature = "v4_18")]
969    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
970    pub fn limit_events(self, limit_events: bool) -> Self {
971        Self {
972            builder: self.builder.property("limit-events", limit_events),
973        }
974    }
975
976    /// Margin on bottom side of widget.
977    ///
978    /// This property adds margin outside of the widget's normal size
979    /// request, the margin will be added in addition to the size from
980    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
981    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
982        Self {
983            builder: self.builder.property("margin-bottom", margin_bottom),
984        }
985    }
986
987    /// Margin on end of widget, horizontally.
988    ///
989    /// This property supports left-to-right and right-to-left text
990    /// directions.
991    ///
992    /// This property adds margin outside of the widget's normal size
993    /// request, the margin will be added in addition to the size from
994    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
995    pub fn margin_end(self, margin_end: i32) -> Self {
996        Self {
997            builder: self.builder.property("margin-end", margin_end),
998        }
999    }
1000
1001    /// Margin on start of widget, horizontally.
1002    ///
1003    /// This property supports left-to-right and right-to-left text
1004    /// directions.
1005    ///
1006    /// This property adds margin outside of the widget's normal size
1007    /// request, the margin will be added in addition to the size from
1008    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1009    pub fn margin_start(self, margin_start: i32) -> Self {
1010        Self {
1011            builder: self.builder.property("margin-start", margin_start),
1012        }
1013    }
1014
1015    /// Margin on top side of widget.
1016    ///
1017    /// This property adds margin outside of the widget's normal size
1018    /// request, the margin will be added in addition to the size from
1019    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1020    pub fn margin_top(self, margin_top: i32) -> Self {
1021        Self {
1022            builder: self.builder.property("margin-top", margin_top),
1023        }
1024    }
1025
1026    /// The name of the widget.
1027    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1028        Self {
1029            builder: self.builder.property("name", name.into()),
1030        }
1031    }
1032
1033    /// The requested opacity of the widget.
1034    pub fn opacity(self, opacity: f64) -> Self {
1035        Self {
1036            builder: self.builder.property("opacity", opacity),
1037        }
1038    }
1039
1040    /// How content outside the widget's content area is treated.
1041    ///
1042    /// This property is meant to be set by widget implementations,
1043    /// typically in their instance init function.
1044    pub fn overflow(self, overflow: Overflow) -> Self {
1045        Self {
1046            builder: self.builder.property("overflow", overflow),
1047        }
1048    }
1049
1050    /// Whether the widget will receive the default action when it is focused.
1051    pub fn receives_default(self, receives_default: bool) -> Self {
1052        Self {
1053            builder: self.builder.property("receives-default", receives_default),
1054        }
1055    }
1056
1057    /// Whether the widget responds to input.
1058    pub fn sensitive(self, sensitive: bool) -> Self {
1059        Self {
1060            builder: self.builder.property("sensitive", sensitive),
1061        }
1062    }
1063
1064    /// Sets the text of tooltip to be the given string, which is marked up
1065    /// with Pango markup.
1066    ///
1067    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1068    ///
1069    /// This is a convenience property which will take care of getting the
1070    /// tooltip shown if the given string is not `NULL`:
1071    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1072    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1073    /// the default signal handler.
1074    ///
1075    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1076    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1077    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1078        Self {
1079            builder: self
1080                .builder
1081                .property("tooltip-markup", tooltip_markup.into()),
1082        }
1083    }
1084
1085    /// Sets the text of tooltip to be the given string.
1086    ///
1087    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1088    ///
1089    /// This is a convenience property which will take care of getting the
1090    /// tooltip shown if the given string is not `NULL`:
1091    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1092    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1093    /// the default signal handler.
1094    ///
1095    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1096    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1097    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1098        Self {
1099            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1100        }
1101    }
1102
1103    /// How to distribute vertical space if widget gets extra space.
1104    pub fn valign(self, valign: Align) -> Self {
1105        Self {
1106            builder: self.builder.property("valign", valign),
1107        }
1108    }
1109
1110    /// Whether to expand vertically.
1111    pub fn vexpand(self, vexpand: bool) -> Self {
1112        Self {
1113            builder: self.builder.property("vexpand", vexpand),
1114        }
1115    }
1116
1117    /// Whether to use the `vexpand` property.
1118    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1119        Self {
1120            builder: self.builder.property("vexpand-set", vexpand_set),
1121        }
1122    }
1123
1124    /// Whether the widget is visible.
1125    pub fn visible(self, visible: bool) -> Self {
1126        Self {
1127            builder: self.builder.property("visible", visible),
1128        }
1129    }
1130
1131    /// Overrides for width request of the widget.
1132    ///
1133    /// If this is -1, the natural request will be used.
1134    pub fn width_request(self, width_request: i32) -> Self {
1135        Self {
1136            builder: self.builder.property("width-request", width_request),
1137        }
1138    }
1139
1140    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1141    ///
1142    /// The accessible role cannot be changed once set.
1143    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1144        Self {
1145            builder: self.builder.property("accessible-role", accessible_role),
1146        }
1147    }
1148
1149    // rustdoc-stripper-ignore-next
1150    /// Build the [`TreeExpander`].
1151    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1152    pub fn build(self) -> TreeExpander {
1153        assert_initialized_main_thread!();
1154        self.builder.build()
1155    }
1156}