1#![allow(deprecated)]
5
6use crate::{ffi, CellArea};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GtkCellAreaContext")]
16 pub struct CellAreaContext(Object<ffi::GtkCellAreaContext, ffi::GtkCellAreaContextClass>);
17
18 match fn {
19 type_ => || ffi::gtk_cell_area_context_get_type(),
20 }
21}
22
23impl CellAreaContext {
24 pub const NONE: Option<&'static CellAreaContext> = None;
25}
26
27pub trait CellAreaContextExt: IsA<CellAreaContext> + 'static {
28 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
29 #[allow(deprecated)]
30 #[doc(alias = "gtk_cell_area_context_allocate")]
31 fn allocate(&self, width: i32, height: i32) {
32 unsafe {
33 ffi::gtk_cell_area_context_allocate(self.as_ref().to_glib_none().0, width, height);
34 }
35 }
36
37 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
38 #[allow(deprecated)]
39 #[doc(alias = "gtk_cell_area_context_get_allocation")]
40 #[doc(alias = "get_allocation")]
41 fn allocation(&self) -> (i32, i32) {
42 unsafe {
43 let mut width = std::mem::MaybeUninit::uninit();
44 let mut height = std::mem::MaybeUninit::uninit();
45 ffi::gtk_cell_area_context_get_allocation(
46 self.as_ref().to_glib_none().0,
47 width.as_mut_ptr(),
48 height.as_mut_ptr(),
49 );
50 (width.assume_init(), height.assume_init())
51 }
52 }
53
54 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
55 #[allow(deprecated)]
56 #[doc(alias = "gtk_cell_area_context_get_area")]
57 #[doc(alias = "get_area")]
58 fn area(&self) -> CellArea {
59 unsafe {
60 from_glib_none(ffi::gtk_cell_area_context_get_area(
61 self.as_ref().to_glib_none().0,
62 ))
63 }
64 }
65
66 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
67 #[allow(deprecated)]
68 #[doc(alias = "gtk_cell_area_context_get_preferred_height")]
69 #[doc(alias = "get_preferred_height")]
70 fn preferred_height(&self) -> (i32, i32) {
71 unsafe {
72 let mut minimum_height = std::mem::MaybeUninit::uninit();
73 let mut natural_height = std::mem::MaybeUninit::uninit();
74 ffi::gtk_cell_area_context_get_preferred_height(
75 self.as_ref().to_glib_none().0,
76 minimum_height.as_mut_ptr(),
77 natural_height.as_mut_ptr(),
78 );
79 (minimum_height.assume_init(), natural_height.assume_init())
80 }
81 }
82
83 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
84 #[allow(deprecated)]
85 #[doc(alias = "gtk_cell_area_context_get_preferred_height_for_width")]
86 #[doc(alias = "get_preferred_height_for_width")]
87 fn preferred_height_for_width(&self, width: i32) -> (i32, i32) {
88 unsafe {
89 let mut minimum_height = std::mem::MaybeUninit::uninit();
90 let mut natural_height = std::mem::MaybeUninit::uninit();
91 ffi::gtk_cell_area_context_get_preferred_height_for_width(
92 self.as_ref().to_glib_none().0,
93 width,
94 minimum_height.as_mut_ptr(),
95 natural_height.as_mut_ptr(),
96 );
97 (minimum_height.assume_init(), natural_height.assume_init())
98 }
99 }
100
101 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
102 #[allow(deprecated)]
103 #[doc(alias = "gtk_cell_area_context_get_preferred_width")]
104 #[doc(alias = "get_preferred_width")]
105 fn preferred_width(&self) -> (i32, i32) {
106 unsafe {
107 let mut minimum_width = std::mem::MaybeUninit::uninit();
108 let mut natural_width = std::mem::MaybeUninit::uninit();
109 ffi::gtk_cell_area_context_get_preferred_width(
110 self.as_ref().to_glib_none().0,
111 minimum_width.as_mut_ptr(),
112 natural_width.as_mut_ptr(),
113 );
114 (minimum_width.assume_init(), natural_width.assume_init())
115 }
116 }
117
118 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
119 #[allow(deprecated)]
120 #[doc(alias = "gtk_cell_area_context_get_preferred_width_for_height")]
121 #[doc(alias = "get_preferred_width_for_height")]
122 fn preferred_width_for_height(&self, height: i32) -> (i32, i32) {
123 unsafe {
124 let mut minimum_width = std::mem::MaybeUninit::uninit();
125 let mut natural_width = std::mem::MaybeUninit::uninit();
126 ffi::gtk_cell_area_context_get_preferred_width_for_height(
127 self.as_ref().to_glib_none().0,
128 height,
129 minimum_width.as_mut_ptr(),
130 natural_width.as_mut_ptr(),
131 );
132 (minimum_width.assume_init(), natural_width.assume_init())
133 }
134 }
135
136 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
137 #[allow(deprecated)]
138 #[doc(alias = "gtk_cell_area_context_push_preferred_height")]
139 fn push_preferred_height(&self, minimum_height: i32, natural_height: i32) {
140 unsafe {
141 ffi::gtk_cell_area_context_push_preferred_height(
142 self.as_ref().to_glib_none().0,
143 minimum_height,
144 natural_height,
145 );
146 }
147 }
148
149 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
150 #[allow(deprecated)]
151 #[doc(alias = "gtk_cell_area_context_push_preferred_width")]
152 fn push_preferred_width(&self, minimum_width: i32, natural_width: i32) {
153 unsafe {
154 ffi::gtk_cell_area_context_push_preferred_width(
155 self.as_ref().to_glib_none().0,
156 minimum_width,
157 natural_width,
158 );
159 }
160 }
161
162 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
163 #[allow(deprecated)]
164 #[doc(alias = "gtk_cell_area_context_reset")]
165 fn reset(&self) {
166 unsafe {
167 ffi::gtk_cell_area_context_reset(self.as_ref().to_glib_none().0);
168 }
169 }
170
171 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
172 #[doc(alias = "minimum-height")]
173 fn minimum_height(&self) -> i32 {
174 ObjectExt::property(self.as_ref(), "minimum-height")
175 }
176
177 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
178 #[doc(alias = "minimum-width")]
179 fn minimum_width(&self) -> i32 {
180 ObjectExt::property(self.as_ref(), "minimum-width")
181 }
182
183 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
184 #[doc(alias = "natural-height")]
185 fn natural_height(&self) -> i32 {
186 ObjectExt::property(self.as_ref(), "natural-height")
187 }
188
189 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
190 #[doc(alias = "natural-width")]
191 fn natural_width(&self) -> i32 {
192 ObjectExt::property(self.as_ref(), "natural-width")
193 }
194
195 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
196 #[doc(alias = "minimum-height")]
197 fn connect_minimum_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
198 unsafe extern "C" fn notify_minimum_height_trampoline<
199 P: IsA<CellAreaContext>,
200 F: Fn(&P) + 'static,
201 >(
202 this: *mut ffi::GtkCellAreaContext,
203 _param_spec: glib::ffi::gpointer,
204 f: glib::ffi::gpointer,
205 ) {
206 let f: &F = &*(f as *const F);
207 f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
208 }
209 unsafe {
210 let f: Box_<F> = Box_::new(f);
211 connect_raw(
212 self.as_ptr() as *mut _,
213 c"notify::minimum-height".as_ptr() as *const _,
214 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
215 notify_minimum_height_trampoline::<Self, F> as *const (),
216 )),
217 Box_::into_raw(f),
218 )
219 }
220 }
221
222 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
223 #[doc(alias = "minimum-width")]
224 fn connect_minimum_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
225 unsafe extern "C" fn notify_minimum_width_trampoline<
226 P: IsA<CellAreaContext>,
227 F: Fn(&P) + 'static,
228 >(
229 this: *mut ffi::GtkCellAreaContext,
230 _param_spec: glib::ffi::gpointer,
231 f: glib::ffi::gpointer,
232 ) {
233 let f: &F = &*(f as *const F);
234 f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
235 }
236 unsafe {
237 let f: Box_<F> = Box_::new(f);
238 connect_raw(
239 self.as_ptr() as *mut _,
240 c"notify::minimum-width".as_ptr() as *const _,
241 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
242 notify_minimum_width_trampoline::<Self, F> as *const (),
243 )),
244 Box_::into_raw(f),
245 )
246 }
247 }
248
249 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
250 #[doc(alias = "natural-height")]
251 fn connect_natural_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
252 unsafe extern "C" fn notify_natural_height_trampoline<
253 P: IsA<CellAreaContext>,
254 F: Fn(&P) + 'static,
255 >(
256 this: *mut ffi::GtkCellAreaContext,
257 _param_spec: glib::ffi::gpointer,
258 f: glib::ffi::gpointer,
259 ) {
260 let f: &F = &*(f as *const F);
261 f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
262 }
263 unsafe {
264 let f: Box_<F> = Box_::new(f);
265 connect_raw(
266 self.as_ptr() as *mut _,
267 c"notify::natural-height".as_ptr() as *const _,
268 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
269 notify_natural_height_trampoline::<Self, F> as *const (),
270 )),
271 Box_::into_raw(f),
272 )
273 }
274 }
275
276 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
277 #[doc(alias = "natural-width")]
278 fn connect_natural_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
279 unsafe extern "C" fn notify_natural_width_trampoline<
280 P: IsA<CellAreaContext>,
281 F: Fn(&P) + 'static,
282 >(
283 this: *mut ffi::GtkCellAreaContext,
284 _param_spec: glib::ffi::gpointer,
285 f: glib::ffi::gpointer,
286 ) {
287 let f: &F = &*(f as *const F);
288 f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
289 }
290 unsafe {
291 let f: Box_<F> = Box_::new(f);
292 connect_raw(
293 self.as_ptr() as *mut _,
294 c"notify::natural-width".as_ptr() as *const _,
295 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
296 notify_natural_width_trampoline::<Self, F> as *const (),
297 )),
298 Box_::into_raw(f),
299 )
300 }
301 }
302}
303
304impl<O: IsA<CellAreaContext>> CellAreaContextExt for O {}