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