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
58mod sealed {
59 pub trait Sealed {}
60 impl<T: super::IsA<super::EmblemedIcon>> Sealed for T {}
61}
62
63/// Trait containing all [`struct@EmblemedIcon`] methods.
64///
65/// # Implementors
66///
67/// [`EmblemedIcon`][struct@crate::EmblemedIcon]
68pub trait EmblemedIconExt: IsA<EmblemedIcon> + sealed::Sealed + 'static {
69 /// Adds @emblem to the #GList of #GEmblems.
70 /// ## `emblem`
71 /// a #GEmblem
72 #[doc(alias = "g_emblemed_icon_add_emblem")]
73 fn add_emblem(&self, emblem: &Emblem) {
74 unsafe {
75 ffi::g_emblemed_icon_add_emblem(
76 self.as_ref().to_glib_none().0,
77 emblem.to_glib_none().0,
78 );
79 }
80 }
81
82 /// Removes all the emblems from @icon.
83 #[doc(alias = "g_emblemed_icon_clear_emblems")]
84 fn clear_emblems(&self) {
85 unsafe {
86 ffi::g_emblemed_icon_clear_emblems(self.as_ref().to_glib_none().0);
87 }
88 }
89
90 /// Gets the list of emblems for the @icon.
91 ///
92 /// # Returns
93 ///
94 /// a #GList of
95 /// #GEmblems that is owned by @self
96 #[doc(alias = "g_emblemed_icon_get_emblems")]
97 #[doc(alias = "get_emblems")]
98 fn emblems(&self) -> Vec<Emblem> {
99 unsafe {
100 FromGlibPtrContainer::from_glib_none(ffi::g_emblemed_icon_get_emblems(
101 self.as_ref().to_glib_none().0,
102 ))
103 }
104 }
105
106 /// Gets the main icon for @self.
107 ///
108 /// # Returns
109 ///
110 /// a #GIcon that is owned by @self
111 #[doc(alias = "g_emblemed_icon_get_icon")]
112 #[doc(alias = "get_icon")]
113 fn icon(&self) -> Icon {
114 unsafe {
115 from_glib_none(ffi::g_emblemed_icon_get_icon(
116 self.as_ref().to_glib_none().0,
117 ))
118 }
119 }
120
121 /// The [`Icon`][crate::Icon] to attach emblems to.
122 fn gicon(&self) -> Option<Icon> {
123 ObjectExt::property(self.as_ref(), "gicon")
124 }
125}
126
127impl<O: IsA<EmblemedIcon>> EmblemedIconExt for O {}