Convert GailScrolledWindow to GtkScrolledWindowAccessible

This commit is contained in:
Matthias Clasen 2011-06-28 23:13:27 -04:00
parent fecefc6cdf
commit 53c90cebb2
8 changed files with 255 additions and 275 deletions

View File

@ -38,7 +38,7 @@ gail_c_sources = \
gtkscaleaccessible.c \
gtkscalebuttonaccessible.c \
gtkscrollbaraccessible.c \
gailscrolledwindow.c \
gtkscrolledwindowaccessible.c \
gtkspinbuttonaccessible.c \
gailsubmenuitem.c \
gailstatusbar.c \
@ -89,7 +89,7 @@ gail_private_h_sources = \
gtkscaleaccessible.h \
gtkscalebuttonaccessible.h \
gtkscrollbaraccessible.h \
gailscrolledwindow.h \
gtkscrolledwindowaccessible.h \
gtkspinbuttonaccessible.h \
gailsubmenuitem.h \
gailstatusbar.h \

View File

@ -38,7 +38,6 @@
#include "gailnotebook.h"
#include "gailradiomenuitem.h"
#include "gailrenderercell.h"
#include "gailscrolledwindow.h"
#include "gailstatusbar.h"
#include "gailtextcell.h"
#include "gailtoplevel.h"
@ -104,7 +103,6 @@ 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 (GAIL_TYPE_NOTEBOOK, GailNotebook, gail_notebook, GTK_TYPE_NOTEBOOK)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TREE_VIEW, GailTreeView, gail_tree_view, GTK_TYPE_TREE_VIEW)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindow, gail_scrolled_window, GTK_TYPE_SCROLLED_WINDOW)
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)
@ -867,7 +865,6 @@ gail_accessibility_module_init (void)
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TOGGLE, gail_boolean_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_PIXBUF, gail_image_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER, gail_renderer_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLED_WINDOW, gail_scrolled_window);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CHECK_MENU_ITEM, gail_check_menu_item);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_MENU_ITEM, gail_radio_menu_item);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_EXPANDER, gail_expander);

View File

@ -1,214 +0,0 @@
/* GAIL - The GNOME Accessibility Enabling 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 "gailscrolledwindow.h"
static void gail_scrolled_window_class_init (GailScrolledWindowClass *klass);
static void gail_scrolled_window_init (GailScrolledWindow *window);
static void gail_scrolled_window_real_initialize
(AtkObject *obj,
gpointer data);
static gint gail_scrolled_window_get_n_children (AtkObject *object);
static AtkObject* gail_scrolled_window_ref_child (AtkObject *obj,
gint child);
static void gail_scrolled_window_scrollbar_visibility_changed
(GObject *object,
GParamSpec *pspec,
gpointer user_data);
G_DEFINE_TYPE (GailScrolledWindow, gail_scrolled_window, GAIL_TYPE_CONTAINER)
static void
gail_scrolled_window_class_init (GailScrolledWindowClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_n_children = gail_scrolled_window_get_n_children;
class->ref_child = gail_scrolled_window_ref_child;
class->initialize = gail_scrolled_window_real_initialize;
}
static void
gail_scrolled_window_init (GailScrolledWindow *window)
{
}
static void
gail_scrolled_window_real_initialize (AtkObject *obj,
gpointer data)
{
GtkScrolledWindow *window;
ATK_OBJECT_CLASS (gail_scrolled_window_parent_class)->initialize (obj, data);
window = GTK_SCROLLED_WINDOW (data);
g_signal_connect_data (gtk_scrolled_window_get_hscrollbar (window), "notify::visible",
G_CALLBACK (gail_scrolled_window_scrollbar_visibility_changed),
obj, NULL, FALSE);
g_signal_connect_data (gtk_scrolled_window_get_vscrollbar (window), "notify::visible",
G_CALLBACK (gail_scrolled_window_scrollbar_visibility_changed),
obj, NULL, FALSE);
obj->role = ATK_ROLE_SCROLL_PANE;
}
static gint
gail_scrolled_window_get_n_children (AtkObject *object)
{
GtkWidget *widget;
GtkScrolledWindow *gtk_window;
GList *children;
gint n_children;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (object));
if (widget == NULL)
/* Object is defunct */
return 0;
gtk_window = GTK_SCROLLED_WINDOW (widget);
/* Get the number of children returned by the backing GtkScrolledWindow */
children = gtk_container_get_children (GTK_CONTAINER(gtk_window));
n_children = g_list_length (children);
g_list_free (children);
/* Add one to the count for each visible scrollbar */
if (gtk_scrolled_window_get_hscrollbar (gtk_window))
n_children++;
if (gtk_scrolled_window_get_vscrollbar (gtk_window))
n_children++;
return n_children;
}
static AtkObject *
gail_scrolled_window_ref_child (AtkObject *obj,
gint child)
{
GtkWidget *widget;
GtkScrolledWindow *gtk_window;
GtkWidget *hscrollbar, *vscrollbar;
GList *children, *tmp_list;
gint n_children;
AtkObject *accessible = NULL;
g_return_val_if_fail (child >= 0, NULL);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
/* Object is defunct */
return NULL;
gtk_window = GTK_SCROLLED_WINDOW (widget);
hscrollbar = gtk_scrolled_window_get_hscrollbar (gtk_window);
vscrollbar = gtk_scrolled_window_get_vscrollbar (gtk_window);
children = gtk_container_get_children (GTK_CONTAINER (gtk_window));
n_children = g_list_length (children);
if (child == n_children)
{
if (gtk_scrolled_window_get_hscrollbar (gtk_window))
accessible = gtk_widget_get_accessible (hscrollbar);
else if (gtk_scrolled_window_get_vscrollbar (gtk_window))
accessible = gtk_widget_get_accessible (vscrollbar);
}
else if (child == n_children+1 &&
gtk_scrolled_window_get_hscrollbar (gtk_window) &&
gtk_scrolled_window_get_vscrollbar (gtk_window))
accessible = gtk_widget_get_accessible (vscrollbar);
else if (child < n_children)
{
tmp_list = g_list_nth (children, child);
if (tmp_list)
accessible = gtk_widget_get_accessible (
GTK_WIDGET (tmp_list->data));
}
g_list_free (children);
if (accessible)
g_object_ref (accessible);
return accessible;
}
static void
gail_scrolled_window_scrollbar_visibility_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
if (!strcmp (pspec->name, "visible"))
{
gint index;
gint n_children;
gboolean child_added = FALSE;
GList *children;
AtkObject *child;
GtkScrolledWindow *gtk_window;
GtkWidget *hscrollbar, *vscrollbar;
GailScrolledWindow *gail_window = GAIL_SCROLLED_WINDOW (user_data);
gchar *signal_name;
gtk_window = GTK_SCROLLED_WINDOW (gtk_accessible_get_widget (GTK_ACCESSIBLE (user_data)));
if (gtk_window == NULL)
return;
children = gtk_container_get_children (GTK_CONTAINER (gtk_window));
index = n_children = g_list_length (children);
g_list_free (children);
hscrollbar = gtk_scrolled_window_get_hscrollbar (gtk_window);
vscrollbar = gtk_scrolled_window_get_vscrollbar (gtk_window);
if ((gpointer) object == (gpointer) (hscrollbar))
{
if (gtk_scrolled_window_get_hscrollbar (gtk_window))
child_added = TRUE;
child = gtk_widget_get_accessible (hscrollbar);
}
else if ((gpointer) object == (gpointer) (vscrollbar))
{
if (gtk_scrolled_window_get_vscrollbar (gtk_window))
child_added = TRUE;
child = gtk_widget_get_accessible (vscrollbar);
if (gtk_scrolled_window_get_hscrollbar (gtk_window))
index = n_children+1;
}
else
{
g_assert_not_reached ();
return;
}
if (child_added)
signal_name = "children_changed::add";
else
signal_name = "children_changed::delete";
g_signal_emit_by_name (gail_window, signal_name, index, child, NULL);
}
}

View File

@ -1,51 +0,0 @@
/* GAIL - The GNOME Accessibility Implementation 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_SCROLLED_WINDOW_H__
#define __GAIL_SCROLLED_WINDOW_H__
#include "gailcontainer.h"
G_BEGIN_DECLS
#define GAIL_TYPE_SCROLLED_WINDOW (gail_scrolled_window_get_type ())
#define GAIL_SCROLLED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindow))
#define GAIL_SCROLLED_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindowClass))
#define GAIL_IS_SCROLLED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_SCROLLED_WINDOW))
#define GAIL_IS_SCROLLED_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_SCROLLED_WINDOW))
#define GAIL_SCROLLED_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindowClass))
typedef struct _GailScrolledWindow GailScrolledWindow;
typedef struct _GailScrolledWindowClass GailScrolledWindowClass;
struct _GailScrolledWindow
{
GailContainer parent;
};
GType gail_scrolled_window_get_type (void);
struct _GailScrolledWindowClass
{
GailContainerClass parent_class;
};
G_END_DECLS
#endif /* __GAIL_SCROLLED_WINDOW_H__ */

View File

@ -0,0 +1,195 @@
/* GAIL - The GNOME Accessibility Enabling 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 "gtkscrolledwindowaccessible.h"
G_DEFINE_TYPE (GtkScrolledWindowAccessible, gtk_scrolled_window_accessible, GAIL_TYPE_CONTAINER)
static void
visibility_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
if (!strcmp (pspec->name, "visible"))
{
gint index;
gint n_children;
gboolean child_added = FALSE;
GList *children;
AtkObject *child;
GtkWidget *widget;
GtkScrolledWindow *scrolled_window;
GtkWidget *hscrollbar, *vscrollbar;
GtkAccessible *accessible = GTK_ACCESSIBLE (user_data);
widget = gtk_accessible_get_widget (user_data);
if (widget == NULL)
return;
scrolled_window = GTK_SCROLLED_WINDOW (widget);
children = gtk_container_get_children (GTK_CONTAINER (widget));
index = n_children = g_list_length (children);
g_list_free (children);
hscrollbar = gtk_scrolled_window_get_hscrollbar (scrolled_window);
vscrollbar = gtk_scrolled_window_get_vscrollbar (scrolled_window);
if ((gpointer) object == (gpointer) (hscrollbar))
{
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
child_added = TRUE;
child = gtk_widget_get_accessible (hscrollbar);
}
else if ((gpointer) object == (gpointer) (vscrollbar))
{
if (gtk_scrolled_window_get_vscrollbar (scrolled_window))
child_added = TRUE;
child = gtk_widget_get_accessible (vscrollbar);
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
index = n_children + 1;
}
else
{
g_assert_not_reached ();
return;
}
if (child_added)
g_signal_emit_by_name (accessible, "children_changed::add", index, child, NULL);
else
g_signal_emit_by_name (accessible, "children_changed::delete", index, child, NULL);
}
}
static void
gtk_scrolled_window_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkScrolledWindow *window;
ATK_OBJECT_CLASS (gtk_scrolled_window_accessible_parent_class)->initialize (obj, data);
window = GTK_SCROLLED_WINDOW (data);
g_signal_connect_data (gtk_scrolled_window_get_hscrollbar (window), "notify::visible",
G_CALLBACK (visibility_changed),
obj, NULL, FALSE);
g_signal_connect_data (gtk_scrolled_window_get_vscrollbar (window), "notify::visible",
G_CALLBACK (visibility_changed),
obj, NULL, FALSE);
obj->role = ATK_ROLE_SCROLL_PANE;
}
static gint
gtk_scrolled_window_accessible_get_n_children (AtkObject *object)
{
GtkWidget *widget;
GtkScrolledWindow *scrolled_window;
GList *children;
gint n_children;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (object));
if (widget == NULL)
return 0;
scrolled_window = GTK_SCROLLED_WINDOW (widget);
children = gtk_container_get_children (GTK_CONTAINER (widget));
n_children = g_list_length (children);
g_list_free (children);
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
n_children++;
if (gtk_scrolled_window_get_vscrollbar (scrolled_window))
n_children++;
return n_children;
}
static AtkObject *
gtk_scrolled_window_accessible_ref_child (AtkObject *obj,
gint child)
{
GtkWidget *widget;
GtkScrolledWindow *scrolled_window;
GtkWidget *hscrollbar, *vscrollbar;
GList *children, *tmp_list;
gint n_children;
AtkObject *accessible = NULL;
g_return_val_if_fail (child >= 0, NULL);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
scrolled_window = GTK_SCROLLED_WINDOW (widget);
hscrollbar = gtk_scrolled_window_get_hscrollbar (scrolled_window);
vscrollbar = gtk_scrolled_window_get_vscrollbar (scrolled_window);
children = gtk_container_get_children (GTK_CONTAINER (widget));
n_children = g_list_length (children);
if (child == n_children)
{
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
accessible = gtk_widget_get_accessible (hscrollbar);
else if (gtk_scrolled_window_get_vscrollbar (scrolled_window))
accessible = gtk_widget_get_accessible (vscrollbar);
}
else if (child == n_children + 1 &&
gtk_scrolled_window_get_hscrollbar (scrolled_window) &&
gtk_scrolled_window_get_vscrollbar (scrolled_window))
accessible = gtk_widget_get_accessible (vscrollbar);
else if (child < n_children)
{
tmp_list = g_list_nth (children, child);
if (tmp_list)
accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
}
g_list_free (children);
if (accessible)
g_object_ref (accessible);
return accessible;
}
static void
gtk_scrolled_window_accessible_class_init (GtkScrolledWindowAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_n_children = gtk_scrolled_window_accessible_get_n_children;
class->ref_child = gtk_scrolled_window_accessible_ref_child;
class->initialize = gtk_scrolled_window_accessible_initialize;
}
static void
gtk_scrolled_window_accessible_init (GtkScrolledWindowAccessible *window)
{
}

View File

@ -0,0 +1,51 @@
/* GAIL - The GNOME Accessibility Implementation 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_SCROLLED_WINDOW_ACCESSIBLE_H__
#define __GTK_SCROLLED_WINDOW_ACCESSIBLE_H__
#include "gailcontainer.h"
G_BEGIN_DECLS
#define GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE (gtk_scrolled_window_accessible_get_type ())
#define GTK_SCROLLED_WINDOW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE, GtkScrolledWindowAccessible))
#define GTK_SCROLLED_WINDOW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE, GtkScrolledWindowAccessibleClass))
#define GTK_IS_SCROLLED_WINDOW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE))
#define GTK_IS_SCROLLED_WINDOW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE))
#define GTK_SCROLLED_WINDOW_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE, GtkScrolledWindowAccessibleClass))
typedef struct _GtkScrolledWindowAccessible GtkScrolledWindowAccessible;
typedef struct _GtkScrolledWindowAccessibleClass GtkScrolledWindowAccessibleClass;
struct _GtkScrolledWindowAccessible
{
GailContainer parent;
};
struct _GtkScrolledWindowAccessibleClass
{
GailContainerClass parent_class;
};
GType gtk_scrolled_window_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_SCROLLED_WINDOW_ACCESSIBLE_H__ */

View File

@ -37,7 +37,7 @@
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
#include "a11y/gtkscrolledwindowaccessible.h"
/**
* SECTION:gtkscrolledwindow
@ -479,6 +479,8 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
g_type_class_add_private (class, sizeof (GtkScrolledWindowPrivate));
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE);
}
static void

View File

@ -82,7 +82,7 @@ window1
<AtkComponent>
layer: widget
alpha: 1
unnamed-GailScrolledWindow-4
unnamed-GtkScrolledWindowAccessible-4
"scroll pane"
parent: unnamed-GailContainer-3
index: 0
@ -93,7 +93,7 @@ window1
alpha: 1
unnamed-GailTreeView-5
"table"
parent: unnamed-GailScrolledWindow-4
parent: unnamed-GtkScrolledWindowAccessible-4
index: 0
state: enabled focusable sensitive showing visible manages-descendants
toolkit: gail
@ -398,7 +398,7 @@ Click "Show other applications", for more options, or "Find applications online"
action 0 description: activate the cell
unnamed-GtkScrollbarAccessible-8
"scroll bar"
parent: unnamed-GailScrolledWindow-4
parent: unnamed-GtkScrolledWindowAccessible-4
index: 1
state: enabled horizontal sensitive
toolkit: gail
@ -414,7 +414,7 @@ Click "Show other applications", for more options, or "Find applications online"
minimum increment: 39.800000
unnamed-GtkScrollbarAccessible-9
"scroll bar"
parent: unnamed-GailScrolledWindow-4
parent: unnamed-GtkScrolledWindowAccessible-4
index: 2
state: enabled sensitive vertical
toolkit: gail