use crate::{ffi, DomDocument, DomNodeList, DomNodeType};
use glib::{prelude::*, translate::*};
glib::wrapper! {
#[doc(alias = "ArvDomNode")]
pub struct DomNode(Object<ffi::ArvDomNode, ffi::ArvDomNodeClass>);
match fn {
type_ => || ffi::arv_dom_node_get_type(),
}
}
impl DomNode {
pub const NONE: Option<&'static DomNode> = None;
}
unsafe impl Send for DomNode {}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::DomNode>> Sealed for T {}
}
pub trait DomNodeExt: IsA<DomNode> + sealed::Sealed + 'static {
#[doc(alias = "arv_dom_node_append_child")]
#[must_use]
fn append_child(&self, new_child: impl IsA<DomNode>) -> Option<DomNode> {
unsafe {
from_glib_none(ffi::arv_dom_node_append_child(
self.as_ref().to_glib_none().0,
new_child.upcast().into_glib_ptr(),
))
}
}
#[doc(alias = "arv_dom_node_changed")]
fn changed(&self) {
unsafe {
ffi::arv_dom_node_changed(self.as_ref().to_glib_none().0);
}
}
#[doc(alias = "arv_dom_node_get_child_nodes")]
#[doc(alias = "get_child_nodes")]
fn child_nodes(&self) -> Option<DomNodeList> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_child_nodes(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_first_child")]
#[doc(alias = "get_first_child")]
#[must_use]
fn first_child(&self) -> Option<DomNode> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_first_child(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_last_child")]
#[doc(alias = "get_last_child")]
#[must_use]
fn last_child(&self) -> Option<DomNode> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_last_child(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_next_sibling")]
#[doc(alias = "get_next_sibling")]
#[must_use]
fn next_sibling(&self) -> Option<DomNode> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_next_sibling(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_node_name")]
#[doc(alias = "get_node_name")]
fn node_name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_node_name(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_node_type")]
#[doc(alias = "get_node_type")]
fn node_type(&self) -> DomNodeType {
unsafe {
from_glib(ffi::arv_dom_node_get_node_type(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_node_value")]
#[doc(alias = "get_node_value")]
fn node_value(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_node_value(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_owner_document")]
#[doc(alias = "get_owner_document")]
fn owner_document(&self) -> Option<DomDocument> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_owner_document(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_parent_node")]
#[doc(alias = "get_parent_node")]
#[must_use]
fn parent_node(&self) -> Option<DomNode> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_parent_node(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_get_previous_sibling")]
#[doc(alias = "get_previous_sibling")]
#[must_use]
fn previous_sibling(&self) -> Option<DomNode> {
unsafe {
from_glib_none(ffi::arv_dom_node_get_previous_sibling(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_has_child_nodes")]
fn has_child_nodes(&self) -> bool {
unsafe {
from_glib(ffi::arv_dom_node_has_child_nodes(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_insert_before")]
#[must_use]
fn insert_before(
&self,
new_child: impl IsA<DomNode>,
ref_child: &impl IsA<DomNode>,
) -> Option<DomNode> {
unsafe {
from_glib_none(ffi::arv_dom_node_insert_before(
self.as_ref().to_glib_none().0,
new_child.upcast().into_glib_ptr(),
ref_child.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_remove_child")]
#[must_use]
fn remove_child(&self, old_child: &impl IsA<DomNode>) -> Option<DomNode> {
unsafe {
from_glib_full(ffi::arv_dom_node_remove_child(
self.as_ref().to_glib_none().0,
old_child.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_replace_child")]
#[must_use]
fn replace_child(
&self,
new_child: impl IsA<DomNode>,
old_child: &impl IsA<DomNode>,
) -> Option<DomNode> {
unsafe {
from_glib_full(ffi::arv_dom_node_replace_child(
self.as_ref().to_glib_none().0,
new_child.upcast().into_glib_ptr(),
old_child.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_dom_node_set_node_value")]
fn set_node_value(&self, new_value: &str) {
unsafe {
ffi::arv_dom_node_set_node_value(
self.as_ref().to_glib_none().0,
new_value.to_glib_none().0,
);
}
}
}
impl<O: IsA<DomNode>> DomNodeExt for O {}