Commit 1da67a22 authored by Matthias Clasen's avatar Matthias Clasen

Convert GailContainerCell to GtkContainerCellAccessible

Including assorted cleanups and _-prefixing of exported API.
parent 07461459
......@@ -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 \
......
......@@ -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;
......
......@@ -20,110 +20,84 @@
#include "config.h"
#include <gtk/gtk.h>
#include "gailcontainercell.h"
#include "gtkcontainercellaccessible.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);
G_DEFINE_TYPE (GtkContainerCellAccessible, _gtk_container_cell_accessible, GTK_TYPE_CELL_ACCESSIBLE)
static void _gail_container_cell_recompute_child_indices
(GailContainerCell *container);
static void gail_container_cell_refresh_child_index (GtkCellAccessible *cell);
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 gail_container_cell_get_n_children (AtkObject *obj);
static AtkObject* gail_container_cell_ref_child (AtkObject *obj,
gint child);
static gint
gtk_container_cell_accessible_get_n_children (AtkObject *obj)
{
GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
G_DEFINE_TYPE (GailContainerCell, gail_container_cell, GTK_TYPE_CELL_ACCESSIBLE)
return cell->NChildren;
}
static void
gail_container_cell_class_init (GailContainerCellClass *klass)
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 = gail_container_cell_finalize;
g_object_class->finalize = gtk_container_cell_accessible_finalize;
class->get_n_children = gail_container_cell_get_n_children;
class->ref_child = gail_container_cell_ref_child;
class->get_n_children = gtk_container_cell_accessible_get_n_children;
class->ref_child = gtk_container_cell_accessible_ref_child;
}
static void
gail_container_cell_init (GailContainerCell *cell)
_gtk_container_cell_accessible_init (GtkContainerCellAccessible *cell)
{
}
GailContainerCell *
gail_container_cell_new (void)
GtkContainerCellAccessible *
_gtk_container_cell_accessible_new (void)
{
GObject *object;
AtkObject *atk_object;
GailContainerCell *container;
GtkContainerCellAccessible *container;
object = g_object_new (GAIL_TYPE_CONTAINER_CELL, NULL);
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 = GAIL_CONTAINER_CELL(object);
container = GTK_CONTAINER_CELL_ACCESSIBLE (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)
recompute_child_indices (GtkContainerCellAccessible *container)
{
gint cur_index = 0;
GList *l;
......@@ -136,37 +110,40 @@ _gail_container_cell_recompute_child_indices (GailContainerCell *container)
}
static void
gail_container_cell_refresh_child_index (GtkCellAccessible *cell)
refresh_child_index (GtkCellAccessible *cell)
{
GailContainerCell *container;
AtkObject *parent;
container = GAIL_CONTAINER_CELL (atk_object_get_parent (ATK_OBJECT (cell)));
parent = atk_object_get_parent (ATK_OBJECT (cell));
_gail_container_cell_recompute_child_indices (container);
recompute_child_indices (GTK_CONTAINER_CELL_ACCESSIBLE (parent));
}
static gint
gail_container_cell_get_n_children (AtkObject *obj)
void
_gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child)
{
GailContainerCell *cell;
g_return_val_if_fail (GAIL_IS_CONTAINER_CELL(obj), 0);
cell = GAIL_CONTAINER_CELL(obj);
return cell->NChildren;
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;
}
static AtkObject *
gail_container_cell_ref_child (AtkObject *obj,
gint child)
void
_gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *container,
GtkCellAccessible *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;
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);
return g_object_ref (ATK_OBJECT (list_node->data));
container->children = g_list_remove (container->children, child);
recompute_child_indices (container);
container->NChildren--;
}
......@@ -17,46 +17,44 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CONTAINER_CELL_H__
#define __GAIL_CONTAINER_CELL_H__
#ifndef __GTK_CONTAINER_CELL_ACCESSIBLE_H__
#define __GTK_CONTAINER_CELL_ACCESSIBLE_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))
#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 _GailContainerCell GailContainerCell;
typedef struct _GailContainerCellClass GailContainerCellClass;
typedef struct _GtkContainerCellAccessible GtkContainerCellAccessible;
typedef struct _GtkContainerCellAccessibleClass GtkContainerCellAccessibleClass;
struct _GailContainerCell
struct _GtkContainerCellAccessible
{
GtkCellAccessible parent;
GList *children;
gint NChildren;
};
struct _GailContainerCellClass
struct _GtkContainerCellAccessibleClass
{
GtkCellAccessibleClass parent_class;
};
GType gail_container_cell_get_type (void);
GType _gtk_container_cell_accessible_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);
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 /* __GAIL_CONTAINER_CELL_H__ */
#endif /* __GTK_CONTAINER_CELL_ACCESSIBLE_H__ */
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment