1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #include <unx/gtk/hudawareness.h>
16 struct HudAwarenessHandle
19 HudAwarenessCallback callback
;
21 GDestroyNotify notify
;
27 hud_awareness_method_call (GDBusConnection
* /* connection */,
28 const gchar
* /* sender */,
29 const gchar
* /* object_path */,
30 const gchar
* /* interface_name */,
31 const gchar
*method_name
,
33 GDBusMethodInvocation
*invocation
,
36 HudAwarenessHandle
*handle
= static_cast<HudAwarenessHandle
*>(user_data
);
38 if (g_str_equal (method_name
, "HudActiveChanged"))
42 g_variant_get (parameters
, "(b)", &active
);
44 (* handle
->callback
) (active
, handle
->user_data
);
47 g_dbus_method_invocation_return_value (invocation
, nullptr);
51 hud_awareness_register (GDBusConnection
*connection
,
52 const gchar
*object_path
,
53 HudAwarenessCallback callback
,
55 GDestroyNotify notify
,
58 static GDBusInterfaceInfo
*iface
;
59 static GDBusNodeInfo
*info
;
60 GDBusInterfaceVTable vtable
;
61 HudAwarenessHandle
*handle
;
64 memset (static_cast<void *>(&vtable
), 0, sizeof (vtable
));
65 vtable
.method_call
= hud_awareness_method_call
;
67 if G_UNLIKELY (iface
== nullptr)
69 GError
*local_error
= nullptr;
71 info
= g_dbus_node_info_new_for_xml ("<node>"
72 "<interface name='com.canonical.hud.Awareness'>"
73 "<method name='CheckAwareness'/>"
74 "<method name='HudActiveChanged'>"
80 g_assert_no_error (local_error
);
81 iface
= g_dbus_node_info_lookup_interface (info
, "com.canonical.hud.Awareness");
82 g_assert (iface
!= nullptr);
85 handle
= static_cast<HudAwarenessHandle
*>(g_malloc (sizeof (HudAwarenessHandle
)));
87 object_id
= g_dbus_connection_register_object (connection
, object_path
, iface
, &vtable
, handle
, &g_free
, error
);
95 handle
->connection
= g_object_ref(connection
);
96 handle
->callback
= callback
;
97 handle
->user_data
= user_data
;
98 handle
->notify
= notify
;
104 hud_awareness_unregister (GDBusConnection
*connection
,
105 guint subscription_id
)
107 g_dbus_connection_unregister_object (connection
, subscription_id
);
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */