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