// 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::{Document, StructureElement, ffi};
use glib::translate::*;

glib::wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct StructureElementIter(Boxed<ffi::PopplerStructureElementIter>);

    match fn {
        copy => |ptr| ffi::poppler_structure_element_iter_copy(mut_override(ptr)),
        free => |ptr| ffi::poppler_structure_element_iter_free(ptr),
        type_ => || ffi::poppler_structure_element_iter_get_type(),
    }
}

impl StructureElementIter {
    #[doc(alias = "poppler_structure_element_iter_new")]
    pub fn new(poppler_document: &Document) -> Option<StructureElementIter> {
        unsafe {
            from_glib_full(ffi::poppler_structure_element_iter_new(
                poppler_document.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "poppler_structure_element_iter_get_child")]
    #[doc(alias = "get_child")]
    #[must_use]
    pub fn child(&mut self) -> Option<StructureElementIter> {
        unsafe {
            from_glib_full(ffi::poppler_structure_element_iter_get_child(
                self.to_glib_none_mut().0,
            ))
        }
    }

    #[doc(alias = "poppler_structure_element_iter_get_element")]
    #[doc(alias = "get_element")]
    pub fn element(&mut self) -> Option<StructureElement> {
        unsafe {
            from_glib_full(ffi::poppler_structure_element_iter_get_element(
                self.to_glib_none_mut().0,
            ))
        }
    }

    #[doc(alias = "poppler_structure_element_iter_next")]
    pub fn next(&mut self) -> bool {
        unsafe {
            from_glib(ffi::poppler_structure_element_iter_next(
                self.to_glib_none_mut().0,
            ))
        }
    }
}
