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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use glib::{prelude::*, translate::*};
use std::fmt;

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `widget`
    ///  Readable | Writeable | Construct Only
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`], [`trait@gio::prelude::ActionGroupExt`]
    #[doc(alias = "DzlWidgetActionGroup")]
    pub struct WidgetActionGroup(Object<ffi::DzlWidgetActionGroup, ffi::DzlWidgetActionGroupClass>) @implements gio::ActionGroup;

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

impl WidgetActionGroup {
    #[doc(alias = "dzl_widget_action_group_set_action_enabled")]
    pub fn set_action_enabled(&self, action_name: &str, enabled: bool) {
        unsafe {
            ffi::dzl_widget_action_group_set_action_enabled(
                self.to_glib_none().0,
                action_name.to_glib_none().0,
                enabled.into_glib(),
            );
        }
    }

    pub fn widget(&self) -> Option<gtk::Widget> {
        ObjectExt::property(self, "widget")
    }

    /// Helper function to create an [`WidgetActionGroup`][crate::WidgetActionGroup] and attach
    /// it to `widget` using the group name `group_name`.
    /// ## `widget`
    /// A [`gtk::Widget`][crate::gtk::Widget]
    /// ## `group_name`
    /// the group name to use for the action group
    #[doc(alias = "dzl_widget_action_group_attach")]
    pub fn attach(widget: &impl IsA<gtk::Widget>, group_name: &str) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::dzl_widget_action_group_attach(
                widget.as_ref().to_glib_none().0,
                group_name.to_glib_none().0,
            );
        }
    }

    ///
    /// # Returns
    ///
    /// An [`WidgetActionGroup`][crate::WidgetActionGroup].
    #[doc(alias = "dzl_widget_action_group_new")]
    pub fn new(widget: &impl IsA<gtk::Widget>) -> Option<gio::ActionGroup> {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::dzl_widget_action_group_new(
                widget.as_ref().to_glib_none().0,
            ))
        }
    }
}

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