Class SimpleAction.Builder<B extends SimpleAction.Builder<B>>
- Type Parameters:
B
- the type of the Builder that is returned
- All Implemented Interfaces:
BuilderInterface
,Action.Builder<B>
- Enclosing class:
SimpleAction
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Finish building theSimpleAction
object.onActivate
(SimpleAction.ActivateCallback handler) Indicates that the action was just activated.Indicates that the action just received a request to change its state.setEnabled
(boolean enabled) Ifaction
is currently enabled.The name of the action.setParameterType
(VariantType parameterType) The type of the parameter that must be given when activating the action.The state of the action, ornull
if the action is stateless.Methods inherited from class org.gnome.gobject.GObject.Builder
onNotify
Methods inherited from class io.github.jwharm.javagi.gobject.Builder
addBuilderProperty, connect, connect, connectSignals, getArena, getNames, getValues
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.jwharm.javagi.gobject.BuilderInterface
addBuilderProperty, connect, connect, getArena
-
Constructor Details
-
Builder
protected Builder()Default constructor for aBuilder
object.
-
-
Method Details
-
build
Finish building theSimpleAction
object. This will callGObject.withProperties(org.gnome.glib.Type, java.lang.String[], org.gnome.gobject.Value[])
to create a new GObject instance, which is then cast toSimpleAction
.- Overrides:
build
in classGObject.Builder<B extends SimpleAction.Builder<B>>
- Returns:
- a new instance of
SimpleAction
with the properties that were set in the Builder object.
-
setEnabled
Ifaction
is currently enabled.If the action is disabled then calls to g_action_activate() and g_action_change_state() have no effect.
- Parameters:
enabled
- the value for theenabled
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setName
-
setParameterType
The type of the parameter that must be given when activating the action.- Parameters:
parameterType
- the value for theparameter-type
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setState
-
onActivate
Indicates that the action was just activated.parameter
will always be of the expected type, i.e. the parameter type specified when the action was created. If an incorrect type is given when activating the action, this signal is not emitted.Since GLib 2.40, if no handler is connected to this signal then the default behaviour for boolean-stated actions with a
null
parameter type is to toggle them via theGSimpleAction
::change-state signal. For stateful actions where the state type is equal to the parameter type, the default is to forward them directly toGSimpleAction
::change-state. This should allow almost all users ofGSimpleAction
to connect only one handler or the other.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onChangeState
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.
- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-