// 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::{
    Accessible, AccessibleHypertext, AccessiblePlatformState, AccessibleRole, AccessibleTextRange,
    ffi,
};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    #[doc(alias = "GtkAccessibleHyperlink")]
    pub struct AccessibleHyperlink(Object<ffi::GtkAccessibleHyperlink, ffi::GtkAccessibleHyperlinkClass>) @implements Accessible;

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

impl AccessibleHyperlink {
    #[doc(alias = "gtk_accessible_hyperlink_new")]
    pub fn new(
        parent: &impl IsA<AccessibleHypertext>,
        index: u32,
        uri: &str,
        bounds: &mut AccessibleTextRange,
    ) -> AccessibleHyperlink {
        skip_assert_initialized!();
        unsafe {
            from_glib_full(ffi::gtk_accessible_hyperlink_new(
                parent.as_ref().to_glib_none().0,
                index,
                uri.to_glib_none().0,
                bounds.to_glib_none_mut().0,
            ))
        }
    }

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

    #[doc(alias = "gtk_accessible_hyperlink_set_platform_state")]
    pub fn set_platform_state(&self, state: AccessiblePlatformState, enabled: bool) {
        unsafe {
            ffi::gtk_accessible_hyperlink_set_platform_state(
                self.to_glib_none().0,
                state.into_glib(),
                enabled.into_glib(),
            );
        }
    }
}

#[cfg(feature = "v4_22")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
impl Default for AccessibleHyperlink {
    fn default() -> Self {
        glib::object::Object::new::<Self>()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`AccessibleHyperlink`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct AccessibleHyperlinkBuilder {
    builder: glib::object::ObjectBuilder<'static, AccessibleHyperlink>,
}

impl AccessibleHyperlinkBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }

    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
        Self {
            builder: self.builder.property("accessible-role", accessible_role),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`AccessibleHyperlink`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> AccessibleHyperlink {
        assert_initialized_main_thread!();
        self.builder.build()
    }
}
