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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
// 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, AnnotFlag, AnnotType, Color, Rectangle};
use glib::{prelude::*, translate::*};
glib::wrapper! {
///
///
/// # Implements
///
/// [`AnnotExt`][trait@crate::prelude::AnnotExt]
#[doc(alias = "PopplerAnnot")]
pub struct Annot(Object<ffi::PopplerAnnot>);
match fn {
type_ => || ffi::poppler_annot_get_type(),
}
}
impl Annot {
pub const NONE: Option<&'static Annot> = None;
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Annot>> Sealed for T {}
}
/// Trait containing all [`struct@Annot`] methods.
///
/// # Implementors
///
/// [`AnnotMarkup`][struct@crate::AnnotMarkup], [`Annot`][struct@crate::Annot]
pub trait AnnotExt: IsA<Annot> + sealed::Sealed + 'static {
/// Gets the type of `self`
///
/// # Returns
///
/// [`AnnotType`][crate::AnnotType] of `self`.
#[doc(alias = "poppler_annot_get_annot_type")]
#[doc(alias = "get_annot_type")]
fn annot_type(&self) -> AnnotType {
unsafe {
from_glib(ffi::poppler_annot_get_annot_type(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves the color of `self`.
///
/// # Returns
///
/// a new allocated [`Color`][crate::Color] with the color values of
/// `self`, or [`None`]. It must be freed with `g_free()` when done.
#[doc(alias = "poppler_annot_get_color")]
#[doc(alias = "get_color")]
fn color(&self) -> Option<Color> {
unsafe { from_glib_full(ffi::poppler_annot_get_color(self.as_ref().to_glib_none().0)) }
}
/// Retrieves the contents of `self`.
///
/// # Returns
///
/// a new allocated string with the contents of `self`. It
/// must be freed with `g_free()` when done.
#[doc(alias = "poppler_annot_get_contents")]
#[doc(alias = "get_contents")]
fn contents(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::poppler_annot_get_contents(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves the flag field specifying various characteristics of the
/// `self`.
///
/// # Returns
///
/// the flag field of `self`.
#[doc(alias = "poppler_annot_get_flags")]
#[doc(alias = "get_flags")]
fn flags(&self) -> AnnotFlag {
unsafe { from_glib(ffi::poppler_annot_get_flags(self.as_ref().to_glib_none().0)) }
}
/// Retrieves the last modification data of `self`. The returned
/// string will be either a PDF format date or a text string.
/// See also `poppler_date_parse()`
///
/// # Returns
///
/// a new allocated string with the last modification data of
/// `self`. It must be freed with `g_free()` when done.
#[doc(alias = "poppler_annot_get_modified")]
#[doc(alias = "get_modified")]
fn modified(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::poppler_annot_get_modified(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves the name of `self`.
///
/// # Returns
///
/// a new allocated string with the name of `self`. It must
/// be freed with `g_free()` when done.
#[doc(alias = "poppler_annot_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> Option<glib::GString> {
unsafe { from_glib_full(ffi::poppler_annot_get_name(self.as_ref().to_glib_none().0)) }
}
/// Returns the page index to which `self` is associated, or -1 if unknown
///
/// # Returns
///
/// page index or -1
#[doc(alias = "poppler_annot_get_page_index")]
#[doc(alias = "get_page_index")]
fn page_index(&self) -> i32 {
unsafe { ffi::poppler_annot_get_page_index(self.as_ref().to_glib_none().0) }
}
/// Retrieves the rectangle representing the page coordinates where the
/// annotation `self` is placed.
///
/// # Returns
///
///
/// ## `poppler_rect`
/// a [`Rectangle`][crate::Rectangle] to store the annotation's coordinates
#[doc(alias = "poppler_annot_get_rectangle")]
#[doc(alias = "get_rectangle")]
fn rectangle(&self) -> Rectangle {
unsafe {
let mut poppler_rect = Rectangle::uninitialized();
ffi::poppler_annot_get_rectangle(
self.as_ref().to_glib_none().0,
poppler_rect.to_glib_none_mut().0,
);
poppler_rect
}
}
/// Sets the color of `self`.
/// ## `poppler_color`
/// a [`Color`][crate::Color], or [`None`]
#[doc(alias = "poppler_annot_set_color")]
fn set_color(&self, poppler_color: Option<&Color>) {
unsafe {
ffi::poppler_annot_set_color(
self.as_ref().to_glib_none().0,
mut_override(poppler_color.to_glib_none().0),
);
}
}
/// Sets the contents of `self` to the given value,
/// replacing the current contents.
/// ## `contents`
/// a text string containing the new contents
#[doc(alias = "poppler_annot_set_contents")]
fn set_contents(&self, contents: &str) {
unsafe {
ffi::poppler_annot_set_contents(
self.as_ref().to_glib_none().0,
contents.to_glib_none().0,
);
}
}
/// Sets the flag field specifying various characteristics of the
/// `self`.
/// ## `flags`
/// a [`AnnotFlag`][crate::AnnotFlag]
#[doc(alias = "poppler_annot_set_flags")]
fn set_flags(&self, flags: AnnotFlag) {
unsafe {
ffi::poppler_annot_set_flags(self.as_ref().to_glib_none().0, flags.into_glib());
}
}
/// Move the annotation to the rectangle representing the page coordinates
/// where the annotation `self` should be placed.
/// ## `poppler_rect`
/// a [`Rectangle`][crate::Rectangle] with the new annotation's coordinates
#[doc(alias = "poppler_annot_set_rectangle")]
fn set_rectangle(&self, poppler_rect: &mut Rectangle) {
unsafe {
ffi::poppler_annot_set_rectangle(
self.as_ref().to_glib_none().0,
poppler_rect.to_glib_none_mut().0,
);
}
}
}
impl<O: IsA<Annot>> AnnotExt for O {}