Skip to main content

gtk/
radio_tool_button.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::RadioToolButton;
4use crate::ToolItem;
5use glib::object::{Cast, ObjectExt};
6use glib::translate::*;
7use std::ptr;
8
9impl RadioToolButton {
10    /// Creates a new [`RadioToolButton`][crate::RadioToolButton], adding it to `group`.
11    /// ## `group`
12    /// An
13    ///  existing radio button group, or [`None`] if you are creating a new group
14    ///
15    /// # Returns
16    ///
17    /// The new [`RadioToolButton`][crate::RadioToolButton]
18    #[doc(alias = "gtk_radio_tool_button_new")]
19    pub fn new() -> Self {
20        assert_initialized_main_thread!();
21        unsafe {
22            ToolItem::from_glib_none(ffi::gtk_radio_tool_button_new(ptr::null_mut())).unsafe_cast()
23        }
24    }
25
26    #[doc(alias = "gtk_radio_tool_button_new_from_stock")]
27    pub fn from_stock(stock_id: &str) -> Self {
28        assert_initialized_main_thread!();
29        unsafe {
30            ToolItem::from_glib_none(ffi::gtk_radio_tool_button_new_from_stock(
31                ptr::null_mut(),
32                stock_id.to_glib_none().0,
33            ))
34            .unsafe_cast()
35        }
36    }
37
38    pub fn join_group(&self, group: Option<&RadioToolButton>) {
39        self.set_property("group", group);
40    }
41}
42
43impl Default for RadioToolButton {
44    fn default() -> Self {
45        Self::new()
46    }
47}