Convert GailStatusbar to GtkStatusbarAccessible

And drop the AtkText implementation at the same time.
Update test results to match.
This commit is contained in:
Matthias Clasen 2011-07-01 00:47:41 -04:00
parent 9a0fd43df2
commit ff5eb4adfe
8 changed files with 208 additions and 798 deletions

View File

@ -40,7 +40,7 @@ gail_c_sources = \
gtkscrolledwindowaccessible.c \
gtkspinbuttonaccessible.c \
gailsubmenuitem.c \
gailstatusbar.c \
gtkstatusbaraccessible.c \
gailtextcell.c \
gailtextutil.c \
gtktextviewaccessible.c \
@ -91,7 +91,7 @@ gail_private_h_sources = \
gtkscrolledwindowaccessible.h \
gtkspinbuttonaccessible.h \
gailsubmenuitem.h \
gailstatusbar.h \
gtkstatusbaraccessible.h \
gailtextcell.h \
gailtextutil.h \
gtktextviewaccessible.h \

View File

@ -36,7 +36,6 @@
#include "gailmenuitem.h"
#include "gailradiomenuitem.h"
#include "gailrenderercell.h"
#include "gailstatusbar.h"
#include "gailtextcell.h"
#include "gailtoplevel.h"
#include "gailutil.h"
@ -94,7 +93,6 @@ GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_MENU_ITEM, GailMenuItem, gail_menu_i
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_MENU_SHELL, GailMenuShell, gail_menu_shell, GTK_TYPE_MENU_SHELL)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_MENU, GailMenu, gail_menu, GTK_TYPE_MENU)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_WINDOW, GailWindow, gail_window, GTK_TYPE_BIN)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_STATUSBAR, GailStatusbar, gail_statusbar, GTK_TYPE_STATUSBAR)
GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_CHECK_MENU_ITEM, GailCheckMenuItem, gail_check_menu_item, gail_check_menu_item_new)
GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_RADIO_MENU_ITEM, GailRadioMenuItem, gail_radio_menu_item, gail_radio_menu_item_new)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_EXPANDER, GailExpander, gail_expander, GTK_TYPE_EXPANDER)
@ -849,7 +847,6 @@ gail_accessibility_module_init (void)
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU_BAR, gail_menu_shell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU, gail_menu);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_WINDOW, gail_window);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_STATUSBAR, gail_statusbar);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TEXT, gail_text_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TOGGLE, gail_boolean_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_PIXBUF, gail_image_cell);

View File

@ -1,650 +0,0 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 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 <string.h>
#include <gtk/gtk.h>
#include "gailstatusbar.h"
#include <libgail-util/gailmisc.h>
static void gail_statusbar_class_init (GailStatusbarClass *klass);
static void gail_statusbar_init (GailStatusbar *bar);
static const gchar* gail_statusbar_get_name (AtkObject *obj);
static gint gail_statusbar_get_n_children (AtkObject *obj);
static AtkObject* gail_statusbar_ref_child (AtkObject *obj,
gint i);
static void gail_statusbar_real_initialize (AtkObject *obj,
gpointer data);
static gint gail_statusbar_notify (GObject *obj,
GParamSpec *pspec,
gpointer user_data);
static void gail_statusbar_finalize (GObject *object);
static void gail_statusbar_init_textutil (GailStatusbar *statusbar,
GtkWidget *label);
/* atktext.h */
static void atk_text_interface_init (AtkTextIface *iface);
static gchar* gail_statusbar_get_text (AtkText *text,
gint start_pos,
gint end_pos);
static gunichar gail_statusbar_get_character_at_offset
(AtkText *text,
gint offset);
static gchar* gail_statusbar_get_text_before_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_statusbar_get_text_at_offset(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_statusbar_get_text_after_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gint gail_statusbar_get_character_count (AtkText *text);
static void gail_statusbar_get_character_extents
(AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords);
static gint gail_statusbar_get_offset_at_point(AtkText *text,
gint x,
gint y,
AtkCoordType coords);
static AtkAttributeSet* gail_statusbar_get_run_attributes
(AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset);
static AtkAttributeSet* gail_statusbar_get_default_attributes
(AtkText *text);
static GtkWidget* get_label_from_statusbar (GtkWidget *statusbar);
G_DEFINE_TYPE_WITH_CODE (GailStatusbar, gail_statusbar, GAIL_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init))
static void
gail_statusbar_class_init (GailStatusbarClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GailContainerClass *container_class;
container_class = (GailContainerClass*)klass;
gobject_class->finalize = gail_statusbar_finalize;
class->get_name = gail_statusbar_get_name;
class->get_n_children = gail_statusbar_get_n_children;
class->ref_child = gail_statusbar_ref_child;
class->initialize = gail_statusbar_real_initialize;
/*
* As we report the statusbar as having no children we are not interested
* in add and remove signals
*/
container_class->add_gtk = NULL;
container_class->remove_gtk = NULL;
}
static void
gail_statusbar_init (GailStatusbar *bar)
{
}
static const gchar*
gail_statusbar_get_name (AtkObject *obj)
{
const gchar* name;
g_return_val_if_fail (GAIL_IS_STATUSBAR (obj), NULL);
name = ATK_OBJECT_CLASS (gail_statusbar_parent_class)->get_name (obj);
if (name != NULL)
return name;
else
{
/*
* Get the text on the label
*/
GtkWidget *widget;
GtkWidget *label;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
g_return_val_if_fail (GTK_IS_STATUSBAR (widget), NULL);
label = get_label_from_statusbar (widget);
if (GTK_IS_LABEL (label))
return gtk_label_get_label (GTK_LABEL (label));
else
return NULL;
}
}
static gint
gail_statusbar_get_n_children (AtkObject *obj)
{
GtkWidget *widget;
GList *children;
gint count = 0;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return 0;
children = gtk_container_get_children (GTK_CONTAINER (widget));
if (children != NULL)
{
count = g_list_length (children);
g_list_free (children);
}
return count;
}
static AtkObject*
gail_statusbar_ref_child (AtkObject *obj,
gint i)
{
GList *children, *tmp_list;
AtkObject *accessible;
GtkWidget *widget;
g_return_val_if_fail ((i >= 0), NULL);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
children = gtk_container_get_children (GTK_CONTAINER (widget));
if (children == NULL)
return NULL;
tmp_list = g_list_nth (children, i);
if (!tmp_list)
{
g_list_free (children);
return NULL;
}
accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
g_list_free (children);
g_object_ref (accessible);
return accessible;
}
static void
gail_statusbar_real_initialize (AtkObject *obj,
gpointer data)
{
GailStatusbar *statusbar = GAIL_STATUSBAR (obj);
GtkWidget *label;
ATK_OBJECT_CLASS (gail_statusbar_parent_class)->initialize (obj, data);
/*
* We get notified of changes to the label
*/
label = get_label_from_statusbar (GTK_WIDGET (data));
if (GTK_IS_LABEL (label))
{
gail_statusbar_init_textutil (statusbar, label);
}
obj->role = ATK_ROLE_STATUSBAR;
}
static gint
gail_statusbar_notify (GObject *obj,
GParamSpec *pspec,
gpointer user_data)
{
AtkObject *atk_obj = ATK_OBJECT (user_data);
GtkLabel *label;
GailStatusbar *statusbar;
if (strcmp (pspec->name, "label") == 0)
{
const gchar* label_text;
label = GTK_LABEL (obj);
label_text = gtk_label_get_text (label);
statusbar = GAIL_STATUSBAR (atk_obj);
gail_text_util_text_setup (statusbar->textutil, label_text);
if (atk_obj->name == NULL)
{
/*
* The label has changed so notify a change in accessible-name
*/
g_object_notify (G_OBJECT (atk_obj), "accessible-name");
}
/*
* The label is the only property which can be changed
*/
g_signal_emit_by_name (atk_obj, "visible_data_changed");
}
return 1;
}
static void
gail_statusbar_init_textutil (GailStatusbar *statusbar,
GtkWidget *label)
{
const gchar *label_text;
statusbar->textutil = gail_text_util_new ();
label_text = gtk_label_get_text (GTK_LABEL (label));
gail_text_util_text_setup (statusbar->textutil, label_text);
g_signal_connect (label,
"notify",
(GCallback) gail_statusbar_notify,
statusbar);
}
static void
gail_statusbar_finalize (GObject *object)
{
GailStatusbar *statusbar = GAIL_STATUSBAR (object);
if (statusbar->textutil)
{
g_object_unref (statusbar->textutil);
}
G_OBJECT_CLASS (gail_statusbar_parent_class)->finalize (object);
}
/* atktext.h */
static void
atk_text_interface_init (AtkTextIface *iface)
{
iface->get_text = gail_statusbar_get_text;
iface->get_character_at_offset = gail_statusbar_get_character_at_offset;
iface->get_text_before_offset = gail_statusbar_get_text_before_offset;
iface->get_text_at_offset = gail_statusbar_get_text_at_offset;
iface->get_text_after_offset = gail_statusbar_get_text_after_offset;
iface->get_character_count = gail_statusbar_get_character_count;
iface->get_character_extents = gail_statusbar_get_character_extents;
iface->get_offset_at_point = gail_statusbar_get_offset_at_point;
iface->get_run_attributes = gail_statusbar_get_run_attributes;
iface->get_default_attributes = gail_statusbar_get_default_attributes;
}
static gchar*
gail_statusbar_get_text (AtkText *text,
gint start_pos,
gint end_pos)
{
GtkWidget *widget;
GtkWidget *label;
GailStatusbar *statusbar;
const gchar *label_text;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return NULL;
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL (label))
return NULL;
statusbar = GAIL_STATUSBAR (text);
if (!statusbar->textutil)
gail_statusbar_init_textutil (statusbar, label);
label_text = gtk_label_get_text (GTK_LABEL (label));
if (label_text == NULL)
return NULL;
else
{
return gail_text_util_get_substring (statusbar->textutil,
start_pos, end_pos);
}
}
static gchar*
gail_statusbar_get_text_before_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
GailStatusbar *statusbar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return NULL;
/* Get label */
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return NULL;
statusbar = GAIL_STATUSBAR (text);
if (!statusbar->textutil)
gail_statusbar_init_textutil (statusbar, label);
return gail_text_util_get_text (statusbar->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_BEFORE_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gchar*
gail_statusbar_get_text_at_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
GailStatusbar *statusbar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return NULL;
/* Get label */
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return NULL;
statusbar = GAIL_STATUSBAR (text);
if (!statusbar->textutil)
gail_statusbar_init_textutil (statusbar, label);
return gail_text_util_get_text (statusbar->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_AT_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gchar*
gail_statusbar_get_text_after_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
GailStatusbar *statusbar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
{
/* State is defunct */
return NULL;
}
/* Get label */
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return NULL;
statusbar = GAIL_STATUSBAR (text);
if (!statusbar->textutil)
gail_statusbar_init_textutil (statusbar, label);
return gail_text_util_get_text (statusbar->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_AFTER_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gint
gail_statusbar_get_character_count (AtkText *text)
{
GtkWidget *widget;
GtkWidget *label;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return 0;
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return 0;
return g_utf8_strlen (gtk_label_get_text (GTK_LABEL (label)), -1);
}
static void
gail_statusbar_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords)
{
GtkWidget *widget;
GtkWidget *label;
PangoRectangle char_rect;
gint index, x_layout, y_layout;
const gchar *label_text;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return;
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return;
gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
label_text = gtk_label_get_text (GTK_LABEL (label));
index = g_utf8_offset_to_pointer (label_text, offset) - label_text;
pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (label)), index, &char_rect);
gail_misc_get_extents_from_pango_rectangle (label, &char_rect,
x_layout, y_layout, x, y, width, height, coords);
}
static gint
gail_statusbar_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords)
{
GtkWidget *widget;
GtkWidget *label;
gint index, x_layout, y_layout;
const gchar *label_text;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return -1;
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return -1;
gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
index = gail_misc_get_index_at_point_in_layout (label,
gtk_label_get_layout (GTK_LABEL (label)),
x_layout, y_layout, x, y, coords);
label_text = gtk_label_get_text (GTK_LABEL (label));
if (index == -1)
{
if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN)
return g_utf8_strlen (label_text, -1);
return index;
}
else
return g_utf8_pointer_to_offset (label_text, label_text + index);
}
static AtkAttributeSet*
gail_statusbar_get_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
AtkAttributeSet *at_set = NULL;
GtkJustification justify;
GtkTextDirection dir;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return NULL;
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return NULL;
/* Get values set for entire label, if any */
justify = gtk_label_get_justify (GTK_LABEL (label));
if (justify != GTK_JUSTIFY_CENTER)
{
at_set = gail_misc_add_attribute (at_set,
ATK_TEXT_ATTR_JUSTIFICATION,
g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, justify)));
}
dir = gtk_widget_get_direction (label);
if (dir == GTK_TEXT_DIR_RTL)
{
at_set = gail_misc_add_attribute (at_set,
ATK_TEXT_ATTR_DIRECTION,
g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, dir)));
}
at_set = gail_misc_layout_get_run_attributes (at_set,
gtk_label_get_layout (GTK_LABEL (label)),
(gchar *) gtk_label_get_text (GTK_LABEL (label)),
offset,
start_offset,
end_offset);
return at_set;
}
static AtkAttributeSet*
gail_statusbar_get_default_attributes (AtkText *text)
{
GtkWidget *widget;
GtkWidget *label;
AtkAttributeSet *at_set = NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return NULL;
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return NULL;
at_set = gail_misc_get_default_attributes (at_set,
gtk_label_get_layout (GTK_LABEL (label)),
widget);
return at_set;
}
static gunichar
gail_statusbar_get_character_at_offset (AtkText *text,
gint offset)
{
GtkWidget *widget;
GtkWidget *label;
const gchar *string;
gchar *index;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
/* State is defunct */
return '\0';
label = get_label_from_statusbar (widget);
if (!GTK_IS_LABEL(label))
return '\0';
string = gtk_label_get_text (GTK_LABEL (label));
if (offset >= g_utf8_strlen (string, -1))
return '\0';
index = g_utf8_offset_to_pointer (string, offset);
return g_utf8_get_char (index);
}
static GtkWidget*
get_label_from_statusbar (GtkWidget *statusbar)
{
GtkWidget *message_area;
GList *children, *l;
GtkWidget *child;
message_area = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
children = gtk_container_get_children (GTK_CONTAINER (message_area));
for (l = children; l; l = l->next)
{
child = l->data;
if (GTK_IS_LABEL (child))
break;
child = NULL;
}
g_list_free (children);
return child;
}

View File

@ -1,54 +0,0 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 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_STATUSBAR_H__
#define __GAIL_STATUSBAR_H__
#include "gailcontainer.h"
#include "gailtextutil.h"
G_BEGIN_DECLS
#define GAIL_TYPE_STATUSBAR (gail_statusbar_get_type ())
#define GAIL_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_STATUSBAR, GailStatusbar))
#define GAIL_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_STATUSBAR, GailStatusbarClass))
#define GAIL_IS_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_STATUSBAR))
#define GAIL_IS_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_STATUSBAR))
#define GAIL_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_STATUSBAR, GailStatusbarClass))
typedef struct _GailStatusbar GailStatusbar;
typedef struct _GailStatusbarClass GailStatusbarClass;
struct _GailStatusbar
{
GailContainer parent;
GailTextUtil *textutil;
};
GType gail_statusbar_get_type (void);
struct _GailStatusbarClass
{
GailContainerClass parent_class;
};
G_END_DECLS
#endif /* __GAIL_STATUSBAR_H__ */

View File

@ -0,0 +1,150 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 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 <string.h>
#include <gtk/gtk.h>
#include "gtkstatusbaraccessible.h"
G_DEFINE_TYPE (GtkStatusbarAccessible, gtk_statusbar_accessible, GAIL_TYPE_CONTAINER)
static void
text_changed (GtkStatusbar *statusbar,
guint context_id,
const gchar *text,
AtkObject *obj)
{
if (!obj->name)
g_object_notify (G_OBJECT (obj), "accessible-name");
g_signal_emit_by_name (obj, "visible-data-changed");
}
static void
gtk_statusbar_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkWidget *statusbar = data;
ATK_OBJECT_CLASS (gtk_statusbar_accessible_parent_class)->initialize (obj, data);
g_signal_connect_after (statusbar, "text-pushed",
G_CALLBACK (text_changed), obj);
g_signal_connect_after (statusbar, "text-popped",
G_CALLBACK (text_changed), obj);
obj->role = ATK_ROLE_STATUSBAR;
}
static GtkWidget *
find_label_child (GtkContainer *container)
{
GList *children, *tmp_list;
GtkWidget *child;
children = gtk_container_get_children (container);
child = NULL;
for (tmp_list = children; tmp_list != NULL; tmp_list = tmp_list->next)
{
if (GTK_IS_LABEL (tmp_list->data))
{
child = GTK_WIDGET (tmp_list->data);
break;
}
else if (GTK_IS_CONTAINER (tmp_list->data))
{
child = find_label_child (GTK_CONTAINER (tmp_list->data));
if (child)
break;
}
}
g_list_free (children);
return child;
}
static GtkWidget *
get_label_from_statusbar (GtkStatusbar *statusbar)
{
GtkWidget *box;
box = gtk_statusbar_get_message_area (statusbar);
return find_label_child (GTK_CONTAINER (box));
}
static const gchar *
gtk_statusbar_accessible_get_name (AtkObject *obj)
{
const gchar *name;
GtkWidget *widget;
GtkWidget *label;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
name = ATK_OBJECT_CLASS (gtk_statusbar_accessible_parent_class)->get_name (obj);
if (name != NULL)
return name;
label = get_label_from_statusbar (GTK_STATUSBAR (widget));
if (GTK_IS_LABEL (label))
return gtk_label_get_label (GTK_LABEL (label));
return NULL;
}
static gint
gtk_statusbar_accessible_get_n_children (AtkObject *obj)
{
return 0;
}
static AtkObject*
gtk_statusbar_accessible_ref_child (AtkObject *obj,
gint i)
{
return NULL;
}
static void
gtk_statusbar_accessible_class_init (GtkStatusbarAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GailContainerClass *container_class = (GailContainerClass*)klass;
class->get_name = gtk_statusbar_accessible_get_name;
class->get_n_children = gtk_statusbar_accessible_get_n_children;
class->ref_child = gtk_statusbar_accessible_ref_child;
class->initialize = gtk_statusbar_accessible_initialize;
/*
* As we report the statusbar as having no children
* we are not interested in add and remove signals
*/
container_class->add_gtk = NULL;
container_class->remove_gtk = NULL;
}
static void
gtk_statusbar_accessible_init (GtkStatusbarAccessible *bar)
{
}

View File

@ -0,0 +1,52 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 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_STATUSBAR_ACCESSIBLE_H__
#define __GTK_STATUSBAR_ACCESSIBLE_H__
#include "gailcontainer.h"
#include "gailtextutil.h"
G_BEGIN_DECLS
#define GTK_TYPE_STATUSBAR_ACCESSIBLE (gtk_statusbar_accessible_get_type ())
#define GTK_STATUSBAR_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_STATUSBAR_ACCESSIBLE, GtkStatusbarAccessible))
#define GTK_STATUSBAR_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STATUSBAR_ACCESSIBLE, GtkStatusbarAccessibleClass))
#define GTK_IS_STATUSBAR_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_STATUSBAR_ACCESSIBLE))
#define GTK_IS_STATUSBAR_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STATUSBAR_ACCESSIBLE))
#define GTK_STATUSBAR_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STATUSBAR_ACCESSIBLE, GtkStatusbarAccessibleClass))
typedef struct _GtkStatusbarAccessible GtkStatusbarAccessible;
typedef struct _GtkStatusbarAccessibleClass GtkStatusbarAccessibleClass;
struct _GtkStatusbarAccessible
{
GailContainer parent;
};
struct _GtkStatusbarAccessibleClass
{
GailContainerClass parent_class;
};
GType gtk_statusbar_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_STATUSBAR_ACCESSIBLE_H__ */

View File

@ -37,6 +37,7 @@
#include "gtkbuildable.h"
#include "gtkorientable.h"
#include "gtktypebuiltins.h"
#include "a11y/gtkstatusbaraccessible.h"
/**
* SECTION:gtkstatusbar
@ -185,6 +186,8 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
GTK_PARAM_READABLE));
g_type_class_add_private (class, sizeof (GtkStatusbarPrivate));
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_STATUSBAR_ACCESSIBLE);
}
static void

View File

@ -7,7 +7,7 @@ window1
layer: window
alpha: 1
statusbar1
"filler"
"statusbar"
parent: window1
index: 0
name:
@ -16,91 +16,3 @@ window1
<AtkComponent>
layer: widget
alpha: 1
<AtkText>
text:
character count: 0
caret offset: 0
default attributes: bg-color: <omitted>
bg-full-height: 0
bg-stipple: false
direction: <omitted>
editable: false
family-name: <omitted>
fg-color: <omitted>
fg-stipple: false
indent: 0
invisible: false
justification: left
language: <omitted>
left-margin: 0
pixels-above-lines: 0
pixels-below-lines: 0
pixels-inside-wrap: 0
right-margin: 0
rise: 0
scale: 1
size: <omitted>
stretch: <omitted>
strikethrough: false
style: <omitted>
underline: none
variant: <omitted>
weight: <omitted>
wrap-mode: word
unnamed-GtkFrameAccessible-0
"panel"
parent: statusbar1
index: 0
state: enabled sensitive showing visible
toolkit: gail
<AtkComponent>
layer: widget
alpha: 1
unnamed-GailContainer-1
"filler"
parent: unnamed-GtkFrameAccessible-0
index: 0
state: enabled horizontal sensitive showing visible
toolkit: gail
<AtkComponent>
layer: widget
alpha: 1
"label"
parent: unnamed-GailContainer-1
index: 0
name:
state: enabled multi-line sensitive showing visible
toolkit: gail
<AtkComponent>
layer: widget
alpha: 1
<AtkText>
text:
character count: 0
caret offset: 0
default attributes: bg-color: <omitted>
bg-full-height: 0
direction: <omitted>
editable: false
family-name: <omitted>
fg-color: <omitted>
indent: 0
invisible: false
justification: left
language: <omitted>
left-margin: 0
pixels-above-lines: 0
pixels-below-lines: 0
pixels-inside-wrap: 0
right-margin: 0
rise: 0
scale: 1
size: <omitted>
stretch: <omitted>
strikethrough: false
style: <omitted>
underline: none
variant: <omitted>
weight: <omitted>
wrap-mode: word