[]Struct gio::SimpleAction

pub struct SimpleAction(_, _);

A SimpleAction is the obvious simple implementation of the Action interface. This is the easiest way to create an action for purposes of adding it to a SimpleActionGroup.

See also GtkAction.

Implements

glib::object::ObjectExt, ActionExt

Methods

impl SimpleAction[src]

pub fn new(name: &str, parameter_type: Option<&VariantTy>) -> SimpleAction[src]

Creates a new action.

The created action is stateless. See SimpleAction::new_stateful to create an action that has state.

name

the name of the action

parameter_type

the type of parameter that will be passed to handlers for the SimpleAction::activate signal, or None for no parameter

Returns

a new SimpleAction

pub fn new_stateful(
    name: &str,
    parameter_type: Option<&VariantTy>,
    state: &Variant
) -> SimpleAction
[src]

Creates a new stateful action.

All future state values must have the same glib::VariantType as the initial state.

If the state glib::Variant is floating, it is consumed.

name

the name of the action

parameter_type

the type of the parameter that will be passed to handlers for the SimpleAction::activate signal, or None for no parameter

state

the initial state of the action

Returns

a new SimpleAction

pub fn set_enabled(&self, enabled: bool)[src]

Sets the action as enabled or not.

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

This should only be called by the implementor of the action. Users of the action should not attempt to modify its enabled flag.

enabled

whether the action is enabled

pub fn set_state(&self, value: &Variant)[src]

Sets the state of the action.

This directly updates the 'state' property to the given value.

This should only be called by the implementor of the action. Users of the action should not attempt to directly modify the 'state' property. Instead, they should call Action::change_state to request the change.

If the value GVariant is floating, it is consumed.

value

the new glib::Variant for the state

pub fn set_state_hint(&self, state_hint: Option<&Variant>)[src]

Sets the state hint for the action.

See Action::get_state_hint for more information about action state hints.

Feature: v2_44

state_hint

a glib::Variant representing the state hint

pub fn connect_activate<F: Fn(&SimpleAction, Option<&Variant>) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Indicates that the action was just activated.

parameter will 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 None parameter type is to toggle them via the SimpleAction::change-state signal. For stateful actions where the state type is equal to the parameter type, the default is to forward them directly to SimpleAction::change-state. This should allow almost all users of SimpleAction to connect only one handler or the other.

parameter

the parameter to the activation, or None if it has no parameter

pub fn connect_change_state<F: Fn(&SimpleAction, Option<&Variant>) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Indicates that the action just received a request to change its state.

value will always be of the correct state type, i.e. the type of the initial state passed to SimpleAction::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 SimpleAction::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 SimpleAction::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.

value

the requested value for the state

pub fn connect_property_enabled_notify<F: Fn(&SimpleAction) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_state_type_notify<F: Fn(&SimpleAction) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Trait Implementations

impl Clone for SimpleAction

impl Debug for SimpleAction

impl Display for SimpleAction[src]

impl Eq for SimpleAction

impl Hash for SimpleAction

impl IsA<Action> for SimpleAction

impl Ord for SimpleAction

impl<T: ObjectType> PartialEq<T> for SimpleAction

impl<T: ObjectType> PartialOrd<T> for SimpleAction

impl StaticType for SimpleAction

Auto Trait Implementations

impl RefUnwindSafe for SimpleAction

impl !Send for SimpleAction

impl !Sync for SimpleAction

impl Unpin for SimpleAction

impl UnwindSafe for SimpleAction

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 
[src]

impl<T> Cast for T where
    T: ObjectType
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: ToValue + SetValue + Send + ?Sized
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.