Class SignalConnection<T>

java.lang.Object
org.javagi.gobject.SignalConnection<T>
Type Parameters:
T - the type of the signal

@NullMarked public class SignalConnection<T> extends Object
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

    Constructors
    Constructor
    Description
    SignalConnection(MemorySegment instance, int handlerId)
    Create a SignalConnection instance for the provided GObject instance and handler ID.
    SignalConnection(MemorySegment instance, int handlerId, @Nullable Closure closure)
    Create a SignalConnection instance for the provided GObject instance and handler ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    Undoes the effect of a previous block() call.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SignalConnection

      public SignalConnection(MemorySegment instance, int handlerId)
      Create a SignalConnection instance for the provided GObject instance and handler ID.
      Parameters:
      instance - the native memory address of the GObject instance
      handlerId - the handler ID of the signal
    • SignalConnection

      public SignalConnection(MemorySegment instance, int handlerId, @Nullable Closure closure)
      Create a SignalConnection instance for the provided GObject instance and handler ID.
      Parameters:
      instance - the native memory address of the GObject instance
      handlerId - the handler ID of the signal
      closure - 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 previous block() 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. The handlerId 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.