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
use glib::object::{Cast, ObjectType};
use glib::translate::*;
use glib::Value;
use gobject_sys;
use gtk_sys;
use std::ptr;
use RadioToolButton;
use ToolItem;

impl RadioToolButton {
    /// Creates a new `RadioToolButton`, adding it to `group`.
    /// ## `group`
    /// An
    ///  existing radio button group, or `None` if you are creating a new group
    ///
    /// # Returns
    ///
    /// The new `RadioToolButton`
    pub fn new() -> RadioToolButton {
        assert_initialized_main_thread!();
        unsafe {
            ToolItem::from_glib_none(gtk_sys::gtk_radio_tool_button_new(ptr::null_mut()))
                .unsafe_cast()
        }
    }

    pub fn from_stock(stock_id: &str) -> RadioToolButton {
        assert_initialized_main_thread!();
        unsafe {
            ToolItem::from_glib_none(gtk_sys::gtk_radio_tool_button_new_from_stock(
                ptr::null_mut(),
                stock_id.to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }

    pub fn join_group(&self, group: Option<&RadioToolButton>) {
        unsafe {
            gobject_sys::g_object_set_property(
                self.as_ptr() as *mut _,
                "group".to_glib_none().0,
                Value::from(group).to_glib_none().0,
            );
        }
    }
}