Package io.github.jwharm.javagi.gobject
Class SignalConnection<T>
java.lang.Object
io.github.jwharm.javagi.gobject.SignalConnection<T>
- Type Parameters:
T
- the type of the signal
Represents a signal connection. With a
SignalConnection
object, a
signal connection can be blocked, unblocked, and disconnected. It is also
possible to check if the signal is still connected.-
Constructor Summary
ConstructorDescriptionSignalConnection
(MemorySegment instance, int handlerId) Create a SignalConnection instance for the provided GObject instance and handler ID.SignalConnection
(MemorySegment instance, int handlerId, Closure closure) Create a SignalConnection instance for the provided GObject instance and handler ID. -
Method Summary
Modifier and TypeMethodDescriptionvoid
block()
Blocks a handler of an instance so it will not be called during any signal emissions unless it is unblocked again.void
Disconnects a handler from an instance so it will not be called during any future or currently ongoing emissions of the signal it has been connected to.boolean
Returns whether this signal is connected.void
unblock()
Undoes the effect of a previousblock()
call.
-
Constructor Details
-
SignalConnection
Create a SignalConnection instance for the provided GObject instance and handler ID.- Parameters:
instance
- the native memory address of the GObject instancehandlerId
- the handler ID of the signal
-
SignalConnection
Create a SignalConnection instance for the provided GObject instance and handler ID.- Parameters:
instance
- the native memory address of the GObject instancehandlerId
- the handler ID of the signalclosure
- closure for the signal callback
-
-
Method Details
-
block
public void block()Blocks a handler of an instance so it will not be called during any signal emissions unless it is unblocked again. Thus "blocking" a signal handler means to temporarily deactivate it, a signal handler has to be unblocked exactly the same amount of times it has been blocked before to become active again. -
unblock
public void unblock()Undoes the effect of a previousblock()
call. A blocked handler is skipped during signal emissions and will not be invoked, unblocking it (for exactly the amount of times it has been blocked before) reverts its "blocked" state, so the handler will be recognized by the signal system and is called upon future or currently ongoing signal emissions (since the order in which handlers are called during signal emissions is deterministic, whether the unblocked handler in question is called as part of a currently ongoing emission depends on how far that emission has proceeded yet). -
disconnect
public void disconnect()Disconnects a handler from an instance so it will not be called during any future or currently ongoing emissions of the signal it has been connected to. ThehandlerId
becomes invalid and may be reused. -
isConnected
public boolean isConnected()Returns whether this signal is connected.- Returns:
- whether the
handlerId
of this signal identifies a handler connected to the instance.
-