1use 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 #[doc(alias = "GtkScrolledWindow")]
19 pub struct ScrolledWindow(Object<ffi::GtkScrolledWindow>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
20
21 match fn {
22 type_ => || ffi::gtk_scrolled_window_get_type(),
23 }
24}
25
26impl ScrolledWindow {
27 #[doc(alias = "gtk_scrolled_window_new")]
28 pub fn new() -> ScrolledWindow {
29 assert_initialized_main_thread!();
30 unsafe { Widget::from_glib_none(ffi::gtk_scrolled_window_new()).unsafe_cast() }
31 }
32
33 pub fn builder() -> ScrolledWindowBuilder {
38 ScrolledWindowBuilder::new()
39 }
40
41 #[doc(alias = "gtk_scrolled_window_get_child")]
42 #[doc(alias = "get_child")]
43 pub fn child(&self) -> Option<Widget> {
44 unsafe { from_glib_none(ffi::gtk_scrolled_window_get_child(self.to_glib_none().0)) }
45 }
46
47 #[doc(alias = "gtk_scrolled_window_get_hadjustment")]
48 #[doc(alias = "get_hadjustment")]
49 pub fn hadjustment(&self) -> Adjustment {
50 unsafe {
51 from_glib_none(ffi::gtk_scrolled_window_get_hadjustment(
52 self.to_glib_none().0,
53 ))
54 }
55 }
56
57 #[doc(alias = "gtk_scrolled_window_get_has_frame")]
58 #[doc(alias = "get_has_frame")]
59 #[doc(alias = "has-frame")]
60 pub fn has_frame(&self) -> bool {
61 unsafe {
62 from_glib(ffi::gtk_scrolled_window_get_has_frame(
63 self.to_glib_none().0,
64 ))
65 }
66 }
67
68 #[doc(alias = "gtk_scrolled_window_get_hscrollbar")]
69 #[doc(alias = "get_hscrollbar")]
70 pub fn hscrollbar(&self) -> Widget {
71 unsafe {
72 from_glib_none(ffi::gtk_scrolled_window_get_hscrollbar(
73 self.to_glib_none().0,
74 ))
75 }
76 }
77
78 #[doc(alias = "gtk_scrolled_window_get_kinetic_scrolling")]
79 #[doc(alias = "get_kinetic_scrolling")]
80 #[doc(alias = "kinetic-scrolling")]
81 pub fn is_kinetic_scrolling(&self) -> bool {
82 unsafe {
83 from_glib(ffi::gtk_scrolled_window_get_kinetic_scrolling(
84 self.to_glib_none().0,
85 ))
86 }
87 }
88
89 #[doc(alias = "gtk_scrolled_window_get_max_content_height")]
90 #[doc(alias = "get_max_content_height")]
91 #[doc(alias = "max-content-height")]
92 pub fn max_content_height(&self) -> i32 {
93 unsafe { ffi::gtk_scrolled_window_get_max_content_height(self.to_glib_none().0) }
94 }
95
96 #[doc(alias = "gtk_scrolled_window_get_max_content_width")]
97 #[doc(alias = "get_max_content_width")]
98 #[doc(alias = "max-content-width")]
99 pub fn max_content_width(&self) -> i32 {
100 unsafe { ffi::gtk_scrolled_window_get_max_content_width(self.to_glib_none().0) }
101 }
102
103 #[doc(alias = "gtk_scrolled_window_get_min_content_height")]
104 #[doc(alias = "get_min_content_height")]
105 #[doc(alias = "min-content-height")]
106 pub fn min_content_height(&self) -> i32 {
107 unsafe { ffi::gtk_scrolled_window_get_min_content_height(self.to_glib_none().0) }
108 }
109
110 #[doc(alias = "gtk_scrolled_window_get_min_content_width")]
111 #[doc(alias = "get_min_content_width")]
112 #[doc(alias = "min-content-width")]
113 pub fn min_content_width(&self) -> i32 {
114 unsafe { ffi::gtk_scrolled_window_get_min_content_width(self.to_glib_none().0) }
115 }
116
117 #[doc(alias = "gtk_scrolled_window_get_overlay_scrolling")]
118 #[doc(alias = "get_overlay_scrolling")]
119 #[doc(alias = "overlay-scrolling")]
120 pub fn is_overlay_scrolling(&self) -> bool {
121 unsafe {
122 from_glib(ffi::gtk_scrolled_window_get_overlay_scrolling(
123 self.to_glib_none().0,
124 ))
125 }
126 }
127
128 #[doc(alias = "gtk_scrolled_window_get_placement")]
129 #[doc(alias = "get_placement")]
130 #[doc(alias = "window-placement")]
131 pub fn placement(&self) -> CornerType {
132 unsafe {
133 from_glib(ffi::gtk_scrolled_window_get_placement(
134 self.to_glib_none().0,
135 ))
136 }
137 }
138
139 #[doc(alias = "gtk_scrolled_window_get_policy")]
140 #[doc(alias = "get_policy")]
141 pub fn policy(&self) -> (PolicyType, PolicyType) {
142 unsafe {
143 let mut hscrollbar_policy = std::mem::MaybeUninit::uninit();
144 let mut vscrollbar_policy = std::mem::MaybeUninit::uninit();
145 ffi::gtk_scrolled_window_get_policy(
146 self.to_glib_none().0,
147 hscrollbar_policy.as_mut_ptr(),
148 vscrollbar_policy.as_mut_ptr(),
149 );
150 (
151 from_glib(hscrollbar_policy.assume_init()),
152 from_glib(vscrollbar_policy.assume_init()),
153 )
154 }
155 }
156
157 #[doc(alias = "gtk_scrolled_window_get_propagate_natural_height")]
158 #[doc(alias = "get_propagate_natural_height")]
159 #[doc(alias = "propagate-natural-height")]
160 pub fn propagates_natural_height(&self) -> bool {
161 unsafe {
162 from_glib(ffi::gtk_scrolled_window_get_propagate_natural_height(
163 self.to_glib_none().0,
164 ))
165 }
166 }
167
168 #[doc(alias = "gtk_scrolled_window_get_propagate_natural_width")]
169 #[doc(alias = "get_propagate_natural_width")]
170 #[doc(alias = "propagate-natural-width")]
171 pub fn propagates_natural_width(&self) -> bool {
172 unsafe {
173 from_glib(ffi::gtk_scrolled_window_get_propagate_natural_width(
174 self.to_glib_none().0,
175 ))
176 }
177 }
178
179 #[doc(alias = "gtk_scrolled_window_get_vadjustment")]
180 #[doc(alias = "get_vadjustment")]
181 pub fn vadjustment(&self) -> Adjustment {
182 unsafe {
183 from_glib_none(ffi::gtk_scrolled_window_get_vadjustment(
184 self.to_glib_none().0,
185 ))
186 }
187 }
188
189 #[doc(alias = "gtk_scrolled_window_get_vscrollbar")]
190 #[doc(alias = "get_vscrollbar")]
191 pub fn vscrollbar(&self) -> Widget {
192 unsafe {
193 from_glib_none(ffi::gtk_scrolled_window_get_vscrollbar(
194 self.to_glib_none().0,
195 ))
196 }
197 }
198
199 #[doc(alias = "gtk_scrolled_window_set_child")]
200 #[doc(alias = "child")]
201 pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
202 unsafe {
203 ffi::gtk_scrolled_window_set_child(
204 self.to_glib_none().0,
205 child.map(|p| p.as_ref()).to_glib_none().0,
206 );
207 }
208 }
209
210 #[doc(alias = "gtk_scrolled_window_set_hadjustment")]
211 #[doc(alias = "hadjustment")]
212 pub fn set_hadjustment(&self, hadjustment: Option<&impl IsA<Adjustment>>) {
213 unsafe {
214 ffi::gtk_scrolled_window_set_hadjustment(
215 self.to_glib_none().0,
216 hadjustment.map(|p| p.as_ref()).to_glib_none().0,
217 );
218 }
219 }
220
221 #[doc(alias = "gtk_scrolled_window_set_has_frame")]
222 #[doc(alias = "has-frame")]
223 pub fn set_has_frame(&self, has_frame: bool) {
224 unsafe {
225 ffi::gtk_scrolled_window_set_has_frame(self.to_glib_none().0, has_frame.into_glib());
226 }
227 }
228
229 #[doc(alias = "gtk_scrolled_window_set_kinetic_scrolling")]
230 #[doc(alias = "kinetic-scrolling")]
231 pub fn set_kinetic_scrolling(&self, kinetic_scrolling: bool) {
232 unsafe {
233 ffi::gtk_scrolled_window_set_kinetic_scrolling(
234 self.to_glib_none().0,
235 kinetic_scrolling.into_glib(),
236 );
237 }
238 }
239
240 #[doc(alias = "gtk_scrolled_window_set_max_content_height")]
241 #[doc(alias = "max-content-height")]
242 pub fn set_max_content_height(&self, height: i32) {
243 unsafe {
244 ffi::gtk_scrolled_window_set_max_content_height(self.to_glib_none().0, height);
245 }
246 }
247
248 #[doc(alias = "gtk_scrolled_window_set_max_content_width")]
249 #[doc(alias = "max-content-width")]
250 pub fn set_max_content_width(&self, width: i32) {
251 unsafe {
252 ffi::gtk_scrolled_window_set_max_content_width(self.to_glib_none().0, width);
253 }
254 }
255
256 #[doc(alias = "gtk_scrolled_window_set_min_content_height")]
257 #[doc(alias = "min-content-height")]
258 pub fn set_min_content_height(&self, height: i32) {
259 unsafe {
260 ffi::gtk_scrolled_window_set_min_content_height(self.to_glib_none().0, height);
261 }
262 }
263
264 #[doc(alias = "gtk_scrolled_window_set_min_content_width")]
265 #[doc(alias = "min-content-width")]
266 pub fn set_min_content_width(&self, width: i32) {
267 unsafe {
268 ffi::gtk_scrolled_window_set_min_content_width(self.to_glib_none().0, width);
269 }
270 }
271
272 #[doc(alias = "gtk_scrolled_window_set_overlay_scrolling")]
273 #[doc(alias = "overlay-scrolling")]
274 pub fn set_overlay_scrolling(&self, overlay_scrolling: bool) {
275 unsafe {
276 ffi::gtk_scrolled_window_set_overlay_scrolling(
277 self.to_glib_none().0,
278 overlay_scrolling.into_glib(),
279 );
280 }
281 }
282
283 #[doc(alias = "gtk_scrolled_window_set_placement")]
284 #[doc(alias = "window-placement")]
285 pub fn set_placement(&self, window_placement: CornerType) {
286 unsafe {
287 ffi::gtk_scrolled_window_set_placement(
288 self.to_glib_none().0,
289 window_placement.into_glib(),
290 );
291 }
292 }
293
294 #[doc(alias = "gtk_scrolled_window_set_policy")]
295 pub fn set_policy(&self, hscrollbar_policy: PolicyType, vscrollbar_policy: PolicyType) {
296 unsafe {
297 ffi::gtk_scrolled_window_set_policy(
298 self.to_glib_none().0,
299 hscrollbar_policy.into_glib(),
300 vscrollbar_policy.into_glib(),
301 );
302 }
303 }
304
305 #[doc(alias = "gtk_scrolled_window_set_propagate_natural_height")]
306 #[doc(alias = "propagate-natural-height")]
307 pub fn set_propagate_natural_height(&self, propagate: bool) {
308 unsafe {
309 ffi::gtk_scrolled_window_set_propagate_natural_height(
310 self.to_glib_none().0,
311 propagate.into_glib(),
312 );
313 }
314 }
315
316 #[doc(alias = "gtk_scrolled_window_set_propagate_natural_width")]
317 #[doc(alias = "propagate-natural-width")]
318 pub fn set_propagate_natural_width(&self, propagate: bool) {
319 unsafe {
320 ffi::gtk_scrolled_window_set_propagate_natural_width(
321 self.to_glib_none().0,
322 propagate.into_glib(),
323 );
324 }
325 }
326
327 #[doc(alias = "gtk_scrolled_window_set_vadjustment")]
328 #[doc(alias = "vadjustment")]
329 pub fn set_vadjustment(&self, vadjustment: Option<&impl IsA<Adjustment>>) {
330 unsafe {
331 ffi::gtk_scrolled_window_set_vadjustment(
332 self.to_glib_none().0,
333 vadjustment.map(|p| p.as_ref()).to_glib_none().0,
334 );
335 }
336 }
337
338 #[doc(alias = "gtk_scrolled_window_unset_placement")]
339 pub fn unset_placement(&self) {
340 unsafe {
341 ffi::gtk_scrolled_window_unset_placement(self.to_glib_none().0);
342 }
343 }
344
345 #[doc(alias = "hscrollbar-policy")]
346 pub fn hscrollbar_policy(&self) -> PolicyType {
347 ObjectExt::property(self, "hscrollbar-policy")
348 }
349
350 #[doc(alias = "hscrollbar-policy")]
351 pub fn set_hscrollbar_policy(&self, hscrollbar_policy: PolicyType) {
352 ObjectExt::set_property(self, "hscrollbar-policy", hscrollbar_policy)
353 }
354
355 #[doc(alias = "vscrollbar-policy")]
356 pub fn vscrollbar_policy(&self) -> PolicyType {
357 ObjectExt::property(self, "vscrollbar-policy")
358 }
359
360 #[doc(alias = "vscrollbar-policy")]
361 pub fn set_vscrollbar_policy(&self, vscrollbar_policy: PolicyType) {
362 ObjectExt::set_property(self, "vscrollbar-policy", vscrollbar_policy)
363 }
364
365 #[doc(alias = "edge-overshot")]
366 pub fn connect_edge_overshot<F: Fn(&Self, PositionType) + 'static>(
367 &self,
368 f: F,
369 ) -> SignalHandlerId {
370 unsafe extern "C" fn edge_overshot_trampoline<
371 F: Fn(&ScrolledWindow, PositionType) + 'static,
372 >(
373 this: *mut ffi::GtkScrolledWindow,
374 pos: ffi::GtkPositionType,
375 f: glib::ffi::gpointer,
376 ) {
377 let f: &F = &*(f as *const F);
378 f(&from_glib_borrow(this), from_glib(pos))
379 }
380 unsafe {
381 let f: Box_<F> = Box_::new(f);
382 connect_raw(
383 self.as_ptr() as *mut _,
384 c"edge-overshot".as_ptr() as *const _,
385 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
386 edge_overshot_trampoline::<F> as *const (),
387 )),
388 Box_::into_raw(f),
389 )
390 }
391 }
392
393 #[doc(alias = "edge-reached")]
394 pub fn connect_edge_reached<F: Fn(&Self, PositionType) + 'static>(
395 &self,
396 f: F,
397 ) -> SignalHandlerId {
398 unsafe extern "C" fn edge_reached_trampoline<
399 F: Fn(&ScrolledWindow, PositionType) + 'static,
400 >(
401 this: *mut ffi::GtkScrolledWindow,
402 pos: ffi::GtkPositionType,
403 f: glib::ffi::gpointer,
404 ) {
405 let f: &F = &*(f as *const F);
406 f(&from_glib_borrow(this), from_glib(pos))
407 }
408 unsafe {
409 let f: Box_<F> = Box_::new(f);
410 connect_raw(
411 self.as_ptr() as *mut _,
412 c"edge-reached".as_ptr() as *const _,
413 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
414 edge_reached_trampoline::<F> as *const (),
415 )),
416 Box_::into_raw(f),
417 )
418 }
419 }
420
421 #[doc(alias = "move-focus-out")]
422 pub fn connect_move_focus_out<F: Fn(&Self, DirectionType) + 'static>(
423 &self,
424 f: F,
425 ) -> SignalHandlerId {
426 unsafe extern "C" fn move_focus_out_trampoline<
427 F: Fn(&ScrolledWindow, DirectionType) + 'static,
428 >(
429 this: *mut ffi::GtkScrolledWindow,
430 direction_type: ffi::GtkDirectionType,
431 f: glib::ffi::gpointer,
432 ) {
433 let f: &F = &*(f as *const F);
434 f(&from_glib_borrow(this), from_glib(direction_type))
435 }
436 unsafe {
437 let f: Box_<F> = Box_::new(f);
438 connect_raw(
439 self.as_ptr() as *mut _,
440 c"move-focus-out".as_ptr() as *const _,
441 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
442 move_focus_out_trampoline::<F> as *const (),
443 )),
444 Box_::into_raw(f),
445 )
446 }
447 }
448
449 pub fn emit_move_focus_out(&self, direction_type: DirectionType) {
450 self.emit_by_name::<()>("move-focus-out", &[&direction_type]);
451 }
452
453 #[doc(alias = "scroll-child")]
454 pub fn connect_scroll_child<F: Fn(&Self, ScrollType, bool) -> bool + 'static>(
455 &self,
456 f: F,
457 ) -> SignalHandlerId {
458 unsafe extern "C" fn scroll_child_trampoline<
459 F: Fn(&ScrolledWindow, ScrollType, bool) -> bool + 'static,
460 >(
461 this: *mut ffi::GtkScrolledWindow,
462 scroll: ffi::GtkScrollType,
463 horizontal: glib::ffi::gboolean,
464 f: glib::ffi::gpointer,
465 ) -> glib::ffi::gboolean {
466 let f: &F = &*(f as *const F);
467 f(
468 &from_glib_borrow(this),
469 from_glib(scroll),
470 from_glib(horizontal),
471 )
472 .into_glib()
473 }
474 unsafe {
475 let f: Box_<F> = Box_::new(f);
476 connect_raw(
477 self.as_ptr() as *mut _,
478 c"scroll-child".as_ptr() as *const _,
479 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480 scroll_child_trampoline::<F> as *const (),
481 )),
482 Box_::into_raw(f),
483 )
484 }
485 }
486
487 pub fn emit_scroll_child(&self, scroll: ScrollType, horizontal: bool) -> bool {
488 self.emit_by_name("scroll-child", &[&scroll, &horizontal])
489 }
490
491 #[doc(alias = "child")]
492 pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
493 unsafe extern "C" fn notify_child_trampoline<F: Fn(&ScrolledWindow) + 'static>(
494 this: *mut ffi::GtkScrolledWindow,
495 _param_spec: glib::ffi::gpointer,
496 f: glib::ffi::gpointer,
497 ) {
498 let f: &F = &*(f as *const F);
499 f(&from_glib_borrow(this))
500 }
501 unsafe {
502 let f: Box_<F> = Box_::new(f);
503 connect_raw(
504 self.as_ptr() as *mut _,
505 c"notify::child".as_ptr() as *const _,
506 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
507 notify_child_trampoline::<F> as *const (),
508 )),
509 Box_::into_raw(f),
510 )
511 }
512 }
513
514 #[doc(alias = "hadjustment")]
515 pub fn connect_hadjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
516 unsafe extern "C" fn notify_hadjustment_trampoline<F: Fn(&ScrolledWindow) + 'static>(
517 this: *mut ffi::GtkScrolledWindow,
518 _param_spec: glib::ffi::gpointer,
519 f: glib::ffi::gpointer,
520 ) {
521 let f: &F = &*(f as *const F);
522 f(&from_glib_borrow(this))
523 }
524 unsafe {
525 let f: Box_<F> = Box_::new(f);
526 connect_raw(
527 self.as_ptr() as *mut _,
528 c"notify::hadjustment".as_ptr() as *const _,
529 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
530 notify_hadjustment_trampoline::<F> as *const (),
531 )),
532 Box_::into_raw(f),
533 )
534 }
535 }
536
537 #[doc(alias = "has-frame")]
538 pub fn connect_has_frame_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
539 unsafe extern "C" fn notify_has_frame_trampoline<F: Fn(&ScrolledWindow) + 'static>(
540 this: *mut ffi::GtkScrolledWindow,
541 _param_spec: glib::ffi::gpointer,
542 f: glib::ffi::gpointer,
543 ) {
544 let f: &F = &*(f as *const F);
545 f(&from_glib_borrow(this))
546 }
547 unsafe {
548 let f: Box_<F> = Box_::new(f);
549 connect_raw(
550 self.as_ptr() as *mut _,
551 c"notify::has-frame".as_ptr() as *const _,
552 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
553 notify_has_frame_trampoline::<F> as *const (),
554 )),
555 Box_::into_raw(f),
556 )
557 }
558 }
559
560 #[doc(alias = "hscrollbar-policy")]
561 pub fn connect_hscrollbar_policy_notify<F: Fn(&Self) + 'static>(
562 &self,
563 f: F,
564 ) -> SignalHandlerId {
565 unsafe extern "C" fn notify_hscrollbar_policy_trampoline<
566 F: Fn(&ScrolledWindow) + 'static,
567 >(
568 this: *mut ffi::GtkScrolledWindow,
569 _param_spec: glib::ffi::gpointer,
570 f: glib::ffi::gpointer,
571 ) {
572 let f: &F = &*(f as *const F);
573 f(&from_glib_borrow(this))
574 }
575 unsafe {
576 let f: Box_<F> = Box_::new(f);
577 connect_raw(
578 self.as_ptr() as *mut _,
579 c"notify::hscrollbar-policy".as_ptr() as *const _,
580 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
581 notify_hscrollbar_policy_trampoline::<F> as *const (),
582 )),
583 Box_::into_raw(f),
584 )
585 }
586 }
587
588 #[doc(alias = "kinetic-scrolling")]
589 pub fn connect_kinetic_scrolling_notify<F: Fn(&Self) + 'static>(
590 &self,
591 f: F,
592 ) -> SignalHandlerId {
593 unsafe extern "C" fn notify_kinetic_scrolling_trampoline<
594 F: Fn(&ScrolledWindow) + 'static,
595 >(
596 this: *mut ffi::GtkScrolledWindow,
597 _param_spec: glib::ffi::gpointer,
598 f: glib::ffi::gpointer,
599 ) {
600 let f: &F = &*(f as *const F);
601 f(&from_glib_borrow(this))
602 }
603 unsafe {
604 let f: Box_<F> = Box_::new(f);
605 connect_raw(
606 self.as_ptr() as *mut _,
607 c"notify::kinetic-scrolling".as_ptr() as *const _,
608 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
609 notify_kinetic_scrolling_trampoline::<F> as *const (),
610 )),
611 Box_::into_raw(f),
612 )
613 }
614 }
615
616 #[doc(alias = "max-content-height")]
617 pub fn connect_max_content_height_notify<F: Fn(&Self) + 'static>(
618 &self,
619 f: F,
620 ) -> SignalHandlerId {
621 unsafe extern "C" fn notify_max_content_height_trampoline<
622 F: Fn(&ScrolledWindow) + 'static,
623 >(
624 this: *mut ffi::GtkScrolledWindow,
625 _param_spec: glib::ffi::gpointer,
626 f: glib::ffi::gpointer,
627 ) {
628 let f: &F = &*(f as *const F);
629 f(&from_glib_borrow(this))
630 }
631 unsafe {
632 let f: Box_<F> = Box_::new(f);
633 connect_raw(
634 self.as_ptr() as *mut _,
635 c"notify::max-content-height".as_ptr() as *const _,
636 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
637 notify_max_content_height_trampoline::<F> as *const (),
638 )),
639 Box_::into_raw(f),
640 )
641 }
642 }
643
644 #[doc(alias = "max-content-width")]
645 pub fn connect_max_content_width_notify<F: Fn(&Self) + 'static>(
646 &self,
647 f: F,
648 ) -> SignalHandlerId {
649 unsafe extern "C" fn notify_max_content_width_trampoline<
650 F: Fn(&ScrolledWindow) + 'static,
651 >(
652 this: *mut ffi::GtkScrolledWindow,
653 _param_spec: glib::ffi::gpointer,
654 f: glib::ffi::gpointer,
655 ) {
656 let f: &F = &*(f as *const F);
657 f(&from_glib_borrow(this))
658 }
659 unsafe {
660 let f: Box_<F> = Box_::new(f);
661 connect_raw(
662 self.as_ptr() as *mut _,
663 c"notify::max-content-width".as_ptr() as *const _,
664 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
665 notify_max_content_width_trampoline::<F> as *const (),
666 )),
667 Box_::into_raw(f),
668 )
669 }
670 }
671
672 #[doc(alias = "min-content-height")]
673 pub fn connect_min_content_height_notify<F: Fn(&Self) + 'static>(
674 &self,
675 f: F,
676 ) -> SignalHandlerId {
677 unsafe extern "C" fn notify_min_content_height_trampoline<
678 F: Fn(&ScrolledWindow) + 'static,
679 >(
680 this: *mut ffi::GtkScrolledWindow,
681 _param_spec: glib::ffi::gpointer,
682 f: glib::ffi::gpointer,
683 ) {
684 let f: &F = &*(f as *const F);
685 f(&from_glib_borrow(this))
686 }
687 unsafe {
688 let f: Box_<F> = Box_::new(f);
689 connect_raw(
690 self.as_ptr() as *mut _,
691 c"notify::min-content-height".as_ptr() as *const _,
692 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
693 notify_min_content_height_trampoline::<F> as *const (),
694 )),
695 Box_::into_raw(f),
696 )
697 }
698 }
699
700 #[doc(alias = "min-content-width")]
701 pub fn connect_min_content_width_notify<F: Fn(&Self) + 'static>(
702 &self,
703 f: F,
704 ) -> SignalHandlerId {
705 unsafe extern "C" fn notify_min_content_width_trampoline<
706 F: Fn(&ScrolledWindow) + 'static,
707 >(
708 this: *mut ffi::GtkScrolledWindow,
709 _param_spec: glib::ffi::gpointer,
710 f: glib::ffi::gpointer,
711 ) {
712 let f: &F = &*(f as *const F);
713 f(&from_glib_borrow(this))
714 }
715 unsafe {
716 let f: Box_<F> = Box_::new(f);
717 connect_raw(
718 self.as_ptr() as *mut _,
719 c"notify::min-content-width".as_ptr() as *const _,
720 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
721 notify_min_content_width_trampoline::<F> as *const (),
722 )),
723 Box_::into_raw(f),
724 )
725 }
726 }
727
728 #[doc(alias = "overlay-scrolling")]
729 pub fn connect_overlay_scrolling_notify<F: Fn(&Self) + 'static>(
730 &self,
731 f: F,
732 ) -> SignalHandlerId {
733 unsafe extern "C" fn notify_overlay_scrolling_trampoline<
734 F: Fn(&ScrolledWindow) + 'static,
735 >(
736 this: *mut ffi::GtkScrolledWindow,
737 _param_spec: glib::ffi::gpointer,
738 f: glib::ffi::gpointer,
739 ) {
740 let f: &F = &*(f as *const F);
741 f(&from_glib_borrow(this))
742 }
743 unsafe {
744 let f: Box_<F> = Box_::new(f);
745 connect_raw(
746 self.as_ptr() as *mut _,
747 c"notify::overlay-scrolling".as_ptr() as *const _,
748 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
749 notify_overlay_scrolling_trampoline::<F> as *const (),
750 )),
751 Box_::into_raw(f),
752 )
753 }
754 }
755
756 #[doc(alias = "propagate-natural-height")]
757 pub fn connect_propagate_natural_height_notify<F: Fn(&Self) + 'static>(
758 &self,
759 f: F,
760 ) -> SignalHandlerId {
761 unsafe extern "C" fn notify_propagate_natural_height_trampoline<
762 F: Fn(&ScrolledWindow) + 'static,
763 >(
764 this: *mut ffi::GtkScrolledWindow,
765 _param_spec: glib::ffi::gpointer,
766 f: glib::ffi::gpointer,
767 ) {
768 let f: &F = &*(f as *const F);
769 f(&from_glib_borrow(this))
770 }
771 unsafe {
772 let f: Box_<F> = Box_::new(f);
773 connect_raw(
774 self.as_ptr() as *mut _,
775 c"notify::propagate-natural-height".as_ptr() as *const _,
776 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
777 notify_propagate_natural_height_trampoline::<F> as *const (),
778 )),
779 Box_::into_raw(f),
780 )
781 }
782 }
783
784 #[doc(alias = "propagate-natural-width")]
785 pub fn connect_propagate_natural_width_notify<F: Fn(&Self) + 'static>(
786 &self,
787 f: F,
788 ) -> SignalHandlerId {
789 unsafe extern "C" fn notify_propagate_natural_width_trampoline<
790 F: Fn(&ScrolledWindow) + 'static,
791 >(
792 this: *mut ffi::GtkScrolledWindow,
793 _param_spec: glib::ffi::gpointer,
794 f: glib::ffi::gpointer,
795 ) {
796 let f: &F = &*(f as *const F);
797 f(&from_glib_borrow(this))
798 }
799 unsafe {
800 let f: Box_<F> = Box_::new(f);
801 connect_raw(
802 self.as_ptr() as *mut _,
803 c"notify::propagate-natural-width".as_ptr() as *const _,
804 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
805 notify_propagate_natural_width_trampoline::<F> as *const (),
806 )),
807 Box_::into_raw(f),
808 )
809 }
810 }
811
812 #[doc(alias = "vadjustment")]
813 pub fn connect_vadjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
814 unsafe extern "C" fn notify_vadjustment_trampoline<F: Fn(&ScrolledWindow) + 'static>(
815 this: *mut ffi::GtkScrolledWindow,
816 _param_spec: glib::ffi::gpointer,
817 f: glib::ffi::gpointer,
818 ) {
819 let f: &F = &*(f as *const F);
820 f(&from_glib_borrow(this))
821 }
822 unsafe {
823 let f: Box_<F> = Box_::new(f);
824 connect_raw(
825 self.as_ptr() as *mut _,
826 c"notify::vadjustment".as_ptr() as *const _,
827 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
828 notify_vadjustment_trampoline::<F> as *const (),
829 )),
830 Box_::into_raw(f),
831 )
832 }
833 }
834
835 #[doc(alias = "vscrollbar-policy")]
836 pub fn connect_vscrollbar_policy_notify<F: Fn(&Self) + 'static>(
837 &self,
838 f: F,
839 ) -> SignalHandlerId {
840 unsafe extern "C" fn notify_vscrollbar_policy_trampoline<
841 F: Fn(&ScrolledWindow) + 'static,
842 >(
843 this: *mut ffi::GtkScrolledWindow,
844 _param_spec: glib::ffi::gpointer,
845 f: glib::ffi::gpointer,
846 ) {
847 let f: &F = &*(f as *const F);
848 f(&from_glib_borrow(this))
849 }
850 unsafe {
851 let f: Box_<F> = Box_::new(f);
852 connect_raw(
853 self.as_ptr() as *mut _,
854 c"notify::vscrollbar-policy".as_ptr() as *const _,
855 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
856 notify_vscrollbar_policy_trampoline::<F> as *const (),
857 )),
858 Box_::into_raw(f),
859 )
860 }
861 }
862
863 #[doc(alias = "window-placement")]
864 pub fn connect_window_placement_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
865 unsafe extern "C" fn notify_window_placement_trampoline<
866 F: Fn(&ScrolledWindow) + 'static,
867 >(
868 this: *mut ffi::GtkScrolledWindow,
869 _param_spec: glib::ffi::gpointer,
870 f: glib::ffi::gpointer,
871 ) {
872 let f: &F = &*(f as *const F);
873 f(&from_glib_borrow(this))
874 }
875 unsafe {
876 let f: Box_<F> = Box_::new(f);
877 connect_raw(
878 self.as_ptr() as *mut _,
879 c"notify::window-placement".as_ptr() as *const _,
880 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
881 notify_window_placement_trampoline::<F> as *const (),
882 )),
883 Box_::into_raw(f),
884 )
885 }
886 }
887}
888
889impl Default for ScrolledWindow {
890 fn default() -> Self {
891 Self::new()
892 }
893}
894
895#[must_use = "The builder must be built to be used"]
900pub struct ScrolledWindowBuilder {
901 builder: glib::object::ObjectBuilder<'static, ScrolledWindow>,
902}
903
904impl ScrolledWindowBuilder {
905 fn new() -> Self {
906 Self {
907 builder: glib::object::Object::builder(),
908 }
909 }
910
911 pub fn child(self, child: &impl IsA<Widget>) -> Self {
912 Self {
913 builder: self.builder.property("child", child.clone().upcast()),
914 }
915 }
916
917 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
918 Self {
919 builder: self
920 .builder
921 .property("hadjustment", hadjustment.clone().upcast()),
922 }
923 }
924
925 pub fn has_frame(self, has_frame: bool) -> Self {
926 Self {
927 builder: self.builder.property("has-frame", has_frame),
928 }
929 }
930
931 pub fn hscrollbar_policy(self, hscrollbar_policy: PolicyType) -> Self {
932 Self {
933 builder: self
934 .builder
935 .property("hscrollbar-policy", hscrollbar_policy),
936 }
937 }
938
939 pub fn kinetic_scrolling(self, kinetic_scrolling: bool) -> Self {
940 Self {
941 builder: self
942 .builder
943 .property("kinetic-scrolling", kinetic_scrolling),
944 }
945 }
946
947 pub fn max_content_height(self, max_content_height: i32) -> Self {
948 Self {
949 builder: self
950 .builder
951 .property("max-content-height", max_content_height),
952 }
953 }
954
955 pub fn max_content_width(self, max_content_width: i32) -> Self {
956 Self {
957 builder: self
958 .builder
959 .property("max-content-width", max_content_width),
960 }
961 }
962
963 pub fn min_content_height(self, min_content_height: i32) -> Self {
964 Self {
965 builder: self
966 .builder
967 .property("min-content-height", min_content_height),
968 }
969 }
970
971 pub fn min_content_width(self, min_content_width: i32) -> Self {
972 Self {
973 builder: self
974 .builder
975 .property("min-content-width", min_content_width),
976 }
977 }
978
979 pub fn overlay_scrolling(self, overlay_scrolling: bool) -> Self {
980 Self {
981 builder: self
982 .builder
983 .property("overlay-scrolling", overlay_scrolling),
984 }
985 }
986
987 pub fn propagate_natural_height(self, propagate_natural_height: bool) -> Self {
988 Self {
989 builder: self
990 .builder
991 .property("propagate-natural-height", propagate_natural_height),
992 }
993 }
994
995 pub fn propagate_natural_width(self, propagate_natural_width: bool) -> Self {
996 Self {
997 builder: self
998 .builder
999 .property("propagate-natural-width", propagate_natural_width),
1000 }
1001 }
1002
1003 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1004 Self {
1005 builder: self
1006 .builder
1007 .property("vadjustment", vadjustment.clone().upcast()),
1008 }
1009 }
1010
1011 pub fn vscrollbar_policy(self, vscrollbar_policy: PolicyType) -> Self {
1012 Self {
1013 builder: self
1014 .builder
1015 .property("vscrollbar-policy", vscrollbar_policy),
1016 }
1017 }
1018
1019 pub fn window_placement(self, window_placement: CornerType) -> Self {
1020 Self {
1021 builder: self.builder.property("window-placement", window_placement),
1022 }
1023 }
1024
1025 pub fn can_focus(self, can_focus: bool) -> Self {
1026 Self {
1027 builder: self.builder.property("can-focus", can_focus),
1028 }
1029 }
1030
1031 pub fn can_target(self, can_target: bool) -> Self {
1032 Self {
1033 builder: self.builder.property("can-target", can_target),
1034 }
1035 }
1036
1037 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1038 Self {
1039 builder: self.builder.property("css-classes", css_classes.into()),
1040 }
1041 }
1042
1043 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1044 Self {
1045 builder: self.builder.property("css-name", css_name.into()),
1046 }
1047 }
1048
1049 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1050 Self {
1051 builder: self.builder.property("cursor", cursor.clone()),
1052 }
1053 }
1054
1055 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1056 Self {
1057 builder: self.builder.property("focus-on-click", focus_on_click),
1058 }
1059 }
1060
1061 pub fn focusable(self, focusable: bool) -> Self {
1062 Self {
1063 builder: self.builder.property("focusable", focusable),
1064 }
1065 }
1066
1067 pub fn halign(self, halign: Align) -> Self {
1068 Self {
1069 builder: self.builder.property("halign", halign),
1070 }
1071 }
1072
1073 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1074 Self {
1075 builder: self.builder.property("has-tooltip", has_tooltip),
1076 }
1077 }
1078
1079 pub fn height_request(self, height_request: i32) -> Self {
1080 Self {
1081 builder: self.builder.property("height-request", height_request),
1082 }
1083 }
1084
1085 pub fn hexpand(self, hexpand: bool) -> Self {
1086 Self {
1087 builder: self.builder.property("hexpand", hexpand),
1088 }
1089 }
1090
1091 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1092 Self {
1093 builder: self.builder.property("hexpand-set", hexpand_set),
1094 }
1095 }
1096
1097 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1098 Self {
1099 builder: self
1100 .builder
1101 .property("layout-manager", layout_manager.clone().upcast()),
1102 }
1103 }
1104
1105 #[cfg(feature = "v4_18")]
1106 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1107 pub fn limit_events(self, limit_events: bool) -> Self {
1108 Self {
1109 builder: self.builder.property("limit-events", limit_events),
1110 }
1111 }
1112
1113 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1114 Self {
1115 builder: self.builder.property("margin-bottom", margin_bottom),
1116 }
1117 }
1118
1119 pub fn margin_end(self, margin_end: i32) -> Self {
1120 Self {
1121 builder: self.builder.property("margin-end", margin_end),
1122 }
1123 }
1124
1125 pub fn margin_start(self, margin_start: i32) -> Self {
1126 Self {
1127 builder: self.builder.property("margin-start", margin_start),
1128 }
1129 }
1130
1131 pub fn margin_top(self, margin_top: i32) -> Self {
1132 Self {
1133 builder: self.builder.property("margin-top", margin_top),
1134 }
1135 }
1136
1137 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1138 Self {
1139 builder: self.builder.property("name", name.into()),
1140 }
1141 }
1142
1143 pub fn opacity(self, opacity: f64) -> Self {
1144 Self {
1145 builder: self.builder.property("opacity", opacity),
1146 }
1147 }
1148
1149 pub fn overflow(self, overflow: Overflow) -> Self {
1150 Self {
1151 builder: self.builder.property("overflow", overflow),
1152 }
1153 }
1154
1155 pub fn receives_default(self, receives_default: bool) -> Self {
1156 Self {
1157 builder: self.builder.property("receives-default", receives_default),
1158 }
1159 }
1160
1161 pub fn sensitive(self, sensitive: bool) -> Self {
1162 Self {
1163 builder: self.builder.property("sensitive", sensitive),
1164 }
1165 }
1166
1167 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1168 Self {
1169 builder: self
1170 .builder
1171 .property("tooltip-markup", tooltip_markup.into()),
1172 }
1173 }
1174
1175 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1176 Self {
1177 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1178 }
1179 }
1180
1181 pub fn valign(self, valign: Align) -> Self {
1182 Self {
1183 builder: self.builder.property("valign", valign),
1184 }
1185 }
1186
1187 pub fn vexpand(self, vexpand: bool) -> Self {
1188 Self {
1189 builder: self.builder.property("vexpand", vexpand),
1190 }
1191 }
1192
1193 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1194 Self {
1195 builder: self.builder.property("vexpand-set", vexpand_set),
1196 }
1197 }
1198
1199 pub fn visible(self, visible: bool) -> Self {
1200 Self {
1201 builder: self.builder.property("visible", visible),
1202 }
1203 }
1204
1205 pub fn width_request(self, width_request: i32) -> Self {
1206 Self {
1207 builder: self.builder.property("width-request", width_request),
1208 }
1209 }
1210
1211 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1212 Self {
1213 builder: self.builder.property("accessible-role", accessible_role),
1214 }
1215 }
1216
1217 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1220 pub fn build(self) -> ScrolledWindow {
1221 assert_initialized_main_thread!();
1222 self.builder.build()
1223 }
1224}