gio/auto/
emblemed_icon.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, Emblem, Icon};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// `GEmblemedIcon` is an implementation of [`Icon`][crate::Icon] that supports
10    /// adding an emblem to an icon. Adding multiple emblems to an
11    /// icon is ensured via [`EmblemedIconExt::add_emblem()`][crate::prelude::EmblemedIconExt::add_emblem()].
12    ///
13    /// Note that `GEmblemedIcon` allows no control over the position
14    /// of the emblems. See also [`Emblem`][crate::Emblem] for more information.
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `gicon`
20    ///  The [`Icon`][crate::Icon] to attach emblems to.
21    ///
22    /// Readable | Writeable | Construct Only
23    ///
24    /// # Implements
25    ///
26    /// [`EmblemedIconExt`][trait@crate::prelude::EmblemedIconExt], [`trait@glib::ObjectExt`], [`IconExt`][trait@crate::prelude::IconExt]
27    #[doc(alias = "GEmblemedIcon")]
28    pub struct EmblemedIcon(Object<ffi::GEmblemedIcon, ffi::GEmblemedIconClass>) @implements Icon;
29
30    match fn {
31        type_ => || ffi::g_emblemed_icon_get_type(),
32    }
33}
34
35impl EmblemedIcon {
36    pub const NONE: Option<&'static EmblemedIcon> = None;
37
38    /// Creates a new emblemed icon for @icon with the emblem @emblem.
39    /// ## `icon`
40    /// a #GIcon
41    /// ## `emblem`
42    /// a #GEmblem, or [`None`]
43    ///
44    /// # Returns
45    ///
46    /// a new #GIcon
47    #[doc(alias = "g_emblemed_icon_new")]
48    pub fn new(icon: &impl IsA<Icon>, emblem: Option<&Emblem>) -> EmblemedIcon {
49        unsafe {
50            from_glib_full(ffi::g_emblemed_icon_new(
51                icon.as_ref().to_glib_none().0,
52                emblem.to_glib_none().0,
53            ))
54        }
55    }
56}
57
58/// Trait containing all [`struct@EmblemedIcon`] methods.
59///
60/// # Implementors
61///
62/// [`EmblemedIcon`][struct@crate::EmblemedIcon]
63pub trait EmblemedIconExt: IsA<EmblemedIcon> + 'static {
64    /// Adds @emblem to the #GList of #GEmblems.
65    /// ## `emblem`
66    /// a #GEmblem
67    #[doc(alias = "g_emblemed_icon_add_emblem")]
68    fn add_emblem(&self, emblem: &Emblem) {
69        unsafe {
70            ffi::g_emblemed_icon_add_emblem(
71                self.as_ref().to_glib_none().0,
72                emblem.to_glib_none().0,
73            );
74        }
75    }
76
77    /// Removes all the emblems from @icon.
78    #[doc(alias = "g_emblemed_icon_clear_emblems")]
79    fn clear_emblems(&self) {
80        unsafe {
81            ffi::g_emblemed_icon_clear_emblems(self.as_ref().to_glib_none().0);
82        }
83    }
84
85    /// Gets the list of emblems for the @icon.
86    ///
87    /// # Returns
88    ///
89    /// a #GList of
90    ///     #GEmblems that is owned by @self
91    #[doc(alias = "g_emblemed_icon_get_emblems")]
92    #[doc(alias = "get_emblems")]
93    fn emblems(&self) -> Vec<Emblem> {
94        unsafe {
95            FromGlibPtrContainer::from_glib_none(ffi::g_emblemed_icon_get_emblems(
96                self.as_ref().to_glib_none().0,
97            ))
98        }
99    }
100
101    /// Gets the main icon for @self.
102    ///
103    /// # Returns
104    ///
105    /// a #GIcon that is owned by @self
106    #[doc(alias = "g_emblemed_icon_get_icon")]
107    #[doc(alias = "get_icon")]
108    fn icon(&self) -> Icon {
109        unsafe {
110            from_glib_none(ffi::g_emblemed_icon_get_icon(
111                self.as_ref().to_glib_none().0,
112            ))
113        }
114    }
115
116    /// The [`Icon`][crate::Icon] to attach emblems to.
117    fn gicon(&self) -> Option<Icon> {
118        ObjectExt::property(self.as_ref(), "gicon")
119    }
120}
121
122impl<O: IsA<EmblemedIcon>> EmblemedIconExt for O {}