Class SignalGroup

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class SignalGroup extends GObject

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.

Since:
2.72
  • Constructor Details

    • SignalGroup

      public SignalGroup(MemorySegment address)
      Create a SignalGroup instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • SignalGroup

      public SignalGroup(Type targetType)
      Creates a new GSignalGroup for target instances of targetType.
      Parameters:
      targetType - the GType of the target instance.
      Since:
      2.72
    • SignalGroup

      public SignalGroup()
      Create a new SignalGroup.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the SignalGroup class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected SignalGroup asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • block

      public void block()

      Blocks all signal handlers managed by this SignalGroup 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.

      Since:
      2.72
    • connect

      public void connect(String detailedSignal, @Nullable Callback cHandler)

      Connects cHandler to the signal detailedSignal on the target instance of self.

      You cannot connect a signal handler after GSignalGroup:target has been set.

      Parameters:
      detailedSignal - a string of the form "signal-name::detail"
      cHandler - the GCallback to connect
      Since:
      2.72
    • connectAfter

      public void connectAfter(String detailedSignal, @Nullable Callback cHandler)

      Connects cHandler to the signal detailedSignal on the target instance of self.

      The cHandler will be called after the default handler of the signal.

      You cannot connect a signal handler after GSignalGroup:target has been set.

      Parameters:
      detailedSignal - a string of the form "signal-name::detail"
      cHandler - the GCallback to connect
      Since:
      2.72
    • connectClosure

      public void connectClosure(String detailedSignal, Closure closure, boolean after)

      Connects closure to the signal detailedSignal on GSignalGroup:target.

      You cannot connect a signal handler after GSignalGroup:target has been set.

      Parameters:
      detailedSignal - 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.
      Since:
      2.74
    • connectData

      public void connectData(String detailedSignal, @Nullable Callback cHandler, @Nullable ClosureNotify notify, Set<ConnectFlags> flags)

      Connects cHandler to the signal detailedSignal on the target instance of self.

      You cannot connect a signal handler after GSignalGroup:target has been set.

      Parameters:
      detailedSignal - a string of the form "signal-name::detail"
      cHandler - the GCallback to connect
      notify - function to be called when disposing of this SignalGroup
      flags - the flags used to create the signal connection
      Since:
      2.72
    • connectData

      public void connectData(String detailedSignal, @Nullable Callback cHandler, @Nullable ClosureNotify notify, ConnectFlags... flags)

      Connects cHandler to the signal detailedSignal on the target instance of self.

      You cannot connect a signal handler after GSignalGroup:target has been set.

      Parameters:
      detailedSignal - a string of the form "signal-name::detail"
      cHandler - the GCallback to connect
      notify - function to be called when disposing of this SignalGroup
      flags - the flags used to create the signal connection
      Since:
      2.72
    • connectObject

      public void connectObject(String detailedSignal, @Nullable Callback cHandler, MemorySegment object, Set<ConnectFlags> flags)

      Connects cHandler to the signal detailedSignal on GSignalGroup:target.

      Ensures that the object stays alive during the call to cHandler by temporarily adding a reference count. When the object is destroyed the signal handler will automatically be removed.

      You cannot connect a signal handler after GSignalGroup:target has been set.

      Parameters:
      detailedSignal - a string of the form signal-name with optional ::signal-detail
      cHandler - the GCallback to connect
      object - the GObject to pass as data to cHandler calls
      flags - GConnectFlags for the signal connection
      Since:
      2.72
    • connectObject

      public void connectObject(String detailedSignal, @Nullable Callback cHandler, MemorySegment object, ConnectFlags... flags)

      Connects cHandler to the signal detailedSignal on GSignalGroup:target.

      Ensures that the object stays alive during the call to cHandler by temporarily adding a reference count. When the object is destroyed the signal handler will automatically be removed.

      You cannot connect a signal handler after GSignalGroup:target has been set.

      Parameters:
      detailedSignal - a string of the form signal-name with optional ::signal-detail
      cHandler - the GCallback to connect
      object - the GObject to pass as data to cHandler calls
      flags - GConnectFlags for the signal connection
      Since:
      2.72
    • connectSwapped

      public void connectSwapped(String detailedSignal, @Nullable Callback cHandler)

      Connects cHandler to the signal detailedSignal on the target instance of self.

      The instance on which the signal is emitted and data will be swapped when calling cHandler.

      You cannot connect a signal handler after GSignalGroup:target has been set.

      Parameters:
      detailedSignal - a string of the form "signal-name::detail"
      cHandler - the GCallback to connect
      Since:
      2.72
    • dupTarget

      public @Nullable GObject dupTarget()
      Gets the target instance used when connecting signals.
      Returns:
      The target instance
      Since:
      2.72
    • setTarget

      public void setTarget(@Nullable GObject 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.
      Since:
      2.72
    • unblock

      public void unblock()
      Unblocks all signal handlers managed by this SignalGroup 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.
      Since:
      2.72
    • onBind

      This signal is emitted when GSignalGroup:target is set to a new value other than null. It is similar to GObject::notify on target except it will not emit when GSignalGroup:target is null and also allows for receiving the GObject without a data-race.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.72
      See Also:
    • emitBind

      public void emitBind(@Nullable GObject instance)
      Emits the "bind" signal. See onBind(SignalGroup.BindCallback).
    • onUnbind

      This signal is emitted when the target instance of self is set to a new GObject.

      This signal will only be emitted if the previous target of self is non-null.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.72
      See Also:
    • emitUnbind

      public void emitUnbind()
      Emits the "unbind" signal. See onUnbind(SignalGroup.UnbindCallback).
    • builder

      public static SignalGroup.Builder<? extends SignalGroup.Builder> builder()
      A SignalGroup.Builder object constructs a SignalGroup with the specified properties. Use the various set...() methods to set properties, and finish construction with SignalGroup.Builder.build().
      Returns:
      the builder object