Class Signals

java.lang.Object
org.javagi.gobject.types.Signals

@NullMarked public class Signals extends Object
Helper class to register signals in a new GType.
  • Field Details

    • g_signal_connect_data

      public static final MethodHandle g_signal_connect_data
      The method handle for g_signal_connect_data is used by all generated signal-connection methods.
    • g_signal_emit_by_name

      public static final MethodHandle g_signal_emit_by_name
      The method handle for g_signal_emit_by_name is used by all generated signal-emission methods.
  • Constructor Details

    • Signals

      public Signals()
  • Method Details

    • installSignals

      public static @Nullable Consumer<TypeClass> installSignals(Class<?> cls)
      If the provided class contains inner interface declarations with a @Signal-annotation, this function will return a class initializer that registers these declarations as GObject signals (using g_signal_newv) in the class initializer.
      Parameters:
      cls - the class that possibly contains @Signal annotations
      Returns:
      a class initializer that registers the signals
    • emit

      public static @Nullable Object emit(GObject gobject, String detailedSignal, Object... params)
      Emits a signal from a GObject.
      Parameters:
      gobject - the object that emits the signal
      detailedSignal - a string of the form "signal-name::detail"
      params - the parameters to emit for this signal
      Returns:
      the return value of the signal, or null if the signal has no return value
      Throws:
      IllegalArgumentException - if a signal with this name is not found for the object
    • getSingleAbstractMethod

      public static Method getSingleAbstractMethod(Class<?> cls) throws IllegalArgumentException
      Get the single abstract method (SAM) implementation of a functional interface. A functional interface has exactly one abstract method.
      Parameters:
      cls - a functional interface
      Returns:
      the Method reference to the method that implements the SAM
      Throws:
      IllegalArgumentException - if cls is not a functional interface