Class SimpleAction.Builder<B extends SimpleAction.Builder<B>>
- Type Parameters:
B- the type of the Builder that is returned
- All Implemented Interfaces:
Action.Builder<B>,BuilderInterface
- Enclosing class:
SimpleAction
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Finish building theSimpleActionobject.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) Ifactionis 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, ornullif the action is stateless.Methods inherited from class org.gnome.gobject.GObject.Builder
onNotifyMethods inherited from class org.javagi.gobject.Builder
addBuilderProperty, connect, connect, connectSignals, getArena, getNames, getValuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.javagi.gobject.BuilderInterface
addBuilderProperty, connect, connect, getArena
-
Constructor Details
-
Builder
protected Builder()Default constructor for aBuilderobject.
-
-
Method Details
-
build
Finish building theSimpleActionobject. 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:
buildin classGObject.Builder<B extends SimpleAction.Builder<B>>- Returns:
- a new instance of
SimpleActionwith the properties that were set in the Builder object.
-
setEnabled
Ifactionis 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 theenabledproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.28
-
setName
-
setParameterType
The type of the parameter that must be given when activating the action.- Parameters:
parameterType- the value for theparameter-typeproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.28
-
setState
-
onActivate
Indicates that the action was just activated.parameterwill 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
nullparameter 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 ofGSimpleActionto connect only one handler or the other.- Parameters:
handler- the signal handler- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.28
- See Also:
-
onChangeState
Indicates that the action just received a request to change its state.valuewill 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
Builderinstance is returned, to allow method chaining - Since:
- 2.30
- See Also:
-