LCOV - code coverage report
Current view: top level - vcl/unx/gtk/window - hudawareness.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 29 0.0 %
Date: 2014-04-11 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  */
       9             : 
      10             : #include <string.h>
      11             : 
      12             : #include <unx/gtk/gtksalmenu.hxx>
      13             : 
      14             : #ifdef ENABLE_GMENU_INTEGRATION
      15             : 
      16             : #include <unx/gtk/hudawareness.h>
      17             : 
      18             : typedef struct
      19             : {
      20             :   GDBusConnection *connection;
      21             :   HudAwarenessCallback callback;
      22             :   gpointer user_data;
      23             :   GDestroyNotify notify;
      24             : } HudAwarenessHandle;
      25             : 
      26             : static void
      27           0 : 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,
      32             :                            GVariant              *parameters,
      33             :                            GDBusMethodInvocation *invocation,
      34             :                            gpointer               user_data)
      35             : {
      36           0 :   HudAwarenessHandle *handle = (HudAwarenessHandle*) user_data;
      37             : 
      38           0 :   if (g_str_equal (method_name, "HudActiveChanged"))
      39             :     {
      40             :       gboolean active;
      41             : 
      42           0 :       g_variant_get (parameters, "(b)", &active);
      43             : 
      44           0 :       (* handle->callback) (active, handle->user_data);
      45             :     }
      46             : 
      47           0 :   g_dbus_method_invocation_return_value (invocation, NULL);
      48           0 : }
      49             : 
      50             : guint
      51           0 : hud_awareness_register (GDBusConnection       *connection,
      52             :                         const gchar           *object_path,
      53             :                         HudAwarenessCallback   callback,
      54             :                         gpointer               user_data,
      55             :                         GDestroyNotify         notify,
      56             :                         GError               **error)
      57             : {
      58             :   static GDBusInterfaceInfo *iface;
      59             :   GDBusInterfaceVTable vtable;
      60             :   HudAwarenessHandle *handle;
      61             :   guint object_id;
      62             : 
      63           0 :   memset ((void *)&vtable, 0, sizeof (vtable));
      64           0 :   vtable.method_call = hud_awareness_method_call;
      65             : 
      66           0 :   if G_UNLIKELY (iface == NULL)
      67             :     {
      68           0 :       GError *local_error = NULL;
      69             :       GDBusNodeInfo *info;
      70             : 
      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'>"
      75             :                                                  "<arg type='b'/>"
      76             :                                                "</method>"
      77             :                                              "</interface>"
      78             :                                            "</node>",
      79           0 :                                            &local_error);
      80           0 :       g_assert_no_error (local_error);
      81           0 :       iface = g_dbus_node_info_lookup_interface (info, "com.canonical.hud.Awareness");
      82           0 :       g_assert (iface != NULL);
      83             :     }
      84             : 
      85           0 :   handle = g_slice_new (HudAwarenessHandle);
      86             : 
      87           0 :   object_id = g_dbus_connection_register_object (connection, object_path, iface, &vtable, handle, NULL, error);
      88             : 
      89           0 :   if (object_id == 0)
      90             :     {
      91           0 :       g_slice_free (HudAwarenessHandle, handle);
      92           0 :       return 0;
      93             :     }
      94             : 
      95           0 :   handle->connection = (GDBusConnection*) g_object_ref (connection);
      96           0 :   handle->callback = callback;
      97           0 :   handle->user_data = user_data;
      98           0 :   handle->notify = notify;
      99             : 
     100           0 :   return object_id;
     101             : }
     102             : 
     103             : void
     104           0 : hud_awareness_unregister (GDBusConnection *connection,
     105             :                           guint            subscription_id)
     106             : {
     107           0 :   g_dbus_connection_unregister_object (connection, subscription_id);
     108           0 : }
     109             : 
     110             : #endif
     111             : 
     112             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10