GObject.SignalGroup¶
class — extends Object
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.
Constructors¶
new¶
Creates a new SignalGroup for target instances of target_type.
Parameters:
target_type— theGTypeof the target instance.
Methods¶
block¶
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.
connect_closure¶
Connects closure to the signal detailed_signal on SignalGroup:target.
You cannot connect a signal handler after SignalGroup:target has been set.
Parameters:
detailed_signal— a string of the formsignal-namewith optional::signal-detailclosure— the closure to connect.after— whether the handler should be called before or after the default handler of the signal.
connect_data¶
def connect_data(self, detailed_signal: str, c_handler: Callback, flags: ConnectFlags | int) -> None
Connects c_handler to the signal detailed_signal
on the target instance of self.
You cannot connect a signal handler after SignalGroup:target has been set.
Parameters:
detailed_signal— a string of the form "signal-name::detail"c_handler— theGCallbackto connectflags— the flags used to create the signal connection
connect_swapped¶
Connects c_handler to the signal detailed_signal
on the target instance of self.
The instance on which the signal is emitted and data
will be swapped when calling c_handler.
You cannot connect a signal handler after SignalGroup:target has been set.
Parameters:
detailed_signal— a string of the form "signal-name::detail"c_handler— theGCallbackto connect
dup_target¶
Gets the target instance used when connecting signals.
set_target¶
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.
Parameters:
target— The target instance used when connecting signals.
unblock¶
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.
Properties¶
target¶
The target instance used when connecting signals.
target_type¶
The GType of the target property.
Signals¶
bind¶
This signal is emitted when SignalGroup:target is set to a new value
other than None. It is similar to Object::notify on target except it
will not emit when SignalGroup:target is None and also allows for
receiving the Object without a data-race.
unbind¶
This signal is emitted when the target instance of self is set to a
new Object.
This signal will only be emitted if the previous target of self is
non-None.