1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ActionGroup;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// The GRemoteActionGroup interface is implemented by [`ActionGroup`][crate::ActionGroup]
    /// instances that either transmit action invocations to other processes
    /// or receive action invocations in the local process from other
    /// processes.
    ///
    /// The interface has `_full` variants of the two
    /// methods on [`ActionGroup`][crate::ActionGroup] used to activate actions:
    /// [`ActionGroupExt::activate_action()`][crate::prelude::ActionGroupExt::activate_action()] and
    /// [`ActionGroupExt::change_action_state()`][crate::prelude::ActionGroupExt::change_action_state()]. These variants allow a
    /// "platform data" [`glib::Variant`][struct@crate::glib::Variant] to be specified: a dictionary providing
    /// context for the action invocation (for example: timestamps, startup
    /// notification IDs, etc).
    ///
    /// [`DBusActionGroup`][crate::DBusActionGroup] implements [`RemoteActionGroup`][crate::RemoteActionGroup]. This provides a
    /// mechanism to send platform data for action invocations over D-Bus.
    ///
    /// Additionally, [`DBusConnection::export_action_group()`][crate::DBusConnection::export_action_group()] will check if
    /// the exported [`ActionGroup`][crate::ActionGroup] implements [`RemoteActionGroup`][crate::RemoteActionGroup] and use the
    /// `_full` variants of the calls if available. This
    /// provides a mechanism by which to receive platform data for action
    /// invocations that arrive by way of D-Bus.
    ///
    /// # Implements
    ///
    /// [`RemoteActionGroupExt`][trait@crate::prelude::RemoteActionGroupExt], [`ActionGroupExt`][trait@crate::prelude::ActionGroupExt]
    #[doc(alias = "GRemoteActionGroup")]
    pub struct RemoteActionGroup(Interface<ffi::GRemoteActionGroup, ffi::GRemoteActionGroupInterface>) @requires ActionGroup;

    match fn {
        type_ => || ffi::g_remote_action_group_get_type(),
    }
}

impl RemoteActionGroup {
    pub const NONE: Option<&'static RemoteActionGroup> = None;
}

/// Trait containing all [`struct@RemoteActionGroup`] methods.
///
/// # Implementors
///
/// [`DBusActionGroup`][struct@crate::DBusActionGroup], [`RemoteActionGroup`][struct@crate::RemoteActionGroup]
pub trait RemoteActionGroupExt: 'static {
    /// Activates the remote action.
    ///
    /// This is the same as [`ActionGroupExt::activate_action()`][crate::prelude::ActionGroupExt::activate_action()] except that it
    /// allows for provision of "platform data" to be sent along with the
    /// activation request. This typically contains details such as the user
    /// interaction timestamp or startup notification information.
    ///
    /// `platform_data` must be non-[`None`] and must have the type
    /// `G_VARIANT_TYPE_VARDICT`. If it is floating, it will be consumed.
    /// ## `action_name`
    /// the name of the action to activate
    /// ## `parameter`
    /// the optional parameter to the activation
    /// ## `platform_data`
    /// the platform data to send
    #[doc(alias = "g_remote_action_group_activate_action_full")]
    fn activate_action_full(
        &self,
        action_name: &str,
        parameter: Option<&glib::Variant>,
        platform_data: &glib::Variant,
    );

    /// Changes the state of a remote action.
    ///
    /// This is the same as [`ActionGroupExt::change_action_state()`][crate::prelude::ActionGroupExt::change_action_state()] except that
    /// it allows for provision of "platform data" to be sent along with the
    /// state change request. This typically contains details such as the
    /// user interaction timestamp or startup notification information.
    ///
    /// `platform_data` must be non-[`None`] and must have the type
    /// `G_VARIANT_TYPE_VARDICT`. If it is floating, it will be consumed.
    /// ## `action_name`
    /// the name of the action to change the state of
    /// ## `value`
    /// the new requested value for the state
    /// ## `platform_data`
    /// the platform data to send
    #[doc(alias = "g_remote_action_group_change_action_state_full")]
    fn change_action_state_full(
        &self,
        action_name: &str,
        value: &glib::Variant,
        platform_data: &glib::Variant,
    );
}

impl<O: IsA<RemoteActionGroup>> RemoteActionGroupExt for O {
    fn activate_action_full(
        &self,
        action_name: &str,
        parameter: Option<&glib::Variant>,
        platform_data: &glib::Variant,
    ) {
        unsafe {
            ffi::g_remote_action_group_activate_action_full(
                self.as_ref().to_glib_none().0,
                action_name.to_glib_none().0,
                parameter.to_glib_none().0,
                platform_data.to_glib_none().0,
            );
        }
    }

    fn change_action_state_full(
        &self,
        action_name: &str,
        value: &glib::Variant,
        platform_data: &glib::Variant,
    ) {
        unsafe {
            ffi::g_remote_action_group_change_action_state_full(
                self.as_ref().to_glib_none().0,
                action_name.to_glib_none().0,
                value.to_glib_none().0,
                platform_data.to_glib_none().0,
            );
        }
    }
}

impl fmt::Display for RemoteActionGroup {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("RemoteActionGroup")
    }
}