gio/auto/
emblem.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, EmblemOrigin, Icon};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// `GEmblem` is an implementation of [`Icon`][crate::Icon] that supports
10    /// having an emblem, which is an icon with additional properties.
11    /// It can than be added to a [`EmblemedIcon`][crate::EmblemedIcon].
12    ///
13    /// Currently, only metainformation about the emblem's origin is
14    /// supported. More may be added in the future.
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `icon`
20    ///  The actual icon of the emblem.
21    ///
22    /// Readable | Writeable | Construct Only
23    ///
24    ///
25    /// #### `origin`
26    ///  The origin the emblem is derived from.
27    ///
28    /// Readable | Writeable | Construct Only
29    ///
30    /// # Implements
31    ///
32    /// [`trait@glib::ObjectExt`], [`IconExt`][trait@crate::prelude::IconExt]
33    #[doc(alias = "GEmblem")]
34    pub struct Emblem(Object<ffi::GEmblem, ffi::GEmblemClass>) @implements Icon;
35
36    match fn {
37        type_ => || ffi::g_emblem_get_type(),
38    }
39}
40
41impl Emblem {
42    /// Creates a new emblem for @icon.
43    /// ## `icon`
44    /// a GIcon containing the icon.
45    ///
46    /// # Returns
47    ///
48    /// a new #GEmblem.
49    #[doc(alias = "g_emblem_new")]
50    pub fn new(icon: &impl IsA<Icon>) -> Emblem {
51        unsafe { from_glib_full(ffi::g_emblem_new(icon.as_ref().to_glib_none().0)) }
52    }
53
54    /// Creates a new emblem for @icon.
55    /// ## `icon`
56    /// a GIcon containing the icon.
57    /// ## `origin`
58    /// a GEmblemOrigin enum defining the emblem's origin
59    ///
60    /// # Returns
61    ///
62    /// a new #GEmblem.
63    #[doc(alias = "g_emblem_new_with_origin")]
64    #[doc(alias = "new_with_origin")]
65    pub fn with_origin(icon: &impl IsA<Icon>, origin: EmblemOrigin) -> Emblem {
66        unsafe {
67            from_glib_full(ffi::g_emblem_new_with_origin(
68                icon.as_ref().to_glib_none().0,
69                origin.into_glib(),
70            ))
71        }
72    }
73
74    /// Gives back the icon from @self.
75    ///
76    /// # Returns
77    ///
78    /// a #GIcon. The returned object belongs to
79    ///          the emblem and should not be modified or freed.
80    #[doc(alias = "g_emblem_get_icon")]
81    #[doc(alias = "get_icon")]
82    pub fn icon(&self) -> Icon {
83        unsafe { from_glib_none(ffi::g_emblem_get_icon(self.to_glib_none().0)) }
84    }
85
86    /// Gets the origin of the emblem.
87    ///
88    /// # Returns
89    ///
90    /// the origin of the emblem
91    #[doc(alias = "g_emblem_get_origin")]
92    #[doc(alias = "get_origin")]
93    pub fn origin(&self) -> EmblemOrigin {
94        unsafe { from_glib(ffi::g_emblem_get_origin(self.to_glib_none().0)) }
95    }
96}