// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

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

glib::wrapper! {
    #[doc(alias = "GtkSourceLanguage")]
    pub struct Language(Object<ffi::GtkSourceLanguage, ffi::GtkSourceLanguageClass>);

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

impl Language {
    #[doc(alias = "gtk_source_language_get_globs")]
    #[doc(alias = "get_globs")]
    pub fn globs(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::gtk_source_language_get_globs(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_source_language_get_hidden")]
    #[doc(alias = "get_hidden")]
    #[doc(alias = "hidden")]
    pub fn is_hidden(&self) -> bool {
        unsafe { from_glib(ffi::gtk_source_language_get_hidden(self.to_glib_none().0)) }
    }

    #[doc(alias = "gtk_source_language_get_id")]
    #[doc(alias = "get_id")]
    pub fn id(&self) -> glib::GString {
        unsafe { from_glib_none(ffi::gtk_source_language_get_id(self.to_glib_none().0)) }
    }

    #[doc(alias = "gtk_source_language_get_metadata")]
    #[doc(alias = "get_metadata")]
    pub fn metadata(&self, name: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gtk_source_language_get_metadata(
                self.to_glib_none().0,
                name.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_source_language_get_mime_types")]
    #[doc(alias = "get_mime_types")]
    pub fn mime_types(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::gtk_source_language_get_mime_types(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_source_language_get_name")]
    #[doc(alias = "get_name")]
    pub fn name(&self) -> glib::GString {
        unsafe { from_glib_none(ffi::gtk_source_language_get_name(self.to_glib_none().0)) }
    }

    #[doc(alias = "gtk_source_language_get_section")]
    #[doc(alias = "get_section")]
    pub fn section(&self) -> glib::GString {
        unsafe { from_glib_none(ffi::gtk_source_language_get_section(self.to_glib_none().0)) }
    }

    #[doc(alias = "gtk_source_language_get_style_fallback")]
    #[doc(alias = "get_style_fallback")]
    pub fn style_fallback(&self, style_id: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gtk_source_language_get_style_fallback(
                self.to_glib_none().0,
                style_id.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_source_language_get_style_ids")]
    #[doc(alias = "get_style_ids")]
    pub fn style_ids(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::gtk_source_language_get_style_ids(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_source_language_get_style_name")]
    #[doc(alias = "get_style_name")]
    pub fn style_name(&self, style_id: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gtk_source_language_get_style_name(
                self.to_glib_none().0,
                style_id.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "hidden")]
    pub fn connect_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_hidden_trampoline<F: Fn(&Language) + 'static>(
            this: *mut ffi::GtkSourceLanguage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::hidden".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_hidden_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "id")]
    pub fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_id_trampoline<F: Fn(&Language) + 'static>(
            this: *mut ffi::GtkSourceLanguage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::id".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_id_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "name")]
    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_name_trampoline<F: Fn(&Language) + 'static>(
            this: *mut ffi::GtkSourceLanguage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::name".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_name_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "section")]
    pub fn connect_section_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_section_trampoline<F: Fn(&Language) + 'static>(
            this: *mut ffi::GtkSourceLanguage,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::section".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_section_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl std::fmt::Display for Language {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(&self.name())
    }
}
