1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
/* CTK+ - accessibility implementations
 * Copyright 2019 Samuel Thibault <sthibault@hypra.fr>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * 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, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <ctk/ctk.h>
#include "ctksocketaccessible.h"

/* We can not make CtkSocketAccessible inherit both from CtkContainerAccessible
 * and CtkSocket, so we make it the atk parent of an AtkSocket */

struct _CtkSocketAccessiblePrivate
{
  AtkObject *accessible_socket;
};

G_DEFINE_TYPE_WITH_CODE (CtkSocketAccessible, ctk_socket_accessible, CTK_TYPE_CONTAINER_ACCESSIBLE,<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_CODE is a macro then please configure it.
                         G_ADD_PRIVATE (CtkSocketAccessible))

static AtkObject*
ctk_socket_accessible_ref_child (AtkObject *obj, int i)
{
  CtkSocketAccessible *socket = CTK_SOCKET_ACCESSIBLE (obj);

  if (i != 0)
    return NULL;

  return g_object_ref (socket->priv->accessible_socket);
}

static int
ctk_socket_accessible_get_n_children (AtkObject *obj G_GNUC_UNUSED)
{
  return 1;
}

static void
ctk_socket_accessible_finalize (GObject *object)
{
  CtkSocketAccessible *socket = CTK_SOCKET_ACCESSIBLE (object);
  CtkSocketAccessiblePrivate *priv = socket->priv;

  g_clear_object (&priv->accessible_socket);

  G_OBJECT_CLASS (ctk_socket_accessible_parent_class)->finalize (object);
}

static void
ctk_socket_accessible_initialize (AtkObject *socket, gpointer data)
{
  AtkObject *atk_socket;

  ATK_OBJECT_CLASS (ctk_socket_accessible_parent_class)->initialize (socket, data);

  atk_socket = atk_socket_new ();

  CTK_SOCKET_ACCESSIBLE(socket)->priv->accessible_socket = atk_socket;
  atk_object_set_parent (atk_socket, socket);
}

static void
ctk_socket_accessible_class_init (CtkSocketAccessibleClass *klass)
{
  CtkContainerAccessibleClass *container_class = (CtkContainerAccessibleClass*)klass;
  AtkObjectClass              *atk_class       = ATK_OBJECT_CLASS (klass);
  GObjectClass                *gobject_class   = G_OBJECT_CLASS (klass);

  container_class->add_ctk    = NULL;
  container_class->remove_ctk = NULL;

  atk_class->initialize     = ctk_socket_accessible_initialize;
  atk_class->get_n_children = ctk_socket_accessible_get_n_children;
  atk_class->ref_child      = ctk_socket_accessible_ref_child;

  gobject_class->finalize = ctk_socket_accessible_finalize;
}

static void
ctk_socket_accessible_init (CtkSocketAccessible *socket)
{
  socket->priv = ctk_socket_accessible_get_instance_private (socket);
}

void
ctk_socket_accessible_embed (CtkSocketAccessible *socket, gchar *path)
{
  atk_socket_embed (ATK_SOCKET (socket->priv->accessible_socket), path);
}