| 1 |
/* GTK+ - accessibility implementations |
| 2 |
* Copyright 2019 Samuel Thibault <[email protected]> |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Lesser General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public |
| 15 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include "config.h" |
| 19 |
|
| 20 |
#include <gtk/gtk.h> |
| 21 |
#include "gtksocketaccessible.h" |
| 22 |
|
| 23 |
/* We can not make GtkSocketAccessible inherit both from GtkContainerAccessible |
| 24 |
* and GtkSocket, so we make it the atk parent of an AtkSocket */ |
| 25 |
|
| 26 |
struct _GtkSocketAccessiblePrivate |
| 27 |
{ |
| 28 |
AtkObject *accessible_socket; |
| 29 |
}; |
| 30 |
|
| 31 |
G_DEFINE_TYPE_WITH_CODE (GtkSocketAccessible, gtk_socket_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE, |
| 32 |
G_ADD_PRIVATE (GtkSocketAccessible)) |
| 33 |
|
| 34 |
static AtkObject* |
| 35 |
gtk_socket_accessible_ref_child (AtkObject *obj, int i) |
| 36 |
{ |
| 37 |
GtkSocketAccessible *socket = GTK_SOCKET_ACCESSIBLE (obj); |
| 38 |
|
| 39 |
if (i != 0) |
| 40 |
return NULL; |
| 41 |
|
| 42 |
return g_object_ref (socket->priv->accessible_socket); |
| 43 |
} |
| 44 |
|
| 45 |
static int |
| 46 |
gtk_socket_accessible_get_n_children (AtkObject *obj) |
| 47 |
{ |
| 48 |
return 1; |
| 49 |
} |
| 50 |
|
| 51 |
static void |
| 52 |
gtk_socket_accessible_finalize (GObject *object) |
| 53 |
{ |
| 54 |
GtkSocketAccessible *socket = GTK_SOCKET_ACCESSIBLE (object); |
| 55 |
GtkSocketAccessiblePrivate *priv = socket->priv; |
| 56 |
|
| 57 |
g_clear_object (&priv->accessible_socket); |
| 58 |
|
| 59 |
G_OBJECT_CLASS (gtk_socket_accessible_parent_class)->finalize (object); |
| 60 |
} |
| 61 |
|
| 62 |
static void |
| 63 |
gtk_socket_accessible_initialize (AtkObject *socket, gpointer data) |
| 64 |
{ |
| 65 |
AtkObject *atk_socket; |
| 66 |
|
| 67 |
ATK_OBJECT_CLASS (gtk_socket_accessible_parent_class)->initialize (socket, data); |
| 68 |
|
| 69 |
atk_socket = atk_socket_new (); |
| 70 |
|
| 71 |
GTK_SOCKET_ACCESSIBLE(socket)->priv->accessible_socket = atk_socket; |
| 72 |
atk_object_set_parent (atk_socket, socket); |
| 73 |
} |
| 74 |
|
| 75 |
static void |
| 76 |
gtk_socket_accessible_class_init (GtkSocketAccessibleClass *klass) |
| 77 |
{ |
| 78 |
GtkContainerAccessibleClass *container_class = (GtkContainerAccessibleClass*)klass; |
| 79 |
AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass); |
| 80 |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 81 |
|
| 82 |
container_class->add_gtk = NULL; |
| 83 |
container_class->remove_gtk = NULL; |
| 84 |
|
| 85 |
atk_class->initialize = gtk_socket_accessible_initialize; |
| 86 |
atk_class->get_n_children = gtk_socket_accessible_get_n_children; |
| 87 |
atk_class->ref_child = gtk_socket_accessible_ref_child; |
| 88 |
|
| 89 |
gobject_class->finalize = gtk_socket_accessible_finalize; |
| 90 |
} |
| 91 |
|
| 92 |
static void |
| 93 |
gtk_socket_accessible_init (GtkSocketAccessible *socket) |
| 94 |
{ |
| 95 |
socket->priv = gtk_socket_accessible_get_instance_private (socket); |
| 96 |
} |
| 97 |
|
| 98 |
void |
| 99 |
gtk_socket_accessible_embed (GtkSocketAccessible *socket, gchar *path) |
| 100 |
{ |
| 101 |
atk_socket_embed (ATK_SOCKET (socket->priv->accessible_socket), path); |
| 102 |
} |