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: GType) SignalGroup#
Creates a new
SignalGroupfor target instances oftarget_type.Added in version 2.72.
- Parameters:
target_type – the
Typeof the target instance.
Methods#
- class SignalGroup
- block() None#
Blocks all signal handlers managed by
selfso 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: Closure, after: bool) None#
Connects
closureto the signaldetailed_signalonSignalGroup: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-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(detailed_signal: str, c_handler: Callable[[], None], data: Any, flags: ConnectFlags) None#
Connects
c_handlerto the signaldetailed_signalon 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
Callbackto connectdata – the data to pass to
c_handlercallsflags – the flags used to create the signal connection
- connect_swapped(detailed_signal: str, c_handler: Callable[[], None], data: Any = None) None#
Connects
c_handlerto the signaldetailed_signalon the target instance ofself.The instance on which the signal is emitted and
datawill 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
Callbackto connectdata – the data to pass to
c_handlercalls
- 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.