1 | // This file was generated by gir (https://github.com/gtk-rs/gir) |
2 | // from gir-files (https://github.com/gtk-rs/gir-files) |
3 | // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) |
4 | // DO NOT EDIT |
5 | |
6 | use glib::{prelude::*, translate::*}; |
7 | use std::ptr; |
8 | |
9 | glib::wrapper! { |
10 | #[doc (alias = "GstPreset" )] |
11 | pub struct Preset(Interface<ffi::GstPreset, ffi::GstPresetInterface>); |
12 | |
13 | match fn { |
14 | type_ => || ffi::gst_preset_get_type(), |
15 | } |
16 | } |
17 | |
18 | impl Preset { |
19 | pub const NONE: Option<&'static Preset> = None; |
20 | |
21 | #[doc (alias = "gst_preset_get_app_dir" )] |
22 | #[doc (alias = "get_app_dir" )] |
23 | pub fn app_dir() -> Option<std::path::PathBuf> { |
24 | assert_initialized_main_thread!(); |
25 | unsafe { from_glib_none(ptr:ffi::gst_preset_get_app_dir()) } |
26 | } |
27 | |
28 | #[doc (alias = "gst_preset_set_app_dir" )] |
29 | pub fn set_app_dir(app_dir: impl AsRef<std::path::Path>) -> Result<(), glib::error::BoolError> { |
30 | assert_initialized_main_thread!(); |
31 | unsafe { |
32 | glib::result_from_gboolean!( |
33 | ffi::gst_preset_set_app_dir(app_dir.as_ref().to_glib_none().0), |
34 | "Failed to set app preset directory" |
35 | ) |
36 | } |
37 | } |
38 | } |
39 | |
40 | unsafe impl Send for Preset {} |
41 | unsafe impl Sync for Preset {} |
42 | |
43 | mod sealed { |
44 | pub trait Sealed {} |
45 | impl<T: super::IsA<super::Preset>> Sealed for T {} |
46 | } |
47 | |
48 | pub trait PresetExt: IsA<Preset> + sealed::Sealed + 'static { |
49 | #[doc (alias = "gst_preset_delete_preset" )] |
50 | fn delete_preset(&self, name: &str) -> Result<(), glib::error::BoolError> { |
51 | unsafe { |
52 | glib::result_from_gboolean!( |
53 | ffi::gst_preset_delete_preset( |
54 | self.as_ref().to_glib_none().0, |
55 | name.to_glib_none().0 |
56 | ), |
57 | "Failed to delete preset" |
58 | ) |
59 | } |
60 | } |
61 | |
62 | #[doc (alias = "gst_preset_get_meta" )] |
63 | #[doc (alias = "get_meta" )] |
64 | fn meta(&self, name: &str, tag: &str) -> Option<glib::GString> { |
65 | unsafe { |
66 | let mut value = ptr::null_mut(); |
67 | let ret = from_glib(ffi::gst_preset_get_meta( |
68 | self.as_ref().to_glib_none().0, |
69 | name.to_glib_none().0, |
70 | tag.to_glib_none().0, |
71 | &mut value, |
72 | )); |
73 | if ret { |
74 | Some(from_glib_full(value)) |
75 | } else { |
76 | None |
77 | } |
78 | } |
79 | } |
80 | |
81 | #[doc (alias = "gst_preset_get_preset_names" )] |
82 | #[doc (alias = "get_preset_names" )] |
83 | fn preset_names(&self) -> Vec<glib::GString> { |
84 | unsafe { |
85 | FromGlibPtrContainer::from_glib_full(ffi::gst_preset_get_preset_names( |
86 | self.as_ref().to_glib_none().0, |
87 | )) |
88 | } |
89 | } |
90 | |
91 | #[doc (alias = "gst_preset_get_property_names" )] |
92 | #[doc (alias = "get_property_names" )] |
93 | fn property_names(&self) -> Vec<glib::GString> { |
94 | unsafe { |
95 | FromGlibPtrContainer::from_glib_full(ffi::gst_preset_get_property_names( |
96 | self.as_ref().to_glib_none().0, |
97 | )) |
98 | } |
99 | } |
100 | |
101 | #[doc (alias = "gst_preset_is_editable" )] |
102 | fn is_editable(&self) -> bool { |
103 | unsafe { from_glib(ffi::gst_preset_is_editable(self.as_ref().to_glib_none().0)) } |
104 | } |
105 | |
106 | #[doc (alias = "gst_preset_load_preset" )] |
107 | fn load_preset(&self, name: &str) -> Result<(), glib::error::BoolError> { |
108 | unsafe { |
109 | glib::result_from_gboolean!( |
110 | ffi::gst_preset_load_preset(self.as_ref().to_glib_none().0, name.to_glib_none().0), |
111 | "Failed to load preset" |
112 | ) |
113 | } |
114 | } |
115 | |
116 | #[doc (alias = "gst_preset_rename_preset" )] |
117 | fn rename_preset(&self, old_name: &str, new_name: &str) -> Result<(), glib::error::BoolError> { |
118 | unsafe { |
119 | glib::result_from_gboolean!( |
120 | ffi::gst_preset_rename_preset( |
121 | self.as_ref().to_glib_none().0, |
122 | old_name.to_glib_none().0, |
123 | new_name.to_glib_none().0 |
124 | ), |
125 | "Failed to rename preset" |
126 | ) |
127 | } |
128 | } |
129 | |
130 | #[doc (alias = "gst_preset_save_preset" )] |
131 | fn save_preset(&self, name: &str) -> Result<(), glib::error::BoolError> { |
132 | unsafe { |
133 | glib::result_from_gboolean!( |
134 | ffi::gst_preset_save_preset(self.as_ref().to_glib_none().0, name.to_glib_none().0), |
135 | "Failed to save preset" |
136 | ) |
137 | } |
138 | } |
139 | |
140 | #[doc (alias = "gst_preset_set_meta" )] |
141 | fn set_meta( |
142 | &self, |
143 | name: &str, |
144 | tag: &str, |
145 | value: Option<&str>, |
146 | ) -> Result<(), glib::error::BoolError> { |
147 | unsafe { |
148 | glib::result_from_gboolean!( |
149 | ffi::gst_preset_set_meta( |
150 | self.as_ref().to_glib_none().0, |
151 | name.to_glib_none().0, |
152 | tag.to_glib_none().0, |
153 | value.to_glib_none().0 |
154 | ), |
155 | "Failed to set preset meta" |
156 | ) |
157 | } |
158 | } |
159 | } |
160 | |
161 | impl<O: IsA<Preset>> PresetExt for O {} |
162 | |