1#![allow(deprecated)]
6
7#[cfg(feature = "v0_80")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v0_80")))]
9use crate::PrintDuplex;
10#[cfg(feature = "v0_73")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v0_73")))]
12use crate::PrintScaling;
13#[cfg(feature = "v23_7")]
14#[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
15use crate::SigningData;
16use crate::{
17 Attachment, Dest, FormField, PDFConformance, PDFPart, PDFSubtype, Page, PageLayout, PageMode,
18 Permissions, ViewerPreferences, ffi,
19};
20use glib::{
21 prelude::*,
22 signal::{SignalHandlerId, connect_raw},
23 translate::*,
24};
25use std::boxed::Box as Box_;
26#[cfg(feature = "v23_7")]
27#[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
28use std::pin::Pin;
29
30glib::wrapper! {
31 #[doc(alias = "PopplerDocument")]
32 pub struct Document(Object<ffi::PopplerDocument>);
33
34 match fn {
35 type_ => || ffi::poppler_document_get_type(),
36 }
37}
38
39impl Document {
40 #[cfg(feature = "v0_82")]
41 #[cfg_attr(docsrs, doc(cfg(feature = "v0_82")))]
42 #[doc(alias = "poppler_document_new_from_bytes")]
43 #[doc(alias = "new_from_bytes")]
44 pub fn from_bytes(
45 bytes: &glib::Bytes,
46 password: Option<&str>,
47 ) -> Result<Document, glib::Error> {
48 unsafe {
49 let mut error = std::ptr::null_mut();
50 let ret = ffi::poppler_document_new_from_bytes(
51 bytes.to_glib_none().0,
52 password.to_glib_none().0,
53 &mut error,
54 );
55 if error.is_null() {
56 Ok(from_glib_full(ret))
57 } else {
58 Err(from_glib_full(error))
59 }
60 }
61 }
62
63 #[cfg_attr(feature = "v0_82", deprecated = "Since 0.82")]
64 #[allow(deprecated)]
65 #[doc(alias = "poppler_document_new_from_data")]
66 #[doc(alias = "new_from_data")]
67 pub fn from_data(data: &[u8], password: Option<&str>) -> Result<Document, glib::Error> {
68 let length = data.len() as _;
69 unsafe {
70 let mut error = std::ptr::null_mut();
71 let ret = ffi::poppler_document_new_from_data(
72 data.to_glib_none().0,
73 length,
74 password.to_glib_none().0,
75 &mut error,
76 );
77 if error.is_null() {
78 Ok(from_glib_full(ret))
79 } else {
80 Err(from_glib_full(error))
81 }
82 }
83 }
84
85 #[cfg(target_os = "linux")]
86 #[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
87 #[cfg(feature = "v21_12")]
88 #[cfg_attr(docsrs, doc(cfg(feature = "v21_12")))]
89 #[doc(alias = "poppler_document_new_from_fd")]
90 #[doc(alias = "new_from_fd")]
91 pub fn from_fd(fd: i32, password: Option<&str>) -> Result<Document, glib::Error> {
92 unsafe {
93 let mut error = std::ptr::null_mut();
94 let ret = ffi::poppler_document_new_from_fd(fd, password.to_glib_none().0, &mut error);
95 if error.is_null() {
96 Ok(from_glib_full(ret))
97 } else {
98 Err(from_glib_full(error))
99 }
100 }
101 }
102
103 #[doc(alias = "poppler_document_new_from_file")]
104 #[doc(alias = "new_from_file")]
105 pub fn from_file(uri: &str, password: Option<&str>) -> Result<Document, glib::Error> {
106 unsafe {
107 let mut error = std::ptr::null_mut();
108 let ret = ffi::poppler_document_new_from_file(
109 uri.to_glib_none().0,
110 password.to_glib_none().0,
111 &mut error,
112 );
113 if error.is_null() {
114 Ok(from_glib_full(ret))
115 } else {
116 Err(from_glib_full(error))
117 }
118 }
119 }
120
121 #[doc(alias = "poppler_document_new_from_gfile")]
122 #[doc(alias = "new_from_gfile")]
123 pub fn from_gfile(
124 file: &impl IsA<gio::File>,
125 password: Option<&str>,
126 cancellable: Option<&impl IsA<gio::Cancellable>>,
127 ) -> Result<Document, glib::Error> {
128 unsafe {
129 let mut error = std::ptr::null_mut();
130 let ret = ffi::poppler_document_new_from_gfile(
131 file.as_ref().to_glib_none().0,
132 password.to_glib_none().0,
133 cancellable.map(|p| p.as_ref()).to_glib_none().0,
134 &mut error,
135 );
136 if error.is_null() {
137 Ok(from_glib_full(ret))
138 } else {
139 Err(from_glib_full(error))
140 }
141 }
142 }
143
144 #[doc(alias = "poppler_document_new_from_stream")]
145 #[doc(alias = "new_from_stream")]
146 pub fn from_stream(
147 stream: &impl IsA<gio::InputStream>,
148 length: i64,
149 password: Option<&str>,
150 cancellable: Option<&impl IsA<gio::Cancellable>>,
151 ) -> Result<Document, glib::Error> {
152 unsafe {
153 let mut error = std::ptr::null_mut();
154 let ret = ffi::poppler_document_new_from_stream(
155 stream.as_ref().to_glib_none().0,
156 length,
157 password.to_glib_none().0,
158 cancellable.map(|p| p.as_ref()).to_glib_none().0,
159 &mut error,
160 );
161 if error.is_null() {
162 Ok(from_glib_full(ret))
163 } else {
164 Err(from_glib_full(error))
165 }
166 }
167 }
168
169 pub fn builder() -> DocumentBuilder {
174 DocumentBuilder::new()
175 }
176
177 #[doc(alias = "poppler_document_find_dest")]
185 pub fn find_dest(&self, link_name: &str) -> Option<Dest> {
186 unsafe {
187 from_glib_full(ffi::poppler_document_find_dest(
188 self.to_glib_none().0,
189 link_name.to_glib_none().0,
190 ))
191 }
192 }
193
194 #[doc(alias = "poppler_document_get_attachments")]
195 #[doc(alias = "get_attachments")]
196 pub fn attachments(&self) -> Vec<Attachment> {
197 unsafe {
198 FromGlibPtrContainer::from_glib_full(ffi::poppler_document_get_attachments(
199 self.to_glib_none().0,
200 ))
201 }
202 }
203
204 #[doc(alias = "poppler_document_get_author")]
205 #[doc(alias = "get_author")]
206 pub fn author(&self) -> Option<glib::GString> {
207 unsafe { from_glib_full(ffi::poppler_document_get_author(self.to_glib_none().0)) }
208 }
209
210 #[doc(alias = "poppler_document_get_creation_date")]
211 #[doc(alias = "get_creation_date")]
212 #[doc(alias = "creation-date")]
213 pub fn creation_date(&self) -> libc::time_t {
214 unsafe { ffi::poppler_document_get_creation_date(self.to_glib_none().0) }
215 }
216
217 #[cfg(feature = "v20_9")]
218 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
219 #[doc(alias = "poppler_document_get_creation_date_time")]
220 #[doc(alias = "get_creation_date_time")]
221 pub fn creation_date_time(&self) -> Option<glib::DateTime> {
222 unsafe {
223 from_glib_full(ffi::poppler_document_get_creation_date_time(
224 self.to_glib_none().0,
225 ))
226 }
227 }
228
229 #[doc(alias = "poppler_document_get_creator")]
230 #[doc(alias = "get_creator")]
231 pub fn creator(&self) -> Option<glib::GString> {
232 unsafe { from_glib_full(ffi::poppler_document_get_creator(self.to_glib_none().0)) }
233 }
234
235 #[doc(alias = "poppler_document_get_form_field")]
236 #[doc(alias = "get_form_field")]
237 pub fn form_field(&self, id: i32) -> Option<FormField> {
238 unsafe {
239 from_glib_full(ffi::poppler_document_get_form_field(
240 self.to_glib_none().0,
241 id,
242 ))
243 }
244 }
245
246 #[doc(alias = "poppler_document_get_id")]
247 #[doc(alias = "get_id")]
248 pub fn id(&self) -> Option<(glib::GString, glib::GString)> {
249 unsafe {
250 let mut permanent_id = std::ptr::null_mut();
251 let mut update_id = std::ptr::null_mut();
252 let ret = from_glib(ffi::poppler_document_get_id(
253 self.to_glib_none().0,
254 &mut permanent_id,
255 &mut update_id,
256 ));
257 if ret {
258 Some((from_glib_full(permanent_id), from_glib_full(update_id)))
259 } else {
260 None
261 }
262 }
263 }
264
265 #[doc(alias = "poppler_document_get_keywords")]
266 #[doc(alias = "get_keywords")]
267 pub fn keywords(&self) -> Option<glib::GString> {
268 unsafe { from_glib_full(ffi::poppler_document_get_keywords(self.to_glib_none().0)) }
269 }
270
271 #[doc(alias = "poppler_document_get_metadata")]
272 #[doc(alias = "get_metadata")]
273 pub fn metadata(&self) -> Option<glib::GString> {
274 unsafe { from_glib_full(ffi::poppler_document_get_metadata(self.to_glib_none().0)) }
275 }
276
277 #[doc(alias = "poppler_document_get_modification_date")]
278 #[doc(alias = "get_modification_date")]
279 pub fn modification_date(&self) -> libc::time_t {
280 unsafe { ffi::poppler_document_get_modification_date(self.to_glib_none().0) }
281 }
282
283 #[cfg(feature = "v20_9")]
284 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
285 #[doc(alias = "poppler_document_get_modification_date_time")]
286 #[doc(alias = "get_modification_date_time")]
287 pub fn modification_date_time(&self) -> Option<glib::DateTime> {
288 unsafe {
289 from_glib_full(ffi::poppler_document_get_modification_date_time(
290 self.to_glib_none().0,
291 ))
292 }
293 }
294
295 #[doc(alias = "poppler_document_get_n_attachments")]
296 #[doc(alias = "get_n_attachments")]
297 pub fn n_attachments(&self) -> u32 {
298 unsafe { ffi::poppler_document_get_n_attachments(self.to_glib_none().0) }
299 }
300
301 #[doc(alias = "poppler_document_get_n_pages")]
302 #[doc(alias = "get_n_pages")]
303 pub fn n_pages(&self) -> i32 {
304 unsafe { ffi::poppler_document_get_n_pages(self.to_glib_none().0) }
305 }
306
307 #[cfg(feature = "v21_12")]
308 #[cfg_attr(docsrs, doc(cfg(feature = "v21_12")))]
309 #[doc(alias = "poppler_document_get_n_signatures")]
310 #[doc(alias = "get_n_signatures")]
311 pub fn n_signatures(&self) -> i32 {
312 unsafe { ffi::poppler_document_get_n_signatures(self.to_glib_none().0) }
313 }
314
315 #[doc(alias = "poppler_document_get_page")]
316 #[doc(alias = "get_page")]
317 pub fn page(&self, index: i32) -> Option<Page> {
318 unsafe { from_glib_full(ffi::poppler_document_get_page(self.to_glib_none().0, index)) }
319 }
320
321 #[doc(alias = "poppler_document_get_page_by_label")]
322 #[doc(alias = "get_page_by_label")]
323 pub fn page_by_label(&self, label: &str) -> Option<Page> {
324 unsafe {
325 from_glib_full(ffi::poppler_document_get_page_by_label(
326 self.to_glib_none().0,
327 label.to_glib_none().0,
328 ))
329 }
330 }
331
332 #[doc(alias = "poppler_document_get_page_layout")]
333 #[doc(alias = "get_page_layout")]
334 #[doc(alias = "page-layout")]
335 pub fn page_layout(&self) -> PageLayout {
336 unsafe { from_glib(ffi::poppler_document_get_page_layout(self.to_glib_none().0)) }
337 }
338
339 #[doc(alias = "poppler_document_get_page_mode")]
340 #[doc(alias = "get_page_mode")]
341 #[doc(alias = "page-mode")]
342 pub fn page_mode(&self) -> PageMode {
343 unsafe { from_glib(ffi::poppler_document_get_page_mode(self.to_glib_none().0)) }
344 }
345
346 #[doc(alias = "poppler_document_get_pdf_conformance")]
347 #[doc(alias = "get_pdf_conformance")]
348 pub fn pdf_conformance(&self) -> PDFConformance {
349 unsafe {
350 from_glib(ffi::poppler_document_get_pdf_conformance(
351 self.to_glib_none().0,
352 ))
353 }
354 }
355
356 #[doc(alias = "poppler_document_get_pdf_part")]
357 #[doc(alias = "get_pdf_part")]
358 pub fn pdf_part(&self) -> PDFPart {
359 unsafe { from_glib(ffi::poppler_document_get_pdf_part(self.to_glib_none().0)) }
360 }
361
362 #[doc(alias = "poppler_document_get_pdf_subtype")]
363 #[doc(alias = "get_pdf_subtype")]
364 pub fn pdf_subtype(&self) -> PDFSubtype {
365 unsafe { from_glib(ffi::poppler_document_get_pdf_subtype(self.to_glib_none().0)) }
366 }
367
368 #[doc(alias = "poppler_document_get_pdf_subtype_string")]
369 #[doc(alias = "get_pdf_subtype_string")]
370 pub fn pdf_subtype_string(&self) -> Option<glib::GString> {
371 unsafe {
372 from_glib_full(ffi::poppler_document_get_pdf_subtype_string(
373 self.to_glib_none().0,
374 ))
375 }
376 }
377
378 #[doc(alias = "poppler_document_get_pdf_version")]
379 #[doc(alias = "get_pdf_version")]
380 pub fn pdf_version(&self) -> (u32, u32) {
381 unsafe {
382 let mut major_version = std::mem::MaybeUninit::uninit();
383 let mut minor_version = std::mem::MaybeUninit::uninit();
384 ffi::poppler_document_get_pdf_version(
385 self.to_glib_none().0,
386 major_version.as_mut_ptr(),
387 minor_version.as_mut_ptr(),
388 );
389 (major_version.assume_init(), minor_version.assume_init())
390 }
391 }
392
393 #[doc(alias = "poppler_document_get_pdf_version_string")]
394 #[doc(alias = "get_pdf_version_string")]
395 pub fn pdf_version_string(&self) -> Option<glib::GString> {
396 unsafe {
397 from_glib_full(ffi::poppler_document_get_pdf_version_string(
398 self.to_glib_none().0,
399 ))
400 }
401 }
402
403 #[doc(alias = "poppler_document_get_permissions")]
404 #[doc(alias = "get_permissions")]
405 pub fn permissions(&self) -> Permissions {
406 unsafe { from_glib(ffi::poppler_document_get_permissions(self.to_glib_none().0)) }
407 }
408
409 #[cfg(feature = "v0_80")]
410 #[cfg_attr(docsrs, doc(cfg(feature = "v0_80")))]
411 #[doc(alias = "poppler_document_get_print_duplex")]
412 #[doc(alias = "get_print_duplex")]
413 #[doc(alias = "print-duplex")]
414 pub fn print_duplex(&self) -> PrintDuplex {
415 unsafe {
416 from_glib(ffi::poppler_document_get_print_duplex(
417 self.to_glib_none().0,
418 ))
419 }
420 }
421
422 #[cfg(feature = "v0_80")]
423 #[cfg_attr(docsrs, doc(cfg(feature = "v0_80")))]
424 #[doc(alias = "poppler_document_get_print_n_copies")]
425 #[doc(alias = "get_print_n_copies")]
426 #[doc(alias = "print-n-copies")]
427 pub fn print_n_copies(&self) -> i32 {
428 unsafe { ffi::poppler_document_get_print_n_copies(self.to_glib_none().0) }
429 }
430
431 #[cfg(feature = "v0_73")]
432 #[cfg_attr(docsrs, doc(cfg(feature = "v0_73")))]
433 #[doc(alias = "poppler_document_get_print_scaling")]
434 #[doc(alias = "get_print_scaling")]
435 #[doc(alias = "print-scaling")]
436 pub fn print_scaling(&self) -> PrintScaling {
437 unsafe {
438 from_glib(ffi::poppler_document_get_print_scaling(
439 self.to_glib_none().0,
440 ))
441 }
442 }
443
444 #[doc(alias = "poppler_document_get_producer")]
445 #[doc(alias = "get_producer")]
446 pub fn producer(&self) -> Option<glib::GString> {
447 unsafe { from_glib_full(ffi::poppler_document_get_producer(self.to_glib_none().0)) }
448 }
449
450 #[cfg(feature = "v22_2")]
451 #[cfg_attr(docsrs, doc(cfg(feature = "v22_2")))]
452 #[doc(alias = "poppler_document_get_signature_fields")]
453 #[doc(alias = "get_signature_fields")]
454 pub fn signature_fields(&self) -> Vec<FormField> {
455 unsafe {
456 FromGlibPtrContainer::from_glib_full(ffi::poppler_document_get_signature_fields(
457 self.to_glib_none().0,
458 ))
459 }
460 }
461
462 #[doc(alias = "poppler_document_get_subject")]
463 #[doc(alias = "get_subject")]
464 pub fn subject(&self) -> Option<glib::GString> {
465 unsafe { from_glib_full(ffi::poppler_document_get_subject(self.to_glib_none().0)) }
466 }
467
468 #[doc(alias = "poppler_document_get_title")]
469 #[doc(alias = "get_title")]
470 pub fn title(&self) -> Option<glib::GString> {
471 unsafe { from_glib_full(ffi::poppler_document_get_title(self.to_glib_none().0)) }
472 }
473
474 #[doc(alias = "poppler_document_has_attachments")]
475 pub fn has_attachments(&self) -> bool {
476 unsafe { from_glib(ffi::poppler_document_has_attachments(self.to_glib_none().0)) }
477 }
478
479 #[cfg(feature = "v0_90")]
480 #[cfg_attr(docsrs, doc(cfg(feature = "v0_90")))]
481 #[doc(alias = "poppler_document_has_javascript")]
482 pub fn has_javascript(&self) -> bool {
483 unsafe { from_glib(ffi::poppler_document_has_javascript(self.to_glib_none().0)) }
484 }
485
486 #[doc(alias = "poppler_document_is_linearized")]
487 #[doc(alias = "linearized")]
488 pub fn is_linearized(&self) -> bool {
489 unsafe { from_glib(ffi::poppler_document_is_linearized(self.to_glib_none().0)) }
490 }
491
492 #[cfg(feature = "v0_90")]
493 #[cfg_attr(docsrs, doc(cfg(feature = "v0_90")))]
494 #[doc(alias = "poppler_document_reset_form")]
495 pub fn reset_form(&self, fields: &[&str], exclude_fields: bool) {
496 unsafe {
497 ffi::poppler_document_reset_form(
498 self.to_glib_none().0,
499 fields.to_glib_none().0,
500 exclude_fields.into_glib(),
501 );
502 }
503 }
504
505 #[doc(alias = "poppler_document_save")]
506 pub fn save(&self, uri: &str) -> Result<(), glib::Error> {
507 unsafe {
508 let mut error = std::ptr::null_mut();
509 let is_ok =
510 ffi::poppler_document_save(self.to_glib_none().0, uri.to_glib_none().0, &mut error);
511 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
512 if error.is_null() {
513 Ok(())
514 } else {
515 Err(from_glib_full(error))
516 }
517 }
518 }
519
520 #[doc(alias = "poppler_document_save_a_copy")]
521 pub fn save_a_copy(&self, uri: &str) -> Result<(), glib::Error> {
522 unsafe {
523 let mut error = std::ptr::null_mut();
524 let is_ok = ffi::poppler_document_save_a_copy(
525 self.to_glib_none().0,
526 uri.to_glib_none().0,
527 &mut error,
528 );
529 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
530 if error.is_null() {
531 Ok(())
532 } else {
533 Err(from_glib_full(error))
534 }
535 }
536 }
537
538 #[cfg(target_os = "linux")]
539 #[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
540 #[cfg(feature = "v21_12")]
541 #[cfg_attr(docsrs, doc(cfg(feature = "v21_12")))]
542 #[doc(alias = "poppler_document_save_to_fd")]
543 pub fn save_to_fd(&self, fd: i32, include_changes: bool) -> Result<(), glib::Error> {
544 unsafe {
545 let mut error = std::ptr::null_mut();
546 let is_ok = ffi::poppler_document_save_to_fd(
547 self.to_glib_none().0,
548 fd,
549 include_changes.into_glib(),
550 &mut error,
551 );
552 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
553 if error.is_null() {
554 Ok(())
555 } else {
556 Err(from_glib_full(error))
557 }
558 }
559 }
560
561 #[doc(alias = "poppler_document_set_author")]
562 #[doc(alias = "author")]
563 pub fn set_author(&self, author: &str) {
564 unsafe {
565 ffi::poppler_document_set_author(self.to_glib_none().0, author.to_glib_none().0);
566 }
567 }
568
569 #[doc(alias = "poppler_document_set_creation_date")]
570 #[doc(alias = "creation-date")]
571 pub fn set_creation_date(&self, creation_date: libc::time_t) {
572 unsafe {
573 ffi::poppler_document_set_creation_date(self.to_glib_none().0, creation_date);
574 }
575 }
576
577 #[cfg(feature = "v20_9")]
578 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
579 #[doc(alias = "poppler_document_set_creation_date_time")]
580 pub fn set_creation_date_time(&self, creation_datetime: Option<&glib::DateTime>) {
581 unsafe {
582 ffi::poppler_document_set_creation_date_time(
583 self.to_glib_none().0,
584 creation_datetime.to_glib_none().0,
585 );
586 }
587 }
588
589 #[doc(alias = "poppler_document_set_creator")]
590 #[doc(alias = "creator")]
591 pub fn set_creator(&self, creator: &str) {
592 unsafe {
593 ffi::poppler_document_set_creator(self.to_glib_none().0, creator.to_glib_none().0);
594 }
595 }
596
597 #[doc(alias = "poppler_document_set_keywords")]
598 #[doc(alias = "keywords")]
599 pub fn set_keywords(&self, keywords: &str) {
600 unsafe {
601 ffi::poppler_document_set_keywords(self.to_glib_none().0, keywords.to_glib_none().0);
602 }
603 }
604
605 #[doc(alias = "poppler_document_set_modification_date")]
606 pub fn set_modification_date(&self, modification_date: libc::time_t) {
607 unsafe {
608 ffi::poppler_document_set_modification_date(self.to_glib_none().0, modification_date);
609 }
610 }
611
612 #[cfg(feature = "v20_9")]
613 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
614 #[doc(alias = "poppler_document_set_modification_date_time")]
615 pub fn set_modification_date_time(&self, modification_datetime: Option<&glib::DateTime>) {
616 unsafe {
617 ffi::poppler_document_set_modification_date_time(
618 self.to_glib_none().0,
619 modification_datetime.to_glib_none().0,
620 );
621 }
622 }
623
624 #[doc(alias = "poppler_document_set_producer")]
625 #[doc(alias = "producer")]
626 pub fn set_producer(&self, producer: &str) {
627 unsafe {
628 ffi::poppler_document_set_producer(self.to_glib_none().0, producer.to_glib_none().0);
629 }
630 }
631
632 #[doc(alias = "poppler_document_set_subject")]
633 #[doc(alias = "subject")]
634 pub fn set_subject(&self, subject: &str) {
635 unsafe {
636 ffi::poppler_document_set_subject(self.to_glib_none().0, subject.to_glib_none().0);
637 }
638 }
639
640 #[doc(alias = "poppler_document_set_title")]
641 #[doc(alias = "title")]
642 pub fn set_title(&self, title: &str) {
643 unsafe {
644 ffi::poppler_document_set_title(self.to_glib_none().0, title.to_glib_none().0);
645 }
646 }
647
648 #[cfg(feature = "v23_7")]
649 #[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
650 #[doc(alias = "poppler_document_sign")]
651 pub fn sign<P: FnOnce(Result<(), glib::Error>) + 'static>(
652 &self,
653 signing_data: &SigningData,
654 cancellable: Option<&impl IsA<gio::Cancellable>>,
655 callback: P,
656 ) {
657 let main_context = glib::MainContext::ref_thread_default();
658 let is_main_context_owner = main_context.is_owner();
659 let has_acquired_main_context = (!is_main_context_owner)
660 .then(|| main_context.acquire().ok())
661 .flatten();
662 assert!(
663 is_main_context_owner || has_acquired_main_context.is_some(),
664 "Async operations only allowed if the thread is owning the MainContext"
665 );
666
667 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
668 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
669 unsafe extern "C" fn sign_trampoline<P: FnOnce(Result<(), glib::Error>) + 'static>(
670 _source_object: *mut glib::gobject_ffi::GObject,
671 res: *mut gio::ffi::GAsyncResult,
672 user_data: glib::ffi::gpointer,
673 ) {
674 unsafe {
675 let mut error = std::ptr::null_mut();
676 ffi::poppler_document_sign_finish(_source_object as *mut _, res, &mut error);
677 let result = if error.is_null() {
678 Ok(())
679 } else {
680 Err(from_glib_full(error))
681 };
682 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
683 Box_::from_raw(user_data as *mut _);
684 let callback: P = callback.into_inner();
685 callback(result);
686 }
687 }
688 let callback = sign_trampoline::<P>;
689 unsafe {
690 ffi::poppler_document_sign(
691 self.to_glib_none().0,
692 signing_data.to_glib_none().0,
693 cancellable.map(|p| p.as_ref()).to_glib_none().0,
694 Some(callback),
695 Box_::into_raw(user_data) as *mut _,
696 );
697 }
698 }
699
700 #[cfg(feature = "v23_7")]
701 #[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
702 pub fn sign_future(
703 &self,
704 signing_data: &SigningData,
705 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
706 let signing_data = signing_data.clone();
707 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
708 obj.sign(&signing_data, Some(cancellable), move |res| {
709 send.resolve(res);
710 });
711 }))
712 }
713
714 #[cfg(feature = "v20_9")]
715 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
716 #[doc(alias = "creation-datetime")]
717 pub fn creation_datetime(&self) -> Option<glib::DateTime> {
718 ObjectExt::property(self, "creation-datetime")
719 }
720
721 #[cfg(feature = "v20_9")]
722 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
723 #[doc(alias = "creation-datetime")]
724 pub fn set_creation_datetime(&self, creation_datetime: Option<&glib::DateTime>) {
725 ObjectExt::set_property(self, "creation-datetime", creation_datetime)
726 }
727
728 pub fn format(&self) -> Option<glib::GString> {
729 ObjectExt::property(self, "format")
730 }
731
732 #[doc(alias = "format-major")]
733 pub fn format_major(&self) -> u32 {
734 ObjectExt::property(self, "format-major")
735 }
736
737 #[doc(alias = "format-minor")]
738 pub fn format_minor(&self) -> u32 {
739 ObjectExt::property(self, "format-minor")
740 }
741
742 #[cfg_attr(feature = "v20_9", deprecated = "Since 20.9")]
743 #[doc(alias = "mod-date")]
744 pub fn mod_date(&self) -> i32 {
745 ObjectExt::property(self, "mod-date")
746 }
747
748 #[cfg_attr(feature = "v20_9", deprecated = "Since 20.9")]
749 #[doc(alias = "mod-date")]
750 pub fn set_mod_date(&self, mod_date: i32) {
751 ObjectExt::set_property(self, "mod-date", mod_date)
752 }
753
754 #[cfg(feature = "v20_9")]
755 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
756 #[doc(alias = "mod-datetime")]
757 pub fn mod_datetime(&self) -> Option<glib::DateTime> {
758 ObjectExt::property(self, "mod-datetime")
759 }
760
761 #[cfg(feature = "v20_9")]
762 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
763 #[doc(alias = "mod-datetime")]
764 pub fn set_mod_datetime(&self, mod_datetime: Option<&glib::DateTime>) {
765 ObjectExt::set_property(self, "mod-datetime", mod_datetime)
766 }
767
768 pub fn subtype(&self) -> PDFSubtype {
769 ObjectExt::property(self, "subtype")
770 }
771
772 #[doc(alias = "subtype-conformance")]
773 pub fn subtype_conformance(&self) -> PDFConformance {
774 ObjectExt::property(self, "subtype-conformance")
775 }
776
777 #[doc(alias = "subtype-part")]
778 pub fn subtype_part(&self) -> PDFPart {
779 ObjectExt::property(self, "subtype-part")
780 }
781
782 #[doc(alias = "subtype-string")]
783 pub fn subtype_string(&self) -> Option<glib::GString> {
784 ObjectExt::property(self, "subtype-string")
785 }
786
787 #[doc(alias = "viewer-preferences")]
788 pub fn viewer_preferences(&self) -> ViewerPreferences {
789 ObjectExt::property(self, "viewer-preferences")
790 }
791
792 #[doc(alias = "author")]
793 pub fn connect_author_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
794 unsafe extern "C" fn notify_author_trampoline<F: Fn(&Document) + 'static>(
795 this: *mut ffi::PopplerDocument,
796 _param_spec: glib::ffi::gpointer,
797 f: glib::ffi::gpointer,
798 ) {
799 unsafe {
800 let f: &F = &*(f as *const F);
801 f(&from_glib_borrow(this))
802 }
803 }
804 unsafe {
805 let f: Box_<F> = Box_::new(f);
806 connect_raw(
807 self.as_ptr() as *mut _,
808 c"notify::author".as_ptr(),
809 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
810 notify_author_trampoline::<F> as *const (),
811 )),
812 Box_::into_raw(f),
813 )
814 }
815 }
816
817 #[cfg_attr(feature = "v20_9", deprecated = "Since 20.9")]
818 #[doc(alias = "creation-date")]
819 pub fn connect_creation_date_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
820 unsafe extern "C" fn notify_creation_date_trampoline<F: Fn(&Document) + 'static>(
821 this: *mut ffi::PopplerDocument,
822 _param_spec: glib::ffi::gpointer,
823 f: glib::ffi::gpointer,
824 ) {
825 unsafe {
826 let f: &F = &*(f as *const F);
827 f(&from_glib_borrow(this))
828 }
829 }
830 unsafe {
831 let f: Box_<F> = Box_::new(f);
832 connect_raw(
833 self.as_ptr() as *mut _,
834 c"notify::creation-date".as_ptr(),
835 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
836 notify_creation_date_trampoline::<F> as *const (),
837 )),
838 Box_::into_raw(f),
839 )
840 }
841 }
842
843 #[cfg(feature = "v20_9")]
844 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
845 #[doc(alias = "creation-datetime")]
846 pub fn connect_creation_datetime_notify<F: Fn(&Self) + 'static>(
847 &self,
848 f: F,
849 ) -> SignalHandlerId {
850 unsafe extern "C" fn notify_creation_datetime_trampoline<F: Fn(&Document) + 'static>(
851 this: *mut ffi::PopplerDocument,
852 _param_spec: glib::ffi::gpointer,
853 f: glib::ffi::gpointer,
854 ) {
855 unsafe {
856 let f: &F = &*(f as *const F);
857 f(&from_glib_borrow(this))
858 }
859 }
860 unsafe {
861 let f: Box_<F> = Box_::new(f);
862 connect_raw(
863 self.as_ptr() as *mut _,
864 c"notify::creation-datetime".as_ptr(),
865 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
866 notify_creation_datetime_trampoline::<F> as *const (),
867 )),
868 Box_::into_raw(f),
869 )
870 }
871 }
872
873 #[doc(alias = "creator")]
874 pub fn connect_creator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
875 unsafe extern "C" fn notify_creator_trampoline<F: Fn(&Document) + 'static>(
876 this: *mut ffi::PopplerDocument,
877 _param_spec: glib::ffi::gpointer,
878 f: glib::ffi::gpointer,
879 ) {
880 unsafe {
881 let f: &F = &*(f as *const F);
882 f(&from_glib_borrow(this))
883 }
884 }
885 unsafe {
886 let f: Box_<F> = Box_::new(f);
887 connect_raw(
888 self.as_ptr() as *mut _,
889 c"notify::creator".as_ptr(),
890 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
891 notify_creator_trampoline::<F> as *const (),
892 )),
893 Box_::into_raw(f),
894 )
895 }
896 }
897
898 #[doc(alias = "format")]
899 pub fn connect_format_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
900 unsafe extern "C" fn notify_format_trampoline<F: Fn(&Document) + 'static>(
901 this: *mut ffi::PopplerDocument,
902 _param_spec: glib::ffi::gpointer,
903 f: glib::ffi::gpointer,
904 ) {
905 unsafe {
906 let f: &F = &*(f as *const F);
907 f(&from_glib_borrow(this))
908 }
909 }
910 unsafe {
911 let f: Box_<F> = Box_::new(f);
912 connect_raw(
913 self.as_ptr() as *mut _,
914 c"notify::format".as_ptr(),
915 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
916 notify_format_trampoline::<F> as *const (),
917 )),
918 Box_::into_raw(f),
919 )
920 }
921 }
922
923 #[doc(alias = "format-major")]
924 pub fn connect_format_major_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
925 unsafe extern "C" fn notify_format_major_trampoline<F: Fn(&Document) + 'static>(
926 this: *mut ffi::PopplerDocument,
927 _param_spec: glib::ffi::gpointer,
928 f: glib::ffi::gpointer,
929 ) {
930 unsafe {
931 let f: &F = &*(f as *const F);
932 f(&from_glib_borrow(this))
933 }
934 }
935 unsafe {
936 let f: Box_<F> = Box_::new(f);
937 connect_raw(
938 self.as_ptr() as *mut _,
939 c"notify::format-major".as_ptr(),
940 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
941 notify_format_major_trampoline::<F> as *const (),
942 )),
943 Box_::into_raw(f),
944 )
945 }
946 }
947
948 #[doc(alias = "format-minor")]
949 pub fn connect_format_minor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
950 unsafe extern "C" fn notify_format_minor_trampoline<F: Fn(&Document) + 'static>(
951 this: *mut ffi::PopplerDocument,
952 _param_spec: glib::ffi::gpointer,
953 f: glib::ffi::gpointer,
954 ) {
955 unsafe {
956 let f: &F = &*(f as *const F);
957 f(&from_glib_borrow(this))
958 }
959 }
960 unsafe {
961 let f: Box_<F> = Box_::new(f);
962 connect_raw(
963 self.as_ptr() as *mut _,
964 c"notify::format-minor".as_ptr(),
965 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
966 notify_format_minor_trampoline::<F> as *const (),
967 )),
968 Box_::into_raw(f),
969 )
970 }
971 }
972
973 #[doc(alias = "keywords")]
974 pub fn connect_keywords_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
975 unsafe extern "C" fn notify_keywords_trampoline<F: Fn(&Document) + 'static>(
976 this: *mut ffi::PopplerDocument,
977 _param_spec: glib::ffi::gpointer,
978 f: glib::ffi::gpointer,
979 ) {
980 unsafe {
981 let f: &F = &*(f as *const F);
982 f(&from_glib_borrow(this))
983 }
984 }
985 unsafe {
986 let f: Box_<F> = Box_::new(f);
987 connect_raw(
988 self.as_ptr() as *mut _,
989 c"notify::keywords".as_ptr(),
990 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
991 notify_keywords_trampoline::<F> as *const (),
992 )),
993 Box_::into_raw(f),
994 )
995 }
996 }
997
998 #[doc(alias = "linearized")]
999 pub fn connect_linearized_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1000 unsafe extern "C" fn notify_linearized_trampoline<F: Fn(&Document) + 'static>(
1001 this: *mut ffi::PopplerDocument,
1002 _param_spec: glib::ffi::gpointer,
1003 f: glib::ffi::gpointer,
1004 ) {
1005 unsafe {
1006 let f: &F = &*(f as *const F);
1007 f(&from_glib_borrow(this))
1008 }
1009 }
1010 unsafe {
1011 let f: Box_<F> = Box_::new(f);
1012 connect_raw(
1013 self.as_ptr() as *mut _,
1014 c"notify::linearized".as_ptr(),
1015 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1016 notify_linearized_trampoline::<F> as *const (),
1017 )),
1018 Box_::into_raw(f),
1019 )
1020 }
1021 }
1022
1023 #[doc(alias = "metadata")]
1024 pub fn connect_metadata_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1025 unsafe extern "C" fn notify_metadata_trampoline<F: Fn(&Document) + 'static>(
1026 this: *mut ffi::PopplerDocument,
1027 _param_spec: glib::ffi::gpointer,
1028 f: glib::ffi::gpointer,
1029 ) {
1030 unsafe {
1031 let f: &F = &*(f as *const F);
1032 f(&from_glib_borrow(this))
1033 }
1034 }
1035 unsafe {
1036 let f: Box_<F> = Box_::new(f);
1037 connect_raw(
1038 self.as_ptr() as *mut _,
1039 c"notify::metadata".as_ptr(),
1040 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1041 notify_metadata_trampoline::<F> as *const (),
1042 )),
1043 Box_::into_raw(f),
1044 )
1045 }
1046 }
1047
1048 #[cfg_attr(feature = "v20_9", deprecated = "Since 20.9")]
1049 #[doc(alias = "mod-date")]
1050 pub fn connect_mod_date_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1051 unsafe extern "C" fn notify_mod_date_trampoline<F: Fn(&Document) + 'static>(
1052 this: *mut ffi::PopplerDocument,
1053 _param_spec: glib::ffi::gpointer,
1054 f: glib::ffi::gpointer,
1055 ) {
1056 unsafe {
1057 let f: &F = &*(f as *const F);
1058 f(&from_glib_borrow(this))
1059 }
1060 }
1061 unsafe {
1062 let f: Box_<F> = Box_::new(f);
1063 connect_raw(
1064 self.as_ptr() as *mut _,
1065 c"notify::mod-date".as_ptr(),
1066 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1067 notify_mod_date_trampoline::<F> as *const (),
1068 )),
1069 Box_::into_raw(f),
1070 )
1071 }
1072 }
1073
1074 #[cfg(feature = "v20_9")]
1075 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
1076 #[doc(alias = "mod-datetime")]
1077 pub fn connect_mod_datetime_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1078 unsafe extern "C" fn notify_mod_datetime_trampoline<F: Fn(&Document) + 'static>(
1079 this: *mut ffi::PopplerDocument,
1080 _param_spec: glib::ffi::gpointer,
1081 f: glib::ffi::gpointer,
1082 ) {
1083 unsafe {
1084 let f: &F = &*(f as *const F);
1085 f(&from_glib_borrow(this))
1086 }
1087 }
1088 unsafe {
1089 let f: Box_<F> = Box_::new(f);
1090 connect_raw(
1091 self.as_ptr() as *mut _,
1092 c"notify::mod-datetime".as_ptr(),
1093 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1094 notify_mod_datetime_trampoline::<F> as *const (),
1095 )),
1096 Box_::into_raw(f),
1097 )
1098 }
1099 }
1100
1101 #[doc(alias = "page-layout")]
1102 pub fn connect_page_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1103 unsafe extern "C" fn notify_page_layout_trampoline<F: Fn(&Document) + 'static>(
1104 this: *mut ffi::PopplerDocument,
1105 _param_spec: glib::ffi::gpointer,
1106 f: glib::ffi::gpointer,
1107 ) {
1108 unsafe {
1109 let f: &F = &*(f as *const F);
1110 f(&from_glib_borrow(this))
1111 }
1112 }
1113 unsafe {
1114 let f: Box_<F> = Box_::new(f);
1115 connect_raw(
1116 self.as_ptr() as *mut _,
1117 c"notify::page-layout".as_ptr(),
1118 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1119 notify_page_layout_trampoline::<F> as *const (),
1120 )),
1121 Box_::into_raw(f),
1122 )
1123 }
1124 }
1125
1126 #[doc(alias = "page-mode")]
1127 pub fn connect_page_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1128 unsafe extern "C" fn notify_page_mode_trampoline<F: Fn(&Document) + 'static>(
1129 this: *mut ffi::PopplerDocument,
1130 _param_spec: glib::ffi::gpointer,
1131 f: glib::ffi::gpointer,
1132 ) {
1133 unsafe {
1134 let f: &F = &*(f as *const F);
1135 f(&from_glib_borrow(this))
1136 }
1137 }
1138 unsafe {
1139 let f: Box_<F> = Box_::new(f);
1140 connect_raw(
1141 self.as_ptr() as *mut _,
1142 c"notify::page-mode".as_ptr(),
1143 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1144 notify_page_mode_trampoline::<F> as *const (),
1145 )),
1146 Box_::into_raw(f),
1147 )
1148 }
1149 }
1150
1151 #[doc(alias = "permissions")]
1152 pub fn connect_permissions_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1153 unsafe extern "C" fn notify_permissions_trampoline<F: Fn(&Document) + 'static>(
1154 this: *mut ffi::PopplerDocument,
1155 _param_spec: glib::ffi::gpointer,
1156 f: glib::ffi::gpointer,
1157 ) {
1158 unsafe {
1159 let f: &F = &*(f as *const F);
1160 f(&from_glib_borrow(this))
1161 }
1162 }
1163 unsafe {
1164 let f: Box_<F> = Box_::new(f);
1165 connect_raw(
1166 self.as_ptr() as *mut _,
1167 c"notify::permissions".as_ptr(),
1168 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1169 notify_permissions_trampoline::<F> as *const (),
1170 )),
1171 Box_::into_raw(f),
1172 )
1173 }
1174 }
1175
1176 #[cfg(feature = "v0_80")]
1177 #[cfg_attr(docsrs, doc(cfg(feature = "v0_80")))]
1178 #[doc(alias = "print-duplex")]
1179 pub fn connect_print_duplex_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1180 unsafe extern "C" fn notify_print_duplex_trampoline<F: Fn(&Document) + 'static>(
1181 this: *mut ffi::PopplerDocument,
1182 _param_spec: glib::ffi::gpointer,
1183 f: glib::ffi::gpointer,
1184 ) {
1185 unsafe {
1186 let f: &F = &*(f as *const F);
1187 f(&from_glib_borrow(this))
1188 }
1189 }
1190 unsafe {
1191 let f: Box_<F> = Box_::new(f);
1192 connect_raw(
1193 self.as_ptr() as *mut _,
1194 c"notify::print-duplex".as_ptr(),
1195 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1196 notify_print_duplex_trampoline::<F> as *const (),
1197 )),
1198 Box_::into_raw(f),
1199 )
1200 }
1201 }
1202
1203 #[cfg(feature = "v0_80")]
1204 #[cfg_attr(docsrs, doc(cfg(feature = "v0_80")))]
1205 #[doc(alias = "print-n-copies")]
1206 pub fn connect_print_n_copies_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1207 unsafe extern "C" fn notify_print_n_copies_trampoline<F: Fn(&Document) + 'static>(
1208 this: *mut ffi::PopplerDocument,
1209 _param_spec: glib::ffi::gpointer,
1210 f: glib::ffi::gpointer,
1211 ) {
1212 unsafe {
1213 let f: &F = &*(f as *const F);
1214 f(&from_glib_borrow(this))
1215 }
1216 }
1217 unsafe {
1218 let f: Box_<F> = Box_::new(f);
1219 connect_raw(
1220 self.as_ptr() as *mut _,
1221 c"notify::print-n-copies".as_ptr(),
1222 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1223 notify_print_n_copies_trampoline::<F> as *const (),
1224 )),
1225 Box_::into_raw(f),
1226 )
1227 }
1228 }
1229
1230 #[cfg(feature = "v0_73")]
1231 #[cfg_attr(docsrs, doc(cfg(feature = "v0_73")))]
1232 #[doc(alias = "print-scaling")]
1233 pub fn connect_print_scaling_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1234 unsafe extern "C" fn notify_print_scaling_trampoline<F: Fn(&Document) + 'static>(
1235 this: *mut ffi::PopplerDocument,
1236 _param_spec: glib::ffi::gpointer,
1237 f: glib::ffi::gpointer,
1238 ) {
1239 unsafe {
1240 let f: &F = &*(f as *const F);
1241 f(&from_glib_borrow(this))
1242 }
1243 }
1244 unsafe {
1245 let f: Box_<F> = Box_::new(f);
1246 connect_raw(
1247 self.as_ptr() as *mut _,
1248 c"notify::print-scaling".as_ptr(),
1249 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1250 notify_print_scaling_trampoline::<F> as *const (),
1251 )),
1252 Box_::into_raw(f),
1253 )
1254 }
1255 }
1256
1257 #[doc(alias = "producer")]
1258 pub fn connect_producer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1259 unsafe extern "C" fn notify_producer_trampoline<F: Fn(&Document) + 'static>(
1260 this: *mut ffi::PopplerDocument,
1261 _param_spec: glib::ffi::gpointer,
1262 f: glib::ffi::gpointer,
1263 ) {
1264 unsafe {
1265 let f: &F = &*(f as *const F);
1266 f(&from_glib_borrow(this))
1267 }
1268 }
1269 unsafe {
1270 let f: Box_<F> = Box_::new(f);
1271 connect_raw(
1272 self.as_ptr() as *mut _,
1273 c"notify::producer".as_ptr(),
1274 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1275 notify_producer_trampoline::<F> as *const (),
1276 )),
1277 Box_::into_raw(f),
1278 )
1279 }
1280 }
1281
1282 #[doc(alias = "subject")]
1283 pub fn connect_subject_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1284 unsafe extern "C" fn notify_subject_trampoline<F: Fn(&Document) + 'static>(
1285 this: *mut ffi::PopplerDocument,
1286 _param_spec: glib::ffi::gpointer,
1287 f: glib::ffi::gpointer,
1288 ) {
1289 unsafe {
1290 let f: &F = &*(f as *const F);
1291 f(&from_glib_borrow(this))
1292 }
1293 }
1294 unsafe {
1295 let f: Box_<F> = Box_::new(f);
1296 connect_raw(
1297 self.as_ptr() as *mut _,
1298 c"notify::subject".as_ptr(),
1299 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1300 notify_subject_trampoline::<F> as *const (),
1301 )),
1302 Box_::into_raw(f),
1303 )
1304 }
1305 }
1306
1307 #[doc(alias = "subtype")]
1308 pub fn connect_subtype_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1309 unsafe extern "C" fn notify_subtype_trampoline<F: Fn(&Document) + 'static>(
1310 this: *mut ffi::PopplerDocument,
1311 _param_spec: glib::ffi::gpointer,
1312 f: glib::ffi::gpointer,
1313 ) {
1314 unsafe {
1315 let f: &F = &*(f as *const F);
1316 f(&from_glib_borrow(this))
1317 }
1318 }
1319 unsafe {
1320 let f: Box_<F> = Box_::new(f);
1321 connect_raw(
1322 self.as_ptr() as *mut _,
1323 c"notify::subtype".as_ptr(),
1324 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1325 notify_subtype_trampoline::<F> as *const (),
1326 )),
1327 Box_::into_raw(f),
1328 )
1329 }
1330 }
1331
1332 #[doc(alias = "subtype-conformance")]
1333 pub fn connect_subtype_conformance_notify<F: Fn(&Self) + 'static>(
1334 &self,
1335 f: F,
1336 ) -> SignalHandlerId {
1337 unsafe extern "C" fn notify_subtype_conformance_trampoline<F: Fn(&Document) + 'static>(
1338 this: *mut ffi::PopplerDocument,
1339 _param_spec: glib::ffi::gpointer,
1340 f: glib::ffi::gpointer,
1341 ) {
1342 unsafe {
1343 let f: &F = &*(f as *const F);
1344 f(&from_glib_borrow(this))
1345 }
1346 }
1347 unsafe {
1348 let f: Box_<F> = Box_::new(f);
1349 connect_raw(
1350 self.as_ptr() as *mut _,
1351 c"notify::subtype-conformance".as_ptr(),
1352 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1353 notify_subtype_conformance_trampoline::<F> as *const (),
1354 )),
1355 Box_::into_raw(f),
1356 )
1357 }
1358 }
1359
1360 #[doc(alias = "subtype-part")]
1361 pub fn connect_subtype_part_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1362 unsafe extern "C" fn notify_subtype_part_trampoline<F: Fn(&Document) + 'static>(
1363 this: *mut ffi::PopplerDocument,
1364 _param_spec: glib::ffi::gpointer,
1365 f: glib::ffi::gpointer,
1366 ) {
1367 unsafe {
1368 let f: &F = &*(f as *const F);
1369 f(&from_glib_borrow(this))
1370 }
1371 }
1372 unsafe {
1373 let f: Box_<F> = Box_::new(f);
1374 connect_raw(
1375 self.as_ptr() as *mut _,
1376 c"notify::subtype-part".as_ptr(),
1377 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1378 notify_subtype_part_trampoline::<F> as *const (),
1379 )),
1380 Box_::into_raw(f),
1381 )
1382 }
1383 }
1384
1385 #[doc(alias = "subtype-string")]
1386 pub fn connect_subtype_string_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1387 unsafe extern "C" fn notify_subtype_string_trampoline<F: Fn(&Document) + 'static>(
1388 this: *mut ffi::PopplerDocument,
1389 _param_spec: glib::ffi::gpointer,
1390 f: glib::ffi::gpointer,
1391 ) {
1392 unsafe {
1393 let f: &F = &*(f as *const F);
1394 f(&from_glib_borrow(this))
1395 }
1396 }
1397 unsafe {
1398 let f: Box_<F> = Box_::new(f);
1399 connect_raw(
1400 self.as_ptr() as *mut _,
1401 c"notify::subtype-string".as_ptr(),
1402 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1403 notify_subtype_string_trampoline::<F> as *const (),
1404 )),
1405 Box_::into_raw(f),
1406 )
1407 }
1408 }
1409
1410 #[doc(alias = "title")]
1411 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1412 unsafe extern "C" fn notify_title_trampoline<F: Fn(&Document) + 'static>(
1413 this: *mut ffi::PopplerDocument,
1414 _param_spec: glib::ffi::gpointer,
1415 f: glib::ffi::gpointer,
1416 ) {
1417 unsafe {
1418 let f: &F = &*(f as *const F);
1419 f(&from_glib_borrow(this))
1420 }
1421 }
1422 unsafe {
1423 let f: Box_<F> = Box_::new(f);
1424 connect_raw(
1425 self.as_ptr() as *mut _,
1426 c"notify::title".as_ptr(),
1427 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1428 notify_title_trampoline::<F> as *const (),
1429 )),
1430 Box_::into_raw(f),
1431 )
1432 }
1433 }
1434
1435 #[doc(alias = "viewer-preferences")]
1436 pub fn connect_viewer_preferences_notify<F: Fn(&Self) + 'static>(
1437 &self,
1438 f: F,
1439 ) -> SignalHandlerId {
1440 unsafe extern "C" fn notify_viewer_preferences_trampoline<F: Fn(&Document) + 'static>(
1441 this: *mut ffi::PopplerDocument,
1442 _param_spec: glib::ffi::gpointer,
1443 f: glib::ffi::gpointer,
1444 ) {
1445 unsafe {
1446 let f: &F = &*(f as *const F);
1447 f(&from_glib_borrow(this))
1448 }
1449 }
1450 unsafe {
1451 let f: Box_<F> = Box_::new(f);
1452 connect_raw(
1453 self.as_ptr() as *mut _,
1454 c"notify::viewer-preferences".as_ptr(),
1455 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1456 notify_viewer_preferences_trampoline::<F> as *const (),
1457 )),
1458 Box_::into_raw(f),
1459 )
1460 }
1461 }
1462}
1463
1464#[must_use = "The builder must be built to be used"]
1469pub struct DocumentBuilder {
1470 builder: glib::object::ObjectBuilder<'static, Document>,
1471}
1472
1473impl DocumentBuilder {
1474 fn new() -> Self {
1475 Self {
1476 builder: glib::object::Object::builder(),
1477 }
1478 }
1479
1480 pub fn author(self, author: impl Into<glib::GString>) -> Self {
1481 Self {
1482 builder: self.builder.property("author", author.into()),
1483 }
1484 }
1485
1486 #[cfg_attr(feature = "v20_9", deprecated = "Since 20.9")]
1487 pub fn creation_date(self, creation_date: i32) -> Self {
1488 Self {
1489 builder: self.builder.property("creation-date", creation_date),
1490 }
1491 }
1492
1493 #[cfg(feature = "v20_9")]
1494 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
1495 pub fn creation_datetime(self, creation_datetime: &glib::DateTime) -> Self {
1496 Self {
1497 builder: self
1498 .builder
1499 .property("creation-datetime", creation_datetime.clone()),
1500 }
1501 }
1502
1503 pub fn creator(self, creator: impl Into<glib::GString>) -> Self {
1504 Self {
1505 builder: self.builder.property("creator", creator.into()),
1506 }
1507 }
1508
1509 pub fn keywords(self, keywords: impl Into<glib::GString>) -> Self {
1510 Self {
1511 builder: self.builder.property("keywords", keywords.into()),
1512 }
1513 }
1514
1515 #[cfg_attr(feature = "v20_9", deprecated = "Since 20.9")]
1516 pub fn mod_date(self, mod_date: i32) -> Self {
1517 Self {
1518 builder: self.builder.property("mod-date", mod_date),
1519 }
1520 }
1521
1522 #[cfg(feature = "v20_9")]
1523 #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
1524 pub fn mod_datetime(self, mod_datetime: &glib::DateTime) -> Self {
1525 Self {
1526 builder: self.builder.property("mod-datetime", mod_datetime.clone()),
1527 }
1528 }
1529
1530 pub fn producer(self, producer: impl Into<glib::GString>) -> Self {
1531 Self {
1532 builder: self.builder.property("producer", producer.into()),
1533 }
1534 }
1535
1536 pub fn subject(self, subject: impl Into<glib::GString>) -> Self {
1537 Self {
1538 builder: self.builder.property("subject", subject.into()),
1539 }
1540 }
1541
1542 pub fn title(self, title: impl Into<glib::GString>) -> Self {
1543 Self {
1544 builder: self.builder.property("title", title.into()),
1545 }
1546 }
1547
1548 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1551 pub fn build(self) -> Document {
1552 self.builder.build()
1553 }
1554}