// 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

use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib_sys;
use gtk;
use handy_sys;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
use Carousel;

glib_wrapper! {
    pub struct CarouselIndicatorDots(Object<handy_sys::HdyCarouselIndicatorDots, handy_sys::HdyCarouselIndicatorDotsClass, CarouselIndicatorDotsClass>) @extends gtk::DrawingArea, gtk::Widget, @implements gtk::Buildable, gtk::Orientable;

    match fn {
        get_type => || handy_sys::hdy_carousel_indicator_dots_get_type(),
    }
}

impl CarouselIndicatorDots {
    pub fn new() -> CarouselIndicatorDots {
        assert_initialized_main_thread!();
        unsafe {
            gtk::Widget::from_glib_full(handy_sys::hdy_carousel_indicator_dots_new()).unsafe_cast()
        }
    }
}

impl Default for CarouselIndicatorDots {
    fn default() -> Self {
        Self::new()
    }
}

pub const NONE_CAROUSEL_INDICATOR_DOTS: Option<&CarouselIndicatorDots> = None;

pub trait CarouselIndicatorDotsExt: 'static {
    fn get_carousel(&self) -> Option<Carousel>;

    fn set_carousel<P: IsA<Carousel>>(&self, carousel: Option<&P>);

    fn connect_property_carousel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<CarouselIndicatorDots>> CarouselIndicatorDotsExt for O {
    fn get_carousel(&self) -> Option<Carousel> {
        unsafe {
            from_glib_none(handy_sys::hdy_carousel_indicator_dots_get_carousel(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn set_carousel<P: IsA<Carousel>>(&self, carousel: Option<&P>) {
        unsafe {
            handy_sys::hdy_carousel_indicator_dots_set_carousel(
                self.as_ref().to_glib_none().0,
                carousel.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    fn connect_property_carousel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_carousel_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut handy_sys::HdyCarouselIndicatorDots,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<CarouselIndicatorDots>,
        {
            let f: &F = &*(f as *const F);
            f(&CarouselIndicatorDots::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::carousel\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_carousel_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl fmt::Display for CarouselIndicatorDots {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "CarouselIndicatorDots")
    }
}
