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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// 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::{Annot, AnnotExternalDataType, AnnotMarkupReplyType, Rectangle};
use glib::{prelude::*, translate::*};
use std::fmt;

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`AnnotMarkupExt`][trait@crate::prelude::AnnotMarkupExt], [`AnnotExt`][trait@crate::prelude::AnnotExt]
    #[doc(alias = "PopplerAnnotMarkup")]
    pub struct AnnotMarkup(Object<ffi::PopplerAnnotMarkup>) @extends Annot;

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

impl AnnotMarkup {
    pub const NONE: Option<&'static AnnotMarkup> = None;
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::AnnotMarkup>> Sealed for T {}
}

/// Trait containing all [`struct@AnnotMarkup`] methods.
///
/// # Implementors
///
/// [`AnnotCircle`][struct@crate::AnnotCircle], [`AnnotFileAttachment`][struct@crate::AnnotFileAttachment], [`AnnotFreeText`][struct@crate::AnnotFreeText], [`AnnotMarkup`][struct@crate::AnnotMarkup]
pub trait AnnotMarkupExt: IsA<AnnotMarkup> + sealed::Sealed + 'static {
    /// Returns the date and time when the annotation was created
    ///
    /// # Returns
    ///
    /// a [`glib::Date`][crate::glib::Date] representing the date and time
    ///  when the annotation was created, or [`None`]
    #[doc(alias = "poppler_annot_markup_get_date")]
    #[doc(alias = "get_date")]
    fn date(&self) -> Option<glib::Date> {
        unsafe {
            from_glib_full(ffi::poppler_annot_markup_get_date(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the external data type of `self`.
    ///
    /// # Returns
    ///
    /// [`AnnotExternalDataType`][crate::AnnotExternalDataType] of `self`.
    #[doc(alias = "poppler_annot_markup_get_external_data")]
    #[doc(alias = "get_external_data")]
    fn external_data(&self) -> AnnotExternalDataType {
        unsafe {
            from_glib(ffi::poppler_annot_markup_get_external_data(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Retrieves the label text of `self`.
    ///
    /// # Returns
    ///
    /// the label text of `self`.
    #[doc(alias = "poppler_annot_markup_get_label")]
    #[doc(alias = "get_label")]
    fn label(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::poppler_annot_markup_get_label(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Retrieves the opacity value of `self`.
    ///
    /// # Returns
    ///
    /// the opacity value of `self`,
    ///  between 0 (transparent) and 1 (opaque)
    #[doc(alias = "poppler_annot_markup_get_opacity")]
    #[doc(alias = "get_opacity")]
    fn opacity(&self) -> f64 {
        unsafe { ffi::poppler_annot_markup_get_opacity(self.as_ref().to_glib_none().0) }
    }

    /// Retrieves the state of the popup window related to `self`.
    ///
    /// # Returns
    ///
    /// the state of `self`. [`true`] if it's open, [`false`] in
    ///  other case.
    #[doc(alias = "poppler_annot_markup_get_popup_is_open")]
    #[doc(alias = "get_popup_is_open")]
    fn is_popup_is_open(&self) -> bool {
        unsafe {
            from_glib(ffi::poppler_annot_markup_get_popup_is_open(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Retrieves the rectangle of the popup window related to `self`.
    ///
    /// # Returns
    ///
    /// [`true`] if [`Rectangle`][crate::Rectangle] was correctly filled, [`false`] otherwise
    ///
    /// ## `poppler_rect`
    /// a [`Rectangle`][crate::Rectangle] to store the popup rectangle
    #[doc(alias = "poppler_annot_markup_get_popup_rectangle")]
    #[doc(alias = "get_popup_rectangle")]
    fn popup_rectangle(&self) -> Option<Rectangle> {
        unsafe {
            let mut poppler_rect = Rectangle::uninitialized();
            let ret = from_glib(ffi::poppler_annot_markup_get_popup_rectangle(
                self.as_ref().to_glib_none().0,
                poppler_rect.to_glib_none_mut().0,
            ));
            if ret {
                Some(poppler_rect)
            } else {
                None
            }
        }
    }

    /// Gets the reply type of `self`.
    ///
    /// # Returns
    ///
    /// [`AnnotMarkupReplyType`][crate::AnnotMarkupReplyType] of `self`.
    #[doc(alias = "poppler_annot_markup_get_reply_to")]
    #[doc(alias = "get_reply_to")]
    fn reply_to(&self) -> AnnotMarkupReplyType {
        unsafe {
            from_glib(ffi::poppler_annot_markup_get_reply_to(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Retrives the subject text of `self`.
    ///
    /// # Returns
    ///
    /// the subject text of `self`.
    #[doc(alias = "poppler_annot_markup_get_subject")]
    #[doc(alias = "get_subject")]
    fn subject(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::poppler_annot_markup_get_subject(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Return [`true`] if the markup annotation has a popup window associated
    ///
    /// # Returns
    ///
    /// [`true`], if `self` has popup, [`false`] otherwise
    #[doc(alias = "poppler_annot_markup_has_popup")]
    fn has_popup(&self) -> bool {
        unsafe {
            from_glib(ffi::poppler_annot_markup_has_popup(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Sets the label text of `self`, replacing the current one
    /// ## `label`
    /// a text string containing the new label, or [`None`]
    #[doc(alias = "poppler_annot_markup_set_label")]
    fn set_label(&self, label: Option<&str>) {
        unsafe {
            ffi::poppler_annot_markup_set_label(
                self.as_ref().to_glib_none().0,
                label.to_glib_none().0,
            );
        }
    }

    /// Sets the opacity of `self`. This value applies to
    /// all visible elements of `self` in its closed state,
    /// but not to the pop-up window that appears when it's openened
    /// ## `opacity`
    /// a constant opacity value, between 0 (transparent) and 1 (opaque)
    #[doc(alias = "poppler_annot_markup_set_opacity")]
    fn set_opacity(&self, opacity: f64) {
        unsafe {
            ffi::poppler_annot_markup_set_opacity(self.as_ref().to_glib_none().0, opacity);
        }
    }

    /// Associates a new popup window for editing contents of `self`.
    /// Popup window shall be displayed by viewers at `popup_rect` on the page.
    /// ## `popup_rect`
    /// a [`Rectangle`][crate::Rectangle]
    #[doc(alias = "poppler_annot_markup_set_popup")]
    fn set_popup(&self, popup_rect: &mut Rectangle) {
        unsafe {
            ffi::poppler_annot_markup_set_popup(
                self.as_ref().to_glib_none().0,
                popup_rect.to_glib_none_mut().0,
            );
        }
    }

    /// Sets the state of the popup window related to `self`.
    /// ## `is_open`
    /// whether popup window should initially be displayed open
    #[doc(alias = "poppler_annot_markup_set_popup_is_open")]
    fn set_popup_is_open(&self, is_open: bool) {
        unsafe {
            ffi::poppler_annot_markup_set_popup_is_open(
                self.as_ref().to_glib_none().0,
                is_open.into_glib(),
            );
        }
    }

    /// Sets the rectangle of the popup window related to `self`.
    /// This doesn't have any effect if `self` doesn't have a
    /// popup associated, use [`set_popup()`][Self::set_popup()] to associate
    /// a popup window to a [`AnnotMarkup`][crate::AnnotMarkup].
    /// ## `poppler_rect`
    /// a [`Rectangle`][crate::Rectangle] to set
    #[doc(alias = "poppler_annot_markup_set_popup_rectangle")]
    fn set_popup_rectangle(&self, poppler_rect: &mut Rectangle) {
        unsafe {
            ffi::poppler_annot_markup_set_popup_rectangle(
                self.as_ref().to_glib_none().0,
                poppler_rect.to_glib_none_mut().0,
            );
        }
    }
}

impl<O: IsA<AnnotMarkup>> AnnotMarkupExt for O {}

impl fmt::Display for AnnotMarkup {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("AnnotMarkup")
    }
}