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
// 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::{prelude::*, translate::*, Object};

crate::wrapper! {
    /// `GSignalGroup` manages a collection of signals on a `GObject`.
    ///
    /// `GSignalGroup` simplifies the process of connecting many signals to a `GObject`
    /// as a group. As such there is no API to disconnect a signal from the group.
    ///
    /// In particular, this allows you to:
    ///
    ///  - Change the target instance, which automatically causes disconnection
    ///  of the signals from the old instance and connecting to the new instance.
    ///  - Block and unblock signals as a group
    ///  - Ensuring that blocked state transfers across target instances.
    ///
    /// One place you might want to use such a structure is with `GtkTextView` and
    /// `GtkTextBuffer`. Often times, you'll need to connect to many signals on
    /// `GtkTextBuffer` from a `GtkTextView` subclass. This allows you to create a
    /// signal group during instance construction, simply bind the
    /// `GtkTextView:buffer` property to `GSignalGroup:target` and connect
    /// all the signals you need. When the `GtkTextView:buffer` property changes
    /// all of the signals will be transitioned correctly.
    ///
    /// ## Properties
    ///
    ///
    /// #### `target`
    ///  The target instance used when connecting signals.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `target-type`
    ///  The `GType` of the target property.
    ///
    /// Readable | Writeable | Construct Only
    ///
    /// ## Signals
    ///
    ///
    /// #### `bind`
    ///  This signal is emitted when [`target`][struct@crate::SignalGroup#target] is set to a new value
    /// other than [`None`]. It is similar to [`notify`][struct@crate::Object#notify] on `target` except it
    /// will not emit when [`target`][struct@crate::SignalGroup#target] is [`None`] and also allows for
    /// receiving the [`Object`][crate::Object] without a data-race.
    ///
    ///
    ///
    ///
    /// #### `unbind`
    ///  This signal is emitted when the target instance of `self_` is set to a
    /// new [`Object`][crate::Object].
    ///
    /// This signal will only be emitted if the previous target of `self_` is
    /// non-[`None`].
    ///
    ///
    ///
    /// # Implements
    ///
    /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
    #[doc(alias = "GSignalGroup")]
    pub struct SignalGroup(Object<gobject_ffi::GSignalGroup>);

    match fn {
        type_ => || gobject_ffi::g_signal_group_get_type(),
    }
}

impl SignalGroup {
    /// Creates a new [`SignalGroup`][crate::SignalGroup] for target instances of `target_type`.
    /// ## `target_type`
    /// the `GType` of the target instance.
    ///
    /// # Returns
    ///
    /// a new [`SignalGroup`][crate::SignalGroup]
    #[doc(alias = "g_signal_group_new")]
    #[doc(alias = "new")]
    pub fn with_type(target_type: crate::types::Type) -> SignalGroup {
        unsafe { from_glib_full(gobject_ffi::g_signal_group_new(target_type.into_glib())) }
    }

    /// Blocks all signal handlers managed by `self` so they will not
    /// be called during any signal emissions. Must be unblocked exactly
    /// the same number of times it has been blocked to become active again.
    ///
    /// This blocked state will be kept across changes of the target instance.
    #[doc(alias = "g_signal_group_block")]
    pub fn block(&self) {
        unsafe {
            gobject_ffi::g_signal_group_block(self.to_glib_none().0);
        }
    }

    /// Gets the target instance used when connecting signals.
    ///
    /// # Returns
    ///
    /// The target instance
    #[doc(alias = "g_signal_group_dup_target")]
    #[doc(alias = "dup_target")]
    pub fn target(&self) -> Option<Object> {
        unsafe {
            from_glib_full(gobject_ffi::g_signal_group_dup_target(
                self.to_glib_none().0,
            ))
        }
    }

    /// Sets the target instance used when connecting signals. Any signal
    /// that has been registered with `g_signal_group_connect_object()` or
    /// similar functions will be connected to this object.
    ///
    /// If the target instance was previously set, signals will be
    /// disconnected from that object prior to connecting to `target`.
    /// ## `target`
    /// The target instance used
    ///  when connecting signals.
    #[doc(alias = "g_signal_group_set_target")]
    pub fn set_target(&self, target: Option<&impl IsA<Object>>) {
        unsafe {
            gobject_ffi::g_signal_group_set_target(
                self.to_glib_none().0,
                target.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    /// Unblocks all signal handlers managed by `self` so they will be
    /// called again during any signal emissions unless it is blocked
    /// again. Must be unblocked exactly the same number of times it
    /// has been blocked to become active again.
    #[doc(alias = "g_signal_group_unblock")]
    pub fn unblock(&self) {
        unsafe {
            gobject_ffi::g_signal_group_unblock(self.to_glib_none().0);
        }
    }

    /// The `GType` of the target property.
    #[cfg(feature = "v2_72")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
    #[doc(alias = "target-type")]
    pub fn target_type(&self) -> crate::types::Type {
        ObjectExt::property(self, "target-type")
    }
}

unsafe impl Send for SignalGroup {}
unsafe impl Sync for SignalGroup {}