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