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