1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
// 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, Document};
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct IndexIter(Boxed<ffi::PopplerIndexIter>);
match fn {
copy => |ptr| ffi::poppler_index_iter_copy(mut_override(ptr)),
free => |ptr| ffi::poppler_index_iter_free(ptr),
type_ => || ffi::poppler_index_iter_get_type(),
}
}
impl IndexIter {
/// Returns the root [`IndexIter`][crate::IndexIter] for `document`, or [`None`]. This must be
/// freed with `poppler_index_iter_free()`.
///
/// Certain documents have an index associated with them. This index can be used
/// to help the user navigate the document, and is similar to a table of
/// contents. Each node in the index will contain a `PopplerAction` that can be
/// displayed to the user — typically a [`ActionType::GotoDest`][crate::ActionType::GotoDest] or a
/// [`ActionType::Uri`][crate::ActionType::Uri]<!-- -->.
///
/// Here is a simple example of some code that walks the full index:
///
/// `<informalexample>``<programlisting>`
/// static void
/// walk_index (PopplerIndexIter *iter)
/// {
/// do
/// {
/// /<!-- -->* Get the action and do something with it *<!-- -->/
/// PopplerIndexIter *child = poppler_index_iter_get_child (iter);
/// if (child)
/// walk_index (child);
/// poppler_index_iter_free (child);
/// }
/// while (poppler_index_iter_next (iter));
/// }
/// ...
/// {
/// iter = poppler_index_iter_new (document);
/// walk_index (iter);
/// poppler_index_iter_free (iter);
/// }
/// `</programlisting>``</informalexample>`
/// ## `document`
/// a [`Document`][crate::Document]
///
/// # Returns
///
/// a new [`IndexIter`][crate::IndexIter]
#[doc(alias = "poppler_index_iter_new")]
pub fn new(document: &Document) -> IndexIter {
unsafe { from_glib_full(ffi::poppler_index_iter_new(document.to_glib_none().0)) }
}
//#[doc(alias = "poppler_index_iter_get_action")]
//#[doc(alias = "get_action")]
//pub fn action(&mut self) -> /*Ignored*/Option<Action> {
// unsafe { TODO: call ffi:poppler_index_iter_get_action() }
//}
/// Returns a newly created child of `self`, or [`None`] if the iter has no child.
/// See [`new()`][Self::new()] for more information on this function.
///
/// # Returns
///
/// a new [`IndexIter`][crate::IndexIter]
#[doc(alias = "poppler_index_iter_get_child")]
#[doc(alias = "get_child")]
#[must_use]
pub fn child(&mut self) -> Option<IndexIter> {
unsafe { from_glib_full(ffi::poppler_index_iter_get_child(self.to_glib_none_mut().0)) }
}
/// Returns whether this node should be expanded by default to the user. The
/// document can provide a hint as to how the document's index should be expanded
/// initially.
///
/// # Returns
///
/// [`true`], if the document wants `self` to be expanded
#[doc(alias = "poppler_index_iter_is_open")]
pub fn is_open(&mut self) -> bool {
unsafe { from_glib(ffi::poppler_index_iter_is_open(self.to_glib_none_mut().0)) }
}
/// Sets `self` to point to the next action at the current level, if valid. See
/// [`new()`][Self::new()] for more information.
///
/// # Returns
///
/// [`true`], if `self` was set to the next action
#[doc(alias = "poppler_index_iter_next")]
pub fn next(&mut self) -> bool {
unsafe { from_glib(ffi::poppler_index_iter_next(self.to_glib_none_mut().0)) }
}
}