// 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 crate::WaylandSurface;
use glib::translate::*;
use std::{boxed::Box as Box_, fmt};

glib::wrapper! {
    #[doc(alias = "GdkWaylandToplevel")]
    pub struct WaylandToplevel(Object<ffi::GdkWaylandToplevel>) @extends WaylandSurface, gdk::Surface, @implements gdk::Toplevel;

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

impl WaylandToplevel {
    #[doc(alias = "gdk_wayland_toplevel_export_handle")]
    pub fn export_handle<P: Fn(&WaylandToplevel, &str) + 'static>(&self, callback: P) -> bool {
        let callback_data: Box_<P> = Box_::new(callback);
        unsafe extern "C" fn callback_func<P: Fn(&WaylandToplevel, &str) + 'static>(
            toplevel: *mut ffi::GdkWaylandToplevel,
            handle: *const libc::c_char,
            user_data: glib::ffi::gpointer,
        ) {
            let toplevel = from_glib_borrow(toplevel);
            let handle: Borrowed<glib::GString> = from_glib_borrow(handle);
            let callback: &P = &*(user_data as *mut _);
            (*callback)(&toplevel, handle.as_str())
        }
        let callback = Some(callback_func::<P> as _);
        unsafe extern "C" fn destroy_func_func<P: Fn(&WaylandToplevel, &str) + 'static>(
            data: glib::ffi::gpointer,
        ) {
            let _callback: Box_<P> = Box_::from_raw(data as *mut _);
        }
        let destroy_call3 = Some(destroy_func_func::<P> as _);
        let super_callback0: Box_<P> = callback_data;
        unsafe {
            from_glib(ffi::gdk_wayland_toplevel_export_handle(
                self.to_glib_none().0,
                callback,
                Box_::into_raw(super_callback0) as *mut _,
                destroy_call3,
            ))
        }
    }

    #[doc(alias = "gdk_wayland_toplevel_set_application_id")]
    pub fn set_application_id(&self, application_id: &str) {
        unsafe {
            ffi::gdk_wayland_toplevel_set_application_id(
                self.to_glib_none().0,
                application_id.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "gdk_wayland_toplevel_set_transient_for_exported")]
    pub fn set_transient_for_exported(&self, parent_handle_str: &str) -> bool {
        unsafe {
            from_glib(ffi::gdk_wayland_toplevel_set_transient_for_exported(
                self.to_glib_none().0,
                parent_handle_str.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_wayland_toplevel_unexport_handle")]
    pub fn unexport_handle(&self) {
        unsafe {
            ffi::gdk_wayland_toplevel_unexport_handle(self.to_glib_none().0);
        }
    }
}

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