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 /// This is a keybinding signal, which will cause this row to be activated.
367 ///
368 /// If you want to be notified when the user activates a row (by key or not),
369 /// use the [`row-activated`][struct@crate::ListBox#row-activated] signal on the row’s parent
370 /// [`ListBox`][crate::ListBox].
371 ///
372 /// Action
373 /// <details><summary><h4>Widget</h4></summary>
374 ///
375 ///
376 /// #### `destroy`
377 /// Signals that all holders of a reference to the widget should release
378 /// the reference that they hold.
379 ///
380 /// May result in finalization of the widget if all references are released.
381 ///
382 /// This signal is not suitable for saving widget state.
383 ///
384 ///
385 ///
386 ///
387 /// #### `direction-changed`
388 /// Emitted when the text direction of a widget changes.
389 ///
390 ///
391 ///
392 ///
393 /// #### `hide`
394 /// Emitted when @widget is hidden.
395 ///
396 ///
397 ///
398 ///
399 /// #### `keynav-failed`
400 /// Emitted if keyboard navigation fails.
401 ///
402 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
403 ///
404 ///
405 ///
406 ///
407 /// #### `map`
408 /// Emitted when @widget is going to be mapped.
409 ///
410 /// A widget is mapped when the widget is visible (which is controlled with
411 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
412 /// are also visible.
413 ///
414 /// The `::map` signal can be used to determine whether a widget will be drawn,
415 /// for instance it can resume an animation that was stopped during the
416 /// emission of [`unmap`][struct@crate::Widget#unmap].
417 ///
418 ///
419 ///
420 ///
421 /// #### `mnemonic-activate`
422 /// Emitted when a widget is activated via a mnemonic.
423 ///
424 /// The default handler for this signal activates @widget if @group_cycling
425 /// is false, or just makes @widget grab focus if @group_cycling is true.
426 ///
427 ///
428 ///
429 ///
430 /// #### `move-focus`
431 /// 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
509#[cfg(not(feature = "v4_10"))]
510glib::wrapper! {
511 #[doc(alias = "GtkListBoxRow")]
512 pub struct ListBoxRow(Object<ffi::GtkListBoxRow, ffi::GtkListBoxRowClass>) @extends Widget, @implements Buildable, ConstraintTarget, Actionable;
513
514 match fn {
515 type_ => || ffi::gtk_list_box_row_get_type(),
516 }
517}
518
519impl ListBoxRow {
520 pub const NONE: Option<&'static ListBoxRow> = None;
521
522 /// Creates a new [`ListBoxRow`][crate::ListBoxRow].
523 ///
524 /// # Returns
525 ///
526 /// a new [`ListBoxRow`][crate::ListBoxRow]
527 #[doc(alias = "gtk_list_box_row_new")]
528 pub fn new() -> ListBoxRow {
529 assert_initialized_main_thread!();
530 unsafe { Widget::from_glib_none(ffi::gtk_list_box_row_new()).unsafe_cast() }
531 }
532
533 // rustdoc-stripper-ignore-next
534 /// Creates a new builder-pattern struct instance to construct [`ListBoxRow`] objects.
535 ///
536 /// This method returns an instance of [`ListBoxRowBuilder`](crate::builders::ListBoxRowBuilder) which can be used to create [`ListBoxRow`] objects.
537 pub fn builder() -> ListBoxRowBuilder {
538 ListBoxRowBuilder::new()
539 }
540}
541
542impl Default for ListBoxRow {
543 fn default() -> Self {
544 Self::new()
545 }
546}
547
548// rustdoc-stripper-ignore-next
549/// A [builder-pattern] type to construct [`ListBoxRow`] objects.
550///
551/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
552#[must_use = "The builder must be built to be used"]
553pub struct ListBoxRowBuilder {
554 builder: glib::object::ObjectBuilder<'static, ListBoxRow>,
555}
556
557impl ListBoxRowBuilder {
558 fn new() -> Self {
559 Self {
560 builder: glib::object::Object::builder(),
561 }
562 }
563
564 /// Determines whether the ::row-activated
565 /// signal will be emitted for this row.
566 pub fn activatable(self, activatable: bool) -> Self {
567 Self {
568 builder: self.builder.property("activatable", activatable),
569 }
570 }
571
572 /// The child widget.
573 pub fn child(self, child: &impl IsA<Widget>) -> Self {
574 Self {
575 builder: self.builder.property("child", child.clone().upcast()),
576 }
577 }
578
579 /// Determines whether this row can be selected.
580 pub fn selectable(self, selectable: bool) -> Self {
581 Self {
582 builder: self.builder.property("selectable", selectable),
583 }
584 }
585
586 /// Whether the widget or any of its descendents can accept
587 /// the input focus.
588 ///
589 /// This property is meant to be set by widget implementations,
590 /// typically in their instance init function.
591 pub fn can_focus(self, can_focus: bool) -> Self {
592 Self {
593 builder: self.builder.property("can-focus", can_focus),
594 }
595 }
596
597 /// Whether the widget can receive pointer events.
598 pub fn can_target(self, can_target: bool) -> Self {
599 Self {
600 builder: self.builder.property("can-target", can_target),
601 }
602 }
603
604 /// A list of css classes applied to this widget.
605 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
606 Self {
607 builder: self.builder.property("css-classes", css_classes.into()),
608 }
609 }
610
611 /// The name of this widget in the CSS tree.
612 ///
613 /// This property is meant to be set by widget implementations,
614 /// typically in their instance init function.
615 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
616 Self {
617 builder: self.builder.property("css-name", css_name.into()),
618 }
619 }
620
621 /// The cursor used by @widget.
622 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
623 Self {
624 builder: self.builder.property("cursor", cursor.clone()),
625 }
626 }
627
628 /// Whether the widget should grab focus when it is clicked with the mouse.
629 ///
630 /// This property is only relevant for widgets that can take focus.
631 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
632 Self {
633 builder: self.builder.property("focus-on-click", focus_on_click),
634 }
635 }
636
637 /// Whether this widget itself will accept the input focus.
638 pub fn focusable(self, focusable: bool) -> Self {
639 Self {
640 builder: self.builder.property("focusable", focusable),
641 }
642 }
643
644 /// How to distribute horizontal space if widget gets extra space.
645 pub fn halign(self, halign: Align) -> Self {
646 Self {
647 builder: self.builder.property("halign", halign),
648 }
649 }
650
651 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
652 /// signal on @widget.
653 ///
654 /// A true value indicates that @widget can have a tooltip, in this case
655 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
656 /// determine whether it will provide a tooltip or not.
657 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
658 Self {
659 builder: self.builder.property("has-tooltip", has_tooltip),
660 }
661 }
662
663 /// Overrides for height request of the widget.
664 ///
665 /// If this is -1, the natural request will be used.
666 pub fn height_request(self, height_request: i32) -> Self {
667 Self {
668 builder: self.builder.property("height-request", height_request),
669 }
670 }
671
672 /// Whether to expand horizontally.
673 pub fn hexpand(self, hexpand: bool) -> Self {
674 Self {
675 builder: self.builder.property("hexpand", hexpand),
676 }
677 }
678
679 /// Whether to use the `hexpand` property.
680 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
681 Self {
682 builder: self.builder.property("hexpand-set", hexpand_set),
683 }
684 }
685
686 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
687 /// the preferred size of the widget, and allocate its children.
688 ///
689 /// This property is meant to be set by widget implementations,
690 /// typically in their instance init function.
691 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
692 Self {
693 builder: self
694 .builder
695 .property("layout-manager", layout_manager.clone().upcast()),
696 }
697 }
698
699 /// Makes this widget act like a modal dialog, with respect to
700 /// event delivery.
701 ///
702 /// Global event controllers will not handle events with targets
703 /// inside the widget, unless they are set up to ignore propagation
704 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
705 #[cfg(feature = "v4_18")]
706 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
707 pub fn limit_events(self, limit_events: bool) -> Self {
708 Self {
709 builder: self.builder.property("limit-events", limit_events),
710 }
711 }
712
713 /// Margin on bottom side of widget.
714 ///
715 /// This property adds margin outside of the widget's normal size
716 /// request, the margin will be added in addition to the size from
717 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
718 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
719 Self {
720 builder: self.builder.property("margin-bottom", margin_bottom),
721 }
722 }
723
724 /// Margin on end of widget, horizontally.
725 ///
726 /// This property supports left-to-right and right-to-left text
727 /// directions.
728 ///
729 /// This property adds margin outside of the widget's normal size
730 /// request, the margin will be added in addition to the size from
731 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
732 pub fn margin_end(self, margin_end: i32) -> Self {
733 Self {
734 builder: self.builder.property("margin-end", margin_end),
735 }
736 }
737
738 /// Margin on start of widget, horizontally.
739 ///
740 /// This property supports left-to-right and right-to-left text
741 /// directions.
742 ///
743 /// This property adds margin outside of the widget's normal size
744 /// request, the margin will be added in addition to the size from
745 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
746 pub fn margin_start(self, margin_start: i32) -> Self {
747 Self {
748 builder: self.builder.property("margin-start", margin_start),
749 }
750 }
751
752 /// Margin on top side of widget.
753 ///
754 /// This property adds margin outside of the widget's normal size
755 /// request, the margin will be added in addition to the size from
756 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
757 pub fn margin_top(self, margin_top: i32) -> Self {
758 Self {
759 builder: self.builder.property("margin-top", margin_top),
760 }
761 }
762
763 /// The name of the widget.
764 pub fn name(self, name: impl Into<glib::GString>) -> Self {
765 Self {
766 builder: self.builder.property("name", name.into()),
767 }
768 }
769
770 /// The requested opacity of the widget.
771 pub fn opacity(self, opacity: f64) -> Self {
772 Self {
773 builder: self.builder.property("opacity", opacity),
774 }
775 }
776
777 /// How content outside the widget's content area is treated.
778 ///
779 /// This property is meant to be set by widget implementations,
780 /// typically in their instance init function.
781 pub fn overflow(self, overflow: Overflow) -> Self {
782 Self {
783 builder: self.builder.property("overflow", overflow),
784 }
785 }
786
787 /// Whether the widget will receive the default action when it is focused.
788 pub fn receives_default(self, receives_default: bool) -> Self {
789 Self {
790 builder: self.builder.property("receives-default", receives_default),
791 }
792 }
793
794 /// Whether the widget responds to input.
795 pub fn sensitive(self, sensitive: bool) -> Self {
796 Self {
797 builder: self.builder.property("sensitive", sensitive),
798 }
799 }
800
801 /// Sets the text of tooltip to be the given string, which is marked up
802 /// with Pango markup.
803 ///
804 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
805 ///
806 /// This is a convenience property which will take care of getting the
807 /// tooltip shown if the given string is not `NULL`:
808 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
809 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
810 /// the default signal handler.
811 ///
812 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
813 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
814 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
815 Self {
816 builder: self
817 .builder
818 .property("tooltip-markup", tooltip_markup.into()),
819 }
820 }
821
822 /// Sets the text of tooltip to be the given string.
823 ///
824 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
825 ///
826 /// This is a convenience property which will take care of getting the
827 /// tooltip shown if the given string is not `NULL`:
828 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
829 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
830 /// the default signal handler.
831 ///
832 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
833 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
834 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
835 Self {
836 builder: self.builder.property("tooltip-text", tooltip_text.into()),
837 }
838 }
839
840 /// How to distribute vertical space if widget gets extra space.
841 pub fn valign(self, valign: Align) -> Self {
842 Self {
843 builder: self.builder.property("valign", valign),
844 }
845 }
846
847 /// Whether to expand vertically.
848 pub fn vexpand(self, vexpand: bool) -> Self {
849 Self {
850 builder: self.builder.property("vexpand", vexpand),
851 }
852 }
853
854 /// Whether to use the `vexpand` property.
855 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
856 Self {
857 builder: self.builder.property("vexpand-set", vexpand_set),
858 }
859 }
860
861 /// Whether the widget is visible.
862 pub fn visible(self, visible: bool) -> Self {
863 Self {
864 builder: self.builder.property("visible", visible),
865 }
866 }
867
868 /// Overrides for width request of the widget.
869 ///
870 /// If this is -1, the natural request will be used.
871 pub fn width_request(self, width_request: i32) -> Self {
872 Self {
873 builder: self.builder.property("width-request", width_request),
874 }
875 }
876
877 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
878 ///
879 /// The accessible role cannot be changed once set.
880 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
881 Self {
882 builder: self.builder.property("accessible-role", accessible_role),
883 }
884 }
885
886 /// The name of the action with which this widget should be associated.
887 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
888 Self {
889 builder: self.builder.property("action-name", action_name.into()),
890 }
891 }
892
893 /// The target value of the actionable widget's action.
894 pub fn action_target(self, action_target: &glib::Variant) -> Self {
895 Self {
896 builder: self
897 .builder
898 .property("action-target", action_target.clone()),
899 }
900 }
901
902 // rustdoc-stripper-ignore-next
903 /// Build the [`ListBoxRow`].
904 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
905 pub fn build(self) -> ListBoxRow {
906 assert_initialized_main_thread!();
907 self.builder.build()
908 }
909}
910
911/// Trait containing all [`struct@ListBoxRow`] methods.
912///
913/// # Implementors
914///
915/// [`ListBoxRow`][struct@crate::ListBoxRow]
916pub trait ListBoxRowExt: IsA<ListBoxRow> + 'static {
917 /// Marks @self as changed, causing any state that depends on this
918 /// to be updated.
919 ///
920 /// This affects sorting, filtering and headers.
921 ///
922 /// Note that calls to this method must be in sync with the data
923 /// used for the row functions. For instance, if the list is
924 /// mirroring some external data set, and *two* rows changed in the
925 /// external data set then when you call gtk_list_box_row_changed()
926 /// on the first row the sort function must only read the new data
927 /// for the first of the two changed rows, otherwise the resorting
928 /// of the rows will be wrong.
929 ///
930 /// This generally means that if you don’t fully control the data
931 /// model you have to duplicate the data that affects the listbox
932 /// row functions into the row widgets themselves. Another alternative
933 /// is to call [`ListBox::invalidate_sort()`][crate::ListBox::invalidate_sort()] on any model change,
934 /// but that is more expensive.
935 #[doc(alias = "gtk_list_box_row_changed")]
936 fn changed(&self) {
937 unsafe {
938 ffi::gtk_list_box_row_changed(self.as_ref().to_glib_none().0);
939 }
940 }
941
942 /// Gets whether the row is activatable.
943 ///
944 /// # Returns
945 ///
946 /// [`true`] if the row is activatable
947 #[doc(alias = "gtk_list_box_row_get_activatable")]
948 #[doc(alias = "get_activatable")]
949 #[doc(alias = "activatable")]
950 fn is_activatable(&self) -> bool {
951 unsafe {
952 from_glib(ffi::gtk_list_box_row_get_activatable(
953 self.as_ref().to_glib_none().0,
954 ))
955 }
956 }
957
958 /// Gets the child widget of @self.
959 ///
960 /// # Returns
961 ///
962 /// the child widget of @self
963 #[doc(alias = "gtk_list_box_row_get_child")]
964 #[doc(alias = "get_child")]
965 fn child(&self) -> Option<Widget> {
966 unsafe {
967 from_glib_none(ffi::gtk_list_box_row_get_child(
968 self.as_ref().to_glib_none().0,
969 ))
970 }
971 }
972
973 /// Returns the current header of the @self.
974 ///
975 /// This can be used
976 /// in a `callback::Gtk::ListBoxUpdateHeaderFunc to see if
977 /// there is a header set already, and if so to update
978 /// the state of it.
979 ///
980 /// # Returns
981 ///
982 /// the current header
983 #[doc(alias = "gtk_list_box_row_get_header")]
984 #[doc(alias = "get_header")]
985 fn header(&self) -> Option<Widget> {
986 unsafe {
987 from_glib_none(ffi::gtk_list_box_row_get_header(
988 self.as_ref().to_glib_none().0,
989 ))
990 }
991 }
992
993 /// Gets the current index of the @self in its [`ListBox`][crate::ListBox] container.
994 ///
995 /// # Returns
996 ///
997 /// the index of the @self, or -1 if the @self is not in a listbox
998 #[doc(alias = "gtk_list_box_row_get_index")]
999 #[doc(alias = "get_index")]
1000 fn index(&self) -> i32 {
1001 unsafe { ffi::gtk_list_box_row_get_index(self.as_ref().to_glib_none().0) }
1002 }
1003
1004 /// Gets whether the row can be selected.
1005 ///
1006 /// # Returns
1007 ///
1008 /// [`true`] if the row is selectable
1009 #[doc(alias = "gtk_list_box_row_get_selectable")]
1010 #[doc(alias = "get_selectable")]
1011 #[doc(alias = "selectable")]
1012 fn is_selectable(&self) -> bool {
1013 unsafe {
1014 from_glib(ffi::gtk_list_box_row_get_selectable(
1015 self.as_ref().to_glib_none().0,
1016 ))
1017 }
1018 }
1019
1020 /// Returns whether the child is currently selected in its
1021 /// [`ListBox`][crate::ListBox] container.
1022 ///
1023 /// # Returns
1024 ///
1025 /// [`true`] if @self is selected
1026 #[doc(alias = "gtk_list_box_row_is_selected")]
1027 fn is_selected(&self) -> bool {
1028 unsafe {
1029 from_glib(ffi::gtk_list_box_row_is_selected(
1030 self.as_ref().to_glib_none().0,
1031 ))
1032 }
1033 }
1034
1035 /// Set whether the row is activatable.
1036 /// ## `activatable`
1037 /// [`true`] to mark the row as activatable
1038 #[doc(alias = "gtk_list_box_row_set_activatable")]
1039 #[doc(alias = "activatable")]
1040 fn set_activatable(&self, activatable: bool) {
1041 unsafe {
1042 ffi::gtk_list_box_row_set_activatable(
1043 self.as_ref().to_glib_none().0,
1044 activatable.into_glib(),
1045 );
1046 }
1047 }
1048
1049 /// Sets the child widget of @self_.
1050 /// ## `child`
1051 /// the child widget
1052 #[doc(alias = "gtk_list_box_row_set_child")]
1053 #[doc(alias = "child")]
1054 fn set_child(&self, child: Option<&impl IsA<Widget>>) {
1055 unsafe {
1056 ffi::gtk_list_box_row_set_child(
1057 self.as_ref().to_glib_none().0,
1058 child.map(|p| p.as_ref()).to_glib_none().0,
1059 );
1060 }
1061 }
1062
1063 /// Sets the current header of the @self.
1064 ///
1065 /// This is only allowed to be called
1066 /// from a `callback::Gtk::ListBoxUpdateHeaderFunc.
1067 /// It will replace any existing header in the row,
1068 /// and be shown in front of the row in the listbox.
1069 /// ## `header`
1070 /// the header
1071 #[doc(alias = "gtk_list_box_row_set_header")]
1072 fn set_header(&self, header: Option<&impl IsA<Widget>>) {
1073 unsafe {
1074 ffi::gtk_list_box_row_set_header(
1075 self.as_ref().to_glib_none().0,
1076 header.map(|p| p.as_ref()).to_glib_none().0,
1077 );
1078 }
1079 }
1080
1081 /// Set whether the row can be selected.
1082 /// ## `selectable`
1083 /// [`true`] to mark the row as selectable
1084 #[doc(alias = "gtk_list_box_row_set_selectable")]
1085 #[doc(alias = "selectable")]
1086 fn set_selectable(&self, selectable: bool) {
1087 unsafe {
1088 ffi::gtk_list_box_row_set_selectable(
1089 self.as_ref().to_glib_none().0,
1090 selectable.into_glib(),
1091 );
1092 }
1093 }
1094
1095 /// This is a keybinding signal, which will cause this row to be activated.
1096 ///
1097 /// If you want to be notified when the user activates a row (by key or not),
1098 /// use the [`row-activated`][struct@crate::ListBox#row-activated] signal on the row’s parent
1099 /// [`ListBox`][crate::ListBox].
1100 #[doc(alias = "activate")]
1101 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1102 unsafe extern "C" fn activate_trampoline<P: IsA<ListBoxRow>, F: Fn(&P) + 'static>(
1103 this: *mut ffi::GtkListBoxRow,
1104 f: glib::ffi::gpointer,
1105 ) {
1106 unsafe {
1107 let f: &F = &*(f as *const F);
1108 f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
1109 }
1110 }
1111 unsafe {
1112 let f: Box_<F> = Box_::new(f);
1113 connect_raw(
1114 self.as_ptr() as *mut _,
1115 c"activate".as_ptr(),
1116 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1117 activate_trampoline::<Self, F> as *const (),
1118 )),
1119 Box_::into_raw(f),
1120 )
1121 }
1122 }
1123
1124 fn emit_activate(&self) {
1125 self.emit_by_name::<()>("activate", &[]);
1126 }
1127
1128 #[doc(alias = "activatable")]
1129 fn connect_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1130 unsafe extern "C" fn notify_activatable_trampoline<
1131 P: IsA<ListBoxRow>,
1132 F: Fn(&P) + 'static,
1133 >(
1134 this: *mut ffi::GtkListBoxRow,
1135 _param_spec: glib::ffi::gpointer,
1136 f: glib::ffi::gpointer,
1137 ) {
1138 unsafe {
1139 let f: &F = &*(f as *const F);
1140 f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
1141 }
1142 }
1143 unsafe {
1144 let f: Box_<F> = Box_::new(f);
1145 connect_raw(
1146 self.as_ptr() as *mut _,
1147 c"notify::activatable".as_ptr(),
1148 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1149 notify_activatable_trampoline::<Self, F> as *const (),
1150 )),
1151 Box_::into_raw(f),
1152 )
1153 }
1154 }
1155
1156 #[doc(alias = "child")]
1157 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1158 unsafe extern "C" fn notify_child_trampoline<P: IsA<ListBoxRow>, F: Fn(&P) + 'static>(
1159 this: *mut ffi::GtkListBoxRow,
1160 _param_spec: glib::ffi::gpointer,
1161 f: glib::ffi::gpointer,
1162 ) {
1163 unsafe {
1164 let f: &F = &*(f as *const F);
1165 f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
1166 }
1167 }
1168 unsafe {
1169 let f: Box_<F> = Box_::new(f);
1170 connect_raw(
1171 self.as_ptr() as *mut _,
1172 c"notify::child".as_ptr(),
1173 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1174 notify_child_trampoline::<Self, F> as *const (),
1175 )),
1176 Box_::into_raw(f),
1177 )
1178 }
1179 }
1180
1181 #[doc(alias = "selectable")]
1182 fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1183 unsafe extern "C" fn notify_selectable_trampoline<
1184 P: IsA<ListBoxRow>,
1185 F: Fn(&P) + 'static,
1186 >(
1187 this: *mut ffi::GtkListBoxRow,
1188 _param_spec: glib::ffi::gpointer,
1189 f: glib::ffi::gpointer,
1190 ) {
1191 unsafe {
1192 let f: &F = &*(f as *const F);
1193 f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
1194 }
1195 }
1196 unsafe {
1197 let f: Box_<F> = Box_::new(f);
1198 connect_raw(
1199 self.as_ptr() as *mut _,
1200 c"notify::selectable".as_ptr(),
1201 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1202 notify_selectable_trampoline::<Self, F> as *const (),
1203 )),
1204 Box_::into_raw(f),
1205 )
1206 }
1207 }
1208}
1209
1210impl<O: IsA<ListBoxRow>> ListBoxRowExt for O {}