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
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib::wrapper! {
    /// [`Adjustment`][crate::Adjustment] is a model for a numeric value.
    ///
    /// The `GtkAdjustment has an associated lower and upper bound.
    /// It also contains step and page increments, and a page size.
    ///
    /// Adjustments are used within several GTK widgets, including
    /// [`SpinButton`][crate::SpinButton], [`Viewport`][crate::Viewport], [`Scrollbar`][crate::Scrollbar]
    /// and [`Scale`][crate::Scale].
    ///
    /// The [`Adjustment`][crate::Adjustment] object does not update the value itself. Instead
    /// it is left up to the owner of the [`Adjustment`][crate::Adjustment] to control the value.
    ///
    /// # Implements
    ///
    /// [`AdjustmentExt`][trait@crate::prelude::AdjustmentExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "GtkAdjustment")]
    pub struct Adjustment(Object<ffi::GtkAdjustment, ffi::GtkAdjustmentClass>);

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

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

    /// Creates a new [`Adjustment`][crate::Adjustment].
    /// ## `value`
    /// the initial value
    /// ## `lower`
    /// the minimum value
    /// ## `upper`
    /// the maximum value
    /// ## `step_increment`
    /// the step increment
    /// ## `page_increment`
    /// the page increment
    /// ## `page_size`
    /// the page size
    ///
    /// # Returns
    ///
    /// a new [`Adjustment`][crate::Adjustment]
    #[doc(alias = "gtk_adjustment_new")]
    pub fn new(
        value: f64,
        lower: f64,
        upper: f64,
        step_increment: f64,
        page_increment: f64,
        page_size: f64,
    ) -> Adjustment {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::gtk_adjustment_new(
                value,
                lower,
                upper,
                step_increment,
                page_increment,
                page_size,
            ))
        }
    }

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`Adjustment`] objects.
    ///
    /// This method returns an instance of [`AdjustmentBuilder`](crate::builders::AdjustmentBuilder) which can be used to create [`Adjustment`] objects.
    pub fn builder() -> AdjustmentBuilder {
        AdjustmentBuilder::default()
    }
}

impl Default for Adjustment {
    fn default() -> Self {
        glib::object::Object::new::<Self>(&[])
            .expect("Can't construct Adjustment object with default parameters")
    }
}

#[derive(Clone, Default)]
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`Adjustment`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
pub struct AdjustmentBuilder {
    lower: Option<f64>,
    page_increment: Option<f64>,
    page_size: Option<f64>,
    step_increment: Option<f64>,
    upper: Option<f64>,
    value: Option<f64>,
}

impl AdjustmentBuilder {
    // rustdoc-stripper-ignore-next
    /// Create a new [`AdjustmentBuilder`].
    pub fn new() -> Self {
        Self::default()
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`Adjustment`].
    #[must_use = "The builder must be built to be used"]
    pub fn build(self) -> Adjustment {
        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
        if let Some(ref lower) = self.lower {
            properties.push(("lower", lower));
        }
        if let Some(ref page_increment) = self.page_increment {
            properties.push(("page-increment", page_increment));
        }
        if let Some(ref page_size) = self.page_size {
            properties.push(("page-size", page_size));
        }
        if let Some(ref step_increment) = self.step_increment {
            properties.push(("step-increment", step_increment));
        }
        if let Some(ref upper) = self.upper {
            properties.push(("upper", upper));
        }
        if let Some(ref value) = self.value {
            properties.push(("value", value));
        }
        glib::Object::new::<Adjustment>(&properties)
            .expect("Failed to create an instance of Adjustment")
    }

    /// The minimum value of the adjustment.
    pub fn lower(mut self, lower: f64) -> Self {
        self.lower = Some(lower);
        self
    }

    /// The page increment of the adjustment.
    pub fn page_increment(mut self, page_increment: f64) -> Self {
        self.page_increment = Some(page_increment);
        self
    }

    /// The page size of the adjustment.
    ///
    /// Note that the page-size is irrelevant and should be set to zero
    /// if the adjustment is used for a simple scalar value, e.g. in a
    /// [`SpinButton`][crate::SpinButton].
    pub fn page_size(mut self, page_size: f64) -> Self {
        self.page_size = Some(page_size);
        self
    }

    /// The step increment of the adjustment.
    pub fn step_increment(mut self, step_increment: f64) -> Self {
        self.step_increment = Some(step_increment);
        self
    }

    /// The maximum value of the adjustment.
    ///
    /// Note that values will be restricted by `upper - page-size` if the page-size
    /// property is nonzero.
    pub fn upper(mut self, upper: f64) -> Self {
        self.upper = Some(upper);
        self
    }

    /// The value of the adjustment.
    pub fn value(mut self, value: f64) -> Self {
        self.value = Some(value);
        self
    }
}

/// Trait containing all [`struct@Adjustment`] methods.
///
/// # Implementors
///
/// [`Adjustment`][struct@crate::Adjustment]
pub trait AdjustmentExt: 'static {
    /// Updates the value property to ensure that the range
    /// between @lower and @upper is in the current page.
    ///
    /// The current page goes from `value` to `value` + `page-size`.
    /// If the range is larger than the page size, then only the
    /// start of it will be in the current page.
    ///
    /// A `signal::Adjustment::value-changed` signal will be emitted
    /// if the value is changed.
    /// ## `lower`
    /// the lower value
    /// ## `upper`
    /// the upper value
    #[doc(alias = "gtk_adjustment_clamp_page")]
    fn clamp_page(&self, lower: f64, upper: f64);

    /// Sets all properties of the adjustment at once.
    ///
    /// Use this function to avoid multiple emissions of the
    /// `signal::Adjustment::changed` signal. See
    /// [`set_lower()`][Self::set_lower()] for an alternative
    /// way of compressing multiple emissions of
    /// `signal::Adjustment::changed` into one.
    /// ## `value`
    /// the new value
    /// ## `lower`
    /// the new minimum value
    /// ## `upper`
    /// the new maximum value
    /// ## `step_increment`
    /// the new step increment
    /// ## `page_increment`
    /// the new page increment
    /// ## `page_size`
    /// the new page size
    #[doc(alias = "gtk_adjustment_configure")]
    fn configure(
        &self,
        value: f64,
        lower: f64,
        upper: f64,
        step_increment: f64,
        page_increment: f64,
        page_size: f64,
    );

    /// Retrieves the minimum value of the adjustment.
    ///
    /// # Returns
    ///
    /// The current minimum value of the adjustment
    #[doc(alias = "gtk_adjustment_get_lower")]
    #[doc(alias = "get_lower")]
    fn lower(&self) -> f64;

    /// Gets the smaller of step increment and page increment.
    ///
    /// # Returns
    ///
    /// the minimum increment of @self
    #[doc(alias = "gtk_adjustment_get_minimum_increment")]
    #[doc(alias = "get_minimum_increment")]
    fn minimum_increment(&self) -> f64;

    /// Retrieves the page increment of the adjustment.
    ///
    /// # Returns
    ///
    /// The current page increment of the adjustment
    #[doc(alias = "gtk_adjustment_get_page_increment")]
    #[doc(alias = "get_page_increment")]
    fn page_increment(&self) -> f64;

    /// Retrieves the page size of the adjustment.
    ///
    /// # Returns
    ///
    /// The current page size of the adjustment
    #[doc(alias = "gtk_adjustment_get_page_size")]
    #[doc(alias = "get_page_size")]
    fn page_size(&self) -> f64;

    /// Retrieves the step increment of the adjustment.
    ///
    /// # Returns
    ///
    /// The current step increment of the adjustment.
    #[doc(alias = "gtk_adjustment_get_step_increment")]
    #[doc(alias = "get_step_increment")]
    fn step_increment(&self) -> f64;

    /// Retrieves the maximum value of the adjustment.
    ///
    /// # Returns
    ///
    /// The current maximum value of the adjustment
    #[doc(alias = "gtk_adjustment_get_upper")]
    #[doc(alias = "get_upper")]
    fn upper(&self) -> f64;

    /// Gets the current value of the adjustment.
    ///
    /// # Returns
    ///
    /// The current value of the adjustment
    #[doc(alias = "gtk_adjustment_get_value")]
    #[doc(alias = "get_value")]
    fn value(&self) -> f64;

    /// Sets the minimum value of the adjustment.
    ///
    /// When setting multiple adjustment properties via their individual
    /// setters, multiple `signal::Adjustment::changed` signals will
    /// be emitted. However, since the emission of the
    /// `signal::Adjustment::changed` signal is tied to the emission
    /// of the ::notify signals of the changed properties, it’s possible
    /// to compress the `signal::Adjustment::changed` signals into one
    /// by calling g_object_freeze_notify() and g_object_thaw_notify()
    /// around the calls to the individual setters.
    ///
    /// Alternatively, using a single g_object_set() for all the properties
    /// to change, or using [`configure()`][Self::configure()] has the same effect.
    /// ## `lower`
    /// the new minimum value
    #[doc(alias = "gtk_adjustment_set_lower")]
    fn set_lower(&self, lower: f64);

    /// Sets the page increment of the adjustment.
    ///
    /// See [`set_lower()`][Self::set_lower()] about how to compress
    /// multiple emissions of the `signal::Adjustment::changed`
    /// signal when setting multiple adjustment properties.
    /// ## `page_increment`
    /// the new page increment
    #[doc(alias = "gtk_adjustment_set_page_increment")]
    fn set_page_increment(&self, page_increment: f64);

    /// Sets the page size of the adjustment.
    ///
    /// See [`set_lower()`][Self::set_lower()] about how to compress
    /// multiple emissions of the `signal::Adjustment::changed`
    /// signal when setting multiple adjustment properties.
    /// ## `page_size`
    /// the new page size
    #[doc(alias = "gtk_adjustment_set_page_size")]
    fn set_page_size(&self, page_size: f64);

    /// Sets the step increment of the adjustment.
    ///
    /// See [`set_lower()`][Self::set_lower()] about how to compress
    /// multiple emissions of the `signal::Adjustment::changed`
    /// signal when setting multiple adjustment properties.
    /// ## `step_increment`
    /// the new step increment
    #[doc(alias = "gtk_adjustment_set_step_increment")]
    fn set_step_increment(&self, step_increment: f64);

    /// Sets the maximum value of the adjustment.
    ///
    /// Note that values will be restricted by `upper - page-size`
    /// if the page-size property is nonzero.
    ///
    /// See [`set_lower()`][Self::set_lower()] about how to compress
    /// multiple emissions of the `signal::Adjustment::changed`
    /// signal when setting multiple adjustment properties.
    /// ## `upper`
    /// the new maximum value
    #[doc(alias = "gtk_adjustment_set_upper")]
    fn set_upper(&self, upper: f64);

    /// Sets the [`Adjustment`][crate::Adjustment] value.
    ///
    /// The value is clamped to lie between `property::Adjustment::lower`
    /// and `property::Adjustment::upper`.
    ///
    /// Note that for adjustments which are used in a [`Scrollbar`][crate::Scrollbar],
    /// the effective range of allowed values goes from
    /// `property::Adjustment::lower` to
    /// `property::Adjustment::upper` - `property::Adjustment::page-size`.
    /// ## `value`
    /// the new value
    #[doc(alias = "gtk_adjustment_set_value")]
    fn set_value(&self, value: f64);

    /// Emitted when one or more of the [`Adjustment`][crate::Adjustment] properties have been
    /// changed.
    ///
    /// Note that the `property::Adjustment::value` property is
    /// covered by the `signal::Adjustment::value-changed` signal.
    #[doc(alias = "changed")]
    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    /// Emitted when the value has been changed.
    #[doc(alias = "value-changed")]
    fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "lower")]
    fn connect_lower_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "page-increment")]
    fn connect_page_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "page-size")]
    fn connect_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "step-increment")]
    fn connect_step_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "upper")]
    fn connect_upper_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "value")]
    fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<Adjustment>> AdjustmentExt for O {
    fn clamp_page(&self, lower: f64, upper: f64) {
        unsafe {
            ffi::gtk_adjustment_clamp_page(self.as_ref().to_glib_none().0, lower, upper);
        }
    }

    fn configure(
        &self,
        value: f64,
        lower: f64,
        upper: f64,
        step_increment: f64,
        page_increment: f64,
        page_size: f64,
    ) {
        unsafe {
            ffi::gtk_adjustment_configure(
                self.as_ref().to_glib_none().0,
                value,
                lower,
                upper,
                step_increment,
                page_increment,
                page_size,
            );
        }
    }

    fn lower(&self) -> f64 {
        unsafe { ffi::gtk_adjustment_get_lower(self.as_ref().to_glib_none().0) }
    }

    fn minimum_increment(&self) -> f64 {
        unsafe { ffi::gtk_adjustment_get_minimum_increment(self.as_ref().to_glib_none().0) }
    }

    fn page_increment(&self) -> f64 {
        unsafe { ffi::gtk_adjustment_get_page_increment(self.as_ref().to_glib_none().0) }
    }

    fn page_size(&self) -> f64 {
        unsafe { ffi::gtk_adjustment_get_page_size(self.as_ref().to_glib_none().0) }
    }

    fn step_increment(&self) -> f64 {
        unsafe { ffi::gtk_adjustment_get_step_increment(self.as_ref().to_glib_none().0) }
    }

    fn upper(&self) -> f64 {
        unsafe { ffi::gtk_adjustment_get_upper(self.as_ref().to_glib_none().0) }
    }

    fn value(&self) -> f64 {
        unsafe { ffi::gtk_adjustment_get_value(self.as_ref().to_glib_none().0) }
    }

    fn set_lower(&self, lower: f64) {
        unsafe {
            ffi::gtk_adjustment_set_lower(self.as_ref().to_glib_none().0, lower);
        }
    }

    fn set_page_increment(&self, page_increment: f64) {
        unsafe {
            ffi::gtk_adjustment_set_page_increment(self.as_ref().to_glib_none().0, page_increment);
        }
    }

    fn set_page_size(&self, page_size: f64) {
        unsafe {
            ffi::gtk_adjustment_set_page_size(self.as_ref().to_glib_none().0, page_size);
        }
    }

    fn set_step_increment(&self, step_increment: f64) {
        unsafe {
            ffi::gtk_adjustment_set_step_increment(self.as_ref().to_glib_none().0, step_increment);
        }
    }

    fn set_upper(&self, upper: f64) {
        unsafe {
            ffi::gtk_adjustment_set_upper(self.as_ref().to_glib_none().0, upper);
        }
    }

    fn set_value(&self, value: f64) {
        unsafe {
            ffi::gtk_adjustment_set_value(self.as_ref().to_glib_none().0, value);
        }
    }

    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn changed_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkAdjustment,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"changed\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    changed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn value_changed_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkAdjustment,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"value-changed\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    value_changed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_lower_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_lower_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkAdjustment,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::lower\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_lower_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_page_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_page_increment_trampoline<
            P: IsA<Adjustment>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkAdjustment,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::page-increment\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_page_increment_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_page_size_trampoline<
            P: IsA<Adjustment>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkAdjustment,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::page-size\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_page_size_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_step_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_step_increment_trampoline<
            P: IsA<Adjustment>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkAdjustment,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::step-increment\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_step_increment_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_upper_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_upper_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkAdjustment,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::upper\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_upper_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_value_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkAdjustment,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::value\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_value_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl fmt::Display for Adjustment {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Adjustment")
    }
}