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