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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface declaration of theBindCallback
callback.static class
SignalGroup.Builder<B extends SignalGroup.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theUnbindCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionSignalGroup
(MemorySegment address) Create a SignalGroup proxy instance for the provided memory address.SignalGroup
(Type targetType) Creates a newGSignalGroup
for target instances oftargetType
. -
Method Summary
Modifier and TypeMethodDescriptionprotected SignalGroup
asParent()
Returns this instance as if it were its parent type.void
block()
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.Builder
object constructs aSignalGroup
with the specified properties.void
ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.void
connectAfter
(String detailedSignal, Callback cHandler) ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.void
connectClosure
(String detailedSignal, Closure closure, boolean after) Connectsclosure
to the signaldetailedSignal
onGSignalGroup
:target.void
connectData
(String detailedSignal, Callback cHandler, ClosureNotify notify, Set<ConnectFlags> flags) ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.void
connectData
(String detailedSignal, Callback cHandler, ClosureNotify notify, ConnectFlags... flags) ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.void
connectObject
(String detailedSignal, Callback cHandler, MemorySegment object, Set<ConnectFlags> flags) ConnectscHandler
to the signaldetailedSignal
onGSignalGroup
:target.void
connectObject
(String detailedSignal, Callback cHandler, MemorySegment object, ConnectFlags... flags) ConnectscHandler
to the signaldetailedSignal
onGSignalGroup
:target.void
connectSwapped
(String detailedSignal, Callback cHandler) ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.Gets the target instance used when connecting signals.void
Emits the "bind" signal.void
Emits the "unbind" signal.static Type
getType()
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 ofself
is set to a newGObject
.void
Sets the target instance used when connecting signals.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.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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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 newGSignalGroup
for target instances oftargetType
.- Parameters:
targetType
- theGType
of the target instance.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, 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.
-
connect
ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.You cannot connect a signal handler after
GSignalGroup
:target has been set.- Parameters:
detailedSignal
- a string of the form "signal-name::detail"cHandler
- theGCallback
to connect
-
connectAfter
ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.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
- theGCallback
to connect
-
connectClosure
Connectsclosure
to the signaldetailedSignal
onGSignalGroup
:target.You cannot connect a signal handler after
GSignalGroup
:target has been set.- Parameters:
detailedSignal
- a string of the formsignal-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.
-
connectData
public void connectData(String detailedSignal, Callback cHandler, ClosureNotify notify, Set<ConnectFlags> flags) ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.You cannot connect a signal handler after
GSignalGroup
:target has been set.- Parameters:
detailedSignal
- a string of the form "signal-name::detail"cHandler
- theGCallback
to connectnotify
- function to be called when disposing of this SignalGroupflags
- the flags used to create the signal connection
-
connectData
public void connectData(String detailedSignal, Callback cHandler, ClosureNotify notify, ConnectFlags... flags) ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.You cannot connect a signal handler after
GSignalGroup
:target has been set.- Parameters:
detailedSignal
- a string of the form "signal-name::detail"cHandler
- theGCallback
to connectnotify
- function to be called when disposing of this SignalGroupflags
- the flags used to create the signal connection
-
connectObject
public void connectObject(String detailedSignal, Callback cHandler, MemorySegment object, Set<ConnectFlags> flags) ConnectscHandler
to the signaldetailedSignal
onGSignalGroup
:target.Ensures that the
object
stays alive during the call tocHandler
by temporarily adding a reference count. When theobject
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 formsignal-name
with optional::signal-detail
cHandler
- theGCallback
to connectobject
- theGObject
to pass as data tocHandler
callsflags
-GConnectFlags
for the signal connection
-
connectObject
public void connectObject(String detailedSignal, Callback cHandler, MemorySegment object, ConnectFlags... flags) ConnectscHandler
to the signaldetailedSignal
onGSignalGroup
:target.Ensures that the
object
stays alive during the call tocHandler
by temporarily adding a reference count. When theobject
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 formsignal-name
with optional::signal-detail
cHandler
- theGCallback
to connectobject
- theGObject
to pass as data tocHandler
callsflags
-GConnectFlags
for the signal connection
-
connectSwapped
ConnectscHandler
to the signaldetailedSignal
on the target instance of this SignalGroup.The instance on which the signal is emitted and
data
will 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
- theGCallback
to connect
-
dupTarget
Gets the target instance used when connecting signals.- Returns:
- The target instance
-
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.
-
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. -
onBind
This signal is emitted whenGSignalGroup
:target is set to a new value other thannull
. It is similar toGObject
::notify ontarget
except it will not emit whenGSignalGroup
:target isnull
and also allows for receiving theGObject
without a data-race.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitBind
Emits the "bind" signal. SeeonBind(org.gnome.gobject.SignalGroup.BindCallback)
. -
onUnbind
This signal is emitted when the target instance ofself
is set to a newGObject
.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
- See Also:
-
emitUnbind
public void emitUnbind()Emits the "unbind" signal. SeeonUnbind(org.gnome.gobject.SignalGroup.UnbindCallback)
. -
builder
ASignalGroup.Builder
object constructs aSignalGroup
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withSignalGroup.Builder.build()
.
-