2012-10-30 14:21:44 +00:00
|
|
|
/* GTK+ - accessibility implementations
|
2011-07-09 22:51:27 +00:00
|
|
|
* Copyright 2001 Sun Microsystems Inc.
|
|
|
|
*
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2011-07-09 22:51:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "gtkcontainercellaccessible.h"
|
2012-12-27 06:04:46 +00:00
|
|
|
#include "gtkcellaccessibleprivate.h"
|
2011-07-09 22:51:27 +00:00
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
struct _GtkContainerCellAccessiblePrivate
|
|
|
|
{
|
|
|
|
GList *children;
|
|
|
|
gint n_children;
|
|
|
|
};
|
2011-07-09 22:51:27 +00:00
|
|
|
|
2013-06-24 18:13:44 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkContainerCellAccessible, gtk_container_cell_accessible, GTK_TYPE_CELL_ACCESSIBLE)
|
2011-07-09 22:51:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_container_cell_accessible_finalize (GObject *obj)
|
|
|
|
{
|
|
|
|
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
|
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
g_list_free_full (container->priv->children, g_object_unref);
|
2011-07-09 22:51:27 +00:00
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
G_OBJECT_CLASS (gtk_container_cell_accessible_parent_class)->finalize (obj);
|
2011-07-09 22:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_container_cell_accessible_get_n_children (AtkObject *obj)
|
|
|
|
{
|
|
|
|
GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
|
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
return cell->priv->n_children;
|
2011-07-09 22:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static AtkObject *
|
|
|
|
gtk_container_cell_accessible_ref_child (AtkObject *obj,
|
|
|
|
gint child)
|
|
|
|
{
|
|
|
|
GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
|
|
|
|
GList *l;
|
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
l = g_list_nth (cell->priv->children, child);
|
2011-07-09 22:51:27 +00:00
|
|
|
if (l == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return g_object_ref (ATK_OBJECT (l->data));
|
|
|
|
}
|
|
|
|
|
2011-12-15 23:12:15 +00:00
|
|
|
static void
|
|
|
|
gtk_container_cell_accessible_update_cache (GtkCellAccessible *cell)
|
|
|
|
{
|
|
|
|
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (cell);
|
|
|
|
GList *l;
|
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
for (l = container->priv->children; l; l = l->next)
|
2012-12-27 06:04:46 +00:00
|
|
|
_gtk_cell_accessible_update_cache (l->data);
|
2011-12-15 23:12:15 +00:00
|
|
|
}
|
|
|
|
|
2011-12-18 20:07:27 +00:00
|
|
|
static void
|
|
|
|
gtk_container_cell_widget_set (GtkAccessible *accessible)
|
|
|
|
{
|
|
|
|
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (accessible);
|
|
|
|
GList *l;
|
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
for (l = container->priv->children; l; l = l->next)
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_accessible_set_widget (l->data, gtk_accessible_get_widget (accessible));
|
2011-12-18 20:07:27 +00:00
|
|
|
|
2015-01-26 20:59:50 +00:00
|
|
|
GTK_ACCESSIBLE_CLASS (gtk_container_cell_accessible_parent_class)->widget_set (accessible);
|
2011-12-18 20:07:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_container_cell_widget_unset (GtkAccessible *accessible)
|
|
|
|
{
|
|
|
|
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (accessible);
|
|
|
|
GList *l;
|
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
for (l = container->priv->children; l; l = l->next)
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_accessible_set_widget (l->data, NULL);
|
2011-12-18 20:07:27 +00:00
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
GTK_ACCESSIBLE_CLASS (gtk_container_cell_accessible_parent_class)->widget_unset (accessible);
|
2011-12-18 20:07:27 +00:00
|
|
|
}
|
|
|
|
|
2011-07-09 22:51:27 +00:00
|
|
|
static void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_container_cell_accessible_class_init (GtkContainerCellAccessibleClass *klass)
|
2011-07-09 22:51:27 +00:00
|
|
|
{
|
2011-12-15 23:12:15 +00:00
|
|
|
GtkCellAccessibleClass *cell_class = GTK_CELL_ACCESSIBLE_CLASS (klass);
|
2011-12-18 20:07:27 +00:00
|
|
|
GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass);
|
2011-12-15 23:12:15 +00:00
|
|
|
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
2011-07-09 22:51:27 +00:00
|
|
|
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
g_object_class->finalize = gtk_container_cell_accessible_finalize;
|
|
|
|
|
|
|
|
class->get_n_children = gtk_container_cell_accessible_get_n_children;
|
|
|
|
class->ref_child = gtk_container_cell_accessible_ref_child;
|
2011-12-15 23:12:15 +00:00
|
|
|
|
2015-01-11 21:34:38 +00:00
|
|
|
accessible_class->widget_set = gtk_container_cell_widget_set;
|
2011-12-18 20:07:27 +00:00
|
|
|
accessible_class->widget_unset = gtk_container_cell_widget_unset;
|
|
|
|
|
2011-12-15 23:12:15 +00:00
|
|
|
cell_class->update_cache = gtk_container_cell_accessible_update_cache;
|
2011-07-09 22:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_container_cell_accessible_init (GtkContainerCellAccessible *cell)
|
2011-07-09 22:51:27 +00:00
|
|
|
{
|
2013-06-24 18:13:44 +00:00
|
|
|
cell->priv = gtk_container_cell_accessible_get_instance_private (cell);
|
2011-07-09 22:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkContainerCellAccessible *
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_container_cell_accessible_new (void)
|
2011-07-09 22:51:27 +00:00
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
|
|
|
|
object = g_object_new (GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, NULL);
|
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
ATK_OBJECT (object)->role = ATK_ROLE_TABLE_CELL;
|
2011-07-09 22:51:27 +00:00
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
return GTK_CONTAINER_CELL_ACCESSIBLE (object);
|
2011-07-09 22:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
|
2011-07-09 22:51:27 +00:00
|
|
|
GtkCellAccessible *child)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
|
|
|
|
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
|
|
|
|
|
2014-02-26 01:29:36 +00:00
|
|
|
g_object_ref (child);
|
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
container->priv->n_children++;
|
|
|
|
container->priv->children = g_list_append (container->priv->children, child);
|
2011-07-09 22:51:27 +00:00
|
|
|
atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *container,
|
2011-07-09 22:51:27 +00:00
|
|
|
GtkCellAccessible *child)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
|
|
|
|
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
|
2012-10-14 19:52:29 +00:00
|
|
|
g_return_if_fail (container->priv->n_children > 0);
|
|
|
|
|
|
|
|
container->priv->children = g_list_remove (container->priv->children, child);
|
|
|
|
container->priv->n_children--;
|
2014-02-26 01:29:36 +00:00
|
|
|
|
|
|
|
g_object_unref (child);
|
2012-10-14 19:52:29 +00:00
|
|
|
}
|
|
|
|
|
2014-05-26 16:32:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_container_cell_accessible_get_children:
|
|
|
|
* @container: the container
|
|
|
|
*
|
|
|
|
* Get a list of children.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none) (element-type Gtk.CellAccessible)
|
|
|
|
*/
|
2012-10-14 19:52:29 +00:00
|
|
|
GList *
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_container_cell_accessible_get_children (GtkContainerCellAccessible *container)
|
2012-10-14 19:52:29 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container), NULL);
|
2011-07-09 22:51:27 +00:00
|
|
|
|
2012-10-14 19:52:29 +00:00
|
|
|
return container->priv->children;
|
2011-07-09 22:51:27 +00:00
|
|
|
}
|