gio::prelude

Trait 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 action-added signal on @self.

This function should only be called by [type@Gio.ActionGroup] implementations.

§action_name

the name of an action in the group

Source

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

Emits the action-enabled-changed signal on @self.

This function should only be called by [type@Gio.ActionGroup] implementations.

§action_name

the name of an action in the group

§enabled

whether the action is now enabled

Source

fn action_removed(&self, action_name: &str)

Emits the action-removed signal on @self.

This function should only be called by [type@Gio.ActionGroup] implementations.

§action_name

the name of an action in the group

Source

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

Emits the action-state-changed signal on @self.

This function should only be called by [type@Gio.ActionGroup] 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 NULL. See action_parameter_type().

If the [type@Gio.ActionGroup] 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, DBusConnection::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 DBusConnection::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 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 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 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 activate_action(), the [type@GLib.Variant] given to that function must be of the type returned by this function.

In the case that this function returns NULL, you must not give any [type@GLib.Variant], but NULL 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 NULL will be returned. If the action is stateful then the type of the return value is the type given by action_state_type().

The return value (if non-NULL) should be freed with GLib::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 NULL 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 [type@GLib.Variant] array is returned then each item in the array is a possible value for the state. If a [type@GLib.Variant] 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-NULL) should be freed with GLib::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 [type@GLib.VariantType] of the state. All calls to change_action_state() must give a [type@GLib.Variant] of this type and action_state() will return a [type@GLib.Variant] of the same type.

If the action is not stateful then this function will return NULL. In that case, action_state() will return NULL and you must not call 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 strfreev() when it is no longer required.

§Returns

a NULL-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

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§