#include "gdbusmethodinvocation.h"
#include "gdbusintrospection.h"
#include "gdbusconnection.h"
+#include "gdbusactiongroup.h"
#include "gactiongroup.h"
#include "gapplication.h"
#include "gdbuserror.h"
+extern GDBusActionGroupEmitHookFunc g_dbus_action_group_before_emit_hook;
+extern GDBusActionGroupEmitHookFunc g_dbus_action_group_after_emit_hook;
+
/**
* SECTION:gactiongroupexporter
* @title: GActionGroup exporter
if (G_IS_APPLICATION (exporter->action_group))
G_APPLICATION_GET_CLASS (exporter->action_group)
->before_emit (G_APPLICATION (exporter->action_group), platform_data);
+
+ else if (g_dbus_action_group_before_emit_hook != NULL)
+ (* g_dbus_action_group_before_emit_hook) (exporter->action_group, platform_data);
}
static void
if (G_IS_APPLICATION (exporter->action_group))
G_APPLICATION_GET_CLASS (exporter->action_group)
->after_emit (G_APPLICATION (exporter->action_group), platform_data);
+
+ else if (g_dbus_action_group_after_emit_hook != NULL)
+ (* g_dbus_action_group_after_emit_hook) (exporter->action_group, platform_data);
}
static void
* 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;
GVariant *value)
{
GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
+ GVariantBuilder platform_data_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);
/* 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, NULL),
+ g_variant_new ("(sva{sv})", action_name, value, &platform_data_builder),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
}
GVariant *parameter)
{
GDBusActionGroup *group = G_DBUS_ACTION_GROUP (g_group);
+ GVariantBuilder platform_data_builder;
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
if (parameter)
g_variant_builder_add (&builder, "v", parameter);
+ 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_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "Activate",
- g_variant_new ("(sava{sv})", action_name, &builder, NULL),
+ g_variant_new ("(sava{sv})", action_name, &builder, &platform_data_builder),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
}
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;
+}
GType g_dbus_action_group_get_type (void) G_GNUC_CONST;
-GDBusActionGroup * g_dbus_action_group_get (GDBusConnection *connection,
- const gchar *bus_name,
- const gchar *object_path);
+GDBusActionGroup * g_dbus_action_group_get (GDBusConnection *connection,
+ const gchar *bus_name,
+ const gchar *object_path);
+
+typedef void (* GDBusActionGroupSendHookFunc) (GDBusActionGroup *group,
+ GVariantBuilder *builder);
+typedef void (* GDBusActionGroupEmitHookFunc) (GActionGroup *group,
+ GVariant *platform_data);
+void g_dbus_action_group_register_platform (GDBusActionGroupSendHookFunc send_hook,
+ GDBusActionGroupEmitHookFunc before_hook,
+ GDBusActionGroupEmitHookFunc after_hook);
G_END_DECLS