[go: up one dir, main page]

gtk4/auto/
scrollable.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::{ffi, Adjustment, Border, ScrollablePolicy};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkScrollable")]
15    pub struct Scrollable(Interface<ffi::GtkScrollable, ffi::GtkScrollableInterface>);
16
17    match fn {
18        type_ => || ffi::gtk_scrollable_get_type(),
19    }
20}
21
22impl Scrollable {
23    pub const NONE: Option<&'static Scrollable> = None;
24}
25
26pub trait ScrollableExt: IsA<Scrollable> + 'static {
27    #[doc(alias = "gtk_scrollable_get_border")]
28    #[doc(alias = "get_border")]
29    fn border(&self) -> Option<Border> {
30        unsafe {
31            let mut border = Border::uninitialized();
32            let ret = from_glib(ffi::gtk_scrollable_get_border(
33                self.as_ref().to_glib_none().0,
34                border.to_glib_none_mut().0,
35            ));
36            if ret {
37                Some(border)
38            } else {
39                None
40            }
41        }
42    }
43
44    #[doc(alias = "gtk_scrollable_get_hadjustment")]
45    #[doc(alias = "get_hadjustment")]
46    fn hadjustment(&self) -> Option<Adjustment> {
47        unsafe {
48            from_glib_none(ffi::gtk_scrollable_get_hadjustment(
49                self.as_ref().to_glib_none().0,
50            ))
51        }
52    }
53
54    #[doc(alias = "gtk_scrollable_get_hscroll_policy")]
55    #[doc(alias = "get_hscroll_policy")]
56    #[doc(alias = "hscroll-policy")]
57    fn hscroll_policy(&self) -> ScrollablePolicy {
58        unsafe {
59            from_glib(ffi::gtk_scrollable_get_hscroll_policy(
60                self.as_ref().to_glib_none().0,
61            ))
62        }
63    }
64
65    #[doc(alias = "gtk_scrollable_get_vadjustment")]
66    #[doc(alias = "get_vadjustment")]
67    fn vadjustment(&self) -> Option<Adjustment> {
68        unsafe {
69            from_glib_none(ffi::gtk_scrollable_get_vadjustment(
70                self.as_ref().to_glib_none().0,
71            ))
72        }
73    }
74
75    #[doc(alias = "gtk_scrollable_get_vscroll_policy")]
76    #[doc(alias = "get_vscroll_policy")]
77    #[doc(alias = "vscroll-policy")]
78    fn vscroll_policy(&self) -> ScrollablePolicy {
79        unsafe {
80            from_glib(ffi::gtk_scrollable_get_vscroll_policy(
81                self.as_ref().to_glib_none().0,
82            ))
83        }
84    }
85
86    #[doc(alias = "gtk_scrollable_set_hadjustment")]
87    #[doc(alias = "hadjustment")]
88    fn set_hadjustment(&self, hadjustment: Option<&impl IsA<Adjustment>>) {
89        unsafe {
90            ffi::gtk_scrollable_set_hadjustment(
91                self.as_ref().to_glib_none().0,
92                hadjustment.map(|p| p.as_ref()).to_glib_none().0,
93            );
94        }
95    }
96
97    #[doc(alias = "gtk_scrollable_set_hscroll_policy")]
98    #[doc(alias = "hscroll-policy")]
99    fn set_hscroll_policy(&self, policy: ScrollablePolicy) {
100        unsafe {
101            ffi::gtk_scrollable_set_hscroll_policy(
102                self.as_ref().to_glib_none().0,
103                policy.into_glib(),
104            );
105        }
106    }
107
108    #[doc(alias = "gtk_scrollable_set_vadjustment")]
109    #[doc(alias = "vadjustment")]
110    fn set_vadjustment(&self, vadjustment: Option<&impl IsA<Adjustment>>) {
111        unsafe {
112            ffi::gtk_scrollable_set_vadjustment(
113                self.as_ref().to_glib_none().0,
114                vadjustment.map(|p| p.as_ref()).to_glib_none().0,
115            );
116        }
117    }
118
119    #[doc(alias = "gtk_scrollable_set_vscroll_policy")]
120    #[doc(alias = "vscroll-policy")]
121    fn set_vscroll_policy(&self, policy: ScrollablePolicy) {
122        unsafe {
123            ffi::gtk_scrollable_set_vscroll_policy(
124                self.as_ref().to_glib_none().0,
125                policy.into_glib(),
126            );
127        }
128    }
129
130    #[doc(alias = "hadjustment")]
131    fn connect_hadjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
132        unsafe extern "C" fn notify_hadjustment_trampoline<
133            P: IsA<Scrollable>,
134            F: Fn(&P) + 'static,
135        >(
136            this: *mut ffi::GtkScrollable,
137            _param_spec: glib::ffi::gpointer,
138            f: glib::ffi::gpointer,
139        ) {
140            let f: &F = &*(f as *const F);
141            f(Scrollable::from_glib_borrow(this).unsafe_cast_ref())
142        }
143        unsafe {
144            let f: Box_<F> = Box_::new(f);
145            connect_raw(
146                self.as_ptr() as *mut _,
147                c"notify::hadjustment".as_ptr() as *const _,
148                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
149                    notify_hadjustment_trampoline::<Self, F> as *const (),
150                )),
151                Box_::into_raw(f),
152            )
153        }
154    }
155
156    #[doc(alias = "hscroll-policy")]
157    fn connect_hscroll_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
158        unsafe extern "C" fn notify_hscroll_policy_trampoline<
159            P: IsA<Scrollable>,
160            F: Fn(&P) + 'static,
161        >(
162            this: *mut ffi::GtkScrollable,
163            _param_spec: glib::ffi::gpointer,
164            f: glib::ffi::gpointer,
165        ) {
166            let f: &F = &*(f as *const F);
167            f(Scrollable::from_glib_borrow(this).unsafe_cast_ref())
168        }
169        unsafe {
170            let f: Box_<F> = Box_::new(f);
171            connect_raw(
172                self.as_ptr() as *mut _,
173                c"notify::hscroll-policy".as_ptr() as *const _,
174                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
175                    notify_hscroll_policy_trampoline::<Self, F> as *const (),
176                )),
177                Box_::into_raw(f),
178            )
179        }
180    }
181
182    #[doc(alias = "vadjustment")]
183    fn connect_vadjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
184        unsafe extern "C" fn notify_vadjustment_trampoline<
185            P: IsA<Scrollable>,
186            F: Fn(&P) + 'static,
187        >(
188            this: *mut ffi::GtkScrollable,
189            _param_spec: glib::ffi::gpointer,
190            f: glib::ffi::gpointer,
191        ) {
192            let f: &F = &*(f as *const F);
193            f(Scrollable::from_glib_borrow(this).unsafe_cast_ref())
194        }
195        unsafe {
196            let f: Box_<F> = Box_::new(f);
197            connect_raw(
198                self.as_ptr() as *mut _,
199                c"notify::vadjustment".as_ptr() as *const _,
200                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
201                    notify_vadjustment_trampoline::<Self, F> as *const (),
202                )),
203                Box_::into_raw(f),
204            )
205        }
206    }
207
208    #[doc(alias = "vscroll-policy")]
209    fn connect_vscroll_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
210        unsafe extern "C" fn notify_vscroll_policy_trampoline<
211            P: IsA<Scrollable>,
212            F: Fn(&P) + 'static,
213        >(
214            this: *mut ffi::GtkScrollable,
215            _param_spec: glib::ffi::gpointer,
216            f: glib::ffi::gpointer,
217        ) {
218            let f: &F = &*(f as *const F);
219            f(Scrollable::from_glib_borrow(this).unsafe_cast_ref())
220        }
221        unsafe {
222            let f: Box_<F> = Box_::new(f);
223            connect_raw(
224                self.as_ptr() as *mut _,
225                c"notify::vscroll-policy".as_ptr() as *const _,
226                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
227                    notify_vscroll_policy_trampoline::<Self, F> as *const (),
228                )),
229                Box_::into_raw(f),
230            )
231        }
232    }
233}
234
235impl<O: IsA<Scrollable>> ScrollableExt for O {}