Class SignalGroup
- All Implemented Interfaces:
Proxy
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface declaration of theBindCallbackcallback.static classSignalGroup.Builder<B extends SignalGroup.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theUnbindCallbackcallback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new SignalGroup.SignalGroup(MemorySegment address) Create a SignalGroup proxy instance for the provided memory address.SignalGroup(Type targetType) Creates a newGSignalGroupfor target instances oftargetType. -
Method Summary
Modifier and TypeMethodDescriptionprotected SignalGroupasParent()Returns this instance as if it were its parent type.voidblock()Blocks all signal handlers managed by this SignalGroup so they will not be called during any signal emissions.static SignalGroup.Builder<? extends SignalGroup.Builder> builder()ASignalGroup.Builderobject constructs aSignalGroupwith the specified properties.voidConnectscHandlerto the signaldetailedSignalon the target instance ofself.voidconnectAfter(String detailedSignal, @Nullable Callback cHandler) ConnectscHandlerto the signaldetailedSignalon the target instance ofself.voidconnectClosure(String detailedSignal, Closure closure, boolean after) Connectsclosureto the signaldetailedSignalonGSignalGroup:target.voidconnectData(String detailedSignal, @Nullable Callback cHandler, @Nullable ClosureNotify notify, Set<ConnectFlags> flags) ConnectscHandlerto the signaldetailedSignalon the target instance ofself.voidconnectData(String detailedSignal, @Nullable Callback cHandler, @Nullable ClosureNotify notify, ConnectFlags... flags) ConnectscHandlerto the signaldetailedSignalon the target instance ofself.voidconnectObject(String detailedSignal, @Nullable Callback cHandler, MemorySegment object, Set<ConnectFlags> flags) ConnectscHandlerto the signaldetailedSignalonGSignalGroup:target.voidconnectObject(String detailedSignal, @Nullable Callback cHandler, MemorySegment object, ConnectFlags... flags) ConnectscHandlerto the signaldetailedSignalonGSignalGroup:target.voidconnectSwapped(String detailedSignal, @Nullable Callback cHandler) ConnectscHandlerto the signaldetailedSignalon the target instance ofself.@Nullable GObjectGets the target instance used when connecting signals.voidEmits the "bind" signal.voidEmits the "unbind" signal.static @Nullable TypegetType()Get the GType of the SignalGroup classonBind(SignalGroup.BindCallback handler) This signal is emitted whenGSignalGroup:target is set to a new value other thannull.onUnbind(SignalGroup.UnbindCallback handler) This signal is emitted when the target instance ofselfis set to a newGObject.voidSets the target instance used when connecting signals.voidunblock()Unblocks all signal handlers managed by this SignalGroup so they will be called again during any signal emissions unless it is blocked again.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
SignalGroup
Create a SignalGroup proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
SignalGroup
Creates a newGSignalGroupfor target instances oftargetType.- Parameters:
targetType- theGTypeof the target instance.- Since:
- 2.72
-
SignalGroup
public SignalGroup()Creates a new SignalGroup.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the 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
ConnectscHandlerto the signaldetailedSignalon the target instance ofself.You cannot connect a signal handler after
GSignalGroup:target has been set.- Parameters:
detailedSignal- a string of the form "signal-name::detail"cHandler- theGCallbackto connect- Since:
- 2.72
-
connectAfter
ConnectscHandlerto the signaldetailedSignalon the target instance ofself.The
cHandlerwill 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- theGCallbackto connect- Since:
- 2.72
-
connectClosure
Connectsclosureto the signaldetailedSignalonGSignalGroup:target.You cannot connect a signal handler after
GSignalGroup:target has been set.- Parameters:
detailedSignal- a string of the formsignal-namewith optional::signal-detailclosure- 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) ConnectscHandlerto the signaldetailedSignalon the target instance ofself.You cannot connect a signal handler after
GSignalGroup:target has been set.- Parameters:
detailedSignal- a string of the form "signal-name::detail"cHandler- theGCallbackto connectnotify- function to be called when disposing of this SignalGroupflags- 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) ConnectscHandlerto the signaldetailedSignalon the target instance ofself.You cannot connect a signal handler after
GSignalGroup:target has been set.- Parameters:
detailedSignal- a string of the form "signal-name::detail"cHandler- theGCallbackto connectnotify- function to be called when disposing of this SignalGroupflags- 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) ConnectscHandlerto the signaldetailedSignalonGSignalGroup:target.Ensures that the
objectstays alive during the call tocHandlerby temporarily adding a reference count. When theobjectis 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 formsignal-namewith optional::signal-detailcHandler- theGCallbackto connectobject- theGObjectto pass as data tocHandlercallsflags-GConnectFlagsfor the signal connection- Since:
- 2.72
-
connectObject
public void connectObject(String detailedSignal, @Nullable Callback cHandler, MemorySegment object, ConnectFlags... flags) ConnectscHandlerto the signaldetailedSignalonGSignalGroup:target.Ensures that the
objectstays alive during the call tocHandlerby temporarily adding a reference count. When theobjectis 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 formsignal-namewith optional::signal-detailcHandler- theGCallbackto connectobject- theGObjectto pass as data tocHandlercallsflags-GConnectFlagsfor the signal connection- Since:
- 2.72
-
connectSwapped
ConnectscHandlerto the signaldetailedSignalon the target instance ofself.The instance on which the signal is emitted and
datawill be swapped when callingcHandler.You cannot connect a signal handler after
GSignalGroup:target has been set.- Parameters:
detailedSignal- a string of the form "signal-name::detail"cHandler- theGCallbackto connect- Since:
- 2.72
-
dupTarget
Gets the target instance used when connecting signals.- Returns:
- The target instance
- Since:
- 2.72
-
setTarget
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 whenGSignalGroup:target is set to a new value other thannull. It is similar toGObject::notify ontargetexcept it will not emit whenGSignalGroup:target isnulland also allows for receiving theGObjectwithout 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
Emits the "bind" signal. SeeonBind(org.gnome.gobject.SignalGroup.BindCallback). -
onUnbind
This signal is emitted when the target instance ofselfis set to a newGObject.This signal will only be emitted if the previous target of
selfis 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. SeeonUnbind(org.gnome.gobject.SignalGroup.UnbindCallback). -
builder
ASignalGroup.Builderobject constructs aSignalGroupwith the specified properties. Use the variousset...()methods to set properties, and finish construction withSignalGroup.Builder.build().- Returns:
- the builder object
-