Convert GailBooleanCell to GtkBooleanCellAccessible

Including assorted cleanups and _-prefixing of exported API.
This commit is contained in:
Matthias Clasen 2011-07-09 19:02:42 -04:00
parent 1da67a2298
commit 3688c1a2d3
6 changed files with 171 additions and 180 deletions

View File

@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libgail.la
gail_c_sources = \ gail_c_sources = \
gail.c \ gail.c \
gtkarrowaccessible.c \ gtkarrowaccessible.c \
gailbooleancell.c \ gtkbooleancellaccessible.c \
gtkboxaccessible.c \ gtkboxaccessible.c \
gtkbuttonaccessible.c \ gtkbuttonaccessible.c \
gtkcellaccessible.c \ gtkcellaccessible.c \
@ -57,7 +57,7 @@ libgailincludedir=$(includedir)/gail-3.0/gail
gail_private_h_sources = \ gail_private_h_sources = \
gtkarrowaccessible.h \ gtkarrowaccessible.h \
gailbooleancell.h \ gtkbooleancellaccessible.h \
gtkboxaccessible.h \ gtkboxaccessible.h \
gtkbuttonaccessible.h \ gtkbuttonaccessible.h \
gtkcellaccessible.h \ gtkcellaccessible.h \

View File

@ -1,119 +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 "gailbooleancell.h"
static void gail_boolean_cell_class_init (GailBooleanCellClass *klass);
static void gail_boolean_cell_init (GailBooleanCell *cell);
/* Misc */
static gboolean gail_boolean_cell_update_cache (GailRendererCell *cell,
gboolean emit_change_signal);
gchar *gail_boolean_cell_property_list[] = {
"active",
"radio",
"sensitive",
NULL
};
G_DEFINE_TYPE (GailBooleanCell, gail_boolean_cell, GAIL_TYPE_RENDERER_CELL)
static void
gail_boolean_cell_class_init (GailBooleanCellClass *klass)
{
GailRendererCellClass *renderer_cell_class = GAIL_RENDERER_CELL_CLASS (klass);
renderer_cell_class->update_cache = gail_boolean_cell_update_cache;
renderer_cell_class->property_list = gail_boolean_cell_property_list;
}
static void
gail_boolean_cell_init (GailBooleanCell *cell)
{
}
AtkObject*
gail_boolean_cell_new (void)
{
GObject *object;
AtkObject *atk_object;
GailRendererCell *cell;
GailBooleanCell *boolean_cell;
object = g_object_new (GAIL_TYPE_BOOLEAN_CELL, NULL);
g_return_val_if_fail (object != NULL, NULL);
atk_object = ATK_OBJECT (object);
atk_object->role = ATK_ROLE_TABLE_CELL;
cell = GAIL_RENDERER_CELL(object);
boolean_cell = GAIL_BOOLEAN_CELL(object);
cell->renderer = gtk_cell_renderer_toggle_new ();
g_object_ref_sink (cell->renderer);
boolean_cell->cell_value = FALSE;
boolean_cell->cell_sensitive = TRUE;
return atk_object;
}
static gboolean
gail_boolean_cell_update_cache (GailRendererCell *cell,
gboolean emit_change_signal)
{
GailBooleanCell *boolean_cell = GAIL_BOOLEAN_CELL (cell);
gboolean rv = FALSE;
gboolean new_boolean;
gboolean new_sensitive;
g_object_get (G_OBJECT(cell->renderer), "active", &new_boolean,
"sensitive", &new_sensitive, NULL);
if (boolean_cell->cell_value != new_boolean)
{
rv = TRUE;
boolean_cell->cell_value = !(boolean_cell->cell_value);
/* Update cell's state */
if (new_boolean)
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_CHECKED, emit_change_signal);
else
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_CHECKED, emit_change_signal);
}
if (boolean_cell->cell_sensitive != new_sensitive)
{
rv = TRUE;
boolean_cell->cell_sensitive = !(boolean_cell->cell_sensitive);
/* Update cell's state */
if (new_sensitive)
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_SENSITIVE, emit_change_signal);
else
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_SENSITIVE, emit_change_signal);
}
return rv;
}

View File

@ -1,56 +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_BOOLEAN_CELL_H__
#define __GAIL_BOOLEAN_CELL_H__
#include <atk/atk.h>
#include "gailrenderercell.h"
G_BEGIN_DECLS
#define GAIL_TYPE_BOOLEAN_CELL (gail_boolean_cell_get_type ())
#define GAIL_BOOLEAN_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_BOOLEAN_CELL, GailBooleanCell))
#define GAIL_BOOLEAN_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_BOOLEAN_CELL, GailBooleanCellClass))
#define GAIL_IS_BOOLEAN_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_BOOLEAN_CELL))
#define GAIL_IS_BOOLEAN_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_BOOLEAN_CELL))
#define GAIL_BOOLEAN_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_BOOLEAN_CELL, GailBooleanCellClass))
typedef struct _GailBooleanCell GailBooleanCell;
typedef struct _GailBooleanCellClass GailBooleanCellClass;
struct _GailBooleanCell
{
GailRendererCell parent;
gboolean cell_value;
gboolean cell_sensitive;
};
GType gail_boolean_cell_get_type (void);
struct _GailBooleanCellClass
{
GailRendererCellClass parent_class;
};
AtkObject *gail_boolean_cell_new (void);
G_END_DECLS
#endif /* __GAIL_TREE_VIEW_BOOLEAN_CELL_H__ */

View File

@ -0,0 +1,111 @@
/* 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 "gtkbooleancellaccessible.h"
static gchar *property_list[] = {
"active",
"radio",
"sensitive",
NULL
};
G_DEFINE_TYPE (GtkBooleanCellAccessible, _gtk_boolean_cell_accessible, GAIL_TYPE_RENDERER_CELL)
static gboolean
gtk_boolean_cell_accessible_update_cache (GailRendererCell *cell,
gboolean emit_change_signal)
{
GtkBooleanCellAccessible *boolean_cell = GTK_BOOLEAN_CELL_ACCESSIBLE (cell);
gboolean rv = FALSE;
gboolean active;
gboolean sensitive;
g_object_get (G_OBJECT (cell->renderer),
"active", &active,
"sensitive", &sensitive,
NULL);
if (boolean_cell->cell_value != active)
{
rv = TRUE;
boolean_cell->cell_value = !boolean_cell->cell_value;
if (active)
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_CHECKED, emit_change_signal);
else
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_CHECKED, emit_change_signal);
}
if (boolean_cell->cell_sensitive != sensitive)
{
rv = TRUE;
boolean_cell->cell_sensitive = !boolean_cell->cell_sensitive;
if (sensitive)
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_SENSITIVE, emit_change_signal);
else
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_SENSITIVE, emit_change_signal);
}
return rv;
}
static void
_gtk_boolean_cell_accessible_class_init (GtkBooleanCellAccessibleClass *klass)
{
GailRendererCellClass *renderer_cell_class = GAIL_RENDERER_CELL_CLASS (klass);
renderer_cell_class->update_cache = gtk_boolean_cell_accessible_update_cache;
renderer_cell_class->property_list = property_list;
}
static void
_gtk_boolean_cell_accessible_init (GtkBooleanCellAccessible *cell)
{
}
AtkObject *
_gtk_boolean_cell_accessible_new (void)
{
GObject *object;
AtkObject *atk_object;
GailRendererCell *cell;
GtkBooleanCellAccessible *boolean_cell;
object = g_object_new (GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE, NULL);
atk_object = ATK_OBJECT (object);
atk_object->role = ATK_ROLE_TABLE_CELL;
cell = GAIL_RENDERER_CELL (object);
cell->renderer = gtk_cell_renderer_toggle_new ();
g_object_ref_sink (cell->renderer);
boolean_cell = GTK_BOOLEAN_CELL_ACCESSIBLE (object);
boolean_cell->cell_value = FALSE;
boolean_cell->cell_sensitive = TRUE;
return atk_object;
}

View File

@ -0,0 +1,55 @@
/* 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_BOOLEAN_CELL_ACCESSIBLE_H__
#define __GTK_BOOLEAN_CELL_ACCESSIBLE_H__
#include <atk/atk.h>
#include "gailrenderercell.h"
G_BEGIN_DECLS
#define GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE (_gtk_boolean_cell_accessible_get_type ())
#define GTK_BOOLEAN_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE, GtkBooleanCellAccessible))
#define GTK_BOOLEAN_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_BOOLEAN_CELL, GtkBooleanCellAccessibleClass))
#define GTK_IS_BOOLEAN_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE))
#define GTK_IS_BOOLEAN_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE))
#define GTK_BOOLEAN_CELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE, GtkBooleanCellAccessibleClass))
typedef struct _GtkBooleanCellAccessible GtkBooleanCellAccessible;
typedef struct _GtkBooleanCellAccessibleClass GtkBooleanCellAccessibleClass;
struct _GtkBooleanCellAccessible
{
GailRendererCell parent;
gboolean cell_value;
gboolean cell_sensitive;
};
struct _GtkBooleanCellAccessibleClass
{
GailRendererCellClass parent_class;
};
GType _gtk_boolean_cell_accessible_get_type (void);
AtkObject *_gtk_boolean_cell_accessible_new (void);
G_END_DECLS
#endif /* __GAIL_TREE_VIEW_BOOLEAN_CELL_H__ */

View File

@ -26,7 +26,7 @@
#endif #endif
#include "gtktreeviewaccessible.h" #include "gtktreeviewaccessible.h"
#include "gailrenderercell.h" #include "gailrenderercell.h"
#include "gailbooleancell.h" #include "gtkbooleancellaccessible.h"
#include "gailimagecell.h" #include "gailimagecell.h"
#include "gtkcontainercellaccessible.h" #include "gtkcontainercellaccessible.h"
#include "gailtextcell.h" #include "gailtextcell.h"
@ -610,7 +610,7 @@ gtk_tree_view_accessible_ref_child (AtkObject *obj,
child = gail_text_cell_new (); child = gail_text_cell_new ();
} }
else if (GTK_IS_CELL_RENDERER_TOGGLE (renderer)) else if (GTK_IS_CELL_RENDERER_TOGGLE (renderer))
child = gail_boolean_cell_new (); child = _gtk_boolean_cell_accessible_new ();
else if (GTK_IS_CELL_RENDERER_PIXBUF (renderer)) else if (GTK_IS_CELL_RENDERER_PIXBUF (renderer))
child = gail_image_cell_new (); child = gail_image_cell_new ();
else else
@ -3033,7 +3033,7 @@ static void
add_cell_actions (GtkCellAccessible *cell, add_cell_actions (GtkCellAccessible *cell,
gboolean editable) gboolean editable)
{ {
if (GAIL_IS_BOOLEAN_CELL (cell)) if (GTK_IS_BOOLEAN_CELL_ACCESSIBLE (cell))
_gtk_cell_accessible_add_action (cell, _gtk_cell_accessible_add_action (cell,
"toggle", "toggles the cell", "toggle", "toggles the cell",
NULL, toggle_cell_toggled); NULL, toggle_cell_toggled);