* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#include "config.h"
-#include "gdbusactiongroup.h"
+#include "gdbusactiongroup-private.h"
+#include "gremoteactiongroup.h"
#include "gdbusconnection.h"
#include "gactiongroup.h"
* SECTION:gdbusactiongroup
* @title: GDBusActionGroup
* @short_description: A D-Bus GActionGroup implementation
- * @see_also: <link linkend="gio-GActionGroup-exporter">GActionGroup exporter</link>
+ * @include: gio/gio.h
+ * @see_also: [GActionGroup exporter][gio-GActionGroup-exporter]
*
* #GDBusActionGroup is an implementation of the #GActionGroup
* interface that can be used as a proxy for an action group
* that is exported over D-Bus with g_dbus_connection_export_action_group().
*/
-G_GNUC_INTERNAL GDBusActionGroupSendHookFunc g_dbus_action_group_send_hook;
-G_GNUC_INTERNAL GDBusActionGroupEmitHookFunc g_dbus_action_group_before_emit_hook;
-G_GNUC_INTERNAL GDBusActionGroupEmitHookFunc g_dbus_action_group_after_emit_hook;
-
struct _GDBusActionGroup
{
GObject parent_instance;
g_slice_free (ActionInfo, info);
}
-ActionInfo *
+static ActionInfo *
action_info_new_from_iter (GVariantIter *iter)
{
const gchar *param_str;
return info;
}
-static void g_dbus_action_group_iface_init (GActionGroupInterface *);
+static void g_dbus_action_group_remote_iface_init (GRemoteActionGroupInterface *iface);
+static void g_dbus_action_group_iface_init (GActionGroupInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GDBusActionGroup, g_dbus_action_group, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, g_dbus_action_group_iface_init))
+ G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, g_dbus_action_group_iface_init)
+ G_IMPLEMENT_INTERFACE (G_TYPE_REMOTE_ACTION_GROUP, g_dbus_action_group_remote_iface_init))
static void
g_dbus_action_group_changed (GDBusConnection *connection,
g_variant_iter_free (iter);
g_variant_unref (reply);
}
+
+ g_object_unref (group);
}
g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "DescribeAll", NULL,
G_VARIANT_TYPE ("(a{s(bgav)})"), G_DBUS_CALL_FLAGS_NONE, -1, NULL,
- g_dbus_action_group_describe_all_done, group);
+ g_dbus_action_group_describe_all_done, g_object_ref (group));
}
static gchar **
else
{
g_dbus_action_group_async_init (group);
+ group->strict = TRUE;
return FALSE;
}
}
static void
-g_dbus_action_group_change_state (GActionGroup *g_group,
- const gchar *action_name,
- GVariant *value)
+g_dbus_action_group_activate_action_full (GRemoteActionGroup *remote,
+ const gchar *action_name,
+ GVariant *parameter,
+ GVariant *platform_data)
{
- GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
- GVariantBuilder platform_data_builder;
+ GDBusActionGroup *group = G_DBUS_ACTION_GROUP (remote);
+ GVariantBuilder builder;
- g_variant_builder_init (&platform_data_builder, G_VARIANT_TYPE_VARDICT);
- if (g_dbus_action_group_send_hook != NULL)
- (* g_dbus_action_group_send_hook) (group, &platform_data_builder);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
- /* Don't bother with the checks. The other side will do it again. */
- g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "SetState",
- g_variant_new ("(sva{sv})", action_name, value, &platform_data_builder),
+ if (parameter)
+ g_variant_builder_add (&builder, "v", parameter);
+
+ g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "Activate",
+ g_variant_new ("(sav@a{sv})", action_name, &builder, platform_data),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
}
static void
-g_dbus_action_group_activate (GActionGroup *g_group,
- const gchar *action_name,
- GVariant *parameter)
+g_dbus_action_group_change_action_state_full (GRemoteActionGroup *remote,
+ const gchar *action_name,
+ GVariant *value,
+ GVariant *platform_data)
{
- GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
- GVariantBuilder platform_data_builder;
- GVariantBuilder builder;
+ GDBusActionGroup *group = G_DBUS_ACTION_GROUP (remote);
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
-
- if (parameter)
- g_variant_builder_add (&builder, "v", parameter);
+ g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "SetState",
+ g_variant_new ("(sv@a{sv})", action_name, value, platform_data),
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+}
- g_variant_builder_init (&platform_data_builder, G_VARIANT_TYPE_VARDICT);
- if (g_dbus_action_group_send_hook != NULL)
- (* g_dbus_action_group_send_hook) (group, &platform_data_builder);
+static void
+g_dbus_action_group_change_state (GActionGroup *group,
+ const gchar *action_name,
+ GVariant *value)
+{
+ g_dbus_action_group_change_action_state_full (G_REMOTE_ACTION_GROUP (group),
+ action_name, value, g_variant_new ("a{sv}", NULL));
+}
- g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "Activate",
- g_variant_new ("(sava{sv})", action_name, &builder, &platform_data_builder),
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+static void
+g_dbus_action_group_activate (GActionGroup *group,
+ const gchar *action_name,
+ GVariant *parameter)
+{
+ g_dbus_action_group_activate_action_full (G_REMOTE_ACTION_GROUP (group),
+ action_name, parameter, g_variant_new ("a{sv}", NULL));
}
static void
}
static void
+g_dbus_action_group_remote_iface_init (GRemoteActionGroupInterface *iface)
+{
+ iface->activate_action_full = g_dbus_action_group_activate_action_full;
+ iface->change_action_state_full = g_dbus_action_group_change_action_state_full;
+}
+
+static void
g_dbus_action_group_iface_init (GActionGroupInterface *iface)
{
iface->list_actions = g_dbus_action_group_list_actions;
return group;
}
-G_GNUC_INTERNAL gboolean
+gboolean
g_dbus_action_group_sync (GDBusActionGroup *group,
GCancellable *cancellable,
GError **error)
return reply != NULL;
}
-
-void
-g_dbus_action_group_register_platform (GDBusActionGroupSendHookFunc send,
- GDBusActionGroupEmitHookFunc before,
- GDBusActionGroupEmitHookFunc after)
-{
- g_return_if_fail (g_dbus_action_group_send_hook == NULL &&
- g_dbus_action_group_before_emit_hook == NULL &&
- g_dbus_action_group_after_emit_hook == NULL);
-
- g_dbus_action_group_send_hook = send;
- g_dbus_action_group_before_emit_hook = before;
- g_dbus_action_group_after_emit_hook = after;
-}