• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2010 Codethink Limited
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General
15  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
16  *
17  * Authors: Ryan Lortie <desrt@desrt.ca>
18  */
19 
20 #include "config.h"
21 
22 #include "gsimpleaction.h"
23 #include "gactiongroup.h"
24 #include "gactionmap.h"
25 #include "gaction.h"
26 
27 /**
28  * SECTION:gremoteactiongroup
29  * @title: GRemoteActionGroup
30  * @short_description: A GActionGroup that interacts with other processes
31  * @include: gio/gio.h
32  *
33  * The GRemoteActionGroup interface is implemented by #GActionGroup
34  * instances that either transmit action invocations to other processes
35  * or receive action invocations in the local process from other
36  * processes.
37  *
38  * The interface has `_full` variants of the two
39  * methods on #GActionGroup used to activate actions:
40  * g_action_group_activate_action() and
41  * g_action_group_change_action_state(). These variants allow a
42  * "platform data" #GVariant to be specified: a dictionary providing
43  * context for the action invocation (for example: timestamps, startup
44  * notification IDs, etc).
45  *
46  * #GDBusActionGroup implements #GRemoteActionGroup.  This provides a
47  * mechanism to send platform data for action invocations over D-Bus.
48  *
49  * Additionally, g_dbus_connection_export_action_group() will check if
50  * the exported #GActionGroup implements #GRemoteActionGroup and use the
51  * `_full` variants of the calls if available.  This
52  * provides a mechanism by which to receive platform data for action
53  * invocations that arrive by way of D-Bus.
54  *
55  * Since: 2.32
56  **/
57 
58 /**
59  * GRemoteActionGroup:
60  *
61  * #GRemoteActionGroup is an opaque data structure and can only be accessed
62  * using the following functions.
63  **/
64 
65 /**
66  * GRemoteActionGroupInterface:
67  * @activate_action_full: the virtual function pointer for g_remote_action_group_activate_action_full()
68  * @change_action_state_full: the virtual function pointer for g_remote_action_group_change_action_state_full()
69  *
70  * The virtual function table for #GRemoteActionGroup.
71  *
72  * Since: 2.32
73  **/
74 
75 #include "config.h"
76 
77 #include "gremoteactiongroup.h"
78 
G_DEFINE_INTERFACE(GRemoteActionGroup,g_remote_action_group,G_TYPE_ACTION_GROUP)79 G_DEFINE_INTERFACE (GRemoteActionGroup, g_remote_action_group, G_TYPE_ACTION_GROUP)
80 
81 static void
82 g_remote_action_group_default_init (GRemoteActionGroupInterface *iface)
83 {
84 }
85 
86 /**
87  * g_remote_action_group_activate_action_full:
88  * @remote: a #GDBusActionGroup
89  * @action_name: the name of the action to activate
90  * @parameter: (nullable): the optional parameter to the activation
91  * @platform_data: the platform data to send
92  *
93  * Activates the remote action.
94  *
95  * This is the same as g_action_group_activate_action() except that it
96  * allows for provision of "platform data" to be sent along with the
97  * activation request.  This typically contains details such as the user
98  * interaction timestamp or startup notification information.
99  *
100  * @platform_data must be non-%NULL and must have the type
101  * %G_VARIANT_TYPE_VARDICT.  If it is floating, it will be consumed.
102  *
103  * Since: 2.32
104  **/
105 void
g_remote_action_group_activate_action_full(GRemoteActionGroup * remote,const gchar * action_name,GVariant * parameter,GVariant * platform_data)106 g_remote_action_group_activate_action_full (GRemoteActionGroup *remote,
107                                             const gchar        *action_name,
108                                             GVariant           *parameter,
109                                             GVariant           *platform_data)
110 {
111   G_REMOTE_ACTION_GROUP_GET_IFACE (remote)
112     ->activate_action_full (remote, action_name, parameter, platform_data);
113 }
114 
115 /**
116  * g_remote_action_group_change_action_state_full:
117  * @remote: a #GRemoteActionGroup
118  * @action_name: the name of the action to change the state of
119  * @value: the new requested value for the state
120  * @platform_data: the platform data to send
121  *
122  * Changes the state of a remote action.
123  *
124  * This is the same as g_action_group_change_action_state() except that
125  * it allows for provision of "platform data" to be sent along with the
126  * state change request.  This typically contains details such as the
127  * user interaction timestamp or startup notification information.
128  *
129  * @platform_data must be non-%NULL and must have the type
130  * %G_VARIANT_TYPE_VARDICT.  If it is floating, it will be consumed.
131  *
132  * Since: 2.32
133  **/
134 void
g_remote_action_group_change_action_state_full(GRemoteActionGroup * remote,const gchar * action_name,GVariant * value,GVariant * platform_data)135 g_remote_action_group_change_action_state_full (GRemoteActionGroup *remote,
136                                                 const gchar        *action_name,
137                                                 GVariant           *value,
138                                                 GVariant           *platform_data)
139 {
140   G_REMOTE_ACTION_GROUP_GET_IFACE (remote)
141     ->change_action_state_full (remote, action_name, value, platform_data);
142 }
143