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