1#[cfg(feature = "v2_66")]
4#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
5use crate::DateTime;
6use crate::{ffi, translate::*};
7
8crate::wrapper! {
9 #[doc(alias = "GBookmarkFile")]
10 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11 pub struct BookmarkFile(Boxed<ffi::GBookmarkFile>);
12
13 match fn {
14 copy => |ptr| ffi::g_bookmark_file_copy(mut_override(ptr)),
15 free => |ptr| ffi::g_bookmark_file_free(ptr),
16 type_ => || ffi::g_bookmark_file_get_type(),
17 }
18}
19
20impl BookmarkFile {
21 #[doc(alias = "g_bookmark_file_new")]
22 pub fn new() -> BookmarkFile {
23 unsafe { from_glib_full(ffi::g_bookmark_file_new()) }
24 }
25
26 #[doc(alias = "g_bookmark_file_add_application")]
27 pub fn add_application(&mut self, uri: &str, name: Option<&str>, exec: Option<&str>) {
28 unsafe {
29 ffi::g_bookmark_file_add_application(
30 self.to_glib_none_mut().0,
31 uri.to_glib_none().0,
32 name.to_glib_none().0,
33 exec.to_glib_none().0,
34 );
35 }
36 }
37
38 #[doc(alias = "g_bookmark_file_add_group")]
39 pub fn add_group(&mut self, uri: &str, group: &str) {
40 unsafe {
41 ffi::g_bookmark_file_add_group(
42 self.to_glib_none_mut().0,
43 uri.to_glib_none().0,
44 group.to_glib_none().0,
45 );
46 }
47 }
48
49 #[cfg_attr(feature = "v2_66", deprecated = "Since 2.66")]
50 #[allow(deprecated)]
51 #[doc(alias = "g_bookmark_file_get_added")]
52 #[doc(alias = "get_added")]
53 pub fn added(&self, uri: &str) -> Result<libc::time_t, crate::Error> {
54 unsafe {
55 let mut error = std::ptr::null_mut();
56 let ret = ffi::g_bookmark_file_get_added(
57 mut_override(self.to_glib_none().0),
58 uri.to_glib_none().0,
59 &mut error,
60 );
61 if error.is_null() {
62 Ok(ret)
63 } else {
64 Err(from_glib_full(error))
65 }
66 }
67 }
68
69 #[cfg(feature = "v2_66")]
70 #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
71 #[doc(alias = "g_bookmark_file_get_added_date_time")]
72 #[doc(alias = "get_added_date_time")]
73 pub fn added_date_time(&self, uri: &str) -> Result<DateTime, crate::Error> {
74 unsafe {
75 let mut error = std::ptr::null_mut();
76 let ret = ffi::g_bookmark_file_get_added_date_time(
77 mut_override(self.to_glib_none().0),
78 uri.to_glib_none().0,
79 &mut error,
80 );
81 if error.is_null() {
82 Ok(from_glib_none(ret))
83 } else {
84 Err(from_glib_full(error))
85 }
86 }
87 }
88
89 #[cfg_attr(feature = "v2_66", deprecated = "Since 2.66")]
90 #[allow(deprecated)]
91 #[doc(alias = "g_bookmark_file_get_app_info")]
92 #[doc(alias = "get_app_info")]
93 pub fn app_info(
94 &self,
95 uri: &str,
96 name: &str,
97 ) -> Result<(crate::GString, u32, libc::time_t), crate::Error> {
98 unsafe {
99 let mut exec = std::ptr::null_mut();
100 let mut count = std::mem::MaybeUninit::uninit();
101 let mut stamp = std::mem::MaybeUninit::uninit();
102 let mut error = std::ptr::null_mut();
103 let is_ok = ffi::g_bookmark_file_get_app_info(
104 mut_override(self.to_glib_none().0),
105 uri.to_glib_none().0,
106 name.to_glib_none().0,
107 &mut exec,
108 count.as_mut_ptr(),
109 stamp.as_mut_ptr(),
110 &mut error,
111 );
112 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
113 if error.is_null() {
114 Ok((
115 from_glib_full(exec),
116 count.assume_init(),
117 stamp.assume_init(),
118 ))
119 } else {
120 Err(from_glib_full(error))
121 }
122 }
123 }
124
125 #[cfg(feature = "v2_66")]
126 #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
127 #[doc(alias = "g_bookmark_file_get_application_info")]
128 #[doc(alias = "get_application_info")]
129 pub fn application_info(
130 &self,
131 uri: &str,
132 name: &str,
133 ) -> Result<(crate::GString, u32, DateTime), crate::Error> {
134 unsafe {
135 let mut exec = std::ptr::null_mut();
136 let mut count = std::mem::MaybeUninit::uninit();
137 let mut stamp = std::ptr::null_mut();
138 let mut error = std::ptr::null_mut();
139 let is_ok = ffi::g_bookmark_file_get_application_info(
140 mut_override(self.to_glib_none().0),
141 uri.to_glib_none().0,
142 name.to_glib_none().0,
143 &mut exec,
144 count.as_mut_ptr(),
145 &mut stamp,
146 &mut error,
147 );
148 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
149 if error.is_null() {
150 Ok((
151 from_glib_full(exec),
152 count.assume_init(),
153 from_glib_none(stamp),
154 ))
155 } else {
156 Err(from_glib_full(error))
157 }
158 }
159 }
160
161 #[doc(alias = "g_bookmark_file_get_applications")]
162 #[doc(alias = "get_applications")]
163 pub fn applications(&self, uri: &str) -> Result<Vec<crate::GString>, crate::Error> {
164 unsafe {
165 let mut length = std::mem::MaybeUninit::uninit();
166 let mut error = std::ptr::null_mut();
167 let ret = ffi::g_bookmark_file_get_applications(
168 mut_override(self.to_glib_none().0),
169 uri.to_glib_none().0,
170 length.as_mut_ptr(),
171 &mut error,
172 );
173 if error.is_null() {
174 Ok(FromGlibContainer::from_glib_full_num(
175 ret,
176 length.assume_init() as _,
177 ))
178 } else {
179 Err(from_glib_full(error))
180 }
181 }
182 }
183
184 #[doc(alias = "g_bookmark_file_get_description")]
185 #[doc(alias = "get_description")]
186 pub fn description(&self, uri: &str) -> Result<crate::GString, crate::Error> {
187 unsafe {
188 let mut error = std::ptr::null_mut();
189 let ret = ffi::g_bookmark_file_get_description(
190 mut_override(self.to_glib_none().0),
191 uri.to_glib_none().0,
192 &mut error,
193 );
194 if error.is_null() {
195 Ok(from_glib_full(ret))
196 } else {
197 Err(from_glib_full(error))
198 }
199 }
200 }
201
202 #[doc(alias = "g_bookmark_file_get_groups")]
203 #[doc(alias = "get_groups")]
204 pub fn groups(&self, uri: &str) -> Result<Vec<crate::GString>, crate::Error> {
205 unsafe {
206 let mut length = std::mem::MaybeUninit::uninit();
207 let mut error = std::ptr::null_mut();
208 let ret = ffi::g_bookmark_file_get_groups(
209 mut_override(self.to_glib_none().0),
210 uri.to_glib_none().0,
211 length.as_mut_ptr(),
212 &mut error,
213 );
214 if error.is_null() {
215 Ok(FromGlibContainer::from_glib_full_num(
216 ret,
217 length.assume_init() as _,
218 ))
219 } else {
220 Err(from_glib_full(error))
221 }
222 }
223 }
224
225 #[doc(alias = "g_bookmark_file_get_icon")]
226 #[doc(alias = "get_icon")]
227 pub fn icon(&self, uri: &str) -> Result<(crate::GString, crate::GString), crate::Error> {
228 unsafe {
229 let mut href = std::ptr::null_mut();
230 let mut mime_type = std::ptr::null_mut();
231 let mut error = std::ptr::null_mut();
232 let is_ok = ffi::g_bookmark_file_get_icon(
233 mut_override(self.to_glib_none().0),
234 uri.to_glib_none().0,
235 &mut href,
236 &mut mime_type,
237 &mut error,
238 );
239 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
240 if error.is_null() {
241 Ok((from_glib_full(href), from_glib_full(mime_type)))
242 } else {
243 Err(from_glib_full(error))
244 }
245 }
246 }
247
248 #[doc(alias = "g_bookmark_file_get_is_private")]
249 #[doc(alias = "get_is_private")]
250 pub fn is_private(&self, uri: &str) -> Result<(), crate::Error> {
251 unsafe {
252 let mut error = std::ptr::null_mut();
253 let is_ok = ffi::g_bookmark_file_get_is_private(
254 mut_override(self.to_glib_none().0),
255 uri.to_glib_none().0,
256 &mut error,
257 );
258 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
259 if error.is_null() {
260 Ok(())
261 } else {
262 Err(from_glib_full(error))
263 }
264 }
265 }
266
267 #[doc(alias = "g_bookmark_file_get_mime_type")]
268 #[doc(alias = "get_mime_type")]
269 pub fn mime_type(&self, uri: &str) -> Result<crate::GString, crate::Error> {
270 unsafe {
271 let mut error = std::ptr::null_mut();
272 let ret = ffi::g_bookmark_file_get_mime_type(
273 mut_override(self.to_glib_none().0),
274 uri.to_glib_none().0,
275 &mut error,
276 );
277 if error.is_null() {
278 Ok(from_glib_full(ret))
279 } else {
280 Err(from_glib_full(error))
281 }
282 }
283 }
284
285 #[cfg_attr(feature = "v2_66", deprecated = "Since 2.66")]
286 #[allow(deprecated)]
287 #[doc(alias = "g_bookmark_file_get_modified")]
288 #[doc(alias = "get_modified")]
289 pub fn modified(&self, uri: &str) -> Result<libc::time_t, crate::Error> {
290 unsafe {
291 let mut error = std::ptr::null_mut();
292 let ret = ffi::g_bookmark_file_get_modified(
293 mut_override(self.to_glib_none().0),
294 uri.to_glib_none().0,
295 &mut error,
296 );
297 if error.is_null() {
298 Ok(ret)
299 } else {
300 Err(from_glib_full(error))
301 }
302 }
303 }
304
305 #[cfg(feature = "v2_66")]
306 #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
307 #[doc(alias = "g_bookmark_file_get_modified_date_time")]
308 #[doc(alias = "get_modified_date_time")]
309 pub fn modified_date_time(&self, uri: &str) -> Result<DateTime, crate::Error> {
310 unsafe {
311 let mut error = std::ptr::null_mut();
312 let ret = ffi::g_bookmark_file_get_modified_date_time(
313 mut_override(self.to_glib_none().0),
314 uri.to_glib_none().0,
315 &mut error,
316 );
317 if error.is_null() {
318 Ok(from_glib_none(ret))
319 } else {
320 Err(from_glib_full(error))
321 }
322 }
323 }
324
325 #[doc(alias = "g_bookmark_file_get_size")]
326 #[doc(alias = "get_size")]
327 pub fn size(&self) -> i32 {
328 unsafe { ffi::g_bookmark_file_get_size(mut_override(self.to_glib_none().0)) }
329 }
330
331 #[doc(alias = "g_bookmark_file_get_title")]
332 #[doc(alias = "get_title")]
333 pub fn title(&self, uri: Option<&str>) -> Result<crate::GString, crate::Error> {
334 unsafe {
335 let mut error = std::ptr::null_mut();
336 let ret = ffi::g_bookmark_file_get_title(
337 mut_override(self.to_glib_none().0),
338 uri.to_glib_none().0,
339 &mut error,
340 );
341 if error.is_null() {
342 Ok(from_glib_full(ret))
343 } else {
344 Err(from_glib_full(error))
345 }
346 }
347 }
348
349 #[doc(alias = "g_bookmark_file_get_uris")]
350 #[doc(alias = "get_uris")]
351 pub fn uris(&self) -> Vec<crate::GString> {
352 unsafe {
353 let mut length = std::mem::MaybeUninit::uninit();
354
355 FromGlibContainer::from_glib_full_num(
356 ffi::g_bookmark_file_get_uris(
357 mut_override(self.to_glib_none().0),
358 length.as_mut_ptr(),
359 ),
360 length.assume_init() as _,
361 )
362 }
363 }
364
365 #[cfg_attr(feature = "v2_66", deprecated = "Since 2.66")]
366 #[allow(deprecated)]
367 #[doc(alias = "g_bookmark_file_get_visited")]
368 #[doc(alias = "get_visited")]
369 pub fn visited(&self, uri: &str) -> Result<libc::time_t, crate::Error> {
370 unsafe {
371 let mut error = std::ptr::null_mut();
372 let ret = ffi::g_bookmark_file_get_visited(
373 mut_override(self.to_glib_none().0),
374 uri.to_glib_none().0,
375 &mut error,
376 );
377 if error.is_null() {
378 Ok(ret)
379 } else {
380 Err(from_glib_full(error))
381 }
382 }
383 }
384
385 #[cfg(feature = "v2_66")]
386 #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
387 #[doc(alias = "g_bookmark_file_get_visited_date_time")]
388 #[doc(alias = "get_visited_date_time")]
389 pub fn visited_date_time(&self, uri: &str) -> Result<DateTime, crate::Error> {
390 unsafe {
391 let mut error = std::ptr::null_mut();
392 let ret = ffi::g_bookmark_file_get_visited_date_time(
393 mut_override(self.to_glib_none().0),
394 uri.to_glib_none().0,
395 &mut error,
396 );
397 if error.is_null() {
398 Ok(from_glib_none(ret))
399 } else {
400 Err(from_glib_full(error))
401 }
402 }
403 }
404
405 #[doc(alias = "g_bookmark_file_has_application")]
406 pub fn has_application(&self, uri: &str, name: &str) -> Result<(), crate::Error> {
407 unsafe {
408 let mut error = std::ptr::null_mut();
409 let is_ok = ffi::g_bookmark_file_has_application(
410 mut_override(self.to_glib_none().0),
411 uri.to_glib_none().0,
412 name.to_glib_none().0,
413 &mut error,
414 );
415 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
416 if error.is_null() {
417 Ok(())
418 } else {
419 Err(from_glib_full(error))
420 }
421 }
422 }
423
424 #[doc(alias = "g_bookmark_file_has_group")]
425 pub fn has_group(&self, uri: &str, group: &str) -> Result<(), crate::Error> {
426 unsafe {
427 let mut error = std::ptr::null_mut();
428 let is_ok = ffi::g_bookmark_file_has_group(
429 mut_override(self.to_glib_none().0),
430 uri.to_glib_none().0,
431 group.to_glib_none().0,
432 &mut error,
433 );
434 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
435 if error.is_null() {
436 Ok(())
437 } else {
438 Err(from_glib_full(error))
439 }
440 }
441 }
442
443 #[doc(alias = "g_bookmark_file_has_item")]
444 pub fn has_item(&self, uri: &str) -> bool {
445 unsafe {
446 from_glib(ffi::g_bookmark_file_has_item(
447 mut_override(self.to_glib_none().0),
448 uri.to_glib_none().0,
449 ))
450 }
451 }
452
453 #[doc(alias = "g_bookmark_file_load_from_data")]
454 pub fn load_from_data(&mut self, data: &[u8]) -> Result<(), crate::Error> {
455 let length = data.len() as _;
456 unsafe {
457 let mut error = std::ptr::null_mut();
458 let is_ok = ffi::g_bookmark_file_load_from_data(
459 self.to_glib_none_mut().0,
460 data.to_glib_none().0,
461 length,
462 &mut error,
463 );
464 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
465 if error.is_null() {
466 Ok(())
467 } else {
468 Err(from_glib_full(error))
469 }
470 }
471 }
472
473 #[doc(alias = "g_bookmark_file_load_from_data_dirs")]
474 pub fn load_from_data_dirs(
475 &mut self,
476 file: impl AsRef<std::path::Path>,
477 ) -> Result<std::path::PathBuf, crate::Error> {
478 unsafe {
479 let mut full_path = std::ptr::null_mut();
480 let mut error = std::ptr::null_mut();
481 let is_ok = ffi::g_bookmark_file_load_from_data_dirs(
482 self.to_glib_none_mut().0,
483 file.as_ref().to_glib_none().0,
484 &mut full_path,
485 &mut error,
486 );
487 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
488 if error.is_null() {
489 Ok(from_glib_full(full_path))
490 } else {
491 Err(from_glib_full(error))
492 }
493 }
494 }
495
496 #[doc(alias = "g_bookmark_file_load_from_file")]
497 pub fn load_from_file(
498 &mut self,
499 filename: impl AsRef<std::path::Path>,
500 ) -> Result<(), crate::Error> {
501 unsafe {
502 let mut error = std::ptr::null_mut();
503 let is_ok = ffi::g_bookmark_file_load_from_file(
504 self.to_glib_none_mut().0,
505 filename.as_ref().to_glib_none().0,
506 &mut error,
507 );
508 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
509 if error.is_null() {
510 Ok(())
511 } else {
512 Err(from_glib_full(error))
513 }
514 }
515 }
516
517 #[doc(alias = "g_bookmark_file_move_item")]
518 pub fn move_item(&mut self, old_uri: &str, new_uri: Option<&str>) -> Result<(), crate::Error> {
519 unsafe {
520 let mut error = std::ptr::null_mut();
521 let is_ok = ffi::g_bookmark_file_move_item(
522 self.to_glib_none_mut().0,
523 old_uri.to_glib_none().0,
524 new_uri.to_glib_none().0,
525 &mut error,
526 );
527 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
528 if error.is_null() {
529 Ok(())
530 } else {
531 Err(from_glib_full(error))
532 }
533 }
534 }
535
536 #[doc(alias = "g_bookmark_file_remove_application")]
537 pub fn remove_application(&mut self, uri: &str, name: &str) -> Result<(), crate::Error> {
538 unsafe {
539 let mut error = std::ptr::null_mut();
540 let is_ok = ffi::g_bookmark_file_remove_application(
541 self.to_glib_none_mut().0,
542 uri.to_glib_none().0,
543 name.to_glib_none().0,
544 &mut error,
545 );
546 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
547 if error.is_null() {
548 Ok(())
549 } else {
550 Err(from_glib_full(error))
551 }
552 }
553 }
554
555 #[doc(alias = "g_bookmark_file_remove_group")]
556 pub fn remove_group(&mut self, uri: &str, group: &str) -> Result<(), crate::Error> {
557 unsafe {
558 let mut error = std::ptr::null_mut();
559 let is_ok = ffi::g_bookmark_file_remove_group(
560 self.to_glib_none_mut().0,
561 uri.to_glib_none().0,
562 group.to_glib_none().0,
563 &mut error,
564 );
565 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
566 if error.is_null() {
567 Ok(())
568 } else {
569 Err(from_glib_full(error))
570 }
571 }
572 }
573
574 #[doc(alias = "g_bookmark_file_remove_item")]
575 pub fn remove_item(&mut self, uri: &str) -> Result<(), crate::Error> {
576 unsafe {
577 let mut error = std::ptr::null_mut();
578 let is_ok = ffi::g_bookmark_file_remove_item(
579 self.to_glib_none_mut().0,
580 uri.to_glib_none().0,
581 &mut error,
582 );
583 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
584 if error.is_null() {
585 Ok(())
586 } else {
587 Err(from_glib_full(error))
588 }
589 }
590 }
591
592 #[cfg_attr(feature = "v2_66", deprecated = "Since 2.66")]
593 #[allow(deprecated)]
594 #[doc(alias = "g_bookmark_file_set_added")]
595 pub fn set_added(&mut self, uri: &str, added: libc::time_t) {
596 unsafe {
597 ffi::g_bookmark_file_set_added(self.to_glib_none_mut().0, uri.to_glib_none().0, added);
598 }
599 }
600
601 #[cfg(feature = "v2_66")]
602 #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
603 #[doc(alias = "g_bookmark_file_set_added_date_time")]
604 pub fn set_added_date_time(&mut self, uri: &str, added: &DateTime) {
605 unsafe {
606 ffi::g_bookmark_file_set_added_date_time(
607 self.to_glib_none_mut().0,
608 uri.to_glib_none().0,
609 added.to_glib_none().0,
610 );
611 }
612 }
613
614 #[cfg_attr(feature = "v2_66", deprecated = "Since 2.66")]
615 #[allow(deprecated)]
616 #[doc(alias = "g_bookmark_file_set_app_info")]
617 pub fn set_app_info(
618 &mut self,
619 uri: &str,
620 name: &str,
621 exec: &str,
622 count: i32,
623 stamp: libc::time_t,
624 ) -> Result<(), crate::Error> {
625 unsafe {
626 let mut error = std::ptr::null_mut();
627 let is_ok = ffi::g_bookmark_file_set_app_info(
628 self.to_glib_none_mut().0,
629 uri.to_glib_none().0,
630 name.to_glib_none().0,
631 exec.to_glib_none().0,
632 count,
633 stamp,
634 &mut error,
635 );
636 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
637 if error.is_null() {
638 Ok(())
639 } else {
640 Err(from_glib_full(error))
641 }
642 }
643 }
644
645 #[cfg(feature = "v2_66")]
646 #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
647 #[doc(alias = "g_bookmark_file_set_application_info")]
648 pub fn set_application_info(
649 &mut self,
650 uri: &str,
651 name: &str,
652 exec: &str,
653 count: i32,
654 stamp: Option<&DateTime>,
655 ) -> Result<(), crate::Error> {
656 unsafe {
657 let mut error = std::ptr::null_mut();
658 let is_ok = ffi::g_bookmark_file_set_application_info(
659 self.to_glib_none_mut().0,
660 uri.to_glib_none().0,
661 name.to_glib_none().0,
662 exec.to_glib_none().0,
663 count,
664 stamp.to_glib_none().0,
665 &mut error,
666 );
667 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
668 if error.is_null() {
669 Ok(())
670 } else {
671 Err(from_glib_full(error))
672 }
673 }
674 }
675
676 #[doc(alias = "g_bookmark_file_set_description")]
677 pub fn set_description(&mut self, uri: Option<&str>, description: &str) {
678 unsafe {
679 ffi::g_bookmark_file_set_description(
680 self.to_glib_none_mut().0,
681 uri.to_glib_none().0,
682 description.to_glib_none().0,
683 );
684 }
685 }
686
687 #[doc(alias = "g_bookmark_file_set_groups")]
688 pub fn set_groups(&mut self, uri: &str, groups: &[&str]) {
689 let length = groups.len() as _;
690 unsafe {
691 ffi::g_bookmark_file_set_groups(
692 self.to_glib_none_mut().0,
693 uri.to_glib_none().0,
694 groups.to_glib_none().0,
695 length,
696 );
697 }
698 }
699
700 #[doc(alias = "g_bookmark_file_set_icon")]
701 pub fn set_icon(&mut self, uri: &str, href: Option<&str>, mime_type: &str) {
702 unsafe {
703 ffi::g_bookmark_file_set_icon(
704 self.to_glib_none_mut().0,
705 uri.to_glib_none().0,
706 href.to_glib_none().0,
707 mime_type.to_glib_none().0,
708 );
709 }
710 }
711
712 #[doc(alias = "g_bookmark_file_set_is_private")]
713 pub fn set_is_private(&mut self, uri: &str, is_private: bool) {
714 unsafe {
715 ffi::g_bookmark_file_set_is_private(
716 self.to_glib_none_mut().0,
717 uri.to_glib_none().0,
718 is_private.into_glib(),
719 );
720 }
721 }
722
723 #[doc(alias = "g_bookmark_file_set_mime_type")]
724 pub fn set_mime_type(&mut self, uri: &str, mime_type: &str) {
725 unsafe {
726 ffi::g_bookmark_file_set_mime_type(
727 self.to_glib_none_mut().0,
728 uri.to_glib_none().0,
729 mime_type.to_glib_none().0,
730 );
731 }
732 }
733
734 #[cfg_attr(feature = "v2_66", deprecated = "Since 2.66")]
735 #[allow(deprecated)]
736 #[doc(alias = "g_bookmark_file_set_modified")]
737 pub fn set_modified(&mut self, uri: &str, modified: libc::time_t) {
738 unsafe {
739 ffi::g_bookmark_file_set_modified(
740 self.to_glib_none_mut().0,
741 uri.to_glib_none().0,
742 modified,
743 );
744 }
745 }
746
747 #[cfg(feature = "v2_66")]
748 #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
749 #[doc(alias = "g_bookmark_file_set_modified_date_time")]
750 pub fn set_modified_date_time(&mut self, uri: &str, modified: &DateTime) {
751 unsafe {
752 ffi::g_bookmark_file_set_modified_date_time(
753 self.to_glib_none_mut().0,
754 uri.to_glib_none().0,
755 modified.to_glib_none().0,
756 );
757 }
758 }
759
760 #[doc(alias = "g_bookmark_file_set_title")]
761 pub fn set_title(&mut self, uri: Option<&str>, title: &str) {
762 unsafe {
763 ffi::g_bookmark_file_set_title(
764 self.to_glib_none_mut().0,
765 uri.to_glib_none().0,
766 title.to_glib_none().0,
767 );
768 }
769 }
770
771 #[cfg_attr(feature = "v2_66", deprecated = "Since 2.66")]
772 #[allow(deprecated)]
773 #[doc(alias = "g_bookmark_file_set_visited")]
774 pub fn set_visited(&mut self, uri: &str, visited: libc::time_t) {
775 unsafe {
776 ffi::g_bookmark_file_set_visited(
777 self.to_glib_none_mut().0,
778 uri.to_glib_none().0,
779 visited,
780 );
781 }
782 }
783
784 #[cfg(feature = "v2_66")]
785 #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
786 #[doc(alias = "g_bookmark_file_set_visited_date_time")]
787 pub fn set_visited_date_time(&mut self, uri: &str, visited: &DateTime) {
788 unsafe {
789 ffi::g_bookmark_file_set_visited_date_time(
790 self.to_glib_none_mut().0,
791 uri.to_glib_none().0,
792 visited.to_glib_none().0,
793 );
794 }
795 }
796
797 #[doc(alias = "g_bookmark_file_to_data")]
798 pub fn to_data(&self) -> Result<Vec<u8>, crate::Error> {
799 unsafe {
800 let mut length = std::mem::MaybeUninit::uninit();
801 let mut error = std::ptr::null_mut();
802 let ret = ffi::g_bookmark_file_to_data(
803 mut_override(self.to_glib_none().0),
804 length.as_mut_ptr(),
805 &mut error,
806 );
807 if error.is_null() {
808 Ok(FromGlibContainer::from_glib_full_num(
809 ret,
810 length.assume_init() as _,
811 ))
812 } else {
813 Err(from_glib_full(error))
814 }
815 }
816 }
817
818 #[doc(alias = "g_bookmark_file_to_file")]
819 pub fn to_file(&self, filename: impl AsRef<std::path::Path>) -> Result<(), crate::Error> {
820 unsafe {
821 let mut error = std::ptr::null_mut();
822 let is_ok = ffi::g_bookmark_file_to_file(
823 mut_override(self.to_glib_none().0),
824 filename.as_ref().to_glib_none().0,
825 &mut error,
826 );
827 debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
828 if error.is_null() {
829 Ok(())
830 } else {
831 Err(from_glib_full(error))
832 }
833 }
834 }
835}
836
837impl Default for BookmarkFile {
838 fn default() -> Self {
839 Self::new()
840 }
841}