Trait gio::prelude::ActionGroupExt

source ·
pub trait ActionGroupExt: IsA<ActionGroup> + Sealed + 'static {
Show 17 methods // Provided methods fn action_added(&self, action_name: &str) { ... } fn action_enabled_changed(&self, action_name: &str, enabled: bool) { ... } fn action_removed(&self, action_name: &str) { ... } fn action_state_changed(&self, action_name: &str, state: &Variant) { ... } fn activate_action(&self, action_name: &str, parameter: Option<&Variant>) { ... } fn change_action_state(&self, action_name: &str, value: &Variant) { ... } fn is_action_enabled(&self, action_name: &str) -> bool { ... } fn action_parameter_type(&self, action_name: &str) -> Option<VariantType> { ... } fn action_state(&self, action_name: &str) -> Option<Variant> { ... } fn action_state_hint(&self, action_name: &str) -> Option<Variant> { ... } fn action_state_type(&self, action_name: &str) -> Option<VariantType> { ... } fn has_action(&self, action_name: &str) -> bool { ... } fn list_actions(&self) -> Vec<GString> { ... } fn connect_action_added<F: Fn(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { ... } fn connect_action_enabled_changed<F: Fn(&Self, &str, bool) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { ... } fn connect_action_removed<F: Fn(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { ... } fn connect_action_state_changed<F: Fn(&Self, &str, &Variant) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { ... }
}
Expand description

Provided Methods§

source

fn action_added(&self, action_name: &str)

Emits the #GActionGroup::action-added signal on @self.

This function should only be called by #GActionGroup implementations.

§action_name

the name of an action in the group

source

fn action_enabled_changed(&self, action_name: &str, enabled: bool)

Emits the #GActionGroup::action-enabled-changed signal on @self.

This function should only be called by #GActionGroup implementations.

§action_name

the name of an action in the group

§enabled

whether or not the action is now enabled

source

fn action_removed(&self, action_name: &str)

Emits the #GActionGroup::action-removed signal on @self.

This function should only be called by #GActionGroup implementations.

§action_name

the name of an action in the group

source

fn action_state_changed(&self, action_name: &str, state: &Variant)

Emits the #GActionGroup::action-state-changed signal on @self.

This function should only be called by #GActionGroup implementations.

§action_name

the name of an action in the group

§state

the new state of the named action

source

fn activate_action(&self, action_name: &str, parameter: Option<&Variant>)

Activate the named action within @self.

If the action is expecting a parameter, then the correct type of parameter must be given as @parameter. If the action is expecting no parameters then @parameter must be None. See g_action_group_get_action_parameter_type().

If the #GActionGroup implementation supports asynchronous remote activation over D-Bus, this call may return before the relevant D-Bus traffic has been sent, or any replies have been received. In order to block on such asynchronous activation calls, g_dbus_connection_flush() should be called prior to the code, which depends on the result of the action activation. Without flushing the D-Bus connection, there is no guarantee that the action would have been activated.

The following code which runs in a remote app instance, shows an example of a “quit” action being activated on the primary app instance over D-Bus. Here g_dbus_connection_flush() is called before exit(). Without g_dbus_connection_flush(), the “quit” action may fail to be activated on the primary instance.

⚠️ The following code is in C ⚠️

// call "quit" action on primary instance
g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL);

// make sure the action is activated now
g_dbus_connection_flush (...);

g_debug ("application has been terminated. exiting.");

exit (0);
§action_name

the name of the action to activate

§parameter

parameters to the activation

source

fn change_action_state(&self, action_name: &str, value: &Variant)

Request for the state of the named action within @self to be changed to @value.

The action must be stateful and @value must be of the correct type. See g_action_group_get_action_state_type().

This call merely requests a change. The action may refuse to change its state or may change its state to something other than @value. See g_action_group_get_action_state_hint().

If the @value GVariant is floating, it is consumed.

§action_name

the name of the action to request the change on

§value

the new state

source

fn is_action_enabled(&self, action_name: &str) -> bool

Checks if the named action within @self is currently enabled.

An action must be enabled in order to be activated or in order to have its state changed from outside callers.

§action_name

the name of the action to query

§Returns

whether or not the action is currently enabled

source

fn action_parameter_type(&self, action_name: &str) -> Option<VariantType>

Queries the type of the parameter that must be given when activating the named action within @self.

When activating the action using g_action_group_activate_action(), the #GVariant given to that function must be of the type returned by this function.

In the case that this function returns None, you must not give any #GVariant, but None instead.

The parameter type of a particular action will never change but it is possible for an action to be removed and for a new action to be added with the same name but a different parameter type.

§action_name

the name of the action to query

§Returns

the parameter type

source

fn action_state(&self, action_name: &str) -> Option<Variant>

Queries the current state of the named action within @self.

If the action is not stateful then None will be returned. If the action is stateful then the type of the return value is the type given by g_action_group_get_action_state_type().

The return value (if non-None) should be freed with g_variant_unref() when it is no longer required.

§action_name

the name of the action to query

§Returns

the current state of the action

source

fn action_state_hint(&self, action_name: &str) -> Option<Variant>

Requests a hint about the valid range of values for the state of the named action within @self.

If None is returned it either means that the action is not stateful or that there is no hint about the valid range of values for the state of the action.

If a #GVariant array is returned then each item in the array is a possible value for the state. If a #GVariant pair (ie: two-tuple) is returned then the tuple specifies the inclusive lower and upper bound of valid values for the state.

In any case, the information is merely a hint. It may be possible to have a state value outside of the hinted range and setting a value within the range may fail.

The return value (if non-None) should be freed with g_variant_unref() when it is no longer required.

§action_name

the name of the action to query

§Returns

the state range hint

source

fn action_state_type(&self, action_name: &str) -> Option<VariantType>

Queries the type of the state of the named action within @self.

If the action is stateful then this function returns the #GVariantType of the state. All calls to g_action_group_change_action_state() must give a #GVariant of this type and g_action_group_get_action_state() will return a #GVariant of the same type.

If the action is not stateful then this function will return None. In that case, g_action_group_get_action_state() will return None and you must not call g_action_group_change_action_state().

The state type of a particular action will never change but it is possible for an action to be removed and for a new action to be added with the same name but a different state type.

§action_name

the name of the action to query

§Returns

the state type, if the action is stateful

source

fn has_action(&self, action_name: &str) -> bool

Checks if the named action exists within @self.

§action_name

the name of the action to check for

§Returns

whether the named action exists

source

fn list_actions(&self) -> Vec<GString>

Lists the actions contained within @self.

The caller is responsible for freeing the list with g_strfreev() when it is no longer required.

§Returns

a None-terminated array of the names of the actions in the group

source

fn connect_action_added<F: Fn(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId

Signals that a new action was just added to the group. This signal is emitted after the action has been added and is now visible.

§action_name

the name of the action in @action_group

source

fn connect_action_enabled_changed<F: Fn(&Self, &str, bool) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId

Signals that the enabled status of the named action has changed.

§action_name

the name of the action in @action_group

§enabled

whether the action is enabled or not

source

fn connect_action_removed<F: Fn(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId

Signals that an action is just about to be removed from the group. This signal is emitted before the action is removed, so the action is still visible and can be queried from the signal handler.

§action_name

the name of the action in @action_group

source

fn connect_action_state_changed<F: Fn(&Self, &str, &Variant) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId

Signals that the state of the named action has changed.

§action_name

the name of the action in @action_group

§value

the new value of the state

Object Safety§

This trait is not object safe.

Implementors§