Commit 9a0fd43d authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Convert GailNotebookPage to GtkNotebookPageAccessible

At the same time, drop the AtkText implementation, and simplify
accordingly. Test output has been updated to match.
parent 8bb24a93
......@@ -26,7 +26,7 @@ gail_c_sources = \
gailmenushell.c \
gailmenuitem.c \
gtknotebookaccessible.c \
gailnotebookpage.c \
gtknotebookpageaccessible.c \
gtkpanedaccessible.c \
gtkprogressbaraccessible.c \
gtkradiobuttonaccessible.c \
......@@ -77,7 +77,7 @@ gail_private_h_sources = \
gailmenushell.h \
gailmenuitem.h \
gtknotebookaccessible.h \
gailnotebookpage.h \
gtknotebookpageaccessible.h \
gtkpanedaccessible.h \
gtkprogressbaraccessible.h \
gtkradiobuttonaccessible.h \
......
This diff is collapsed.
......@@ -26,7 +26,7 @@
#include <gdk/x11/gdkx.h>
#endif
#include "gailwidget.h"
#include "gailnotebookpage.h"
#include "gtknotebookpageaccessible.h"
extern GtkWidget *focus_widget;
......@@ -525,7 +525,7 @@ gail_widget_get_index_in_parent (AtkObject *accessible)
parent = accessible->accessible_parent;
if (GAIL_IS_NOTEBOOK_PAGE (parent))
if (GTK_IS_NOTEBOOK_PAGE_ACCESSIBLE (parent))
return 0;
else
{
......
......@@ -22,7 +22,7 @@
#include <string.h>
#include <gtk/gtk.h>
#include "gtknotebookaccessible.h"
#include "gailnotebookpage.h"
#include "gtknotebookpageaccessible.h"
static void atk_selection_interface_init (AtkSelectionIface *iface);
......@@ -92,7 +92,7 @@ create_notebook_page_accessible (GtkNotebookAccessible *accessible,
{
AtkObject *obj;
obj = gail_notebook_page_new (accessible, child);
obj = gtk_notebook_page_accessible_new (accessible, child);
g_hash_table_insert (accessible->pages, child, obj);
atk_object_set_parent (obj, ATK_OBJECT (accessible));
g_signal_emit_by_name (accessible, "children_changed::add", page_num, obj, NULL);
......@@ -127,7 +127,7 @@ page_removed_cb (GtkNotebook *notebook,
g_return_if_fail (obj);
g_signal_emit_by_name (accessible, "children_changed::remove",
page_num, obj, NULL);
gail_notebook_page_invalidate (GAIL_NOTEBOOK_PAGE (obj));
gtk_notebook_page_accessible_invalidate (GTK_NOTEBOOK_PAGE_ACCESSIBLE (obj));
g_hash_table_remove (accessible->pages, widget);
}
......
/* 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 "gtknotebookpageaccessible.h"
static void atk_component_interface_init (AtkComponentIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkNotebookPageAccessible, gtk_notebook_page_accessible, ATK_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
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_notebook_page (GtkNotebookPageAccessible *page)
{
GtkWidget *child;
GtkNotebook *notebook;
notebook = GTK_NOTEBOOK (gtk_accessible_get_widget (page->notebook));
if (!notebook)
return NULL;
if (!gtk_notebook_get_show_tabs (notebook))
return NULL;
child = gtk_notebook_get_tab_label (notebook, page->child);
if (GTK_IS_LABEL (child))
return child;
if (GTK_IS_CONTAINER (child))
child = find_label_child (GTK_CONTAINER (child));
return child;
}
static const gchar *
gtk_notebook_page_accessible_get_name (AtkObject *accessible)
{
GtkWidget *label;
if (accessible->name != NULL)
return accessible->name;
label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible));
if (GTK_IS_LABEL (label))
return gtk_label_get_text (GTK_LABEL (label));
return NULL;
}
static AtkObject *
gtk_notebook_page_accessible_get_parent (AtkObject *accessible)
{
GtkNotebookPageAccessible *page;
page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
return ATK_OBJECT (page->notebook);
}
static gint
gtk_notebook_page_accessible_get_n_children (AtkObject *accessible)
{
return 1;
}
static AtkObject *
gtk_notebook_page_accessible_ref_child (AtkObject *accessible,
gint i)
{
AtkObject *child_obj;
GtkNotebookPageAccessible *page = NULL;
if (i != 0)
return NULL;
page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
if (!page->child)
return NULL;
child_obj = gtk_widget_get_accessible (page->child);
g_object_ref (child_obj);
return child_obj;
}
static AtkStateSet *
gtk_notebook_page_accessible_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set, *label_state_set, *merged_state_set;
AtkObject *atk_label;
GtkWidget *label;
state_set = ATK_OBJECT_CLASS (gtk_notebook_page_accessible_parent_class)->ref_state_set (accessible);
label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible));
if (label)
{
atk_label = gtk_widget_get_accessible (label);
label_state_set = atk_object_ref_state_set (atk_label);
merged_state_set = atk_state_set_or_sets (state_set, label_state_set);
g_object_unref (label_state_set);
g_object_unref (state_set);
}
else
{
AtkObject *child;
child = atk_object_ref_accessible_child (accessible, 0);
if (!child)
return state_set;
merged_state_set = state_set;
state_set = atk_object_ref_state_set (child);
if (atk_state_set_contains_state (state_set, ATK_STATE_VISIBLE))
{
atk_state_set_add_state (merged_state_set, ATK_STATE_VISIBLE);
if (atk_state_set_contains_state (state_set, ATK_STATE_ENABLED))
atk_state_set_add_state (merged_state_set, ATK_STATE_ENABLED);
if (atk_state_set_contains_state (state_set, ATK_STATE_SHOWING))
atk_state_set_add_state (merged_state_set, ATK_STATE_SHOWING);
}
g_object_unref (state_set);
g_object_unref (child);
}
return merged_state_set;
}
static gint
gtk_notebook_page_accessible_get_index_in_parent (AtkObject *accessible)
{
GtkNotebookPageAccessible *page;
page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
if (!page->child)
return -1;
return gtk_notebook_page_num (GTK_NOTEBOOK (gtk_accessible_get_widget (page->notebook)),
page->child);
}
static void
gtk_notebook_page_accessible_class_init (GtkNotebookPageAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_name = gtk_notebook_page_accessible_get_name;
class->get_parent = gtk_notebook_page_accessible_get_parent;
class->get_n_children = gtk_notebook_page_accessible_get_n_children;
class->ref_child = gtk_notebook_page_accessible_ref_child;
class->ref_state_set = gtk_notebook_page_accessible_ref_state_set;
class->get_index_in_parent = gtk_notebook_page_accessible_get_index_in_parent;
}
static void
gtk_notebook_page_accessible_init (GtkNotebookPageAccessible *page)
{
}
static void
notify_tab_label (GObject *object,
GParamSpec *pspec,
AtkObject *atk_obj)
{
if (atk_obj->name == NULL)
g_object_notify (G_OBJECT (atk_obj), "accessible-name");
g_signal_emit_by_name (atk_obj, "visible-data-changed");
}
AtkObject *
gtk_notebook_page_accessible_new (GtkNotebookAccessible *notebook,
GtkWidget *child)
{
GObject *object;
AtkObject *atk_object;
GtkNotebookPageAccessible *page;
g_return_val_if_fail (GTK_IS_NOTEBOOK_ACCESSIBLE (notebook), NULL);
g_return_val_if_fail (GTK_WIDGET (child), NULL);
object = g_object_new (GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE, NULL);
page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (object);
page->notebook = GTK_ACCESSIBLE (notebook);
page->child = child;
atk_object = ATK_OBJECT (page);
atk_object->role = ATK_ROLE_PAGE_TAB;
atk_object->layer = ATK_LAYER_WIDGET;
g_signal_connect (gtk_accessible_get_widget (page->notebook),
"child-notify::tab-label",
G_CALLBACK (notify_tab_label), page);
return atk_object;
}
void
gtk_notebook_page_accessible_invalidate (GtkNotebookPageAccessible *page)
{
AtkObject *obj = ATK_OBJECT (page);
GtkWidget *notebook;
notebook = gtk_accessible_get_widget (page->notebook);
if (notebook)
g_signal_handlers_disconnect_by_func (notebook, notify_tab_label, page);
atk_object_notify_state_change (obj, ATK_STATE_DEFUNCT, TRUE);
atk_object_set_parent (obj, NULL);
page->notebook = NULL;
page->child = NULL;
}
static AtkObject*
gtk_notebook_page_accessible_ref_accessible_at_point (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type)
{
/* There is only one child so we return it */
AtkObject* child;
child = atk_object_ref_accessible_child (ATK_OBJECT (component), 0);
return child;
}
static void
gtk_notebook_page_accessible_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
GtkWidget *label;
AtkObject *atk_label;
label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (component));
if (!label)
{
AtkObject *child;
*width = 0;
*height = 0;
child = atk_object_ref_accessible_child (ATK_OBJECT (component), 0);
if (!child)
return;
atk_component_get_position (ATK_COMPONENT (child), x, y, coord_type);
g_object_unref (child);
}
else
{
atk_label = gtk_widget_get_accessible (label);
atk_component_get_extents (ATK_COMPONENT (atk_label),
x, y, width, height, coord_type);
}
}
static void
atk_component_interface_init (AtkComponentIface *iface)
{
/* We use the default implementations for contains, get_position, get_size */
iface->ref_accessible_at_point = gtk_notebook_page_accessible_ref_accessible_at_point;
iface->get_extents = gtk_notebook_page_accessible_get_extents;
}
......@@ -17,47 +17,45 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_NOTEBOOK_PAGE_H__
#define __GAIL_NOTEBOOK_PAGE_H__
#ifndef __GTK_NOTEBOOK_PAGE_ACCESSIBLE_H__
#define __GTK_NOTEBOOK_PAGE_ACCESSIBLE_H__
#include "gtknotebookaccessible.h"
#include "gailtextutil.h"
G_BEGIN_DECLS
#define GAIL_TYPE_NOTEBOOK_PAGE (gail_notebook_page_get_type ())
#define GAIL_NOTEBOOK_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),GAIL_TYPE_NOTEBOOK_PAGE, GailNotebookPage))
#define GAIL_NOTEBOOK_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_NOTEBOOK_PAGE, GailNotebookPageClass))
#define GAIL_IS_NOTEBOOK_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_NOTEBOOK_PAGE))
#define GAIL_IS_NOTEBOOK_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_NOTEBOOK_PAGE))
#define GAIL_NOTEBOOK_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_NOTEBOOK_PAGE, GailNotebookPageClass))
#define GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE (gtk_notebook_page_accessible_get_type ())
#define GTK_NOTEBOOK_PAGE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE, GtkNotebookPageAccessible))
#define GTK_NOTEBOOK_PAGE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE, GtkNotebookPageAccessibleClass))
#define GTK_IS_NOTEBOOK_PAGE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE))
#define GTK_IS_NOTEBOOK_PAGE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE))
#define GTK_NOTEBOOK_PAGE_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE, GtkNotebookPageAccessibleClass))
typedef struct _GailNotebookPage GailNotebookPage;
typedef struct _GailNotebookPageClass GailNotebookPageClass;
typedef struct _GtkNotebookPageAccessible GtkNotebookPageAccessible;
typedef struct _GtkNotebookPageAccessibleClass GtkNotebookPageAccessibleClass;
struct _GailNotebookPage
struct _GtkNotebookPageAccessible
{
AtkObject parent;
GtkAccessible *notebook;
GtkWidget *child;
GailTextUtil *textutil;
};
struct _GailNotebookPageClass
struct _GtkNotebookPageAccessibleClass
{
AtkObjectClass parent_class;
};
GType gail_notebook_page_get_type (void);
GType gtk_notebook_page_accessible_get_type (void);
AtkObject *gail_notebook_page_new (GtkNotebookAccessible *notebook,
GtkWidget *child);
AtkObject *gtk_notebook_page_accessible_new (GtkNotebookAccessible *notebook,
GtkWidget *child);
void gail_notebook_page_invalidate (GailNotebookPage *page);
void gtk_notebook_page_accessible_invalidate (GtkNotebookPageAccessible *page);
G_END_DECLS
#endif /* __GAIL_NOTEBOOK_PAGE_H__ */
#endif /* __GTK_NOTEBOOK_PAGE_ACCESSIBLE_H__ */
......@@ -86,8 +86,8 @@ window1
layer: widget
alpha: 1
<AtkSelection>
selected children: unnamed-GailNotebookPage-4
unnamed-GailNotebookPage-4
selected children: unnamed-GtkNotebookPageAccessible-4
unnamed-GtkNotebookPageAccessible-4
"page tab"
parent: unnamed-GtkNotebookAccessible-3
index: 0
......@@ -95,10 +95,6 @@ window1
<AtkComponent>
layer: widget
alpha: 1
<AtkText>
text: (null)
character count: 0
caret offset: 0
unnamed-GailContainer-5
"filler"
index: 0
......
......@@ -16,8 +16,8 @@ window1
layer: widget
alpha: 1
<AtkSelection>
selected children: Tab 1
Tab 1
selected children: unnamed-GtkNotebookPageAccessible-0
unnamed-GtkNotebookPageAccessible-0
"page tab"
parent: notebook1
index: 0
......@@ -26,37 +26,6 @@ window1
<AtkComponent>
layer: widget
alpha: 1
<AtkText>
text: Tab 1
character count: 5
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
page1
"push button"
index: 0
......@@ -103,7 +72,7 @@ window1
<AtkAction>
action 0 name: click
action 0 keybinding: <Alt>y
Tab 2
unnamed-GtkNotebookPageAccessible-1
"page tab"
parent: notebook1
index: 1
......@@ -112,37 +81,6 @@ window1
<AtkComponent>
layer: widget
alpha: 1
<AtkText>
text: Tab 2
character count: 5
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
page2
"push button"
index: 1
......
......@@ -70,7 +70,7 @@ window1
image description: (null)
<AtkAction>
action 0 name: click
unnamed-GailComboBox-0
unnamed-GtkComboBoxAccessible-0
"combo box"
parent: button4
index: 1
......@@ -84,7 +84,7 @@ window1
<AtkSelection>
unnamed-GailMenu-1
"menu"
parent: unnamed-GailComboBox-0
parent: unnamed-GtkComboBoxAccessible-0
index: 0
state: enabled selectable sensitive
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