gtk/modules/other/gail/gailbooleancell.c
Christian Persch a8e6ee33b1 Integrate gail into gtk+. Bug #169488.
* configure.in:
	* docs/reference/Makefile.am:
	* docs/reference/libgail-util/*:
	* gail-uninstalled.pc.in:
	* gail.pc.in:
	* modules/Makefile.am:
	* modules/other/Makefile.am:
	* modules/other/gail/*:
	* modules/other/gail/libgail-util/*:
	* po/POTFILES.skip: Integrate gail into gtk+. Bug #169488.

svn path=/trunk/; revision=19196
2007-12-18 13:51:12 +00:00

123 lines
3.6 KiB
C

/* 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 <gtk/gtk.h>
#include "gailbooleancell.h"
static void gail_boolean_cell_class_init (GailBooleanCellClass *klass);
/* Misc */
static gboolean gail_boolean_cell_update_cache (GailRendererCell *cell,
gboolean emit_change_signal);
gchar *gail_boolean_cell_property_list[] = {
"active",
"radio",
NULL
};
GType
gail_boolean_cell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailBooleanCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_boolean_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailBooleanCell), /* instance size */
0, /* nb preallocs */
NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_RENDERER_CELL,
"GailBooleanCell", &tinfo, 0);
gail_cell_type_add_action_interface (type);
}
return type;
}
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;
}
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 (cell->renderer);
gtk_object_sink (GTK_OBJECT (cell->renderer));
boolean_cell->cell_value = FALSE;
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;
g_object_get (G_OBJECT(cell->renderer), "active", &new_boolean, 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)
gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_CHECKED, emit_change_signal);
else
gail_cell_remove_state (GAIL_CELL (cell), ATK_STATE_CHECKED, emit_change_signal);
}
return rv;
}