| 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 "gtkplugaccessible.h" |
| 22 |
|
| 23 |
#ifdef GTK_HAVE_ATK_PLUG_SET_CHILD |
| 24 |
|
| 25 |
/* We can not make GtkPlugAccessible inherit both from GtkContainerAccessible |
| 26 |
* and GtkPlug, so we make it the atk child of an AtkPlug */ |
| 27 |
|
| 28 |
struct _GtkPlugAccessiblePrivate |
| 29 |
{ |
| 30 |
AtkObject *accessible_plug; |
| 31 |
}; |
| 32 |
|
| 33 |
G_DEFINE_TYPE_WITH_CODE (GtkPlugAccessible, gtk_plug_accessible, GTK_TYPE_WINDOW_ACCESSIBLE, |
| 34 |
G_ADD_PRIVATE (GtkPlugAccessible)) |
| 35 |
|
| 36 |
|
| 37 |
static void |
| 38 |
gtk_plug_accessible_finalize (GObject *object) |
| 39 |
{ |
| 40 |
GtkPlugAccessible *plug = GTK_PLUG_ACCESSIBLE (object); |
| 41 |
GtkPlugAccessiblePrivate *priv = plug->priv; |
| 42 |
|
| 43 |
g_clear_object (&priv->accessible_plug); |
| 44 |
|
| 45 |
G_OBJECT_CLASS (gtk_plug_accessible_parent_class)->finalize (object); |
| 46 |
} |
| 47 |
|
| 48 |
static void |
| 49 |
gtk_plug_accessible_initialize (AtkObject *plug, gpointer data) |
| 50 |
{ |
| 51 |
AtkObject *atk_plug; |
| 52 |
|
| 53 |
ATK_OBJECT_CLASS (gtk_plug_accessible_parent_class)->initialize (plug, data); |
| 54 |
|
| 55 |
atk_plug = atk_plug_new (); |
| 56 |
atk_plug_set_child (ATK_PLUG (atk_plug), plug); |
| 57 |
GTK_PLUG_ACCESSIBLE (plug)->priv->accessible_plug = atk_plug; |
| 58 |
} |
| 59 |
|
| 60 |
static void |
| 61 |
gtk_plug_accessible_class_init (GtkPlugAccessibleClass *klass) { |
| 62 |
AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass); |
| 63 |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 64 |
|
| 65 |
atk_class->initialize = gtk_plug_accessible_initialize; |
| 66 |
gobject_class->finalize = gtk_plug_accessible_finalize; |
| 67 |
} |
| 68 |
|
| 69 |
static void |
| 70 |
gtk_plug_accessible_init (GtkPlugAccessible *plug) |
| 71 |
{ |
| 72 |
plug->priv = gtk_plug_accessible_get_instance_private (plug); |
| 73 |
} |
| 74 |
|
| 75 |
gchar * |
| 76 |
gtk_plug_accessible_get_id (GtkPlugAccessible *plug) |
| 77 |
{ |
| 78 |
return atk_plug_get_id (ATK_PLUG (plug->priv->accessible_plug)); |
| 79 |
} |
| 80 |
|
| 81 |
#endif /* GTK_HAVE_ATK_PLUG_SET_CHILD */ |