gdk_pixbuf/auto/
enums.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::{prelude::*, translate::*};
7
8/// This enumeration defines the color spaces that are supported by
9/// the gdk-pixbuf library.
10///
11/// Currently only RGB is supported.
12#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
13#[non_exhaustive]
14#[doc(alias = "GdkColorspace")]
15pub enum Colorspace {
16    /// Indicates a red/green/blue additive color space.
17    #[doc(alias = "GDK_COLORSPACE_RGB")]
18    Rgb,
19    #[doc(hidden)]
20    __Unknown(i32),
21}
22
23#[doc(hidden)]
24impl IntoGlib for Colorspace {
25    type GlibType = ffi::GdkColorspace;
26
27    #[inline]
28    fn into_glib(self) -> ffi::GdkColorspace {
29        match self {
30            Self::Rgb => ffi::GDK_COLORSPACE_RGB,
31            Self::__Unknown(value) => value,
32        }
33    }
34}
35
36#[doc(hidden)]
37impl FromGlib<ffi::GdkColorspace> for Colorspace {
38    #[inline]
39    unsafe fn from_glib(value: ffi::GdkColorspace) -> Self {
40        match value {
41            ffi::GDK_COLORSPACE_RGB => Self::Rgb,
42            value => Self::__Unknown(value),
43        }
44    }
45}
46
47impl StaticType for Colorspace {
48    #[inline]
49    #[doc(alias = "gdk_colorspace_get_type")]
50    fn static_type() -> glib::Type {
51        unsafe { from_glib(ffi::gdk_colorspace_get_type()) }
52    }
53}
54
55impl glib::HasParamSpec for Colorspace {
56    type ParamSpec = glib::ParamSpecEnum;
57    type SetValue = Self;
58    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
59
60    fn param_spec_builder() -> Self::BuilderFn {
61        Self::ParamSpec::builder_with_default
62    }
63}
64
65impl glib::value::ValueType for Colorspace {
66    type Type = Self;
67}
68
69unsafe impl<'a> glib::value::FromValue<'a> for Colorspace {
70    type Checker = glib::value::GenericValueTypeChecker<Self>;
71
72    #[inline]
73    unsafe fn from_value(value: &'a glib::Value) -> Self {
74        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
75    }
76}
77
78impl ToValue for Colorspace {
79    #[inline]
80    fn to_value(&self) -> glib::Value {
81        let mut value = glib::Value::for_value_type::<Self>();
82        unsafe {
83            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
84        }
85        value
86    }
87
88    #[inline]
89    fn value_type(&self) -> glib::Type {
90        Self::static_type()
91    }
92}
93
94impl From<Colorspace> for glib::Value {
95    #[inline]
96    fn from(v: Colorspace) -> Self {
97        ToValue::to_value(&v)
98    }
99}
100
101/// Interpolation modes for scaling functions.
102///
103/// The `GDK_INTERP_NEAREST` mode is the fastest scaling method, but has
104/// horrible quality when scaling down; `GDK_INTERP_BILINEAR` is the best
105/// choice if you aren't sure what to choose, it has a good speed/quality
106/// balance.
107///
108/// **Note**: Cubic filtering is missing from the list; hyperbolic
109/// interpolation is just as fast and results in higher quality.
110#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
111#[non_exhaustive]
112#[doc(alias = "GdkInterpType")]
113pub enum InterpType {
114    /// Nearest neighbor sampling; this is the fastest
115    ///  and lowest quality mode. Quality is normally unacceptable when scaling
116    ///  down, but may be OK when scaling up.
117    #[doc(alias = "GDK_INTERP_NEAREST")]
118    Nearest,
119    /// This is an accurate simulation of the PostScript
120    ///  image operator without any interpolation enabled.  Each pixel is
121    ///  rendered as a tiny parallelogram of solid color, the edges of which
122    ///  are implemented with antialiasing.  It resembles nearest neighbor for
123    ///  enlargement, and bilinear for reduction.
124    #[doc(alias = "GDK_INTERP_TILES")]
125    Tiles,
126    /// Best quality/speed balance; use this mode by
127    ///  default. Bilinear interpolation.  For enlargement, it is
128    ///  equivalent to point-sampling the ideal bilinear-interpolated image.
129    ///  For reduction, it is equivalent to laying down small tiles and
130    ///  integrating over the coverage area.
131    #[doc(alias = "GDK_INTERP_BILINEAR")]
132    Bilinear,
133    /// This is the slowest and highest quality
134    ///  reconstruction function. It is derived from the hyperbolic filters in
135    ///  Wolberg's "Digital Image Warping", and is formally defined as the
136    ///  hyperbolic-filter sampling the ideal hyperbolic-filter interpolated
137    ///  image (the filter is designed to be idempotent for 1:1 pixel mapping).
138    ///  **Deprecated**: this interpolation filter is deprecated, as in reality
139    ///  it has a lower quality than the @GDK_INTERP_BILINEAR filter
140    ///  (Since: 2.38)
141    #[doc(alias = "GDK_INTERP_HYPER")]
142    Hyper,
143    #[doc(hidden)]
144    __Unknown(i32),
145}
146
147#[doc(hidden)]
148impl IntoGlib for InterpType {
149    type GlibType = ffi::GdkInterpType;
150
151    #[inline]
152    fn into_glib(self) -> ffi::GdkInterpType {
153        match self {
154            Self::Nearest => ffi::GDK_INTERP_NEAREST,
155            Self::Tiles => ffi::GDK_INTERP_TILES,
156            Self::Bilinear => ffi::GDK_INTERP_BILINEAR,
157            Self::Hyper => ffi::GDK_INTERP_HYPER,
158            Self::__Unknown(value) => value,
159        }
160    }
161}
162
163#[doc(hidden)]
164impl FromGlib<ffi::GdkInterpType> for InterpType {
165    #[inline]
166    unsafe fn from_glib(value: ffi::GdkInterpType) -> Self {
167        match value {
168            ffi::GDK_INTERP_NEAREST => Self::Nearest,
169            ffi::GDK_INTERP_TILES => Self::Tiles,
170            ffi::GDK_INTERP_BILINEAR => Self::Bilinear,
171            ffi::GDK_INTERP_HYPER => Self::Hyper,
172            value => Self::__Unknown(value),
173        }
174    }
175}
176
177impl StaticType for InterpType {
178    #[inline]
179    #[doc(alias = "gdk_interp_type_get_type")]
180    fn static_type() -> glib::Type {
181        unsafe { from_glib(ffi::gdk_interp_type_get_type()) }
182    }
183}
184
185impl glib::HasParamSpec for InterpType {
186    type ParamSpec = glib::ParamSpecEnum;
187    type SetValue = Self;
188    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
189
190    fn param_spec_builder() -> Self::BuilderFn {
191        Self::ParamSpec::builder_with_default
192    }
193}
194
195impl glib::value::ValueType for InterpType {
196    type Type = Self;
197}
198
199unsafe impl<'a> glib::value::FromValue<'a> for InterpType {
200    type Checker = glib::value::GenericValueTypeChecker<Self>;
201
202    #[inline]
203    unsafe fn from_value(value: &'a glib::Value) -> Self {
204        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
205    }
206}
207
208impl ToValue for InterpType {
209    #[inline]
210    fn to_value(&self) -> glib::Value {
211        let mut value = glib::Value::for_value_type::<Self>();
212        unsafe {
213            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
214        }
215        value
216    }
217
218    #[inline]
219    fn value_type(&self) -> glib::Type {
220        Self::static_type()
221    }
222}
223
224impl From<InterpType> for glib::Value {
225    #[inline]
226    fn from(v: InterpType) -> Self {
227        ToValue::to_value(&v)
228    }
229}
230
231/// Control the alpha channel for drawables.
232///
233/// These values can be passed to gdk_pixbuf_xlib_render_to_drawable_alpha()
234/// in gdk-pixbuf-xlib to control how the alpha channel of an image should
235/// be handled.
236///
237/// This function can create a bilevel clipping mask (black and white) and use
238/// it while painting the image.
239///
240/// In the future, when the X Window System gets an alpha channel extension,
241/// it will be possible to do full alpha compositing onto arbitrary drawables.
242/// For now both cases fall back to a bilevel clipping mask.
243///
244/// # Deprecated since 2.42
245///
246/// There is no user of GdkPixbufAlphaMode in GdkPixbuf,
247///   and the Xlib utility functions have been split out to their own
248///   library, gdk-pixbuf-xlib
249#[cfg_attr(feature = "v2_42", deprecated = "Since 2.42")]
250#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
251#[non_exhaustive]
252#[doc(alias = "GdkPixbufAlphaMode")]
253pub enum PixbufAlphaMode {
254    /// A bilevel clipping mask (black and white)
255    ///  will be created and used to draw the image.  Pixels below 0.5 opacity
256    ///  will be considered fully transparent, and all others will be
257    ///  considered fully opaque.
258    #[doc(alias = "GDK_PIXBUF_ALPHA_BILEVEL")]
259    Bilevel,
260    /// For now falls back to #GDK_PIXBUF_ALPHA_BILEVEL.
261    ///  In the future it will do full alpha compositing.
262    #[doc(alias = "GDK_PIXBUF_ALPHA_FULL")]
263    Full,
264    #[doc(hidden)]
265    __Unknown(i32),
266}
267
268#[allow(deprecated)]
269#[doc(hidden)]
270impl IntoGlib for PixbufAlphaMode {
271    type GlibType = ffi::GdkPixbufAlphaMode;
272
273    #[inline]
274    fn into_glib(self) -> ffi::GdkPixbufAlphaMode {
275        match self {
276            Self::Bilevel => ffi::GDK_PIXBUF_ALPHA_BILEVEL,
277            Self::Full => ffi::GDK_PIXBUF_ALPHA_FULL,
278            Self::__Unknown(value) => value,
279        }
280    }
281}
282
283#[allow(deprecated)]
284#[doc(hidden)]
285impl FromGlib<ffi::GdkPixbufAlphaMode> for PixbufAlphaMode {
286    #[inline]
287    unsafe fn from_glib(value: ffi::GdkPixbufAlphaMode) -> Self {
288        match value {
289            ffi::GDK_PIXBUF_ALPHA_BILEVEL => Self::Bilevel,
290            ffi::GDK_PIXBUF_ALPHA_FULL => Self::Full,
291            value => Self::__Unknown(value),
292        }
293    }
294}
295
296#[allow(deprecated)]
297impl StaticType for PixbufAlphaMode {
298    #[inline]
299    #[doc(alias = "gdk_pixbuf_alpha_mode_get_type")]
300    fn static_type() -> glib::Type {
301        unsafe { from_glib(ffi::gdk_pixbuf_alpha_mode_get_type()) }
302    }
303}
304
305#[allow(deprecated)]
306impl glib::HasParamSpec for PixbufAlphaMode {
307    type ParamSpec = glib::ParamSpecEnum;
308    type SetValue = Self;
309    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
310
311    fn param_spec_builder() -> Self::BuilderFn {
312        Self::ParamSpec::builder_with_default
313    }
314}
315
316#[allow(deprecated)]
317impl glib::value::ValueType for PixbufAlphaMode {
318    type Type = Self;
319}
320
321#[allow(deprecated)]
322unsafe impl<'a> glib::value::FromValue<'a> for PixbufAlphaMode {
323    type Checker = glib::value::GenericValueTypeChecker<Self>;
324
325    #[inline]
326    unsafe fn from_value(value: &'a glib::Value) -> Self {
327        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
328    }
329}
330
331#[allow(deprecated)]
332impl ToValue for PixbufAlphaMode {
333    #[inline]
334    fn to_value(&self) -> glib::Value {
335        let mut value = glib::Value::for_value_type::<Self>();
336        unsafe {
337            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
338        }
339        value
340    }
341
342    #[inline]
343    fn value_type(&self) -> glib::Type {
344        Self::static_type()
345    }
346}
347
348#[allow(deprecated)]
349impl From<PixbufAlphaMode> for glib::Value {
350    #[inline]
351    fn from(v: PixbufAlphaMode) -> Self {
352        ToValue::to_value(&v)
353    }
354}
355
356/// An error code in the `GDK_PIXBUF_ERROR` domain.
357///
358/// Many gdk-pixbuf operations can cause errors in this domain, or in
359/// the `G_FILE_ERROR` domain.
360#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
361#[non_exhaustive]
362#[doc(alias = "GdkPixbufError")]
363pub enum PixbufError {
364    /// An image file was broken somehow.
365    #[doc(alias = "GDK_PIXBUF_ERROR_CORRUPT_IMAGE")]
366    CorruptImage,
367    /// Not enough memory.
368    #[doc(alias = "GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY")]
369    InsufficientMemory,
370    /// A bad option was passed to a pixbuf save module.
371    #[doc(alias = "GDK_PIXBUF_ERROR_BAD_OPTION")]
372    BadOption,
373    /// Unknown image type.
374    #[doc(alias = "GDK_PIXBUF_ERROR_UNKNOWN_TYPE")]
375    UnknownType,
376    /// Don't know how to perform the
377    ///  given operation on the type of image at hand.
378    #[doc(alias = "GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION")]
379    UnsupportedOperation,
380    /// Generic failure code, something went wrong.
381    #[doc(alias = "GDK_PIXBUF_ERROR_FAILED")]
382    Failed,
383    /// Only part of the animation was loaded.
384    #[doc(alias = "GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION")]
385    IncompleteAnimation,
386    #[doc(hidden)]
387    __Unknown(i32),
388}
389
390#[doc(hidden)]
391impl IntoGlib for PixbufError {
392    type GlibType = ffi::GdkPixbufError;
393
394    #[inline]
395    fn into_glib(self) -> ffi::GdkPixbufError {
396        match self {
397            Self::CorruptImage => ffi::GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
398            Self::InsufficientMemory => ffi::GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
399            Self::BadOption => ffi::GDK_PIXBUF_ERROR_BAD_OPTION,
400            Self::UnknownType => ffi::GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
401            Self::UnsupportedOperation => ffi::GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
402            Self::Failed => ffi::GDK_PIXBUF_ERROR_FAILED,
403            Self::IncompleteAnimation => ffi::GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION,
404            Self::__Unknown(value) => value,
405        }
406    }
407}
408
409#[doc(hidden)]
410impl FromGlib<ffi::GdkPixbufError> for PixbufError {
411    #[inline]
412    unsafe fn from_glib(value: ffi::GdkPixbufError) -> Self {
413        match value {
414            ffi::GDK_PIXBUF_ERROR_CORRUPT_IMAGE => Self::CorruptImage,
415            ffi::GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY => Self::InsufficientMemory,
416            ffi::GDK_PIXBUF_ERROR_BAD_OPTION => Self::BadOption,
417            ffi::GDK_PIXBUF_ERROR_UNKNOWN_TYPE => Self::UnknownType,
418            ffi::GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION => Self::UnsupportedOperation,
419            ffi::GDK_PIXBUF_ERROR_FAILED => Self::Failed,
420            ffi::GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION => Self::IncompleteAnimation,
421            value => Self::__Unknown(value),
422        }
423    }
424}
425
426impl glib::error::ErrorDomain for PixbufError {
427    #[inline]
428    fn domain() -> glib::Quark {
429        unsafe { from_glib(ffi::gdk_pixbuf_error_quark()) }
430    }
431
432    #[inline]
433    fn code(self) -> i32 {
434        self.into_glib()
435    }
436
437    #[inline]
438    #[allow(clippy::match_single_binding)]
439    fn from(code: i32) -> Option<Self> {
440        match unsafe { from_glib(code) } {
441            Self::__Unknown(_) => Some(Self::Failed),
442            value => Some(value),
443        }
444    }
445}
446
447impl StaticType for PixbufError {
448    #[inline]
449    #[doc(alias = "gdk_pixbuf_error_get_type")]
450    fn static_type() -> glib::Type {
451        unsafe { from_glib(ffi::gdk_pixbuf_error_get_type()) }
452    }
453}
454
455impl glib::HasParamSpec for PixbufError {
456    type ParamSpec = glib::ParamSpecEnum;
457    type SetValue = Self;
458    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
459
460    fn param_spec_builder() -> Self::BuilderFn {
461        Self::ParamSpec::builder_with_default
462    }
463}
464
465impl glib::value::ValueType for PixbufError {
466    type Type = Self;
467}
468
469unsafe impl<'a> glib::value::FromValue<'a> for PixbufError {
470    type Checker = glib::value::GenericValueTypeChecker<Self>;
471
472    #[inline]
473    unsafe fn from_value(value: &'a glib::Value) -> Self {
474        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
475    }
476}
477
478impl ToValue for PixbufError {
479    #[inline]
480    fn to_value(&self) -> glib::Value {
481        let mut value = glib::Value::for_value_type::<Self>();
482        unsafe {
483            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
484        }
485        value
486    }
487
488    #[inline]
489    fn value_type(&self) -> glib::Type {
490        Self::static_type()
491    }
492}
493
494impl From<PixbufError> for glib::Value {
495    #[inline]
496    fn from(v: PixbufError) -> Self {
497        ToValue::to_value(&v)
498    }
499}
500
501/// The possible rotations which can be passed to gdk_pixbuf_rotate_simple().
502///
503/// To make them easier to use, their numerical values are the actual degrees.
504#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
505#[non_exhaustive]
506#[doc(alias = "GdkPixbufRotation")]
507pub enum PixbufRotation {
508    /// No rotation.
509    #[doc(alias = "GDK_PIXBUF_ROTATE_NONE")]
510    None,
511    /// Rotate by 90 degrees.
512    #[doc(alias = "GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE")]
513    Counterclockwise,
514    /// Rotate by 180 degrees.
515    #[doc(alias = "GDK_PIXBUF_ROTATE_UPSIDEDOWN")]
516    Upsidedown,
517    /// Rotate by 270 degrees.
518    #[doc(alias = "GDK_PIXBUF_ROTATE_CLOCKWISE")]
519    Clockwise,
520    #[doc(hidden)]
521    __Unknown(i32),
522}
523
524#[doc(hidden)]
525impl IntoGlib for PixbufRotation {
526    type GlibType = ffi::GdkPixbufRotation;
527
528    #[inline]
529    fn into_glib(self) -> ffi::GdkPixbufRotation {
530        match self {
531            Self::None => ffi::GDK_PIXBUF_ROTATE_NONE,
532            Self::Counterclockwise => ffi::GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE,
533            Self::Upsidedown => ffi::GDK_PIXBUF_ROTATE_UPSIDEDOWN,
534            Self::Clockwise => ffi::GDK_PIXBUF_ROTATE_CLOCKWISE,
535            Self::__Unknown(value) => value,
536        }
537    }
538}
539
540#[doc(hidden)]
541impl FromGlib<ffi::GdkPixbufRotation> for PixbufRotation {
542    #[inline]
543    unsafe fn from_glib(value: ffi::GdkPixbufRotation) -> Self {
544        match value {
545            ffi::GDK_PIXBUF_ROTATE_NONE => Self::None,
546            ffi::GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE => Self::Counterclockwise,
547            ffi::GDK_PIXBUF_ROTATE_UPSIDEDOWN => Self::Upsidedown,
548            ffi::GDK_PIXBUF_ROTATE_CLOCKWISE => Self::Clockwise,
549            value => Self::__Unknown(value),
550        }
551    }
552}
553
554impl StaticType for PixbufRotation {
555    #[inline]
556    #[doc(alias = "gdk_pixbuf_rotation_get_type")]
557    fn static_type() -> glib::Type {
558        unsafe { from_glib(ffi::gdk_pixbuf_rotation_get_type()) }
559    }
560}
561
562impl glib::HasParamSpec for PixbufRotation {
563    type ParamSpec = glib::ParamSpecEnum;
564    type SetValue = Self;
565    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
566
567    fn param_spec_builder() -> Self::BuilderFn {
568        Self::ParamSpec::builder_with_default
569    }
570}
571
572impl glib::value::ValueType for PixbufRotation {
573    type Type = Self;
574}
575
576unsafe impl<'a> glib::value::FromValue<'a> for PixbufRotation {
577    type Checker = glib::value::GenericValueTypeChecker<Self>;
578
579    #[inline]
580    unsafe fn from_value(value: &'a glib::Value) -> Self {
581        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
582    }
583}
584
585impl ToValue for PixbufRotation {
586    #[inline]
587    fn to_value(&self) -> glib::Value {
588        let mut value = glib::Value::for_value_type::<Self>();
589        unsafe {
590            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
591        }
592        value
593    }
594
595    #[inline]
596    fn value_type(&self) -> glib::Type {
597        Self::static_type()
598    }
599}
600
601impl From<PixbufRotation> for glib::Value {
602    #[inline]
603    fn from(v: PixbufRotation) -> Self {
604        ToValue::to_value(&v)
605    }
606}