GDBusActionGroup: add static platform registration

We provide a mechanism by which a 'platform' (eg: Gtk) can register some
hook functions to be called to collect platform-data at the point of
sending an outgoing action activation request and also to inform the
platform of this data on incoming requests (before and after dispatching
the actual request).

This can be used for forwarding timestamp and startup-notification
information (as is presently done in GApplication) but the before/after
hook could also be used for acquiring/releasing the Gdk lock or other
similar things.

https://bugzilla.gnome.org/show_bug.cgi?id=665737
This commit is contained in:
Ryan Lortie
2011-12-14 13:31:27 -05:00
parent 1d4009e6f7
commit fcc9902e98
4 changed files with 52 additions and 5 deletions

View File

@@ -27,10 +27,14 @@
#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
@@ -449,6 +453,9 @@ g_action_group_exporter_pre_emit (GActionGroupExporter *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
@@ -458,6 +465,9 @@ g_action_group_exporter_post_emit (GActionGroupExporter *exporter,
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