Commit 53c90ceb authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Convert GailScrolledWindow to GtkScrolledWindowAccessible

parent fecefc6c
......@@ -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 \
......
......@@ -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);
......
......@@ -21,96 +21,121 @@
#include <string.h>
#include <gtk/gtk.h>
#include "gailscrolledwindow.h"
#include "gtkscrolledwindowaccessible.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)
G_DEFINE_TYPE (GtkScrolledWindowAccessible, gtk_scrolled_window_accessible, GAIL_TYPE_CONTAINER)
static void
gail_scrolled_window_class_init (GailScrolledWindowClass *klass)
visibility_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
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);
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;
}
widget = gtk_accessible_get_widget (user_data);
if (widget == NULL)
return;
static void
gail_scrolled_window_init (GailScrolledWindow *window)
{
}
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
gail_scrolled_window_real_initialize (AtkObject *obj,
gpointer data)
gtk_scrolled_window_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkScrolledWindow *window;
ATK_OBJECT_CLASS (gail_scrolled_window_parent_class)->initialize (obj, data);
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 (gail_scrolled_window_scrollbar_visibility_changed),
G_CALLBACK (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),
G_CALLBACK (visibility_changed),
obj, NULL, FALSE);
obj->role = ATK_ROLE_SCROLL_PANE;
}
static gint
gail_scrolled_window_get_n_children (AtkObject *object)
gtk_scrolled_window_accessible_get_n_children (AtkObject *object)
{
GtkWidget *widget;
GtkScrolledWindow *gtk_window;
GtkScrolledWindow *scrolled_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 */
scrolled_window = GTK_SCROLLED_WINDOW (widget);
children = gtk_container_get_children (GTK_CONTAINER(gtk_window));
children = gtk_container_get_children (GTK_CONTAINER (widget));
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))
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
n_children++;
if (gtk_scrolled_window_get_vscrollbar (gtk_window))
if (gtk_scrolled_window_get_vscrollbar (scrolled_window))
n_children++;
return n_children;
}
static AtkObject *
gail_scrolled_window_ref_child (AtkObject *obj,
gint child)
gtk_scrolled_window_accessible_ref_child (AtkObject *obj,
gint child)
{
GtkWidget *widget;
GtkScrolledWindow *gtk_window;
GtkScrolledWindow *scrolled_window;
GtkWidget *hscrollbar, *vscrollbar;
GList *children, *tmp_list;
gint n_children;
......@@ -120,95 +145,51 @@ gail_scrolled_window_ref_child (AtkObject *obj,
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);
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 (gtk_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 (gtk_window))
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
accessible = gtk_widget_get_accessible (hscrollbar);
else if (gtk_scrolled_window_get_vscrollbar (gtk_window))
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 (gtk_window) &&
gtk_scrolled_window_get_vscrollbar (gtk_window))
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));
accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
}
g_list_free (children);
if (accessible)
g_object_ref (accessible);
return accessible;
return accessible;
}
static void
gail_scrolled_window_scrollbar_visibility_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
gtk_scrolled_window_accessible_class_init (GtkScrolledWindowAccessibleClass *klass)
{
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;
}
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
if (child_added)
signal_name = "children_changed::add";
else
signal_name = "children_changed::delete";
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;
}
g_signal_emit_by_name (gail_window, signal_name, index, child, NULL);
}
static void
gtk_scrolled_window_accessible_init (GtkScrolledWindowAccessible *window)
{
}
......@@ -17,35 +17,35 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_SCROLLED_WINDOW_H__
#define __GAIL_SCROLLED_WINDOW_H__
#ifndef __GTK_SCROLLED_WINDOW_ACCESSIBLE_H__
#define __GTK_SCROLLED_WINDOW_ACCESSIBLE_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))
#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 _GailScrolledWindow GailScrolledWindow;
typedef struct _GailScrolledWindowClass GailScrolledWindowClass;
typedef struct _GtkScrolledWindowAccessible GtkScrolledWindowAccessible;
typedef struct _GtkScrolledWindowAccessibleClass GtkScrolledWindowAccessibleClass;
struct _GailScrolledWindow
struct _GtkScrolledWindowAccessible
{
GailContainer parent;
};
GType gail_scrolled_window_get_type (void);
struct _GailScrolledWindowClass
struct _GtkScrolledWindowAccessibleClass
{
GailContainerClass parent_class;
};
GType gtk_scrolled_window_accessible_get_type (void);
G_END_DECLS
#endif /* __GAIL_SCROLLED_WINDOW_H__ */
#endif /* __GTK_SCROLLED_WINDOW_ACCESSIBLE_H__ */
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment