use crate::PathElement;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[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);
}
}
#[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)) }
}
#[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")
}
}