1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
#![allow(deprecated)]

use crate::CellArea;
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// This object will be removed in GTK 5
    /// Stores geometrical information for a series of rows in a GtkCellArea
    ///
    /// The [`CellAreaContext`][crate::CellAreaContext] object is created by a given [`CellArea`][crate::CellArea]
    /// implementation via its `GtkCellAreaClass.create_context()` virtual
    /// method and is used to store cell sizes and alignments for a series of
    /// [`TreeModel`][crate::TreeModel] rows that are requested and rendered in the same context.
    ///
    /// [`CellLayout`][crate::CellLayout] widgets can create any number of contexts in which to
    /// request and render groups of data rows. However, it’s important that the
    /// same context which was used to request sizes for a given [`TreeModel`][crate::TreeModel]
    /// row also be used for the same row when calling other [`CellArea`][crate::CellArea] APIs
    /// such as gtk_cell_area_render() and gtk_cell_area_event().
    ///
    /// ## Properties
    ///
    ///
    /// #### `area`
    ///  The [`CellArea`][crate::CellArea] this context was created by
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `minimum-height`
    ///  The minimum height for the [`CellArea`][crate::CellArea] in this context
    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
    /// for using gtk_cell_area_get_preferred_height().
    ///
    /// Readable
    ///
    ///
    /// #### `minimum-width`
    ///  The minimum width for the [`CellArea`][crate::CellArea] in this context
    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
    /// for using gtk_cell_area_get_preferred_width().
    ///
    /// Readable
    ///
    ///
    /// #### `natural-height`
    ///  The natural height for the [`CellArea`][crate::CellArea] in this context
    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
    /// for using gtk_cell_area_get_preferred_height().
    ///
    /// Readable
    ///
    ///
    /// #### `natural-width`
    ///  The natural width for the [`CellArea`][crate::CellArea] in this context
    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
    /// for using gtk_cell_area_get_preferred_width().
    ///
    /// Readable
    ///
    /// # Implements
    ///
    /// [`CellAreaContextExt`][trait@crate::prelude::CellAreaContextExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "GtkCellAreaContext")]
    pub struct CellAreaContext(Object<ffi::GtkCellAreaContext, ffi::GtkCellAreaContextClass>);

    match fn {
        type_ => || ffi::gtk_cell_area_context_get_type(),
    }
}

impl CellAreaContext {
    pub const NONE: Option<&'static CellAreaContext> = None;
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::CellAreaContext>> Sealed for T {}
}

/// Trait containing all [`struct@CellAreaContext`] methods.
///
/// # Implementors
///
/// [`CellAreaContext`][struct@crate::CellAreaContext]
pub trait CellAreaContextExt: IsA<CellAreaContext> + sealed::Sealed + 'static {
    /// Allocates a width and/or a height for all rows which are to be
    /// rendered with @self.
    ///
    /// Usually allocation is performed only horizontally or sometimes
    /// vertically since a group of rows are usually rendered side by
    /// side vertically or horizontally and share either the same width
    /// or the same height. Sometimes they are allocated in both horizontal
    /// and vertical orientations producing a homogeneous effect of the
    /// rows. This is generally the case for [`TreeView`][crate::TreeView] when
    /// `GtkTreeView:fixed-height-mode` is enabled.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    /// ## `width`
    /// the allocated width for all [`TreeModel`][crate::TreeModel] rows rendered
    ///   with @self, or -1
    /// ## `height`
    /// the allocated height for all [`TreeModel`][crate::TreeModel] rows rendered
    ///   with @self, or -1
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_allocate")]
    fn allocate(&self, width: i32, height: i32) {
        unsafe {
            ffi::gtk_cell_area_context_allocate(self.as_ref().to_glib_none().0, width, height);
        }
    }

    /// Fetches the current allocation size for @self.
    ///
    /// If the context was not allocated in width or height, or if the
    /// context was recently reset with gtk_cell_area_context_reset(),
    /// the returned value will be -1.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    ///
    /// # Returns
    ///
    ///
    /// ## `width`
    /// location to store the allocated width
    ///
    /// ## `height`
    /// location to store the allocated height
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_get_allocation")]
    #[doc(alias = "get_allocation")]
    fn allocation(&self) -> (i32, i32) {
        unsafe {
            let mut width = std::mem::MaybeUninit::uninit();
            let mut height = std::mem::MaybeUninit::uninit();
            ffi::gtk_cell_area_context_get_allocation(
                self.as_ref().to_glib_none().0,
                width.as_mut_ptr(),
                height.as_mut_ptr(),
            );
            (width.assume_init(), height.assume_init())
        }
    }

    /// Fetches the [`CellArea`][crate::CellArea] this @self was created by.
    ///
    /// This is generally unneeded by layouting widgets; however,
    /// it is important for the context implementation itself to
    /// fetch information about the area it is being used for.
    ///
    /// For instance at `GtkCellAreaContextClass.allocate()` time
    /// it’s important to know details about any cell spacing
    /// that the [`CellArea`][crate::CellArea] is configured with in order to
    /// compute a proper allocation.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    ///
    /// # Returns
    ///
    /// the [`CellArea`][crate::CellArea] this context was created by.
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_get_area")]
    #[doc(alias = "get_area")]
    fn area(&self) -> CellArea {
        unsafe {
            from_glib_none(ffi::gtk_cell_area_context_get_area(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the accumulative preferred height for all rows which have been
    /// requested with this context.
    ///
    /// After gtk_cell_area_context_reset() is called and/or before ever
    /// requesting the size of a [`CellArea`][crate::CellArea], the returned values are 0.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    ///
    /// # Returns
    ///
    ///
    /// ## `minimum_height`
    /// location to store the minimum height
    ///
    /// ## `natural_height`
    /// location to store the natural height
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_get_preferred_height")]
    #[doc(alias = "get_preferred_height")]
    fn preferred_height(&self) -> (i32, i32) {
        unsafe {
            let mut minimum_height = std::mem::MaybeUninit::uninit();
            let mut natural_height = std::mem::MaybeUninit::uninit();
            ffi::gtk_cell_area_context_get_preferred_height(
                self.as_ref().to_glib_none().0,
                minimum_height.as_mut_ptr(),
                natural_height.as_mut_ptr(),
            );
            (minimum_height.assume_init(), natural_height.assume_init())
        }
    }

    /// Gets the accumulative preferred height for @width for all rows
    /// which have been requested for the same said @width with this context.
    ///
    /// After gtk_cell_area_context_reset() is called and/or before ever
    /// requesting the size of a [`CellArea`][crate::CellArea], the returned values are -1.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    /// ## `width`
    /// a proposed width for allocation
    ///
    /// # Returns
    ///
    ///
    /// ## `minimum_height`
    /// location to store the minimum height
    ///
    /// ## `natural_height`
    /// location to store the natural height
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_get_preferred_height_for_width")]
    #[doc(alias = "get_preferred_height_for_width")]
    fn preferred_height_for_width(&self, width: i32) -> (i32, i32) {
        unsafe {
            let mut minimum_height = std::mem::MaybeUninit::uninit();
            let mut natural_height = std::mem::MaybeUninit::uninit();
            ffi::gtk_cell_area_context_get_preferred_height_for_width(
                self.as_ref().to_glib_none().0,
                width,
                minimum_height.as_mut_ptr(),
                natural_height.as_mut_ptr(),
            );
            (minimum_height.assume_init(), natural_height.assume_init())
        }
    }

    /// Gets the accumulative preferred width for all rows which have been
    /// requested with this context.
    ///
    /// After gtk_cell_area_context_reset() is called and/or before ever
    /// requesting the size of a [`CellArea`][crate::CellArea], the returned values are 0.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    ///
    /// # Returns
    ///
    ///
    /// ## `minimum_width`
    /// location to store the minimum width
    ///
    /// ## `natural_width`
    /// location to store the natural width
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_get_preferred_width")]
    #[doc(alias = "get_preferred_width")]
    fn preferred_width(&self) -> (i32, i32) {
        unsafe {
            let mut minimum_width = std::mem::MaybeUninit::uninit();
            let mut natural_width = std::mem::MaybeUninit::uninit();
            ffi::gtk_cell_area_context_get_preferred_width(
                self.as_ref().to_glib_none().0,
                minimum_width.as_mut_ptr(),
                natural_width.as_mut_ptr(),
            );
            (minimum_width.assume_init(), natural_width.assume_init())
        }
    }

    /// Gets the accumulative preferred width for @height for all rows which
    /// have been requested for the same said @height with this context.
    ///
    /// After gtk_cell_area_context_reset() is called and/or before ever
    /// requesting the size of a [`CellArea`][crate::CellArea], the returned values are -1.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    /// ## `height`
    /// a proposed height for allocation
    ///
    /// # Returns
    ///
    ///
    /// ## `minimum_width`
    /// location to store the minimum width
    ///
    /// ## `natural_width`
    /// location to store the natural width
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_get_preferred_width_for_height")]
    #[doc(alias = "get_preferred_width_for_height")]
    fn preferred_width_for_height(&self, height: i32) -> (i32, i32) {
        unsafe {
            let mut minimum_width = std::mem::MaybeUninit::uninit();
            let mut natural_width = std::mem::MaybeUninit::uninit();
            ffi::gtk_cell_area_context_get_preferred_width_for_height(
                self.as_ref().to_glib_none().0,
                height,
                minimum_width.as_mut_ptr(),
                natural_width.as_mut_ptr(),
            );
            (minimum_width.assume_init(), natural_width.assume_init())
        }
    }

    /// Causes the minimum and/or natural height to grow if the new
    /// proposed sizes exceed the current minimum and natural height.
    ///
    /// This is used by [`CellAreaContext`][crate::CellAreaContext] implementations during
    /// the request process over a series of [`TreeModel`][crate::TreeModel] rows to
    /// progressively push the requested height over a series of
    /// gtk_cell_area_get_preferred_height() requests.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    /// ## `minimum_height`
    /// the proposed new minimum height for @self
    /// ## `natural_height`
    /// the proposed new natural height for @self
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_push_preferred_height")]
    fn push_preferred_height(&self, minimum_height: i32, natural_height: i32) {
        unsafe {
            ffi::gtk_cell_area_context_push_preferred_height(
                self.as_ref().to_glib_none().0,
                minimum_height,
                natural_height,
            );
        }
    }

    /// Causes the minimum and/or natural width to grow if the new
    /// proposed sizes exceed the current minimum and natural width.
    ///
    /// This is used by [`CellAreaContext`][crate::CellAreaContext] implementations during
    /// the request process over a series of [`TreeModel`][crate::TreeModel] rows to
    /// progressively push the requested width over a series of
    /// gtk_cell_area_get_preferred_width() requests.
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    /// ## `minimum_width`
    /// the proposed new minimum width for @self
    /// ## `natural_width`
    /// the proposed new natural width for @self
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_push_preferred_width")]
    fn push_preferred_width(&self, minimum_width: i32, natural_width: i32) {
        unsafe {
            ffi::gtk_cell_area_context_push_preferred_width(
                self.as_ref().to_glib_none().0,
                minimum_width,
                natural_width,
            );
        }
    }

    /// Resets any previously cached request and allocation
    /// data.
    ///
    /// When underlying [`TreeModel`][crate::TreeModel] data changes its
    /// important to reset the context if the content
    /// size is allowed to shrink. If the content size
    /// is only allowed to grow (this is usually an option
    /// for views rendering large data stores as a measure
    /// of optimization), then only the row that changed
    /// or was inserted needs to be (re)requested with
    /// gtk_cell_area_get_preferred_width().
    ///
    /// When the new overall size of the context requires
    /// that the allocated size changes (or whenever this
    /// allocation changes at all), the variable row
    /// sizes need to be re-requested for every row.
    ///
    /// For instance, if the rows are displayed all with
    /// the same width from top to bottom then a change
    /// in the allocated width necessitates a recalculation
    /// of all the displayed row heights using
    /// gtk_cell_area_get_preferred_height_for_width().
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_cell_area_context_reset")]
    fn reset(&self) {
        unsafe {
            ffi::gtk_cell_area_context_reset(self.as_ref().to_glib_none().0);
        }
    }

    /// The minimum height for the [`CellArea`][crate::CellArea] in this context
    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
    /// for using gtk_cell_area_get_preferred_height().
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[doc(alias = "minimum-height")]
    fn minimum_height(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "minimum-height")
    }

    /// The minimum width for the [`CellArea`][crate::CellArea] in this context
    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
    /// for using gtk_cell_area_get_preferred_width().
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[doc(alias = "minimum-width")]
    fn minimum_width(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "minimum-width")
    }

    /// The natural height for the [`CellArea`][crate::CellArea] in this context
    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
    /// for using gtk_cell_area_get_preferred_height().
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[doc(alias = "natural-height")]
    fn natural_height(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "natural-height")
    }

    /// The natural width for the [`CellArea`][crate::CellArea] in this context
    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
    /// for using gtk_cell_area_get_preferred_width().
    ///
    /// # Deprecated since 4.10
    ///
    /// This object will be removed in GTK 5
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[doc(alias = "natural-width")]
    fn natural_width(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "natural-width")
    }

    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[doc(alias = "minimum-height")]
    fn connect_minimum_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_minimum_height_trampoline<
            P: IsA<CellAreaContext>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkCellAreaContext,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::minimum-height\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_minimum_height_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[doc(alias = "minimum-width")]
    fn connect_minimum_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_minimum_width_trampoline<
            P: IsA<CellAreaContext>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkCellAreaContext,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::minimum-width\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_minimum_width_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[doc(alias = "natural-height")]
    fn connect_natural_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_natural_height_trampoline<
            P: IsA<CellAreaContext>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkCellAreaContext,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::natural-height\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_natural_height_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[doc(alias = "natural-width")]
    fn connect_natural_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_natural_width_trampoline<
            P: IsA<CellAreaContext>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkCellAreaContext,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::natural-width\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_natural_width_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<CellAreaContext>> CellAreaContextExt for O {}