SignalGroup#
Added in version 2.72.
Superclasses: 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#
- class SignalGroup
- classmethod new(target_type: type) SignalGroup #
Creates a new
SignalGroup
for target instances oftarget_type
.Added in version 2.72.
- Parameters:
target_type – the
Type
of the target instance.
Methods#
- class SignalGroup
- block() None #
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.
Added in version 2.72.
- connect_closure(detailed_signal: str, closure: Callable[[...], Any], after: bool) None #
Connects
closure
to the signaldetailed_signal
onSignalGroup
:target.You cannot connect a signal handler after
SignalGroup
:target has been set.Added in version 2.74.
- Parameters:
detailed_signal – a string of the form
signal-name
with optional::signal-detail
closure – the closure to connect.
after – whether the handler should be called before or after the default handler of the signal.
- connect_data(detailed_signal: str, c_handler: Callable[[...], None], flags: ConnectFlags, *data: Any) None #
Connects
c_handler
to the signaldetailed_signal
on the target instance ofself
.You cannot connect a signal handler after
SignalGroup
:target has been set.Added in version 2.72.
- Parameters:
detailed_signal – a string of the form “signal-name::detail”
c_handler – the
Callback
to connectflags – the flags used to create the signal connection
data – the data to pass to
c_handler
calls
- connect_swapped(detailed_signal: str, c_handler: Callable[[...], None], *data: Any) None #
Connects
c_handler
to the signaldetailed_signal
on the target instance ofself
.The instance on which the signal is emitted and
data
will be swapped when callingc_handler
.You cannot connect a signal handler after
SignalGroup
:target has been set.Added in version 2.72.
- Parameters:
detailed_signal – a string of the form “signal-name::detail”
c_handler – the
Callback
to connectdata – the data to pass to
c_handler
calls
- dup_target() Object | None #
Gets the target instance used when connecting signals.
Added in version 2.72.
- set_target(target: Object | None = None) None #
Sets the target instance used when connecting signals. Any signal that has been registered with
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
.Added in version 2.72.
- Parameters:
target – The target instance used when connecting signals.