Package org.gnome.gio
Interface SimpleAction.ChangeStateCallback
- All Superinterfaces:
FunctionPointer
- Enclosing class:
SimpleAction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public static interface SimpleAction.ChangeStateCallback
extends FunctionPointer
Functional interface declaration of the
ChangeStateCallback
callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Indicates that the action just received a request to change its state.default MemorySegment
toCallback
(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
method.default void
upcall
(MemorySegment sourceSimpleAction, MemorySegment value) Theupcall
method is called from native code.
-
Method Details
-
run
Indicates that the action just received a request to change its state.value
will always be of the correct state type, i.e. the type of the initial state passed to g_simple_action_new_stateful(). If an incorrect type is given when requesting to change the state, this signal is not emitted.If no handler is connected to this signal then the default behaviour is to call g_simple_action_set_state() to set the state to the requested value. If you connect a signal handler then no default action is taken. If the state should change then you must call g_simple_action_set_state() from the handler.
An example of a 'change-state' handler:
static void change_volume_state (GSimpleAction *action, GVariant *value, gpointer user_data) { gint requested; requested = g_variant_get_int32 (value); // Volume only goes from 0 to 10 if (0 <= requested && requested <= 10) g_simple_action_set_state (action, value); }
The handler need not set the state to the requested value. It could set it to any value at all, or take some other action.
-
upcall
Theupcall
method is called from native code. The parameters are marshaled andrun(org.gnome.glib.Variant)
is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
method.- Specified by:
toCallback
in interfaceFunctionPointer
- Parameters:
arena
- the function pointer will be allocated in this arena- Returns:
- the native function pointer
-