2007-12-18 13:51:12 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2007-12-23 12:27:33 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "gailbooleancell.h"
|
|
|
|
|
|
|
|
static void gail_boolean_cell_class_init (GailBooleanCellClass *klass);
|
2007-12-23 12:24:59 +00:00
|
|
|
static void gail_boolean_cell_init (GailBooleanCell *cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
/* Misc */
|
|
|
|
|
|
|
|
static gboolean gail_boolean_cell_update_cache (GailRendererCell *cell,
|
|
|
|
gboolean emit_change_signal);
|
|
|
|
|
|
|
|
gchar *gail_boolean_cell_property_list[] = {
|
|
|
|
"active",
|
|
|
|
"radio",
|
2010-03-05 06:48:23 +00:00
|
|
|
"sensitive",
|
2007-12-18 13:51:12 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2010-04-26 08:12:59 +00:00
|
|
|
G_DEFINE_TYPE (GailBooleanCell, gail_boolean_cell, GAIL_TYPE_RENDERER_CELL)
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-12-23 12:24:59 +00:00
|
|
|
static void
|
|
|
|
gail_boolean_cell_init (GailBooleanCell *cell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
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 ();
|
2008-08-15 11:37:00 +00:00
|
|
|
g_object_ref_sink (cell->renderer);
|
2007-12-18 13:51:12 +00:00
|
|
|
boolean_cell->cell_value = FALSE;
|
2010-03-05 06:48:23 +00:00
|
|
|
boolean_cell->cell_sensitive = TRUE;
|
2007-12-18 13:51:12 +00:00
|
|
|
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;
|
2010-03-05 06:48:23 +00:00
|
|
|
gboolean new_sensitive;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-03-05 06:48:23 +00:00
|
|
|
g_object_get (G_OBJECT(cell->renderer), "active", &new_boolean,
|
|
|
|
"sensitive", &new_sensitive, NULL);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-03-05 06:48:23 +00:00
|
|
|
if (boolean_cell->cell_sensitive != new_sensitive)
|
|
|
|
{
|
|
|
|
rv = TRUE;
|
|
|
|
boolean_cell->cell_sensitive = !(boolean_cell->cell_sensitive);
|
|
|
|
|
|
|
|
/* Update cell's state */
|
|
|
|
|
|
|
|
if (new_sensitive)
|
|
|
|
gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_SENSITIVE, emit_change_signal);
|
|
|
|
else
|
|
|
|
gail_cell_remove_state (GAIL_CELL (cell), ATK_STATE_SENSITIVE, emit_change_signal);
|
|
|
|
}
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
return rv;
|
|
|
|
}
|