gtk4/auto/scrolled_window.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, Adjustment, Align, Buildable, ConstraintTarget, CornerType,
7 DirectionType, LayoutManager, Overflow, PolicyType, PositionType, ScrollType, 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 /// [`ScrolledWindow`][crate::ScrolledWindow] is a container that makes its child scrollable.
19 ///
20 /// It does so using either internally added scrollbars or externally
21 /// associated adjustments, and optionally draws a frame around the child.
22 ///
23 /// Widgets with native scrolling support, i.e. those whose classes implement
24 /// the [`Scrollable`][crate::Scrollable] interface, are added directly. For other types
25 /// of widget, the class [`Viewport`][crate::Viewport] acts as an adaptor, giving
26 /// scrollability to other widgets. [`set_child()`][Self::set_child()]
27 /// intelligently accounts for whether or not the added child is a [`Scrollable`][crate::Scrollable].
28 /// If it isn’t, then it wraps the child in a [`Viewport`][crate::Viewport]. Therefore, you can
29 /// just add any child widget and not worry about the details.
30 ///
31 /// If [`set_child()`][Self::set_child()] has added a [`Viewport`][crate::Viewport] for you,
32 /// it will be automatically removed when you unset the child.
33 /// Unless [`hscrollbar-policy`][struct@crate::ScrolledWindow#hscrollbar-policy] and
34 /// [`vscrollbar-policy`][struct@crate::ScrolledWindow#vscrollbar-policy] are [`PolicyType::Never`][crate::PolicyType::Never] or
35 /// [`PolicyType::External`][crate::PolicyType::External], [`ScrolledWindow`][crate::ScrolledWindow] adds internal [`Scrollbar`][crate::Scrollbar] widgets
36 /// around its child. The scroll position of the child, and if applicable the
37 /// scrollbars, is controlled by the [`hadjustment`][struct@crate::ScrolledWindow#hadjustment]
38 /// and [`vadjustment`][struct@crate::ScrolledWindow#vadjustment] that are associated with the
39 /// [`ScrolledWindow`][crate::ScrolledWindow]. See the docs on [`Scrollbar`][crate::Scrollbar] for the details,
40 /// but note that the “step_increment” and “page_increment” fields are only
41 /// effective if the policy causes scrollbars to be present.
42 ///
43 /// If a [`ScrolledWindow`][crate::ScrolledWindow] doesn’t behave quite as you would like, or
44 /// doesn’t have exactly the right layout, it’s very possible to set up
45 /// your own scrolling with [`Scrollbar`][crate::Scrollbar] and for example a [`Grid`][crate::Grid].
46 ///
47 /// # Touch support
48 ///
49 /// [`ScrolledWindow`][crate::ScrolledWindow] has built-in support for touch devices. When a
50 /// touchscreen is used, swiping will move the scrolled window, and will
51 /// expose 'kinetic' behavior. This can be turned off with the
52 /// [`kinetic-scrolling`][struct@crate::ScrolledWindow#kinetic-scrolling] property if it is undesired.
53 ///
54 /// [`ScrolledWindow`][crate::ScrolledWindow] also displays visual 'overshoot' indication when
55 /// the content is pulled beyond the end, and this situation can be
56 /// captured with the [`edge-overshot`][struct@crate::ScrolledWindow#edge-overshot] signal.
57 ///
58 /// If no mouse device is present, the scrollbars will overlaid as
59 /// narrow, auto-hiding indicators over the content. If traditional
60 /// scrollbars are desired although no mouse is present, this behaviour
61 /// can be turned off with the [`overlay-scrolling`][struct@crate::ScrolledWindow#overlay-scrolling]
62 /// property.
63 ///
64 /// # Shortcuts and Gestures
65 ///
66 /// The following signals have default keybindings:
67 ///
68 /// - [`scroll-child`][struct@crate::ScrolledWindow#scroll-child]
69 ///
70 /// # CSS nodes
71 ///
72 /// [`ScrolledWindow`][crate::ScrolledWindow] has a main CSS node with name scrolledwindow.
73 /// It gets a .frame style class added when [`has-frame`][struct@crate::ScrolledWindow#has-frame]
74 /// is [`true`].
75 ///
76 /// It uses subnodes with names overshoot and undershoot to draw the overflow
77 /// and underflow indications. These nodes get the .left, .right, .top or .bottom
78 /// style class added depending on where the indication is drawn.
79 ///
80 /// [`ScrolledWindow`][crate::ScrolledWindow] also sets the positional style classes (.left, .right,
81 /// .top, .bottom) and style classes related to overlay scrolling
82 /// (.overlay-indicator, .dragging, .hovering) on its scrollbars.
83 ///
84 /// If both scrollbars are visible, the area where they meet is drawn
85 /// with a subnode named junction.
86 ///
87 /// # Accessibility
88 ///
89 /// Until GTK 4.10, [`ScrolledWindow`][crate::ScrolledWindow] used the `GTK_ACCESSIBLE_ROLE_GROUP` role.
90 ///
91 /// Starting from GTK 4.12, [`ScrolledWindow`][crate::ScrolledWindow] uses the `GTK_ACCESSIBLE_ROLE_GENERIC` role.
92 ///
93 /// ## Properties
94 ///
95 ///
96 /// #### `child`
97 /// The child widget.
98 ///
99 /// When setting this property, if the child widget does not implement
100 /// [`Scrollable`][crate::Scrollable], the scrolled window will add the child to
101 /// a [`Viewport`][crate::Viewport] and then set the viewport as the child.
102 ///
103 /// Readable | Writeable
104 ///
105 ///
106 /// #### `hadjustment`
107 /// The [`Adjustment`][crate::Adjustment] for the horizontal position.
108 ///
109 /// Readable | Writeable | Construct
110 ///
111 ///
112 /// #### `has-frame`
113 /// Whether to draw a frame around the contents.
114 ///
115 /// Readable | Writeable
116 ///
117 ///
118 /// #### `hscrollbar-policy`
119 /// When the horizontal scrollbar is displayed.
120 ///
121 /// Use [`ScrolledWindow::set_policy()`][crate::ScrolledWindow::set_policy()] to set
122 /// this property.
123 ///
124 /// Readable | Writeable
125 ///
126 ///
127 /// #### `kinetic-scrolling`
128 /// Whether kinetic scrolling is enabled or not.
129 ///
130 /// Kinetic scrolling only applies to devices with source `GDK_SOURCE_TOUCHSCREEN`.
131 ///
132 /// Readable | Writeable
133 ///
134 ///
135 /// #### `max-content-height`
136 /// The maximum content height of @scrolled_window.
137 ///
138 /// Readable | Writeable
139 ///
140 ///
141 /// #### `max-content-width`
142 /// The maximum content width of @scrolled_window.
143 ///
144 /// Readable | Writeable
145 ///
146 ///
147 /// #### `min-content-height`
148 /// The minimum content height of @scrolled_window.
149 ///
150 /// Readable | Writeable
151 ///
152 ///
153 /// #### `min-content-width`
154 /// The minimum content width of @scrolled_window.
155 ///
156 /// Readable | Writeable
157 ///
158 ///
159 /// #### `overlay-scrolling`
160 /// Whether overlay scrolling is enabled or not.
161 ///
162 /// If it is, the scrollbars are only added as traditional widgets
163 /// when a mouse is present. Otherwise, they are overlaid on top of
164 /// the content, as narrow indicators.
165 ///
166 /// Note that overlay scrolling can also be globally disabled, with
167 /// the [`gtk-overlay-scrolling`][struct@crate::Settings#gtk-overlay-scrolling] setting.
168 ///
169 /// Readable | Writeable
170 ///
171 ///
172 /// #### `propagate-natural-height`
173 /// Whether the natural height of the child should be calculated and propagated
174 /// through the scrolled window’s requested natural height.
175 ///
176 /// This is useful in cases where an attempt should be made to allocate exactly
177 /// enough space for the natural size of the child.
178 ///
179 /// Readable | Writeable
180 ///
181 ///
182 /// #### `propagate-natural-width`
183 /// Whether the natural width of the child should be calculated and propagated
184 /// through the scrolled window’s requested natural width.
185 ///
186 /// This is useful in cases where an attempt should be made to allocate exactly
187 /// enough space for the natural size of the child.
188 ///
189 /// Readable | Writeable
190 ///
191 ///
192 /// #### `vadjustment`
193 /// The [`Adjustment`][crate::Adjustment] for the vertical position.
194 ///
195 /// Readable | Writeable | Construct
196 ///
197 ///
198 /// #### `vscrollbar-policy`
199 /// When the vertical scrollbar is displayed.
200 ///
201 /// Use [`ScrolledWindow::set_policy()`][crate::ScrolledWindow::set_policy()] to set
202 /// this property.
203 ///
204 /// Readable | Writeable
205 ///
206 ///
207 /// #### `window-placement`
208 /// Where the contents are located with respect to the scrollbars.
209 ///
210 /// Readable | Writeable
211 /// <details><summary><h4>Widget</h4></summary>
212 ///
213 ///
214 /// #### `can-focus`
215 /// Whether the widget or any of its descendents can accept
216 /// the input focus.
217 ///
218 /// This property is meant to be set by widget implementations,
219 /// typically in their instance init function.
220 ///
221 /// Readable | Writeable
222 ///
223 ///
224 /// #### `can-target`
225 /// Whether the widget can receive pointer events.
226 ///
227 /// Readable | Writeable
228 ///
229 ///
230 /// #### `css-classes`
231 /// A list of css classes applied to this widget.
232 ///
233 /// Readable | Writeable
234 ///
235 ///
236 /// #### `css-name`
237 /// The name of this widget in the CSS tree.
238 ///
239 /// This property is meant to be set by widget implementations,
240 /// typically in their instance init function.
241 ///
242 /// Readable | Writeable | Construct Only
243 ///
244 ///
245 /// #### `cursor`
246 /// The cursor used by @widget.
247 ///
248 /// Readable | Writeable
249 ///
250 ///
251 /// #### `focus-on-click`
252 /// Whether the widget should grab focus when it is clicked with the mouse.
253 ///
254 /// This property is only relevant for widgets that can take focus.
255 ///
256 /// Readable | Writeable
257 ///
258 ///
259 /// #### `focusable`
260 /// Whether this widget itself will accept the input focus.
261 ///
262 /// Readable | Writeable
263 ///
264 ///
265 /// #### `halign`
266 /// How to distribute horizontal space if widget gets extra space.
267 ///
268 /// Readable | Writeable
269 ///
270 ///
271 /// #### `has-default`
272 /// Whether the widget is the default widget.
273 ///
274 /// Readable
275 ///
276 ///
277 /// #### `has-focus`
278 /// Whether the widget has the input focus.
279 ///
280 /// Readable
281 ///
282 ///
283 /// #### `has-tooltip`
284 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
285 /// signal on @widget.
286 ///
287 /// A true value indicates that @widget can have a tooltip, in this case
288 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
289 /// determine whether it will provide a tooltip or not.
290 ///
291 /// Readable | Writeable
292 ///
293 ///
294 /// #### `height-request`
295 /// Overrides for height request of the widget.
296 ///
297 /// If this is -1, the natural request will be used.
298 ///
299 /// Readable | Writeable
300 ///
301 ///
302 /// #### `hexpand`
303 /// Whether to expand horizontally.
304 ///
305 /// Readable | Writeable
306 ///
307 ///
308 /// #### `hexpand-set`
309 /// Whether to use the `hexpand` property.
310 ///
311 /// Readable | Writeable
312 ///
313 ///
314 /// #### `layout-manager`
315 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
316 /// the preferred size of the widget, and allocate its children.
317 ///
318 /// This property is meant to be set by widget implementations,
319 /// typically in their instance init function.
320 ///
321 /// Readable | Writeable
322 ///
323 ///
324 /// #### `limit-events`
325 /// Makes this widget act like a modal dialog, with respect to
326 /// event delivery.
327 ///
328 /// Global event controllers will not handle events with targets
329 /// inside the widget, unless they are set up to ignore propagation
330 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
331 ///
332 /// Readable | Writeable
333 ///
334 ///
335 /// #### `margin-bottom`
336 /// Margin on bottom side of widget.
337 ///
338 /// This property adds margin outside of the widget's normal size
339 /// request, the margin will be added in addition to the size from
340 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
341 ///
342 /// Readable | Writeable
343 ///
344 ///
345 /// #### `margin-end`
346 /// Margin on end of widget, horizontally.
347 ///
348 /// This property supports left-to-right and right-to-left text
349 /// directions.
350 ///
351 /// This property adds margin outside of the widget's normal size
352 /// request, the margin will be added in addition to the size from
353 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
354 ///
355 /// Readable | Writeable
356 ///
357 ///
358 /// #### `margin-start`
359 /// Margin on start of widget, horizontally.
360 ///
361 /// This property supports left-to-right and right-to-left text
362 /// directions.
363 ///
364 /// This property adds margin outside of the widget's normal size
365 /// request, the margin will be added in addition to the size from
366 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
367 ///
368 /// Readable | Writeable
369 ///
370 ///
371 /// #### `margin-top`
372 /// Margin on top side of widget.
373 ///
374 /// This property adds margin outside of the widget's normal size
375 /// request, the margin will be added in addition to the size from
376 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
377 ///
378 /// Readable | Writeable
379 ///
380 ///
381 /// #### `name`
382 /// The name of the widget.
383 ///
384 /// Readable | Writeable
385 ///
386 ///
387 /// #### `opacity`
388 /// The requested opacity of the widget.
389 ///
390 /// Readable | Writeable
391 ///
392 ///
393 /// #### `overflow`
394 /// How content outside the widget's content area is treated.
395 ///
396 /// This property is meant to be set by widget implementations,
397 /// typically in their instance init function.
398 ///
399 /// Readable | Writeable
400 ///
401 ///
402 /// #### `parent`
403 /// The parent widget of this widget.
404 ///
405 /// Readable
406 ///
407 ///
408 /// #### `receives-default`
409 /// Whether the widget will receive the default action when it is focused.
410 ///
411 /// Readable | Writeable
412 ///
413 ///
414 /// #### `root`
415 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
416 ///
417 /// This will be `NULL` if the widget is not contained in a root widget.
418 ///
419 /// Readable
420 ///
421 ///
422 /// #### `scale-factor`
423 /// The scale factor of the widget.
424 ///
425 /// Readable
426 ///
427 ///
428 /// #### `sensitive`
429 /// Whether the widget responds to input.
430 ///
431 /// Readable | Writeable
432 ///
433 ///
434 /// #### `tooltip-markup`
435 /// Sets the text of tooltip to be the given string, which is marked up
436 /// with Pango markup.
437 ///
438 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
439 ///
440 /// This is a convenience property which will take care of getting the
441 /// tooltip shown if the given string is not `NULL`:
442 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
443 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
444 /// the default signal handler.
445 ///
446 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
447 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
448 ///
449 /// Readable | Writeable
450 ///
451 ///
452 /// #### `tooltip-text`
453 /// Sets the text of tooltip to be the given string.
454 ///
455 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
456 ///
457 /// This is a convenience property which will take care of getting the
458 /// tooltip shown if the given string is not `NULL`:
459 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
460 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
461 /// the default signal handler.
462 ///
463 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
464 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
465 ///
466 /// Readable | Writeable
467 ///
468 ///
469 /// #### `valign`
470 /// How to distribute vertical space if widget gets extra space.
471 ///
472 /// Readable | Writeable
473 ///
474 ///
475 /// #### `vexpand`
476 /// Whether to expand vertically.
477 ///
478 /// Readable | Writeable
479 ///
480 ///
481 /// #### `vexpand-set`
482 /// Whether to use the `vexpand` property.
483 ///
484 /// Readable | Writeable
485 ///
486 ///
487 /// #### `visible`
488 /// Whether the widget is visible.
489 ///
490 /// Readable | Writeable
491 ///
492 ///
493 /// #### `width-request`
494 /// Overrides for width request of the widget.
495 ///
496 /// If this is -1, the natural request will be used.
497 ///
498 /// Readable | Writeable
499 /// </details>
500 /// <details><summary><h4>Accessible</h4></summary>
501 ///
502 ///
503 /// #### `accessible-role`
504 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
505 ///
506 /// The accessible role cannot be changed once set.
507 ///
508 /// Readable | Writeable
509 /// </details>
510 ///
511 /// ## Signals
512 ///
513 ///
514 /// #### `edge-overshot`
515 /// Emitted whenever user initiated scrolling makes the scrolled
516 /// window firmly surpass the limits defined by the adjustment
517 /// in that orientation.
518 ///
519 /// A similar behavior without edge resistance is provided by the
520 /// [`edge-reached`][struct@crate::ScrolledWindow#edge-reached] signal.
521 ///
522 /// Note: The @pos argument is LTR/RTL aware, so callers should be
523 /// aware too if intending to provide behavior on horizontal edges.
524 ///
525 ///
526 ///
527 ///
528 /// #### `edge-reached`
529 /// Emitted whenever user-initiated scrolling makes the scrolled
530 /// window exactly reach the lower or upper limits defined by the
531 /// adjustment in that orientation.
532 ///
533 /// A similar behavior with edge resistance is provided by the
534 /// [`edge-overshot`][struct@crate::ScrolledWindow#edge-overshot] signal.
535 ///
536 /// Note: The @pos argument is LTR/RTL aware, so callers should be
537 /// aware too if intending to provide behavior on horizontal edges.
538 ///
539 ///
540 ///
541 ///
542 /// #### `move-focus-out`
543 /// Emitted when focus is moved away from the scrolled window by a
544 /// keybinding.
545 ///
546 /// This is a [keybinding signal](class.SignalAction.html).
547 ///
548 /// The default bindings for this signal are
549 /// <kbd>Ctrl</kbd>+<kbd>Tab</kbd> to move forward and
550 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Tab</kbd>` to move backward.
551 ///
552 /// Action
553 ///
554 ///
555 /// #### `scroll-child`
556 /// Emitted when a keybinding that scrolls is pressed.
557 ///
558 /// This is a [keybinding signal](class.SignalAction.html).
559 ///
560 /// The horizontal or vertical adjustment is updated which triggers a
561 /// signal that the scrolled window’s child may listen to and scroll itself.
562 ///
563 /// Action
564 /// <details><summary><h4>Widget</h4></summary>
565 ///
566 ///
567 /// #### `destroy`
568 /// Signals that all holders of a reference to the widget should release
569 /// the reference that they hold.
570 ///
571 /// May result in finalization of the widget if all references are released.
572 ///
573 /// This signal is not suitable for saving widget state.
574 ///
575 ///
576 ///
577 ///
578 /// #### `direction-changed`
579 /// Emitted when the text direction of a widget changes.
580 ///
581 ///
582 ///
583 ///
584 /// #### `hide`
585 /// Emitted when @widget is hidden.
586 ///
587 ///
588 ///
589 ///
590 /// #### `keynav-failed`
591 /// Emitted if keyboard navigation fails.
592 ///
593 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
594 ///
595 ///
596 ///
597 ///
598 /// #### `map`
599 /// Emitted when @widget is going to be mapped.
600 ///
601 /// A widget is mapped when the widget is visible (which is controlled with
602 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
603 /// are also visible.
604 ///
605 /// The `::map` signal can be used to determine whether a widget will be drawn,
606 /// for instance it can resume an animation that was stopped during the
607 /// emission of [`unmap`][struct@crate::Widget#unmap].
608 ///
609 ///
610 ///
611 ///
612 /// #### `mnemonic-activate`
613 /// Emitted when a widget is activated via a mnemonic.
614 ///
615 /// The default handler for this signal activates @widget if @group_cycling
616 /// is false, or just makes @widget grab focus if @group_cycling is true.
617 ///
618 ///
619 ///
620 ///
621 /// #### `move-focus`
622 /// Emitted when the focus is moved.
623 ///
624 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
625 ///
626 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
627 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
628 ///
629 /// Action
630 ///
631 ///
632 /// #### `query-tooltip`
633 /// Emitted when the widget’s tooltip is about to be shown.
634 ///
635 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
636 /// is true and the hover timeout has expired with the cursor hovering
637 /// above @widget; or emitted when @widget got focus in keyboard mode.
638 ///
639 /// Using the given coordinates, the signal handler should determine
640 /// whether a tooltip should be shown for @widget. If this is the case
641 /// true should be returned, false otherwise. Note that if @keyboard_mode
642 /// is true, the values of @x and @y are undefined and should not be used.
643 ///
644 /// The signal handler is free to manipulate @tooltip with the therefore
645 /// destined function calls.
646 ///
647 ///
648 ///
649 ///
650 /// #### `realize`
651 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
652 ///
653 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
654 /// or the widget has been mapped (that is, it is going to be drawn).
655 ///
656 ///
657 ///
658 ///
659 /// #### `show`
660 /// Emitted when @widget is shown.
661 ///
662 ///
663 ///
664 ///
665 /// #### `state-flags-changed`
666 /// Emitted when the widget state changes.
667 ///
668 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
669 ///
670 ///
671 ///
672 ///
673 /// #### `unmap`
674 /// Emitted when @widget is going to be unmapped.
675 ///
676 /// A widget is unmapped when either it or any of its parents up to the
677 /// toplevel widget have been set as hidden.
678 ///
679 /// As `::unmap` indicates that a widget will not be shown any longer,
680 /// it can be used to, for example, stop an animation on the widget.
681 ///
682 ///
683 ///
684 ///
685 /// #### `unrealize`
686 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
687 ///
688 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
689 /// or the widget has been unmapped (that is, it is going to be hidden).
690 ///
691 ///
692 /// </details>
693 ///
694 /// # Implements
695 ///
696 /// [`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]
697 #[doc(alias = "GtkScrolledWindow")]
698 pub struct ScrolledWindow(Object<ffi::GtkScrolledWindow>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
699
700 match fn {
701 type_ => || ffi::gtk_scrolled_window_get_type(),
702 }
703}
704
705impl ScrolledWindow {
706 /// Creates a new scrolled window.
707 ///
708 /// # Returns
709 ///
710 /// a new scrolled window
711 #[doc(alias = "gtk_scrolled_window_new")]
712 pub fn new() -> ScrolledWindow {
713 assert_initialized_main_thread!();
714 unsafe { Widget::from_glib_none(ffi::gtk_scrolled_window_new()).unsafe_cast() }
715 }
716
717 // rustdoc-stripper-ignore-next
718 /// Creates a new builder-pattern struct instance to construct [`ScrolledWindow`] objects.
719 ///
720 /// This method returns an instance of [`ScrolledWindowBuilder`](crate::builders::ScrolledWindowBuilder) which can be used to create [`ScrolledWindow`] objects.
721 pub fn builder() -> ScrolledWindowBuilder {
722 ScrolledWindowBuilder::new()
723 }
724
725 /// Gets the child widget of @self.
726 ///
727 /// If the scrolled window automatically added a [`Viewport`][crate::Viewport], this
728 /// function will return the viewport widget, and you can retrieve its child
729 /// using [`Viewport::child()`][crate::Viewport::child()].
730 ///
731 /// # Returns
732 ///
733 /// the child widget of @self
734 #[doc(alias = "gtk_scrolled_window_get_child")]
735 #[doc(alias = "get_child")]
736 pub fn child(&self) -> Option<Widget> {
737 unsafe { from_glib_none(ffi::gtk_scrolled_window_get_child(self.to_glib_none().0)) }
738 }
739
740 /// Returns the horizontal scrollbar’s adjustment.
741 ///
742 /// This is the adjustment used to connect the horizontal scrollbar
743 /// to the child widget’s horizontal scroll functionality.
744 ///
745 /// # Returns
746 ///
747 /// the horizontal [`Adjustment`][crate::Adjustment]
748 #[doc(alias = "gtk_scrolled_window_get_hadjustment")]
749 #[doc(alias = "get_hadjustment")]
750 pub fn hadjustment(&self) -> Adjustment {
751 unsafe {
752 from_glib_none(ffi::gtk_scrolled_window_get_hadjustment(
753 self.to_glib_none().0,
754 ))
755 }
756 }
757
758 /// Gets whether the scrolled window draws a frame.
759 ///
760 /// # Returns
761 ///
762 /// [`true`] if the @self has a frame
763 #[doc(alias = "gtk_scrolled_window_get_has_frame")]
764 #[doc(alias = "get_has_frame")]
765 #[doc(alias = "has-frame")]
766 pub fn has_frame(&self) -> bool {
767 unsafe {
768 from_glib(ffi::gtk_scrolled_window_get_has_frame(
769 self.to_glib_none().0,
770 ))
771 }
772 }
773
774 /// Returns the horizontal scrollbar of @self.
775 ///
776 /// # Returns
777 ///
778 /// the horizontal scrollbar of the scrolled window.
779 #[doc(alias = "gtk_scrolled_window_get_hscrollbar")]
780 #[doc(alias = "get_hscrollbar")]
781 pub fn hscrollbar(&self) -> Widget {
782 unsafe {
783 from_glib_none(ffi::gtk_scrolled_window_get_hscrollbar(
784 self.to_glib_none().0,
785 ))
786 }
787 }
788
789 /// Returns the specified kinetic scrolling behavior.
790 ///
791 /// # Returns
792 ///
793 /// the scrolling behavior flags.
794 #[doc(alias = "gtk_scrolled_window_get_kinetic_scrolling")]
795 #[doc(alias = "get_kinetic_scrolling")]
796 #[doc(alias = "kinetic-scrolling")]
797 pub fn is_kinetic_scrolling(&self) -> bool {
798 unsafe {
799 from_glib(ffi::gtk_scrolled_window_get_kinetic_scrolling(
800 self.to_glib_none().0,
801 ))
802 }
803 }
804
805 /// Returns the maximum content height set.
806 ///
807 /// # Returns
808 ///
809 /// the maximum content height, or -1
810 #[doc(alias = "gtk_scrolled_window_get_max_content_height")]
811 #[doc(alias = "get_max_content_height")]
812 #[doc(alias = "max-content-height")]
813 pub fn max_content_height(&self) -> i32 {
814 unsafe { ffi::gtk_scrolled_window_get_max_content_height(self.to_glib_none().0) }
815 }
816
817 /// Returns the maximum content width set.
818 ///
819 /// # Returns
820 ///
821 /// the maximum content width, or -1
822 #[doc(alias = "gtk_scrolled_window_get_max_content_width")]
823 #[doc(alias = "get_max_content_width")]
824 #[doc(alias = "max-content-width")]
825 pub fn max_content_width(&self) -> i32 {
826 unsafe { ffi::gtk_scrolled_window_get_max_content_width(self.to_glib_none().0) }
827 }
828
829 /// Gets the minimal content height of @self.
830 ///
831 /// # Returns
832 ///
833 /// the minimal content height
834 #[doc(alias = "gtk_scrolled_window_get_min_content_height")]
835 #[doc(alias = "get_min_content_height")]
836 #[doc(alias = "min-content-height")]
837 pub fn min_content_height(&self) -> i32 {
838 unsafe { ffi::gtk_scrolled_window_get_min_content_height(self.to_glib_none().0) }
839 }
840
841 /// Gets the minimum content width of @self.
842 ///
843 /// # Returns
844 ///
845 /// the minimum content width
846 #[doc(alias = "gtk_scrolled_window_get_min_content_width")]
847 #[doc(alias = "get_min_content_width")]
848 #[doc(alias = "min-content-width")]
849 pub fn min_content_width(&self) -> i32 {
850 unsafe { ffi::gtk_scrolled_window_get_min_content_width(self.to_glib_none().0) }
851 }
852
853 /// Returns whether overlay scrolling is enabled for this scrolled window.
854 ///
855 /// # Returns
856 ///
857 /// [`true`] if overlay scrolling is enabled
858 #[doc(alias = "gtk_scrolled_window_get_overlay_scrolling")]
859 #[doc(alias = "get_overlay_scrolling")]
860 #[doc(alias = "overlay-scrolling")]
861 pub fn is_overlay_scrolling(&self) -> bool {
862 unsafe {
863 from_glib(ffi::gtk_scrolled_window_get_overlay_scrolling(
864 self.to_glib_none().0,
865 ))
866 }
867 }
868
869 /// Gets the placement of the contents with respect to the scrollbars.
870 ///
871 /// # Returns
872 ///
873 /// the current placement value.
874 #[doc(alias = "gtk_scrolled_window_get_placement")]
875 #[doc(alias = "get_placement")]
876 #[doc(alias = "window-placement")]
877 pub fn placement(&self) -> CornerType {
878 unsafe {
879 from_glib(ffi::gtk_scrolled_window_get_placement(
880 self.to_glib_none().0,
881 ))
882 }
883 }
884
885 /// Retrieves the current policy values for the horizontal and vertical
886 /// scrollbars.
887 ///
888 /// See [`set_policy()`][Self::set_policy()].
889 ///
890 /// # Returns
891 ///
892 ///
893 /// ## `hscrollbar_policy`
894 /// location to store the policy
895 /// for the horizontal scrollbar
896 ///
897 /// ## `vscrollbar_policy`
898 /// location to store the policy
899 /// for the vertical scrollbar
900 #[doc(alias = "gtk_scrolled_window_get_policy")]
901 #[doc(alias = "get_policy")]
902 pub fn policy(&self) -> (PolicyType, PolicyType) {
903 unsafe {
904 let mut hscrollbar_policy = std::mem::MaybeUninit::uninit();
905 let mut vscrollbar_policy = std::mem::MaybeUninit::uninit();
906 ffi::gtk_scrolled_window_get_policy(
907 self.to_glib_none().0,
908 hscrollbar_policy.as_mut_ptr(),
909 vscrollbar_policy.as_mut_ptr(),
910 );
911 (
912 from_glib(hscrollbar_policy.assume_init()),
913 from_glib(vscrollbar_policy.assume_init()),
914 )
915 }
916 }
917
918 /// Reports whether the natural height of the child will be calculated
919 /// and propagated through the scrolled window’s requested natural height.
920 ///
921 /// # Returns
922 ///
923 /// whether natural height propagation is enabled.
924 #[doc(alias = "gtk_scrolled_window_get_propagate_natural_height")]
925 #[doc(alias = "get_propagate_natural_height")]
926 #[doc(alias = "propagate-natural-height")]
927 pub fn propagates_natural_height(&self) -> bool {
928 unsafe {
929 from_glib(ffi::gtk_scrolled_window_get_propagate_natural_height(
930 self.to_glib_none().0,
931 ))
932 }
933 }
934
935 /// Reports whether the natural width of the child will be calculated
936 /// and propagated through the scrolled window’s requested natural width.
937 ///
938 /// # Returns
939 ///
940 /// whether natural width propagation is enabled.
941 #[doc(alias = "gtk_scrolled_window_get_propagate_natural_width")]
942 #[doc(alias = "get_propagate_natural_width")]
943 #[doc(alias = "propagate-natural-width")]
944 pub fn propagates_natural_width(&self) -> bool {
945 unsafe {
946 from_glib(ffi::gtk_scrolled_window_get_propagate_natural_width(
947 self.to_glib_none().0,
948 ))
949 }
950 }
951
952 /// Returns the vertical scrollbar’s adjustment.
953 ///
954 /// This is the adjustment used to connect the vertical
955 /// scrollbar to the child widget’s vertical scroll functionality.
956 ///
957 /// # Returns
958 ///
959 /// the vertical [`Adjustment`][crate::Adjustment]
960 #[doc(alias = "gtk_scrolled_window_get_vadjustment")]
961 #[doc(alias = "get_vadjustment")]
962 pub fn vadjustment(&self) -> Adjustment {
963 unsafe {
964 from_glib_none(ffi::gtk_scrolled_window_get_vadjustment(
965 self.to_glib_none().0,
966 ))
967 }
968 }
969
970 /// Returns the vertical scrollbar of @self.
971 ///
972 /// # Returns
973 ///
974 /// the vertical scrollbar of the scrolled window.
975 #[doc(alias = "gtk_scrolled_window_get_vscrollbar")]
976 #[doc(alias = "get_vscrollbar")]
977 pub fn vscrollbar(&self) -> Widget {
978 unsafe {
979 from_glib_none(ffi::gtk_scrolled_window_get_vscrollbar(
980 self.to_glib_none().0,
981 ))
982 }
983 }
984
985 /// Sets the child widget of @self.
986 ///
987 /// If @child does not implement the [`Scrollable`][crate::Scrollable] interface,
988 /// the scrolled window will add @child to a [`Viewport`][crate::Viewport] instance
989 /// and then add the viewport as its child widget.
990 /// ## `child`
991 /// the child widget
992 #[doc(alias = "gtk_scrolled_window_set_child")]
993 #[doc(alias = "child")]
994 pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
995 unsafe {
996 ffi::gtk_scrolled_window_set_child(
997 self.to_glib_none().0,
998 child.map(|p| p.as_ref()).to_glib_none().0,
999 );
1000 }
1001 }
1002
1003 /// Sets the [`Adjustment`][crate::Adjustment] for the horizontal scrollbar.
1004 /// ## `hadjustment`
1005 /// the [`Adjustment`][crate::Adjustment] to use, or [`None`] to create a new one
1006 #[doc(alias = "gtk_scrolled_window_set_hadjustment")]
1007 #[doc(alias = "hadjustment")]
1008 pub fn set_hadjustment(&self, hadjustment: Option<&impl IsA<Adjustment>>) {
1009 unsafe {
1010 ffi::gtk_scrolled_window_set_hadjustment(
1011 self.to_glib_none().0,
1012 hadjustment.map(|p| p.as_ref()).to_glib_none().0,
1013 );
1014 }
1015 }
1016
1017 /// Changes the frame drawn around the contents of @self.
1018 /// ## `has_frame`
1019 /// whether to draw a frame around scrolled window contents
1020 #[doc(alias = "gtk_scrolled_window_set_has_frame")]
1021 #[doc(alias = "has-frame")]
1022 pub fn set_has_frame(&self, has_frame: bool) {
1023 unsafe {
1024 ffi::gtk_scrolled_window_set_has_frame(self.to_glib_none().0, has_frame.into_glib());
1025 }
1026 }
1027
1028 /// Turns kinetic scrolling on or off.
1029 ///
1030 /// Kinetic scrolling only applies to devices with source
1031 /// `GDK_SOURCE_TOUCHSCREEN`.
1032 /// ## `kinetic_scrolling`
1033 /// [`true`] to enable kinetic scrolling
1034 #[doc(alias = "gtk_scrolled_window_set_kinetic_scrolling")]
1035 #[doc(alias = "kinetic-scrolling")]
1036 pub fn set_kinetic_scrolling(&self, kinetic_scrolling: bool) {
1037 unsafe {
1038 ffi::gtk_scrolled_window_set_kinetic_scrolling(
1039 self.to_glib_none().0,
1040 kinetic_scrolling.into_glib(),
1041 );
1042 }
1043 }
1044
1045 /// Sets the maximum height that @self should keep visible.
1046 ///
1047 /// The @self will grow up to this height before it starts
1048 /// scrolling the content.
1049 ///
1050 /// It is a programming error to set the maximum content height to a value
1051 /// smaller than [`min-content-height`][struct@crate::ScrolledWindow#min-content-height].
1052 /// ## `height`
1053 /// the maximum content height
1054 #[doc(alias = "gtk_scrolled_window_set_max_content_height")]
1055 #[doc(alias = "max-content-height")]
1056 pub fn set_max_content_height(&self, height: i32) {
1057 unsafe {
1058 ffi::gtk_scrolled_window_set_max_content_height(self.to_glib_none().0, height);
1059 }
1060 }
1061
1062 /// Sets the maximum width that @self should keep visible.
1063 ///
1064 /// The @self will grow up to this width before it starts
1065 /// scrolling the content.
1066 ///
1067 /// It is a programming error to set the maximum content width to a
1068 /// value smaller than [`min-content-width`][struct@crate::ScrolledWindow#min-content-width].
1069 /// ## `width`
1070 /// the maximum content width
1071 #[doc(alias = "gtk_scrolled_window_set_max_content_width")]
1072 #[doc(alias = "max-content-width")]
1073 pub fn set_max_content_width(&self, width: i32) {
1074 unsafe {
1075 ffi::gtk_scrolled_window_set_max_content_width(self.to_glib_none().0, width);
1076 }
1077 }
1078
1079 /// Sets the minimum height that @self should keep visible.
1080 ///
1081 /// Note that this can and (usually will) be smaller than the minimum
1082 /// size of the content.
1083 ///
1084 /// It is a programming error to set the minimum content height to a
1085 /// value greater than [`max-content-height`][struct@crate::ScrolledWindow#max-content-height].
1086 /// ## `height`
1087 /// the minimal content height
1088 #[doc(alias = "gtk_scrolled_window_set_min_content_height")]
1089 #[doc(alias = "min-content-height")]
1090 pub fn set_min_content_height(&self, height: i32) {
1091 unsafe {
1092 ffi::gtk_scrolled_window_set_min_content_height(self.to_glib_none().0, height);
1093 }
1094 }
1095
1096 /// Sets the minimum width that @self should keep visible.
1097 ///
1098 /// Note that this can and (usually will) be smaller than the minimum
1099 /// size of the content.
1100 ///
1101 /// It is a programming error to set the minimum content width to a
1102 /// value greater than [`max-content-width`][struct@crate::ScrolledWindow#max-content-width].
1103 /// ## `width`
1104 /// the minimal content width
1105 #[doc(alias = "gtk_scrolled_window_set_min_content_width")]
1106 #[doc(alias = "min-content-width")]
1107 pub fn set_min_content_width(&self, width: i32) {
1108 unsafe {
1109 ffi::gtk_scrolled_window_set_min_content_width(self.to_glib_none().0, width);
1110 }
1111 }
1112
1113 /// Enables or disables overlay scrolling for this scrolled window.
1114 /// ## `overlay_scrolling`
1115 /// whether to enable overlay scrolling
1116 #[doc(alias = "gtk_scrolled_window_set_overlay_scrolling")]
1117 #[doc(alias = "overlay-scrolling")]
1118 pub fn set_overlay_scrolling(&self, overlay_scrolling: bool) {
1119 unsafe {
1120 ffi::gtk_scrolled_window_set_overlay_scrolling(
1121 self.to_glib_none().0,
1122 overlay_scrolling.into_glib(),
1123 );
1124 }
1125 }
1126
1127 /// Sets the placement of the contents with respect to the scrollbars
1128 /// for the scrolled window.
1129 ///
1130 /// The default is [`CornerType::TopLeft`][crate::CornerType::TopLeft], meaning the child is
1131 /// in the top left, with the scrollbars underneath and to the right.
1132 /// Other values in [`CornerType`][crate::CornerType] are [`CornerType::TopRight`][crate::CornerType::TopRight],
1133 /// [`CornerType::BottomLeft`][crate::CornerType::BottomLeft], and [`CornerType::BottomRight`][crate::CornerType::BottomRight].
1134 ///
1135 /// See also [`placement()`][Self::placement()] and
1136 /// [`unset_placement()`][Self::unset_placement()].
1137 /// ## `window_placement`
1138 /// position of the child window
1139 #[doc(alias = "gtk_scrolled_window_set_placement")]
1140 #[doc(alias = "window-placement")]
1141 pub fn set_placement(&self, window_placement: CornerType) {
1142 unsafe {
1143 ffi::gtk_scrolled_window_set_placement(
1144 self.to_glib_none().0,
1145 window_placement.into_glib(),
1146 );
1147 }
1148 }
1149
1150 /// Sets the scrollbar policy for the horizontal and vertical scrollbars.
1151 ///
1152 /// The policy determines when the scrollbar should appear; it is a value
1153 /// from the [`PolicyType`][crate::PolicyType] enumeration. If [`PolicyType::Always`][crate::PolicyType::Always], the
1154 /// scrollbar is always present; if [`PolicyType::Never`][crate::PolicyType::Never], the scrollbar is
1155 /// never present; if [`PolicyType::Automatic`][crate::PolicyType::Automatic], the scrollbar is present only
1156 /// if needed (that is, if the slider part of the bar would be smaller
1157 /// than the trough — the display is larger than the page size).
1158 /// ## `hscrollbar_policy`
1159 /// policy for horizontal bar
1160 /// ## `vscrollbar_policy`
1161 /// policy for vertical bar
1162 #[doc(alias = "gtk_scrolled_window_set_policy")]
1163 pub fn set_policy(&self, hscrollbar_policy: PolicyType, vscrollbar_policy: PolicyType) {
1164 unsafe {
1165 ffi::gtk_scrolled_window_set_policy(
1166 self.to_glib_none().0,
1167 hscrollbar_policy.into_glib(),
1168 vscrollbar_policy.into_glib(),
1169 );
1170 }
1171 }
1172
1173 /// Sets whether the natural height of the child should be calculated
1174 /// and propagated through the scrolled window’s requested natural height.
1175 /// ## `propagate`
1176 /// whether to propagate natural height
1177 #[doc(alias = "gtk_scrolled_window_set_propagate_natural_height")]
1178 #[doc(alias = "propagate-natural-height")]
1179 pub fn set_propagate_natural_height(&self, propagate: bool) {
1180 unsafe {
1181 ffi::gtk_scrolled_window_set_propagate_natural_height(
1182 self.to_glib_none().0,
1183 propagate.into_glib(),
1184 );
1185 }
1186 }
1187
1188 /// Sets whether the natural width of the child should be calculated
1189 /// and propagated through the scrolled window’s requested natural width.
1190 /// ## `propagate`
1191 /// whether to propagate natural width
1192 #[doc(alias = "gtk_scrolled_window_set_propagate_natural_width")]
1193 #[doc(alias = "propagate-natural-width")]
1194 pub fn set_propagate_natural_width(&self, propagate: bool) {
1195 unsafe {
1196 ffi::gtk_scrolled_window_set_propagate_natural_width(
1197 self.to_glib_none().0,
1198 propagate.into_glib(),
1199 );
1200 }
1201 }
1202
1203 /// Sets the [`Adjustment`][crate::Adjustment] for the vertical scrollbar.
1204 /// ## `vadjustment`
1205 /// the [`Adjustment`][crate::Adjustment] to use, or [`None`] to create a new one
1206 #[doc(alias = "gtk_scrolled_window_set_vadjustment")]
1207 #[doc(alias = "vadjustment")]
1208 pub fn set_vadjustment(&self, vadjustment: Option<&impl IsA<Adjustment>>) {
1209 unsafe {
1210 ffi::gtk_scrolled_window_set_vadjustment(
1211 self.to_glib_none().0,
1212 vadjustment.map(|p| p.as_ref()).to_glib_none().0,
1213 );
1214 }
1215 }
1216
1217 /// Unsets the placement of the contents with respect to the scrollbars.
1218 ///
1219 /// If no window placement is set for a scrolled window,
1220 /// it defaults to [`CornerType::TopLeft`][crate::CornerType::TopLeft].
1221 #[doc(alias = "gtk_scrolled_window_unset_placement")]
1222 pub fn unset_placement(&self) {
1223 unsafe {
1224 ffi::gtk_scrolled_window_unset_placement(self.to_glib_none().0);
1225 }
1226 }
1227
1228 /// When the horizontal scrollbar is displayed.
1229 ///
1230 /// Use [`set_policy()`][Self::set_policy()] to set
1231 /// this property.
1232 #[doc(alias = "hscrollbar-policy")]
1233 pub fn hscrollbar_policy(&self) -> PolicyType {
1234 ObjectExt::property(self, "hscrollbar-policy")
1235 }
1236
1237 /// When the horizontal scrollbar is displayed.
1238 ///
1239 /// Use [`set_policy()`][Self::set_policy()] to set
1240 /// this property.
1241 #[doc(alias = "hscrollbar-policy")]
1242 pub fn set_hscrollbar_policy(&self, hscrollbar_policy: PolicyType) {
1243 ObjectExt::set_property(self, "hscrollbar-policy", hscrollbar_policy)
1244 }
1245
1246 /// When the vertical scrollbar is displayed.
1247 ///
1248 /// Use [`set_policy()`][Self::set_policy()] to set
1249 /// this property.
1250 #[doc(alias = "vscrollbar-policy")]
1251 pub fn vscrollbar_policy(&self) -> PolicyType {
1252 ObjectExt::property(self, "vscrollbar-policy")
1253 }
1254
1255 /// When the vertical scrollbar is displayed.
1256 ///
1257 /// Use [`set_policy()`][Self::set_policy()] to set
1258 /// this property.
1259 #[doc(alias = "vscrollbar-policy")]
1260 pub fn set_vscrollbar_policy(&self, vscrollbar_policy: PolicyType) {
1261 ObjectExt::set_property(self, "vscrollbar-policy", vscrollbar_policy)
1262 }
1263
1264 /// Emitted whenever user initiated scrolling makes the scrolled
1265 /// window firmly surpass the limits defined by the adjustment
1266 /// in that orientation.
1267 ///
1268 /// A similar behavior without edge resistance is provided by the
1269 /// [`edge-reached`][struct@crate::ScrolledWindow#edge-reached] signal.
1270 ///
1271 /// Note: The @pos argument is LTR/RTL aware, so callers should be
1272 /// aware too if intending to provide behavior on horizontal edges.
1273 /// ## `pos`
1274 /// edge side that was hit
1275 #[doc(alias = "edge-overshot")]
1276 pub fn connect_edge_overshot<F: Fn(&Self, PositionType) + 'static>(
1277 &self,
1278 f: F,
1279 ) -> SignalHandlerId {
1280 unsafe extern "C" fn edge_overshot_trampoline<
1281 F: Fn(&ScrolledWindow, PositionType) + 'static,
1282 >(
1283 this: *mut ffi::GtkScrolledWindow,
1284 pos: ffi::GtkPositionType,
1285 f: glib::ffi::gpointer,
1286 ) {
1287 let f: &F = &*(f as *const F);
1288 f(&from_glib_borrow(this), from_glib(pos))
1289 }
1290 unsafe {
1291 let f: Box_<F> = Box_::new(f);
1292 connect_raw(
1293 self.as_ptr() as *mut _,
1294 b"edge-overshot\0".as_ptr() as *const _,
1295 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1296 edge_overshot_trampoline::<F> as *const (),
1297 )),
1298 Box_::into_raw(f),
1299 )
1300 }
1301 }
1302
1303 /// Emitted whenever user-initiated scrolling makes the scrolled
1304 /// window exactly reach the lower or upper limits defined by the
1305 /// adjustment in that orientation.
1306 ///
1307 /// A similar behavior with edge resistance is provided by the
1308 /// [`edge-overshot`][struct@crate::ScrolledWindow#edge-overshot] signal.
1309 ///
1310 /// Note: The @pos argument is LTR/RTL aware, so callers should be
1311 /// aware too if intending to provide behavior on horizontal edges.
1312 /// ## `pos`
1313 /// edge side that was reached
1314 #[doc(alias = "edge-reached")]
1315 pub fn connect_edge_reached<F: Fn(&Self, PositionType) + 'static>(
1316 &self,
1317 f: F,
1318 ) -> SignalHandlerId {
1319 unsafe extern "C" fn edge_reached_trampoline<
1320 F: Fn(&ScrolledWindow, PositionType) + 'static,
1321 >(
1322 this: *mut ffi::GtkScrolledWindow,
1323 pos: ffi::GtkPositionType,
1324 f: glib::ffi::gpointer,
1325 ) {
1326 let f: &F = &*(f as *const F);
1327 f(&from_glib_borrow(this), from_glib(pos))
1328 }
1329 unsafe {
1330 let f: Box_<F> = Box_::new(f);
1331 connect_raw(
1332 self.as_ptr() as *mut _,
1333 b"edge-reached\0".as_ptr() as *const _,
1334 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1335 edge_reached_trampoline::<F> as *const (),
1336 )),
1337 Box_::into_raw(f),
1338 )
1339 }
1340 }
1341
1342 /// Emitted when focus is moved away from the scrolled window by a
1343 /// keybinding.
1344 ///
1345 /// This is a [keybinding signal](class.SignalAction.html).
1346 ///
1347 /// The default bindings for this signal are
1348 /// <kbd>Ctrl</kbd>+<kbd>Tab</kbd> to move forward and
1349 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Tab</kbd>` to move backward.
1350 /// ## `direction_type`
1351 /// either [`DirectionType::TabForward`][crate::DirectionType::TabForward] or
1352 /// [`DirectionType::TabBackward`][crate::DirectionType::TabBackward]
1353 #[doc(alias = "move-focus-out")]
1354 pub fn connect_move_focus_out<F: Fn(&Self, DirectionType) + 'static>(
1355 &self,
1356 f: F,
1357 ) -> SignalHandlerId {
1358 unsafe extern "C" fn move_focus_out_trampoline<
1359 F: Fn(&ScrolledWindow, DirectionType) + 'static,
1360 >(
1361 this: *mut ffi::GtkScrolledWindow,
1362 direction_type: ffi::GtkDirectionType,
1363 f: glib::ffi::gpointer,
1364 ) {
1365 let f: &F = &*(f as *const F);
1366 f(&from_glib_borrow(this), from_glib(direction_type))
1367 }
1368 unsafe {
1369 let f: Box_<F> = Box_::new(f);
1370 connect_raw(
1371 self.as_ptr() as *mut _,
1372 b"move-focus-out\0".as_ptr() as *const _,
1373 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1374 move_focus_out_trampoline::<F> as *const (),
1375 )),
1376 Box_::into_raw(f),
1377 )
1378 }
1379 }
1380
1381 pub fn emit_move_focus_out(&self, direction_type: DirectionType) {
1382 self.emit_by_name::<()>("move-focus-out", &[&direction_type]);
1383 }
1384
1385 /// Emitted when a keybinding that scrolls is pressed.
1386 ///
1387 /// This is a [keybinding signal](class.SignalAction.html).
1388 ///
1389 /// The horizontal or vertical adjustment is updated which triggers a
1390 /// signal that the scrolled window’s child may listen to and scroll itself.
1391 /// ## `scroll`
1392 /// a [`ScrollType`][crate::ScrollType] describing how much to scroll
1393 /// ## `horizontal`
1394 /// whether the keybinding scrolls the child
1395 /// horizontally or not
1396 ///
1397 /// # Returns
1398 ///
1399 /// whether the scroll happened
1400 #[doc(alias = "scroll-child")]
1401 pub fn connect_scroll_child<F: Fn(&Self, ScrollType, bool) -> bool + 'static>(
1402 &self,
1403 f: F,
1404 ) -> SignalHandlerId {
1405 unsafe extern "C" fn scroll_child_trampoline<
1406 F: Fn(&ScrolledWindow, ScrollType, bool) -> bool + 'static,
1407 >(
1408 this: *mut ffi::GtkScrolledWindow,
1409 scroll: ffi::GtkScrollType,
1410 horizontal: glib::ffi::gboolean,
1411 f: glib::ffi::gpointer,
1412 ) -> glib::ffi::gboolean {
1413 let f: &F = &*(f as *const F);
1414 f(
1415 &from_glib_borrow(this),
1416 from_glib(scroll),
1417 from_glib(horizontal),
1418 )
1419 .into_glib()
1420 }
1421 unsafe {
1422 let f: Box_<F> = Box_::new(f);
1423 connect_raw(
1424 self.as_ptr() as *mut _,
1425 b"scroll-child\0".as_ptr() as *const _,
1426 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1427 scroll_child_trampoline::<F> as *const (),
1428 )),
1429 Box_::into_raw(f),
1430 )
1431 }
1432 }
1433
1434 pub fn emit_scroll_child(&self, scroll: ScrollType, horizontal: bool) -> bool {
1435 self.emit_by_name("scroll-child", &[&scroll, &horizontal])
1436 }
1437
1438 #[doc(alias = "child")]
1439 pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1440 unsafe extern "C" fn notify_child_trampoline<F: Fn(&ScrolledWindow) + 'static>(
1441 this: *mut ffi::GtkScrolledWindow,
1442 _param_spec: glib::ffi::gpointer,
1443 f: glib::ffi::gpointer,
1444 ) {
1445 let f: &F = &*(f as *const F);
1446 f(&from_glib_borrow(this))
1447 }
1448 unsafe {
1449 let f: Box_<F> = Box_::new(f);
1450 connect_raw(
1451 self.as_ptr() as *mut _,
1452 b"notify::child\0".as_ptr() as *const _,
1453 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1454 notify_child_trampoline::<F> as *const (),
1455 )),
1456 Box_::into_raw(f),
1457 )
1458 }
1459 }
1460
1461 #[doc(alias = "hadjustment")]
1462 pub fn connect_hadjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1463 unsafe extern "C" fn notify_hadjustment_trampoline<F: Fn(&ScrolledWindow) + 'static>(
1464 this: *mut ffi::GtkScrolledWindow,
1465 _param_spec: glib::ffi::gpointer,
1466 f: glib::ffi::gpointer,
1467 ) {
1468 let f: &F = &*(f as *const F);
1469 f(&from_glib_borrow(this))
1470 }
1471 unsafe {
1472 let f: Box_<F> = Box_::new(f);
1473 connect_raw(
1474 self.as_ptr() as *mut _,
1475 b"notify::hadjustment\0".as_ptr() as *const _,
1476 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1477 notify_hadjustment_trampoline::<F> as *const (),
1478 )),
1479 Box_::into_raw(f),
1480 )
1481 }
1482 }
1483
1484 #[doc(alias = "has-frame")]
1485 pub fn connect_has_frame_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1486 unsafe extern "C" fn notify_has_frame_trampoline<F: Fn(&ScrolledWindow) + 'static>(
1487 this: *mut ffi::GtkScrolledWindow,
1488 _param_spec: glib::ffi::gpointer,
1489 f: glib::ffi::gpointer,
1490 ) {
1491 let f: &F = &*(f as *const F);
1492 f(&from_glib_borrow(this))
1493 }
1494 unsafe {
1495 let f: Box_<F> = Box_::new(f);
1496 connect_raw(
1497 self.as_ptr() as *mut _,
1498 b"notify::has-frame\0".as_ptr() as *const _,
1499 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1500 notify_has_frame_trampoline::<F> as *const (),
1501 )),
1502 Box_::into_raw(f),
1503 )
1504 }
1505 }
1506
1507 #[doc(alias = "hscrollbar-policy")]
1508 pub fn connect_hscrollbar_policy_notify<F: Fn(&Self) + 'static>(
1509 &self,
1510 f: F,
1511 ) -> SignalHandlerId {
1512 unsafe extern "C" fn notify_hscrollbar_policy_trampoline<
1513 F: Fn(&ScrolledWindow) + 'static,
1514 >(
1515 this: *mut ffi::GtkScrolledWindow,
1516 _param_spec: glib::ffi::gpointer,
1517 f: glib::ffi::gpointer,
1518 ) {
1519 let f: &F = &*(f as *const F);
1520 f(&from_glib_borrow(this))
1521 }
1522 unsafe {
1523 let f: Box_<F> = Box_::new(f);
1524 connect_raw(
1525 self.as_ptr() as *mut _,
1526 b"notify::hscrollbar-policy\0".as_ptr() as *const _,
1527 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1528 notify_hscrollbar_policy_trampoline::<F> as *const (),
1529 )),
1530 Box_::into_raw(f),
1531 )
1532 }
1533 }
1534
1535 #[doc(alias = "kinetic-scrolling")]
1536 pub fn connect_kinetic_scrolling_notify<F: Fn(&Self) + 'static>(
1537 &self,
1538 f: F,
1539 ) -> SignalHandlerId {
1540 unsafe extern "C" fn notify_kinetic_scrolling_trampoline<
1541 F: Fn(&ScrolledWindow) + 'static,
1542 >(
1543 this: *mut ffi::GtkScrolledWindow,
1544 _param_spec: glib::ffi::gpointer,
1545 f: glib::ffi::gpointer,
1546 ) {
1547 let f: &F = &*(f as *const F);
1548 f(&from_glib_borrow(this))
1549 }
1550 unsafe {
1551 let f: Box_<F> = Box_::new(f);
1552 connect_raw(
1553 self.as_ptr() as *mut _,
1554 b"notify::kinetic-scrolling\0".as_ptr() as *const _,
1555 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1556 notify_kinetic_scrolling_trampoline::<F> as *const (),
1557 )),
1558 Box_::into_raw(f),
1559 )
1560 }
1561 }
1562
1563 #[doc(alias = "max-content-height")]
1564 pub fn connect_max_content_height_notify<F: Fn(&Self) + 'static>(
1565 &self,
1566 f: F,
1567 ) -> SignalHandlerId {
1568 unsafe extern "C" fn notify_max_content_height_trampoline<
1569 F: Fn(&ScrolledWindow) + 'static,
1570 >(
1571 this: *mut ffi::GtkScrolledWindow,
1572 _param_spec: glib::ffi::gpointer,
1573 f: glib::ffi::gpointer,
1574 ) {
1575 let f: &F = &*(f as *const F);
1576 f(&from_glib_borrow(this))
1577 }
1578 unsafe {
1579 let f: Box_<F> = Box_::new(f);
1580 connect_raw(
1581 self.as_ptr() as *mut _,
1582 b"notify::max-content-height\0".as_ptr() as *const _,
1583 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1584 notify_max_content_height_trampoline::<F> as *const (),
1585 )),
1586 Box_::into_raw(f),
1587 )
1588 }
1589 }
1590
1591 #[doc(alias = "max-content-width")]
1592 pub fn connect_max_content_width_notify<F: Fn(&Self) + 'static>(
1593 &self,
1594 f: F,
1595 ) -> SignalHandlerId {
1596 unsafe extern "C" fn notify_max_content_width_trampoline<
1597 F: Fn(&ScrolledWindow) + 'static,
1598 >(
1599 this: *mut ffi::GtkScrolledWindow,
1600 _param_spec: glib::ffi::gpointer,
1601 f: glib::ffi::gpointer,
1602 ) {
1603 let f: &F = &*(f as *const F);
1604 f(&from_glib_borrow(this))
1605 }
1606 unsafe {
1607 let f: Box_<F> = Box_::new(f);
1608 connect_raw(
1609 self.as_ptr() as *mut _,
1610 b"notify::max-content-width\0".as_ptr() as *const _,
1611 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1612 notify_max_content_width_trampoline::<F> as *const (),
1613 )),
1614 Box_::into_raw(f),
1615 )
1616 }
1617 }
1618
1619 #[doc(alias = "min-content-height")]
1620 pub fn connect_min_content_height_notify<F: Fn(&Self) + 'static>(
1621 &self,
1622 f: F,
1623 ) -> SignalHandlerId {
1624 unsafe extern "C" fn notify_min_content_height_trampoline<
1625 F: Fn(&ScrolledWindow) + 'static,
1626 >(
1627 this: *mut ffi::GtkScrolledWindow,
1628 _param_spec: glib::ffi::gpointer,
1629 f: glib::ffi::gpointer,
1630 ) {
1631 let f: &F = &*(f as *const F);
1632 f(&from_glib_borrow(this))
1633 }
1634 unsafe {
1635 let f: Box_<F> = Box_::new(f);
1636 connect_raw(
1637 self.as_ptr() as *mut _,
1638 b"notify::min-content-height\0".as_ptr() as *const _,
1639 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1640 notify_min_content_height_trampoline::<F> as *const (),
1641 )),
1642 Box_::into_raw(f),
1643 )
1644 }
1645 }
1646
1647 #[doc(alias = "min-content-width")]
1648 pub fn connect_min_content_width_notify<F: Fn(&Self) + 'static>(
1649 &self,
1650 f: F,
1651 ) -> SignalHandlerId {
1652 unsafe extern "C" fn notify_min_content_width_trampoline<
1653 F: Fn(&ScrolledWindow) + 'static,
1654 >(
1655 this: *mut ffi::GtkScrolledWindow,
1656 _param_spec: glib::ffi::gpointer,
1657 f: glib::ffi::gpointer,
1658 ) {
1659 let f: &F = &*(f as *const F);
1660 f(&from_glib_borrow(this))
1661 }
1662 unsafe {
1663 let f: Box_<F> = Box_::new(f);
1664 connect_raw(
1665 self.as_ptr() as *mut _,
1666 b"notify::min-content-width\0".as_ptr() as *const _,
1667 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1668 notify_min_content_width_trampoline::<F> as *const (),
1669 )),
1670 Box_::into_raw(f),
1671 )
1672 }
1673 }
1674
1675 #[doc(alias = "overlay-scrolling")]
1676 pub fn connect_overlay_scrolling_notify<F: Fn(&Self) + 'static>(
1677 &self,
1678 f: F,
1679 ) -> SignalHandlerId {
1680 unsafe extern "C" fn notify_overlay_scrolling_trampoline<
1681 F: Fn(&ScrolledWindow) + 'static,
1682 >(
1683 this: *mut ffi::GtkScrolledWindow,
1684 _param_spec: glib::ffi::gpointer,
1685 f: glib::ffi::gpointer,
1686 ) {
1687 let f: &F = &*(f as *const F);
1688 f(&from_glib_borrow(this))
1689 }
1690 unsafe {
1691 let f: Box_<F> = Box_::new(f);
1692 connect_raw(
1693 self.as_ptr() as *mut _,
1694 b"notify::overlay-scrolling\0".as_ptr() as *const _,
1695 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1696 notify_overlay_scrolling_trampoline::<F> as *const (),
1697 )),
1698 Box_::into_raw(f),
1699 )
1700 }
1701 }
1702
1703 #[doc(alias = "propagate-natural-height")]
1704 pub fn connect_propagate_natural_height_notify<F: Fn(&Self) + 'static>(
1705 &self,
1706 f: F,
1707 ) -> SignalHandlerId {
1708 unsafe extern "C" fn notify_propagate_natural_height_trampoline<
1709 F: Fn(&ScrolledWindow) + 'static,
1710 >(
1711 this: *mut ffi::GtkScrolledWindow,
1712 _param_spec: glib::ffi::gpointer,
1713 f: glib::ffi::gpointer,
1714 ) {
1715 let f: &F = &*(f as *const F);
1716 f(&from_glib_borrow(this))
1717 }
1718 unsafe {
1719 let f: Box_<F> = Box_::new(f);
1720 connect_raw(
1721 self.as_ptr() as *mut _,
1722 b"notify::propagate-natural-height\0".as_ptr() as *const _,
1723 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1724 notify_propagate_natural_height_trampoline::<F> as *const (),
1725 )),
1726 Box_::into_raw(f),
1727 )
1728 }
1729 }
1730
1731 #[doc(alias = "propagate-natural-width")]
1732 pub fn connect_propagate_natural_width_notify<F: Fn(&Self) + 'static>(
1733 &self,
1734 f: F,
1735 ) -> SignalHandlerId {
1736 unsafe extern "C" fn notify_propagate_natural_width_trampoline<
1737 F: Fn(&ScrolledWindow) + 'static,
1738 >(
1739 this: *mut ffi::GtkScrolledWindow,
1740 _param_spec: glib::ffi::gpointer,
1741 f: glib::ffi::gpointer,
1742 ) {
1743 let f: &F = &*(f as *const F);
1744 f(&from_glib_borrow(this))
1745 }
1746 unsafe {
1747 let f: Box_<F> = Box_::new(f);
1748 connect_raw(
1749 self.as_ptr() as *mut _,
1750 b"notify::propagate-natural-width\0".as_ptr() as *const _,
1751 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1752 notify_propagate_natural_width_trampoline::<F> as *const (),
1753 )),
1754 Box_::into_raw(f),
1755 )
1756 }
1757 }
1758
1759 #[doc(alias = "vadjustment")]
1760 pub fn connect_vadjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1761 unsafe extern "C" fn notify_vadjustment_trampoline<F: Fn(&ScrolledWindow) + 'static>(
1762 this: *mut ffi::GtkScrolledWindow,
1763 _param_spec: glib::ffi::gpointer,
1764 f: glib::ffi::gpointer,
1765 ) {
1766 let f: &F = &*(f as *const F);
1767 f(&from_glib_borrow(this))
1768 }
1769 unsafe {
1770 let f: Box_<F> = Box_::new(f);
1771 connect_raw(
1772 self.as_ptr() as *mut _,
1773 b"notify::vadjustment\0".as_ptr() as *const _,
1774 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1775 notify_vadjustment_trampoline::<F> as *const (),
1776 )),
1777 Box_::into_raw(f),
1778 )
1779 }
1780 }
1781
1782 #[doc(alias = "vscrollbar-policy")]
1783 pub fn connect_vscrollbar_policy_notify<F: Fn(&Self) + 'static>(
1784 &self,
1785 f: F,
1786 ) -> SignalHandlerId {
1787 unsafe extern "C" fn notify_vscrollbar_policy_trampoline<
1788 F: Fn(&ScrolledWindow) + 'static,
1789 >(
1790 this: *mut ffi::GtkScrolledWindow,
1791 _param_spec: glib::ffi::gpointer,
1792 f: glib::ffi::gpointer,
1793 ) {
1794 let f: &F = &*(f as *const F);
1795 f(&from_glib_borrow(this))
1796 }
1797 unsafe {
1798 let f: Box_<F> = Box_::new(f);
1799 connect_raw(
1800 self.as_ptr() as *mut _,
1801 b"notify::vscrollbar-policy\0".as_ptr() as *const _,
1802 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1803 notify_vscrollbar_policy_trampoline::<F> as *const (),
1804 )),
1805 Box_::into_raw(f),
1806 )
1807 }
1808 }
1809
1810 #[doc(alias = "window-placement")]
1811 pub fn connect_window_placement_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1812 unsafe extern "C" fn notify_window_placement_trampoline<
1813 F: Fn(&ScrolledWindow) + 'static,
1814 >(
1815 this: *mut ffi::GtkScrolledWindow,
1816 _param_spec: glib::ffi::gpointer,
1817 f: glib::ffi::gpointer,
1818 ) {
1819 let f: &F = &*(f as *const F);
1820 f(&from_glib_borrow(this))
1821 }
1822 unsafe {
1823 let f: Box_<F> = Box_::new(f);
1824 connect_raw(
1825 self.as_ptr() as *mut _,
1826 b"notify::window-placement\0".as_ptr() as *const _,
1827 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1828 notify_window_placement_trampoline::<F> as *const (),
1829 )),
1830 Box_::into_raw(f),
1831 )
1832 }
1833 }
1834}
1835
1836impl Default for ScrolledWindow {
1837 fn default() -> Self {
1838 Self::new()
1839 }
1840}
1841
1842// rustdoc-stripper-ignore-next
1843/// A [builder-pattern] type to construct [`ScrolledWindow`] objects.
1844///
1845/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1846#[must_use = "The builder must be built to be used"]
1847pub struct ScrolledWindowBuilder {
1848 builder: glib::object::ObjectBuilder<'static, ScrolledWindow>,
1849}
1850
1851impl ScrolledWindowBuilder {
1852 fn new() -> Self {
1853 Self {
1854 builder: glib::object::Object::builder(),
1855 }
1856 }
1857
1858 /// The child widget.
1859 ///
1860 /// When setting this property, if the child widget does not implement
1861 /// [`Scrollable`][crate::Scrollable], the scrolled window will add the child to
1862 /// a [`Viewport`][crate::Viewport] and then set the viewport as the child.
1863 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1864 Self {
1865 builder: self.builder.property("child", child.clone().upcast()),
1866 }
1867 }
1868
1869 /// The [`Adjustment`][crate::Adjustment] for the horizontal position.
1870 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
1871 Self {
1872 builder: self
1873 .builder
1874 .property("hadjustment", hadjustment.clone().upcast()),
1875 }
1876 }
1877
1878 /// Whether to draw a frame around the contents.
1879 pub fn has_frame(self, has_frame: bool) -> Self {
1880 Self {
1881 builder: self.builder.property("has-frame", has_frame),
1882 }
1883 }
1884
1885 /// When the horizontal scrollbar is displayed.
1886 ///
1887 /// Use [`ScrolledWindow::set_policy()`][crate::ScrolledWindow::set_policy()] to set
1888 /// this property.
1889 pub fn hscrollbar_policy(self, hscrollbar_policy: PolicyType) -> Self {
1890 Self {
1891 builder: self
1892 .builder
1893 .property("hscrollbar-policy", hscrollbar_policy),
1894 }
1895 }
1896
1897 /// Whether kinetic scrolling is enabled or not.
1898 ///
1899 /// Kinetic scrolling only applies to devices with source `GDK_SOURCE_TOUCHSCREEN`.
1900 pub fn kinetic_scrolling(self, kinetic_scrolling: bool) -> Self {
1901 Self {
1902 builder: self
1903 .builder
1904 .property("kinetic-scrolling", kinetic_scrolling),
1905 }
1906 }
1907
1908 /// The maximum content height of @scrolled_window.
1909 pub fn max_content_height(self, max_content_height: i32) -> Self {
1910 Self {
1911 builder: self
1912 .builder
1913 .property("max-content-height", max_content_height),
1914 }
1915 }
1916
1917 /// The maximum content width of @scrolled_window.
1918 pub fn max_content_width(self, max_content_width: i32) -> Self {
1919 Self {
1920 builder: self
1921 .builder
1922 .property("max-content-width", max_content_width),
1923 }
1924 }
1925
1926 /// The minimum content height of @scrolled_window.
1927 pub fn min_content_height(self, min_content_height: i32) -> Self {
1928 Self {
1929 builder: self
1930 .builder
1931 .property("min-content-height", min_content_height),
1932 }
1933 }
1934
1935 /// The minimum content width of @scrolled_window.
1936 pub fn min_content_width(self, min_content_width: i32) -> Self {
1937 Self {
1938 builder: self
1939 .builder
1940 .property("min-content-width", min_content_width),
1941 }
1942 }
1943
1944 /// Whether overlay scrolling is enabled or not.
1945 ///
1946 /// If it is, the scrollbars are only added as traditional widgets
1947 /// when a mouse is present. Otherwise, they are overlaid on top of
1948 /// the content, as narrow indicators.
1949 ///
1950 /// Note that overlay scrolling can also be globally disabled, with
1951 /// the [`gtk-overlay-scrolling`][struct@crate::Settings#gtk-overlay-scrolling] setting.
1952 pub fn overlay_scrolling(self, overlay_scrolling: bool) -> Self {
1953 Self {
1954 builder: self
1955 .builder
1956 .property("overlay-scrolling", overlay_scrolling),
1957 }
1958 }
1959
1960 /// Whether the natural height of the child should be calculated and propagated
1961 /// through the scrolled window’s requested natural height.
1962 ///
1963 /// This is useful in cases where an attempt should be made to allocate exactly
1964 /// enough space for the natural size of the child.
1965 pub fn propagate_natural_height(self, propagate_natural_height: bool) -> Self {
1966 Self {
1967 builder: self
1968 .builder
1969 .property("propagate-natural-height", propagate_natural_height),
1970 }
1971 }
1972
1973 /// Whether the natural width of the child should be calculated and propagated
1974 /// through the scrolled window’s requested natural width.
1975 ///
1976 /// This is useful in cases where an attempt should be made to allocate exactly
1977 /// enough space for the natural size of the child.
1978 pub fn propagate_natural_width(self, propagate_natural_width: bool) -> Self {
1979 Self {
1980 builder: self
1981 .builder
1982 .property("propagate-natural-width", propagate_natural_width),
1983 }
1984 }
1985
1986 /// The [`Adjustment`][crate::Adjustment] for the vertical position.
1987 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1988 Self {
1989 builder: self
1990 .builder
1991 .property("vadjustment", vadjustment.clone().upcast()),
1992 }
1993 }
1994
1995 /// When the vertical scrollbar is displayed.
1996 ///
1997 /// Use [`ScrolledWindow::set_policy()`][crate::ScrolledWindow::set_policy()] to set
1998 /// this property.
1999 pub fn vscrollbar_policy(self, vscrollbar_policy: PolicyType) -> Self {
2000 Self {
2001 builder: self
2002 .builder
2003 .property("vscrollbar-policy", vscrollbar_policy),
2004 }
2005 }
2006
2007 /// Where the contents are located with respect to the scrollbars.
2008 pub fn window_placement(self, window_placement: CornerType) -> Self {
2009 Self {
2010 builder: self.builder.property("window-placement", window_placement),
2011 }
2012 }
2013
2014 /// Whether the widget or any of its descendents can accept
2015 /// the input focus.
2016 ///
2017 /// This property is meant to be set by widget implementations,
2018 /// typically in their instance init function.
2019 pub fn can_focus(self, can_focus: bool) -> Self {
2020 Self {
2021 builder: self.builder.property("can-focus", can_focus),
2022 }
2023 }
2024
2025 /// Whether the widget can receive pointer events.
2026 pub fn can_target(self, can_target: bool) -> Self {
2027 Self {
2028 builder: self.builder.property("can-target", can_target),
2029 }
2030 }
2031
2032 /// A list of css classes applied to this widget.
2033 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
2034 Self {
2035 builder: self.builder.property("css-classes", css_classes.into()),
2036 }
2037 }
2038
2039 /// The name of this widget in the CSS tree.
2040 ///
2041 /// This property is meant to be set by widget implementations,
2042 /// typically in their instance init function.
2043 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
2044 Self {
2045 builder: self.builder.property("css-name", css_name.into()),
2046 }
2047 }
2048
2049 /// The cursor used by @widget.
2050 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
2051 Self {
2052 builder: self.builder.property("cursor", cursor.clone()),
2053 }
2054 }
2055
2056 /// Whether the widget should grab focus when it is clicked with the mouse.
2057 ///
2058 /// This property is only relevant for widgets that can take focus.
2059 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
2060 Self {
2061 builder: self.builder.property("focus-on-click", focus_on_click),
2062 }
2063 }
2064
2065 /// Whether this widget itself will accept the input focus.
2066 pub fn focusable(self, focusable: bool) -> Self {
2067 Self {
2068 builder: self.builder.property("focusable", focusable),
2069 }
2070 }
2071
2072 /// How to distribute horizontal space if widget gets extra space.
2073 pub fn halign(self, halign: Align) -> Self {
2074 Self {
2075 builder: self.builder.property("halign", halign),
2076 }
2077 }
2078
2079 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
2080 /// signal on @widget.
2081 ///
2082 /// A true value indicates that @widget can have a tooltip, in this case
2083 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
2084 /// determine whether it will provide a tooltip or not.
2085 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
2086 Self {
2087 builder: self.builder.property("has-tooltip", has_tooltip),
2088 }
2089 }
2090
2091 /// Overrides for height request of the widget.
2092 ///
2093 /// If this is -1, the natural request will be used.
2094 pub fn height_request(self, height_request: i32) -> Self {
2095 Self {
2096 builder: self.builder.property("height-request", height_request),
2097 }
2098 }
2099
2100 /// Whether to expand horizontally.
2101 pub fn hexpand(self, hexpand: bool) -> Self {
2102 Self {
2103 builder: self.builder.property("hexpand", hexpand),
2104 }
2105 }
2106
2107 /// Whether to use the `hexpand` property.
2108 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
2109 Self {
2110 builder: self.builder.property("hexpand-set", hexpand_set),
2111 }
2112 }
2113
2114 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
2115 /// the preferred size of the widget, and allocate its children.
2116 ///
2117 /// This property is meant to be set by widget implementations,
2118 /// typically in their instance init function.
2119 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
2120 Self {
2121 builder: self
2122 .builder
2123 .property("layout-manager", layout_manager.clone().upcast()),
2124 }
2125 }
2126
2127 /// Makes this widget act like a modal dialog, with respect to
2128 /// event delivery.
2129 ///
2130 /// Global event controllers will not handle events with targets
2131 /// inside the widget, unless they are set up to ignore propagation
2132 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
2133 #[cfg(feature = "v4_18")]
2134 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
2135 pub fn limit_events(self, limit_events: bool) -> Self {
2136 Self {
2137 builder: self.builder.property("limit-events", limit_events),
2138 }
2139 }
2140
2141 /// Margin on bottom side of widget.
2142 ///
2143 /// This property adds margin outside of the widget's normal size
2144 /// request, the margin will be added in addition to the size from
2145 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2146 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
2147 Self {
2148 builder: self.builder.property("margin-bottom", margin_bottom),
2149 }
2150 }
2151
2152 /// Margin on end of widget, horizontally.
2153 ///
2154 /// This property supports left-to-right and right-to-left text
2155 /// directions.
2156 ///
2157 /// This property adds margin outside of the widget's normal size
2158 /// request, the margin will be added in addition to the size from
2159 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2160 pub fn margin_end(self, margin_end: i32) -> Self {
2161 Self {
2162 builder: self.builder.property("margin-end", margin_end),
2163 }
2164 }
2165
2166 /// Margin on start of widget, horizontally.
2167 ///
2168 /// This property supports left-to-right and right-to-left text
2169 /// directions.
2170 ///
2171 /// This property adds margin outside of the widget's normal size
2172 /// request, the margin will be added in addition to the size from
2173 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2174 pub fn margin_start(self, margin_start: i32) -> Self {
2175 Self {
2176 builder: self.builder.property("margin-start", margin_start),
2177 }
2178 }
2179
2180 /// Margin on top side of widget.
2181 ///
2182 /// This property adds margin outside of the widget's normal size
2183 /// request, the margin will be added in addition to the size from
2184 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2185 pub fn margin_top(self, margin_top: i32) -> Self {
2186 Self {
2187 builder: self.builder.property("margin-top", margin_top),
2188 }
2189 }
2190
2191 /// The name of the widget.
2192 pub fn name(self, name: impl Into<glib::GString>) -> Self {
2193 Self {
2194 builder: self.builder.property("name", name.into()),
2195 }
2196 }
2197
2198 /// The requested opacity of the widget.
2199 pub fn opacity(self, opacity: f64) -> Self {
2200 Self {
2201 builder: self.builder.property("opacity", opacity),
2202 }
2203 }
2204
2205 /// How content outside the widget's content area is treated.
2206 ///
2207 /// This property is meant to be set by widget implementations,
2208 /// typically in their instance init function.
2209 pub fn overflow(self, overflow: Overflow) -> Self {
2210 Self {
2211 builder: self.builder.property("overflow", overflow),
2212 }
2213 }
2214
2215 /// Whether the widget will receive the default action when it is focused.
2216 pub fn receives_default(self, receives_default: bool) -> Self {
2217 Self {
2218 builder: self.builder.property("receives-default", receives_default),
2219 }
2220 }
2221
2222 /// Whether the widget responds to input.
2223 pub fn sensitive(self, sensitive: bool) -> Self {
2224 Self {
2225 builder: self.builder.property("sensitive", sensitive),
2226 }
2227 }
2228
2229 /// Sets the text of tooltip to be the given string, which is marked up
2230 /// with Pango markup.
2231 ///
2232 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2233 ///
2234 /// This is a convenience property which will take care of getting the
2235 /// tooltip shown if the given string is not `NULL`:
2236 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2237 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2238 /// the default signal handler.
2239 ///
2240 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2241 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2242 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2243 Self {
2244 builder: self
2245 .builder
2246 .property("tooltip-markup", tooltip_markup.into()),
2247 }
2248 }
2249
2250 /// Sets the text of tooltip to be the given string.
2251 ///
2252 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2253 ///
2254 /// This is a convenience property which will take care of getting the
2255 /// tooltip shown if the given string is not `NULL`:
2256 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2257 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2258 /// the default signal handler.
2259 ///
2260 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2261 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2262 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2263 Self {
2264 builder: self.builder.property("tooltip-text", tooltip_text.into()),
2265 }
2266 }
2267
2268 /// How to distribute vertical space if widget gets extra space.
2269 pub fn valign(self, valign: Align) -> Self {
2270 Self {
2271 builder: self.builder.property("valign", valign),
2272 }
2273 }
2274
2275 /// Whether to expand vertically.
2276 pub fn vexpand(self, vexpand: bool) -> Self {
2277 Self {
2278 builder: self.builder.property("vexpand", vexpand),
2279 }
2280 }
2281
2282 /// Whether to use the `vexpand` property.
2283 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2284 Self {
2285 builder: self.builder.property("vexpand-set", vexpand_set),
2286 }
2287 }
2288
2289 /// Whether the widget is visible.
2290 pub fn visible(self, visible: bool) -> Self {
2291 Self {
2292 builder: self.builder.property("visible", visible),
2293 }
2294 }
2295
2296 /// Overrides for width request of the widget.
2297 ///
2298 /// If this is -1, the natural request will be used.
2299 pub fn width_request(self, width_request: i32) -> Self {
2300 Self {
2301 builder: self.builder.property("width-request", width_request),
2302 }
2303 }
2304
2305 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2306 ///
2307 /// The accessible role cannot be changed once set.
2308 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2309 Self {
2310 builder: self.builder.property("accessible-role", accessible_role),
2311 }
2312 }
2313
2314 // rustdoc-stripper-ignore-next
2315 /// Build the [`ScrolledWindow`].
2316 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2317 pub fn build(self) -> ScrolledWindow {
2318 assert_initialized_main_thread!();
2319 self.builder.build()
2320 }
2321}