gdk_pixbuf/auto/pixbuf_format.rs
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// DO NOT EDIT
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 /// A [`PixbufFormat`][crate::PixbufFormat] contains information about the image format accepted
10 /// by a module.
11 ///
12 /// Only modules should access the fields directly, applications should
13 /// use the `gdk_pixbuf_format_*` family of functions.
14 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
15 pub struct PixbufFormat(Boxed<ffi::GdkPixbufFormat>);
16
17 match fn {
18 copy => |ptr| ffi::gdk_pixbuf_format_copy(ptr),
19 free => |ptr| ffi::gdk_pixbuf_format_free(ptr),
20 type_ => || ffi::gdk_pixbuf_format_get_type(),
21 }
22}
23
24impl PixbufFormat {
25 /// Returns a description of the format.
26 ///
27 /// # Returns
28 ///
29 /// a description of the format.
30 #[doc(alias = "gdk_pixbuf_format_get_description")]
31 #[doc(alias = "get_description")]
32 pub fn description(&self) -> Option<glib::GString> {
33 unsafe {
34 from_glib_full(ffi::gdk_pixbuf_format_get_description(mut_override(
35 self.to_glib_none().0,
36 )))
37 }
38 }
39
40 /// Returns the filename extensions typically used for files in the
41 /// given format.
42 ///
43 /// # Returns
44 ///
45 /// an array of
46 /// filename extensions
47 #[doc(alias = "gdk_pixbuf_format_get_extensions")]
48 #[doc(alias = "get_extensions")]
49 pub fn extensions(&self) -> Vec<glib::GString> {
50 unsafe {
51 FromGlibPtrContainer::from_glib_full(ffi::gdk_pixbuf_format_get_extensions(
52 mut_override(self.to_glib_none().0),
53 ))
54 }
55 }
56
57 /// Returns information about the license of the image loader for the format.
58 ///
59 /// The returned string should be a shorthand for a well known license, e.g.
60 /// "LGPL", "GPL", "QPL", "GPL/QPL", or "other" to indicate some other license.
61 ///
62 /// # Returns
63 ///
64 /// a string describing the license of the pixbuf format
65 #[doc(alias = "gdk_pixbuf_format_get_license")]
66 #[doc(alias = "get_license")]
67 pub fn license(&self) -> Option<glib::GString> {
68 unsafe {
69 from_glib_full(ffi::gdk_pixbuf_format_get_license(mut_override(
70 self.to_glib_none().0,
71 )))
72 }
73 }
74
75 /// Returns the mime types supported by the format.
76 ///
77 /// # Returns
78 ///
79 /// an array of mime types
80 #[doc(alias = "gdk_pixbuf_format_get_mime_types")]
81 #[doc(alias = "get_mime_types")]
82 pub fn mime_types(&self) -> Vec<glib::GString> {
83 unsafe {
84 FromGlibPtrContainer::from_glib_full(ffi::gdk_pixbuf_format_get_mime_types(
85 mut_override(self.to_glib_none().0),
86 ))
87 }
88 }
89
90 /// Returns the name of the format.
91 ///
92 /// # Returns
93 ///
94 /// the name of the format.
95 #[doc(alias = "gdk_pixbuf_format_get_name")]
96 #[doc(alias = "get_name")]
97 pub fn name(&self) -> Option<glib::GString> {
98 unsafe {
99 from_glib_full(ffi::gdk_pixbuf_format_get_name(mut_override(
100 self.to_glib_none().0,
101 )))
102 }
103 }
104
105 /// Returns whether this image format is disabled.
106 ///
107 /// See gdk_pixbuf_format_set_disabled().
108 ///
109 /// # Returns
110 ///
111 /// whether this image format is disabled.
112 #[doc(alias = "gdk_pixbuf_format_is_disabled")]
113 pub fn is_disabled(&self) -> bool {
114 unsafe {
115 from_glib(ffi::gdk_pixbuf_format_is_disabled(mut_override(
116 self.to_glib_none().0,
117 )))
118 }
119 }
120
121 /// Returns `TRUE` if the save option specified by @option_key is supported when
122 /// saving a pixbuf using the module implementing @self.
123 ///
124 /// See gdk_pixbuf_save() for more information about option keys.
125 /// ## `option_key`
126 /// the name of an option
127 ///
128 /// # Returns
129 ///
130 /// `TRUE` if the specified option is supported
131 #[doc(alias = "gdk_pixbuf_format_is_save_option_supported")]
132 pub fn is_save_option_supported(&self, option_key: &str) -> bool {
133 unsafe {
134 from_glib(ffi::gdk_pixbuf_format_is_save_option_supported(
135 mut_override(self.to_glib_none().0),
136 option_key.to_glib_none().0,
137 ))
138 }
139 }
140
141 /// Returns whether this image format is scalable.
142 ///
143 /// If a file is in a scalable format, it is preferable to load it at
144 /// the desired size, rather than loading it at the default size and
145 /// scaling the resulting pixbuf to the desired size.
146 ///
147 /// # Returns
148 ///
149 /// whether this image format is scalable.
150 #[doc(alias = "gdk_pixbuf_format_is_scalable")]
151 pub fn is_scalable(&self) -> bool {
152 unsafe {
153 from_glib(ffi::gdk_pixbuf_format_is_scalable(mut_override(
154 self.to_glib_none().0,
155 )))
156 }
157 }
158
159 /// Returns whether pixbufs can be saved in the given format.
160 ///
161 /// # Returns
162 ///
163 /// whether pixbufs can be saved in the given format.
164 #[doc(alias = "gdk_pixbuf_format_is_writable")]
165 pub fn is_writable(&self) -> bool {
166 unsafe {
167 from_glib(ffi::gdk_pixbuf_format_is_writable(mut_override(
168 self.to_glib_none().0,
169 )))
170 }
171 }
172
173 /// Disables or enables an image format.
174 ///
175 /// If a format is disabled, GdkPixbuf won't use the image loader for
176 /// this format to load images.
177 ///
178 /// Applications can use this to avoid using image loaders with an
179 /// inappropriate license, see gdk_pixbuf_format_get_license().
180 /// ## `disabled`
181 /// `TRUE` to disable the format @self
182 #[doc(alias = "gdk_pixbuf_format_set_disabled")]
183 pub fn set_disabled(&mut self, disabled: bool) {
184 unsafe {
185 ffi::gdk_pixbuf_format_set_disabled(self.to_glib_none_mut().0, disabled.into_glib());
186 }
187 }
188}
189
190unsafe impl Send for PixbufFormat {}
191unsafe impl Sync for PixbufFormat {}