1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::Buildable;
use crate::IconSize;
use crate::Orientation;
use crate::ReliefStyle;
use crate::SizeGroup;
use crate::ToolbarStyle;
use crate::Widget;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// The [`ToolShell`][crate::ToolShell] interface allows container widgets to provide additional
    /// information when embedding [`ToolItem`][crate::ToolItem] widgets.
    ///
    /// # Implements
    ///
    /// [`ToolShellExt`][trait@crate::prelude::ToolShellExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
    #[doc(alias = "GtkToolShell")]
    pub struct ToolShell(Interface<ffi::GtkToolShell, ffi::GtkToolShellIface>) @requires Widget, Buildable;

    match fn {
        type_ => || ffi::gtk_tool_shell_get_type(),
    }
}

impl ToolShell {
    pub const NONE: Option<&'static ToolShell> = None;
}

/// Trait containing all [`struct@ToolShell`] methods.
///
/// # Implementors
///
/// [`ToolItemGroup`][struct@crate::ToolItemGroup], [`ToolShell`][struct@crate::ToolShell], [`Toolbar`][struct@crate::Toolbar]
pub trait ToolShellExt: 'static {
    /// Retrieves the current ellipsize mode for the tool shell. Tool items must not
    /// call this function directly, but rely on [`ToolItemExt::ellipsize_mode()`][crate::prelude::ToolItemExt::ellipsize_mode()]
    /// instead.
    ///
    /// # Returns
    ///
    /// the current ellipsize mode of `self`
    #[doc(alias = "gtk_tool_shell_get_ellipsize_mode")]
    #[doc(alias = "get_ellipsize_mode")]
    fn ellipsize_mode(&self) -> pango::EllipsizeMode;

    /// Retrieves the icon size for the tool shell. Tool items must not call this
    /// function directly, but rely on [`ToolItemExt::icon_size()`][crate::prelude::ToolItemExt::icon_size()] instead.
    ///
    /// # Returns
    ///
    /// the current size ([`IconSize`][crate::IconSize]) for icons of `self`
    #[doc(alias = "gtk_tool_shell_get_icon_size")]
    #[doc(alias = "get_icon_size")]
    fn icon_size(&self) -> IconSize;

    /// Retrieves the current orientation for the tool shell. Tool items must not
    /// call this function directly, but rely on [`ToolItemExt::orientation()`][crate::prelude::ToolItemExt::orientation()]
    /// instead.
    ///
    /// # Returns
    ///
    /// the current orientation of `self`
    #[doc(alias = "gtk_tool_shell_get_orientation")]
    #[doc(alias = "get_orientation")]
    fn orientation(&self) -> Orientation;

    /// Returns the relief style of buttons on `self`. Tool items must not call this
    /// function directly, but rely on [`ToolItemExt::relief_style()`][crate::prelude::ToolItemExt::relief_style()] instead.
    ///
    /// # Returns
    ///
    /// The relief style of buttons on `self`.
    #[doc(alias = "gtk_tool_shell_get_relief_style")]
    #[doc(alias = "get_relief_style")]
    fn relief_style(&self) -> ReliefStyle;

    /// Retrieves whether the tool shell has text, icons, or both. Tool items must
    /// not call this function directly, but rely on [`ToolItemExt::toolbar_style()`][crate::prelude::ToolItemExt::toolbar_style()]
    /// instead.
    ///
    /// # Returns
    ///
    /// the current style of `self`
    #[doc(alias = "gtk_tool_shell_get_style")]
    #[doc(alias = "get_style")]
    fn style(&self) -> ToolbarStyle;

    /// Retrieves the current text alignment for the tool shell. Tool items must not
    /// call this function directly, but rely on [`ToolItemExt::text_alignment()`][crate::prelude::ToolItemExt::text_alignment()]
    /// instead.
    ///
    /// # Returns
    ///
    /// the current text alignment of `self`
    #[doc(alias = "gtk_tool_shell_get_text_alignment")]
    #[doc(alias = "get_text_alignment")]
    fn text_alignment(&self) -> f32;

    /// Retrieves the current text orientation for the tool shell. Tool items must not
    /// call this function directly, but rely on [`ToolItemExt::text_orientation()`][crate::prelude::ToolItemExt::text_orientation()]
    /// instead.
    ///
    /// # Returns
    ///
    /// the current text orientation of `self`
    #[doc(alias = "gtk_tool_shell_get_text_orientation")]
    #[doc(alias = "get_text_orientation")]
    fn text_orientation(&self) -> Orientation;

    /// Retrieves the current text size group for the tool shell. Tool items must not
    /// call this function directly, but rely on [`ToolItemExt::text_size_group()`][crate::prelude::ToolItemExt::text_size_group()]
    /// instead.
    ///
    /// # Returns
    ///
    /// the current text size group of `self`
    #[doc(alias = "gtk_tool_shell_get_text_size_group")]
    #[doc(alias = "get_text_size_group")]
    fn text_size_group(&self) -> Option<SizeGroup>;

    /// Calling this function signals the tool shell that the overflow menu item for
    /// tool items have changed. If there is an overflow menu and if it is visible
    /// when this function it called, the menu will be rebuilt.
    ///
    /// Tool items must not call this function directly, but rely on
    /// [`ToolItemExt::rebuild_menu()`][crate::prelude::ToolItemExt::rebuild_menu()] instead.
    #[doc(alias = "gtk_tool_shell_rebuild_menu")]
    fn rebuild_menu(&self);
}

impl<O: IsA<ToolShell>> ToolShellExt for O {
    fn ellipsize_mode(&self) -> pango::EllipsizeMode {
        unsafe {
            from_glib(ffi::gtk_tool_shell_get_ellipsize_mode(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn icon_size(&self) -> IconSize {
        unsafe {
            from_glib(ffi::gtk_tool_shell_get_icon_size(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn orientation(&self) -> Orientation {
        unsafe {
            from_glib(ffi::gtk_tool_shell_get_orientation(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn relief_style(&self) -> ReliefStyle {
        unsafe {
            from_glib(ffi::gtk_tool_shell_get_relief_style(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn style(&self) -> ToolbarStyle {
        unsafe {
            from_glib(ffi::gtk_tool_shell_get_style(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn text_alignment(&self) -> f32 {
        unsafe { ffi::gtk_tool_shell_get_text_alignment(self.as_ref().to_glib_none().0) }
    }

    fn text_orientation(&self) -> Orientation {
        unsafe {
            from_glib(ffi::gtk_tool_shell_get_text_orientation(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn text_size_group(&self) -> Option<SizeGroup> {
        unsafe {
            from_glib_none(ffi::gtk_tool_shell_get_text_size_group(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn rebuild_menu(&self) {
        unsafe {
            ffi::gtk_tool_shell_rebuild_menu(self.as_ref().to_glib_none().0);
        }
    }
}

impl fmt::Display for ToolShell {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("ToolShell")
    }
}