Struct gio::Action[][src]

pub struct Action(_);
Expand description

Action represents a single named action.

The main interface to an action is that it can be activated with ActionExt::activate(). This results in the ‘activate’ signal being emitted. An activation has a glib::Variant parameter (which may be None). The correct type for the parameter is determined by a static parameter type (which is given at construction time).

An action may optionally have a state, in which case the state may be set with ActionExt::change_state(). This call takes a glib::Variant. The correct type for the state is determined by a static state type (which is given at construction time).

The state may have a hint associated with it, specifying its valid range.

Action is merely the interface to the concept of an action, as described above. Various implementations of actions exist, including SimpleAction.

In all cases, the implementing class is responsible for storing the name of the action, the parameter type, the enabled state, the optional state type and the state and emitting the appropriate signals when these change. The implementor is responsible for filtering calls to ActionExt::activate() and ActionExt::change_state() for type safety and for the state being enabled.

Probably the only useful thing to do with a Action is to put it inside of a SimpleActionGroup.

Implements

ActionExt

Implementations

Checks if action_name is valid.

action_name is valid if it consists only of alphanumeric characters, plus ‘-’ and ‘.’. The empty string is not a valid action name.

It is an error to call this function with a non-utf8 action_name. action_name must not be None.

action_name

a potential action name

Returns

true if action_name is valid

Parses a detailed action name into its separate name and target components.

Detailed action names can have three formats.

The first format is used to represent an action name with no target value and consists of just an action name containing no whitespace nor the characters ‘:’, ‘(’ or ‘)’. For example: “app.action”.

The second format is used to represent an action with a target value that is a non-empty string consisting only of alphanumerics, plus ‘-’ and ‘.’. In that case, the action name and target value are separated by a double colon (“::”). For example: “app.action::target”.

The third format is used to represent an action with any type of target value, including strings. The target value follows the action name, surrounded in parens. For example: “app.action(42)”. The target value is parsed using g_variant_parse(). If a tuple-typed value is desired, it must be specified in the same way, resulting in two sets of parens, for example: “app.action((1,2,3))”. A string target can be specified this way as well: “app.action(‘target’)”. For strings, this third format must be used if * target value is empty or contains characters other than alphanumerics, ‘-’ and ‘.’.

detailed_name

a detailed action name

Returns

true if successful, else false with error set

action_name

the action name

target_value

the target value, or None for no target

Formats a detailed action name from action_name and target_value.

It is an error to call this function with an invalid action name.

This function is the opposite of parse_detailed_name(). It will produce a string that can be parsed back to the action_name and target_value by that function.

See that function for the types of strings that will be printed by this function.

action_name

a valid action name

target_value

a glib::Variant target value, or None

Returns

a detailed format string

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Emit signal with details by signal id.

Emit signal by it’s name.

Same as emit but takes Value for the arguments.

Same as emit_by_name but takes Value for the arguments.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.