Trait gio::prelude::ActionGroupExt[][src]

pub trait ActionGroupExt: 'static {
Show 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

Required methods

Emits the signal::ActionGroup::action-added signal on self.

This function should only be called by ActionGroup implementations.

action_name

the name of an action in the group

Emits the signal::ActionGroup::action-enabled-changed signal on self.

This function should only be called by ActionGroup implementations.

action_name

the name of an action in the group

enabled

whether or not the action is now enabled

Emits the signal::ActionGroup::action-removed signal on self.

This function should only be called by ActionGroup implementations.

action_name

the name of an action in the group

Emits the signal::ActionGroup::action-state-changed signal on self.

This function should only be called by ActionGroup implementations.

action_name

the name of an action in the group

state

the new state of the named action

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 action_parameter_type().

If the 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 DBusConnection::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

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

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

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 glib::Variant 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 glib::Variant, 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

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

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 glib::Variant array is returned then each item in the array is a possible value for the state. If a 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-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

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

If the action is stateful then this function returns the glib::VariantType of the state. All calls to change_action_state() must give a glib::Variant of this type and action_state() will return a glib::Variant of the same type.

If the action is not stateful then this function will return None. In that case, action_state() will return None 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

Checks if the named action exists within self.

action_name

the name of the action to check for

Returns

whether the named action exists

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

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

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

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

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

Implementors