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