Convert GailContainerCell to GtkContainerCellAccessible

Including assorted cleanups and _-prefixing of exported API.
This commit is contained in:
Matthias Clasen 2011-07-09 18:51:27 -04:00
parent 07461459d4
commit 1da67a2298
7 changed files with 225 additions and 250 deletions

View File

@ -14,7 +14,7 @@ gail_c_sources = \
gtkchecksubmenuitemaccessible.c \
gtkcomboboxaccessible.c \
gtkcontaineraccessible.c \
gailcontainercell.c \
gtkcontainercellaccessible.c \
gtkentryaccessible.c \
gtkexpanderaccessible.c \
gtkframeaccessible.c \
@ -66,7 +66,7 @@ gail_private_h_sources = \
gtkchecksubmenuitemaccessible.h \
gtkcomboboxaccessible.h \
gtkcontaineraccessible.h \
gailcontainercell.h \
gtkcontainercellaccessible.h \
gtkentryaccessible.h \
gtkexpanderaccessible.h \
gtkframeaccessible.h \

View File

@ -1,172 +0,0 @@
/* GAIL - The GNOME Accessibility Enabling Library
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gailcontainercell.h"
static void gail_container_cell_class_init (GailContainerCellClass *klass);
static void gail_container_cell_init (GailContainerCell *cell);
static void gail_container_cell_finalize (GObject *obj);
static void _gail_container_cell_recompute_child_indices
(GailContainerCell *container);
static void gail_container_cell_refresh_child_index (GtkCellAccessible *cell);
static gint gail_container_cell_get_n_children (AtkObject *obj);
static AtkObject* gail_container_cell_ref_child (AtkObject *obj,
gint child);
G_DEFINE_TYPE (GailContainerCell, gail_container_cell, GTK_TYPE_CELL_ACCESSIBLE)
static void
gail_container_cell_class_init (GailContainerCellClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
g_object_class->finalize = gail_container_cell_finalize;
class->get_n_children = gail_container_cell_get_n_children;
class->ref_child = gail_container_cell_ref_child;
}
static void
gail_container_cell_init (GailContainerCell *cell)
{
}
GailContainerCell *
gail_container_cell_new (void)
{
GObject *object;
AtkObject *atk_object;
GailContainerCell *container;
object = g_object_new (GAIL_TYPE_CONTAINER_CELL, NULL);
g_return_val_if_fail (object != NULL, NULL);
atk_object = ATK_OBJECT (object);
atk_object->role = ATK_ROLE_TABLE_CELL;
container = GAIL_CONTAINER_CELL(object);
container->children = NULL;
container->NChildren = 0;
return container;
}
static void
gail_container_cell_finalize (GObject *obj)
{
GailContainerCell *container = GAIL_CONTAINER_CELL (obj);
GList *list;
list = container->children;
while (list)
{
g_object_unref (list->data);
list = list->next;
}
g_list_free (container->children);
G_OBJECT_CLASS (gail_container_cell_parent_class)->finalize (obj);
}
void
gail_container_cell_add_child (GailContainerCell *container,
GtkCellAccessible *child)
{
gint child_index;
g_return_if_fail (GAIL_IS_CONTAINER_CELL (container));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
child_index = container->NChildren++;
container->children = g_list_append (container->children, child);
child->index = child_index;
atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container));
child->refresh_index = gail_container_cell_refresh_child_index;
}
void
gail_container_cell_remove_child (GailContainerCell *container,
GtkCellAccessible *child)
{
g_return_if_fail (GAIL_IS_CONTAINER_CELL (container));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
g_return_if_fail (container->NChildren > 0);
container->children = g_list_remove (container->children, child);
_gail_container_cell_recompute_child_indices (container);
container->NChildren--;
}
static void
_gail_container_cell_recompute_child_indices (GailContainerCell *container)
{
gint cur_index = 0;
GList *l;
for (l = container->children; l; l = l->next)
{
GTK_CELL_ACCESSIBLE (l->data)->index = cur_index;
cur_index++;
}
}
static void
gail_container_cell_refresh_child_index (GtkCellAccessible *cell)
{
GailContainerCell *container;
container = GAIL_CONTAINER_CELL (atk_object_get_parent (ATK_OBJECT (cell)));
_gail_container_cell_recompute_child_indices (container);
}
static gint
gail_container_cell_get_n_children (AtkObject *obj)
{
GailContainerCell *cell;
g_return_val_if_fail (GAIL_IS_CONTAINER_CELL(obj), 0);
cell = GAIL_CONTAINER_CELL(obj);
return cell->NChildren;
}
static AtkObject *
gail_container_cell_ref_child (AtkObject *obj,
gint child)
{
GailContainerCell *cell;
GList *list_node;
g_return_val_if_fail (GAIL_IS_CONTAINER_CELL(obj), NULL);
cell = GAIL_CONTAINER_CELL(obj);
list_node = g_list_nth (cell->children, child);
if (!list_node)
return NULL;
return g_object_ref (ATK_OBJECT (list_node->data));
}

View File

@ -1,62 +0,0 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CONTAINER_CELL_H__
#define __GAIL_CONTAINER_CELL_H__
#include <atk/atk.h>
#include "gtkcellaccessible.h"
G_BEGIN_DECLS
#define GAIL_TYPE_CONTAINER_CELL (gail_container_cell_get_type ())
#define GAIL_CONTAINER_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CONTAINER_CELL, GailContainerCell))
#define GAIL_CONTAINER_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CONTAINER_CELL, GailContainerCellClass))
#define GAIL_IS_CONTAINER_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CONTAINER_CELL))
#define GAIL_IS_CONTAINER_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CONTAINER_CELL))
#define GAIL_CONTAINER_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CONTAINER_CELL, GailContainerCellClass))
typedef struct _GailContainerCell GailContainerCell;
typedef struct _GailContainerCellClass GailContainerCellClass;
struct _GailContainerCell
{
GtkCellAccessible parent;
GList *children;
gint NChildren;
};
struct _GailContainerCellClass
{
GtkCellAccessibleClass parent_class;
};
GType gail_container_cell_get_type (void);
GailContainerCell * gail_container_cell_new (void);
void gail_container_cell_add_child (GailContainerCell *container,
GtkCellAccessible *child);
void gail_container_cell_remove_child (GailContainerCell *container,
GtkCellAccessible *child);
G_END_DECLS
#endif /* __GAIL_CONTAINER_CELL_H__ */

View File

@ -20,7 +20,7 @@
#include "config.h"
#include <gtk/gtk.h>
#include "gailcontainercell.h"
#include "gtkcontainercellaccessible.h"
#include "gtkcellaccessible.h"
#include "gailcellparent.h"
@ -189,7 +189,7 @@ _gtk_cell_accessible_add_state (GtkCellAccessible *cell,
* change to it also
*/
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (parent), state_type, emit_signal);
return rc;
@ -225,7 +225,7 @@ _gtk_cell_accessible_remove_state (GtkCellAccessible *cell,
/* If the parent is a flyweight container cell, propagate the state
* change to it also
*/
if (GAIL_IS_CONTAINER_CELL (parent))
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (parent), state_type, emit_signal);
return rc;

View File

@ -0,0 +1,149 @@
/* GAIL - The GNOME Accessibility Enabling Library
* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gtkcontainercellaccessible.h"
G_DEFINE_TYPE (GtkContainerCellAccessible, _gtk_container_cell_accessible, GTK_TYPE_CELL_ACCESSIBLE)
static void
gtk_container_cell_accessible_finalize (GObject *obj)
{
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
g_list_free_full (container->children, g_object_unref);
G_OBJECT_CLASS (_gtk_container_cell_accessible_parent_class)->finalize (obj);
}
static gint
gtk_container_cell_accessible_get_n_children (AtkObject *obj)
{
GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
return cell->NChildren;
}
static AtkObject *
gtk_container_cell_accessible_ref_child (AtkObject *obj,
gint child)
{
GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
GList *l;
l = g_list_nth (cell->children, child);
if (l == NULL)
return NULL;
return g_object_ref (ATK_OBJECT (l->data));
}
static void
_gtk_container_cell_accessible_class_init (GtkContainerCellAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
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;
}
static void
_gtk_container_cell_accessible_init (GtkContainerCellAccessible *cell)
{
}
GtkContainerCellAccessible *
_gtk_container_cell_accessible_new (void)
{
GObject *object;
AtkObject *atk_object;
GtkContainerCellAccessible *container;
object = g_object_new (GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, NULL);
g_return_val_if_fail (object != NULL, NULL);
atk_object = ATK_OBJECT (object);
atk_object->role = ATK_ROLE_TABLE_CELL;
container = GTK_CONTAINER_CELL_ACCESSIBLE (object);
container->children = NULL;
container->NChildren = 0;
return container;
}
static void
recompute_child_indices (GtkContainerCellAccessible *container)
{
gint cur_index = 0;
GList *l;
for (l = container->children; l; l = l->next)
{
GTK_CELL_ACCESSIBLE (l->data)->index = cur_index;
cur_index++;
}
}
static void
refresh_child_index (GtkCellAccessible *cell)
{
AtkObject *parent;
parent = atk_object_get_parent (ATK_OBJECT (cell));
recompute_child_indices (GTK_CONTAINER_CELL_ACCESSIBLE (parent));
}
void
_gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child)
{
gint child_index;
g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
child_index = container->NChildren++;
container->children = g_list_append (container->children, child);
child->index = child_index;
atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container));
child->refresh_index = refresh_child_index;
}
void
_gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child)
{
g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
g_return_if_fail (container->NChildren > 0);
container->children = g_list_remove (container->children, child);
recompute_child_indices (container);
container->NChildren--;
}

View File

@ -0,0 +1,60 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_CONTAINER_CELL_ACCESSIBLE_H__
#define __GTK_CONTAINER_CELL_ACCESSIBLE_H__
#include <atk/atk.h>
#include "gtkcellaccessible.h"
G_BEGIN_DECLS
#define GTK_TYPE_CONTAINER_CELL_ACCESSIBLE (_gtk_container_cell_accessible_get_type ())
#define GTK_CONTAINER_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, GtkContainerCellAccessible))
#define GTK_CONTAINER_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, GtkContainerCellAccessibleClass))
#define GTK_IS_CONTAINER_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE))
#define GTK_IS_CONTAINER_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE))
#define GTK_CONTAINER_CELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, GtkContainerCellAccessibleClass))
typedef struct _GtkContainerCellAccessible GtkContainerCellAccessible;
typedef struct _GtkContainerCellAccessibleClass GtkContainerCellAccessibleClass;
struct _GtkContainerCellAccessible
{
GtkCellAccessible parent;
GList *children;
gint NChildren;
};
struct _GtkContainerCellAccessibleClass
{
GtkCellAccessibleClass parent_class;
};
GType _gtk_container_cell_accessible_get_type (void);
GtkContainerCellAccessible *_gtk_container_cell_accessible_new (void);
void _gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child);
void _gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child);
G_END_DECLS
#endif /* __GTK_CONTAINER_CELL_ACCESSIBLE_H__ */

View File

@ -28,7 +28,7 @@
#include "gailrenderercell.h"
#include "gailbooleancell.h"
#include "gailimagecell.h"
#include "gailcontainercell.h"
#include "gtkcontainercellaccessible.h"
#include "gailtextcell.h"
#include "gailcellparent.h"
@ -483,7 +483,7 @@ gtk_tree_view_accessible_ref_child (AtkObject *obj,
GtkTreeViewColumn *expander_tv;
GList *renderer_list;
GList *l;
GailContainerCell *container = NULL;
GtkContainerCellAccessible *container = NULL;
GailRendererCell *renderer_cell;
gboolean is_expander, is_expanded, retval;
gboolean editable = FALSE;
@ -552,7 +552,7 @@ gtk_tree_view_accessible_ref_child (AtkObject *obj,
{
GtkCellAccessible *container_cell;
container = gail_container_cell_new ();
container = _gtk_container_cell_accessible_new ();
container_cell = GTK_CELL_ACCESSIBLE (container);
_gtk_cell_accessible_initialise (container_cell, widget, ATK_OBJECT (accessible), i);
@ -625,7 +625,7 @@ gtk_tree_view_accessible_ref_child (AtkObject *obj,
_gtk_cell_accessible_initialise (cell, widget, parent, i);
if (container)
gail_container_cell_add_child (container, cell);
_gtk_container_cell_accessible_add_child (container, cell);
else
cell->refresh_index = refresh_cell_index;
@ -1491,7 +1491,7 @@ gtk_tree_view_accessible_grab_cell_focus (GailCellParent *parent,
tv_col = cell_info->cell_col_ref;
if (parent_cell != ATK_OBJECT (parent))
{
/* GtkCellAccessible is in a GailContainerCell.
/* GtkCellAccessible is in a GtkContainerCellAccessible.
* The GtkTreeViewColumn has multiple renderers;
* find the corresponding one.
*/
@ -2417,7 +2417,7 @@ update_cell_value (GailRendererCell *renderer_cell,
{
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
cur_renderer = g_list_nth (renderers, cell->index);
else
cur_renderer = renderers;
@ -3011,7 +3011,7 @@ set_expand_state (GtkTreeView *tree_view,
_gtk_cell_accessible_remove_state (cell, ATK_STATE_EXPANDED, TRUE);
if (_gtk_cell_accessible_remove_state (cell, ATK_STATE_EXPANDABLE, TRUE))
/* The state may have been propagated to the container cell */
if (!GAIL_IS_CONTAINER_CELL (cell))
if (!GTK_IS_CONTAINER_CELL_ACCESSIBLE (cell))
_gtk_cell_accessible_remove_action_by_name (cell,
"expand or contract");
}
@ -3056,7 +3056,7 @@ toggle_cell_expanded (GtkCellAccessible *cell)
AtkStateSet *stateset;
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
parent = atk_object_get_parent (parent);
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
@ -3088,7 +3088,7 @@ toggle_cell_toggled (GtkCellAccessible *cell)
gboolean is_container_cell = FALSE;
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
{
is_container_cell = TRUE;
parent = atk_object_get_parent (parent);
@ -3132,7 +3132,7 @@ edit_cell (GtkCellAccessible *cell)
AtkObject *parent;
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
parent = atk_object_get_parent (parent);
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
@ -3156,7 +3156,7 @@ activate_cell (GtkCellAccessible *cell)
AtkObject *parent;
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
parent = atk_object_get_parent (parent);
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);