1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::PathElement;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`]
    #[doc(alias = "DzlPath")]
    pub struct Path(Object<ffi::DzlPath, ffi::DzlPathClass>);

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

impl Path {
    #[doc(alias = "dzl_path_new")]
    pub fn new() -> Path {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::dzl_path_new()) }
    }

    #[doc(alias = "dzl_path_append")]
    pub fn append(&self, element: &PathElement) {
        unsafe {
            ffi::dzl_path_append(self.to_glib_none().0, element.to_glib_none().0);
        }
    }

    /// Gets the path element found at `index`.
    ///
    /// Indexes start from zero.
    ///
    /// # Returns
    ///
    /// An [`PathElement`][crate::PathElement].
    #[doc(alias = "dzl_path_get_element")]
    #[doc(alias = "get_element")]
    pub fn element(&self, index: u32) -> Option<PathElement> {
        unsafe { from_glib_none(ffi::dzl_path_get_element(self.to_glib_none().0, index)) }
    }

    ///
    /// # Returns
    ///
    /// The elements of the path.
    #[doc(alias = "dzl_path_get_elements")]
    #[doc(alias = "get_elements")]
    pub fn elements(&self) -> Vec<PathElement> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::dzl_path_get_elements(self.to_glib_none().0))
        }
    }

    #[doc(alias = "dzl_path_get_length")]
    #[doc(alias = "get_length")]
    pub fn length(&self) -> u32 {
        unsafe { ffi::dzl_path_get_length(self.to_glib_none().0) }
    }

    #[doc(alias = "dzl_path_has_prefix")]
    pub fn has_prefix(&self, prefix: &Path) -> bool {
        unsafe {
            from_glib(ffi::dzl_path_has_prefix(
                self.to_glib_none().0,
                prefix.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "dzl_path_is_empty")]
    pub fn is_empty(&self) -> bool {
        unsafe { from_glib(ffi::dzl_path_is_empty(self.to_glib_none().0)) }
    }

    #[doc(alias = "dzl_path_prepend")]
    pub fn prepend(&self, element: &PathElement) {
        unsafe {
            ffi::dzl_path_prepend(self.to_glib_none().0, element.to_glib_none().0);
        }
    }

    #[doc(alias = "dzl_path_printf")]
    pub fn printf(&self) -> Option<glib::GString> {
        unsafe { from_glib_full(ffi::dzl_path_printf(self.to_glib_none().0)) }
    }
}

impl Default for Path {
    fn default() -> Self {
        Self::new()
    }
}

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