Interface

Gio-2.0GioSimpleActionSignalSignatures

interface SignalSignatures {
    activate: (arg0: GLib.Variant<any>) => void;
    "change-state": (arg0: GLib.Variant<any>) => void;
    notify: (arg0: GObject.ParamSpec) => void;
    "notify::enabled": (pspec: GObject.ParamSpec) => void;
    "notify::name": (pspec: GObject.ParamSpec) => void;
    "notify::parameter-type": (pspec: GObject.ParamSpec) => void;
    "notify::state": (pspec: GObject.ParamSpec) => void;
    "notify::state-type": (pspec: GObject.ParamSpec) => void;
}

Hierarchy (View Summary)

Index

Properties

activate: (arg0: GLib.Variant<any>) => void

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 null parameter type is to toggle them via the Gio.SimpleAction.SignalSignatures.change_state | Gio.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 Gio.SimpleAction.SignalSignatures.change_state | Gio.SimpleAction::change-state. This should allow almost all users of Gio.SimpleAction to connect only one handler or the other.

2.28

"change-state": (arg0: GLib.Variant<any>) => void

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

2.30

"notify::enabled": (pspec: GObject.ParamSpec) => void
"notify::name": (pspec: GObject.ParamSpec) => void
"notify::parameter-type": (pspec: GObject.ParamSpec) => void
"notify::state": (pspec: GObject.ParamSpec) => void
"notify::state-type": (pspec: GObject.ParamSpec) => void

Properties - Inherited from GObject

notify: (arg0: GObject.ParamSpec) => void

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with GObject.ParamFlags.EXPLICIT_NOTIFY, then any call to g_object_set_property() results in ::notify being emitted, even if the new value is the same as the old. If they did pass GObject.ParamFlags.EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

g_signal_connect (text_view->buffer, "notify::paste-target-list",
G_CALLBACK (gtk_text_view_target_list_notify),
text_view)

It is important to note that you must use [canonical parameter names][class@GObject.ParamSpec#parameter-names] as detail strings for the notify signal.