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
// 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::Container;
use crate::Widget;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// The [`Bin`][crate::Bin] widget is a container with just one child.
    /// It is not very useful itself, but it is useful for deriving subclasses,
    /// since it provides common code needed for handling a single child widget.
    ///
    /// Many GTK+ widgets are subclasses of [`Bin`][crate::Bin], including [`Window`][crate::Window],
    /// [`Button`][crate::Button], [`Frame`][crate::Frame], `GtkHandleBox` or [`ScrolledWindow`][crate::ScrolledWindow].
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// # Implements
    ///
    /// [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`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 = "GtkBin")]
    pub struct Bin(Object<ffi::GtkBin, ffi::GtkBinClass>) @extends Container, Widget, @implements Buildable;

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

pub const NONE_BIN: Option<&Bin> = None;

/// Trait containing all [`struct@Bin`] methods.
///
/// # Implementors
///
/// [`ActionBar`][struct@crate::ActionBar], [`Bin`][struct@crate::Bin], [`Button`][struct@crate::Button], [`ComboBox`][struct@crate::ComboBox], [`EventBox`][struct@crate::EventBox], [`Expander`][struct@crate::Expander], [`FlowBoxChild`][struct@crate::FlowBoxChild], [`Frame`][struct@crate::Frame], [`ListBoxRow`][struct@crate::ListBoxRow], [`MenuItem`][struct@crate::MenuItem], [`Overlay`][struct@crate::Overlay], [`Popover`][struct@crate::Popover], [`Revealer`][struct@crate::Revealer], [`ScrolledWindow`][struct@crate::ScrolledWindow], [`SearchBar`][struct@crate::SearchBar], [`StackSidebar`][struct@crate::StackSidebar], [`ToolItem`][struct@crate::ToolItem], [`Viewport`][struct@crate::Viewport], [`Window`][struct@crate::Window]
pub trait BinExt: 'static {
    /// Gets the child of the [`Bin`][crate::Bin], or [`None`] if the bin contains
    /// no child widget. The returned widget does not have a reference
    /// added, so you do not need to unref it.
    ///
    /// # Returns
    ///
    /// the child of `self`, or [`None`] if it does
    /// not have a child.
    #[doc(alias = "gtk_bin_get_child")]
    #[doc(alias = "get_child")]
    fn child(&self) -> Option<Widget>;
}

impl<O: IsA<Bin>> BinExt for O {
    fn child(&self) -> Option<Widget> {
        unsafe { from_glib_none(ffi::gtk_bin_get_child(self.as_ref().to_glib_none().0)) }
    }
}

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