forked from AuroraMiddleware/gtk
Convert GailMenu to GtkMenuAccessible
This commit is contained in:
parent
ed08baccd9
commit
0e2f3271b9
@ -23,7 +23,7 @@ gail_c_sources = \
|
||||
gtklabelaccessible.c \
|
||||
gtklinkbuttonaccessible.c \
|
||||
gailmisc.c \
|
||||
gailmenu.c \
|
||||
gtkmenuaccessible.c \
|
||||
gailmenushell.c \
|
||||
gtkmenuitemaccessible.c \
|
||||
gtknotebookaccessible.c \
|
||||
@ -75,7 +75,7 @@ gail_private_h_sources = \
|
||||
gtklabelaccessible.h \
|
||||
gtklinkbuttonaccessible.h \
|
||||
gailmisc.h \
|
||||
gailmenu.h \
|
||||
gtkmenuaccessible.h \
|
||||
gailmenushell.h \
|
||||
gtkmenuitemaccessible.h \
|
||||
gtknotebookaccessible.h \
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "gailcontainer.h"
|
||||
#include "gailcontainercell.h"
|
||||
#include "gailimagecell.h"
|
||||
#include "gailmenu.h"
|
||||
#include "gailmenushell.h"
|
||||
#include "gailrenderercell.h"
|
||||
#include "gailtextcell.h"
|
||||
@ -83,7 +82,6 @@ static GQuark quark_focus_object = 0;
|
||||
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_WIDGET, GailWidget, gail_widget, GTK_TYPE_WIDGET)
|
||||
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_CONTAINER, GailContainer, gail_container, GTK_TYPE_CONTAINER)
|
||||
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_WITH_FUNC_DUMMY (GAIL_TYPE_RENDERER_CELL, GailRendererCell, gail_renderer_cell, GTK_TYPE_CELL_RENDERER, gail_renderer_cell_new)
|
||||
GAIL_IMPLEMENT_FACTORY_WITH_FUNC_DUMMY (GAIL_TYPE_BOOLEAN_CELL, GailBooleanCell, gail_boolean_cell, GTK_TYPE_CELL_RENDERER_TOGGLE, gail_boolean_cell_new)
|
||||
GAIL_IMPLEMENT_FACTORY_WITH_FUNC_DUMMY (GAIL_TYPE_IMAGE_CELL, GailImageCell, gail_image_cell, GTK_TYPE_CELL_RENDERER_PIXBUF, gail_image_cell_new)
|
||||
@ -831,7 +829,6 @@ gail_accessibility_module_init (void)
|
||||
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_WIDGET, gail_widget);
|
||||
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CONTAINER, gail_container);
|
||||
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_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);
|
||||
|
@ -1,126 +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 "gailmenu.h"
|
||||
|
||||
static void gail_menu_class_init (GailMenuClass *klass);
|
||||
static void gail_menu_init (GailMenu *accessible);
|
||||
|
||||
static void gail_menu_real_initialize (AtkObject *obj,
|
||||
gpointer data);
|
||||
|
||||
static AtkObject* gail_menu_get_parent (AtkObject *accessible);
|
||||
static gint gail_menu_get_index_in_parent (AtkObject *accessible);
|
||||
|
||||
G_DEFINE_TYPE (GailMenu, gail_menu, GAIL_TYPE_MENU_SHELL)
|
||||
|
||||
static void
|
||||
gail_menu_class_init (GailMenuClass *klass)
|
||||
{
|
||||
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
||||
|
||||
class->get_parent = gail_menu_get_parent;
|
||||
class->get_index_in_parent = gail_menu_get_index_in_parent;
|
||||
class->initialize = gail_menu_real_initialize;
|
||||
}
|
||||
|
||||
static void
|
||||
gail_menu_init (GailMenu *accessible)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gail_menu_real_initialize (AtkObject *obj,
|
||||
gpointer data)
|
||||
{
|
||||
ATK_OBJECT_CLASS (gail_menu_parent_class)->initialize (obj, data);
|
||||
|
||||
obj->role = ATK_ROLE_MENU;
|
||||
|
||||
g_object_set_data (G_OBJECT (obj), "atk-component-layer",
|
||||
GINT_TO_POINTER (ATK_LAYER_POPUP));
|
||||
}
|
||||
|
||||
static AtkObject*
|
||||
gail_menu_get_parent (AtkObject *accessible)
|
||||
{
|
||||
AtkObject *parent;
|
||||
|
||||
parent = accessible->accessible_parent;
|
||||
|
||||
if (parent != NULL)
|
||||
{
|
||||
g_return_val_if_fail (ATK_IS_OBJECT (parent), NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *widget, *parent_widget;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
||||
if (widget == NULL)
|
||||
{
|
||||
/*
|
||||
* State is defunct
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
g_return_val_if_fail (GTK_IS_MENU (widget), NULL);
|
||||
|
||||
/*
|
||||
* If the menu is attached to a menu item or a button (Gnome Menu)
|
||||
* report the menu item as parent.
|
||||
*/
|
||||
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
|
||||
|
||||
if (!GTK_IS_MENU_ITEM (parent_widget) && !GTK_IS_BUTTON (parent_widget) && !GTK_IS_COMBO_BOX (parent_widget))
|
||||
parent_widget = gtk_widget_get_parent (widget);
|
||||
|
||||
if (parent_widget == NULL)
|
||||
return NULL;
|
||||
|
||||
parent = gtk_widget_get_accessible (parent_widget);
|
||||
atk_object_set_parent (accessible, parent);
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
static gint
|
||||
gail_menu_get_index_in_parent (AtkObject *accessible)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
||||
|
||||
if (widget == NULL)
|
||||
{
|
||||
/*
|
||||
* State is defunct
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
g_return_val_if_fail (GTK_IS_MENU (widget), -1);
|
||||
|
||||
if (gtk_menu_get_attach_widget (GTK_MENU (widget)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ATK_OBJECT_CLASS (gail_menu_parent_class)->get_index_in_parent (accessible);
|
||||
}
|
@ -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_MENU_H__
|
||||
#define __GAIL_MENU_H__
|
||||
|
||||
#include "gailmenushell.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GAIL_TYPE_MENU (gail_menu_get_type ())
|
||||
#define GAIL_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_MENU_SHELL, GailMenu))
|
||||
#define GAIL_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_MENU, GailMenuClass))
|
||||
#define GAIL_IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_MENU))
|
||||
#define GAIL_IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_MENU))
|
||||
#define GAIL_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_MENU, GailMenuClass))
|
||||
|
||||
typedef struct _GailMenu GailMenu;
|
||||
typedef struct _GailMenuClass GailMenuClass;
|
||||
|
||||
struct _GailMenu
|
||||
{
|
||||
GailMenuShell parent;
|
||||
};
|
||||
|
||||
GType gail_menu_get_type (void);
|
||||
|
||||
struct _GailMenuClass
|
||||
{
|
||||
GailMenuShellClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GAIL_MENU_H__ */
|
100
gtk/a11y/gtkmenuaccessible.c
Normal file
100
gtk/a11y/gtkmenuaccessible.c
Normal file
@ -0,0 +1,100 @@
|
||||
/* 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 "gtkmenuaccessible.h"
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GtkMenuAccessible, gtk_menu_accessible, GAIL_TYPE_MENU_SHELL)
|
||||
|
||||
static void
|
||||
gtk_menu_accessible_initialize (AtkObject *obj,
|
||||
gpointer data)
|
||||
{
|
||||
ATK_OBJECT_CLASS (gtk_menu_accessible_parent_class)->initialize (obj, data);
|
||||
|
||||
obj->role = ATK_ROLE_MENU;
|
||||
|
||||
g_object_set_data (G_OBJECT (obj), "atk-component-layer",
|
||||
GINT_TO_POINTER (ATK_LAYER_POPUP));
|
||||
}
|
||||
|
||||
static AtkObject *
|
||||
gtk_menu_accessible_get_parent (AtkObject *accessible)
|
||||
{
|
||||
AtkObject *parent;
|
||||
GtkWidget *widget, *parent_widget;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
||||
if (widget == NULL)
|
||||
return NULL;
|
||||
|
||||
parent = accessible->accessible_parent;
|
||||
if (parent != NULL)
|
||||
return parent;
|
||||
|
||||
/* If the menu is attached to a menu item or a button (Gnome Menu)
|
||||
* report the menu item as parent.
|
||||
*/
|
||||
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
|
||||
|
||||
if (!GTK_IS_MENU_ITEM (parent_widget) &&
|
||||
!GTK_IS_BUTTON (parent_widget) &&
|
||||
!GTK_IS_COMBO_BOX (parent_widget))
|
||||
parent_widget = gtk_widget_get_parent (widget);
|
||||
|
||||
if (parent_widget == NULL)
|
||||
return NULL;
|
||||
|
||||
parent = gtk_widget_get_accessible (parent_widget);
|
||||
atk_object_set_parent (accessible, parent);
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_menu_accessible_get_index_in_parent (AtkObject *accessible)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
||||
if (widget == NULL)
|
||||
return -1;
|
||||
|
||||
if (gtk_menu_get_attach_widget (GTK_MENU (widget)))
|
||||
return 0;
|
||||
|
||||
return ATK_OBJECT_CLASS (gtk_menu_accessible_parent_class)->get_index_in_parent (accessible);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_accessible_class_init (GtkMenuAccessibleClass *klass)
|
||||
{
|
||||
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
||||
|
||||
class->get_parent = gtk_menu_accessible_get_parent;
|
||||
class->get_index_in_parent = gtk_menu_accessible_get_index_in_parent;
|
||||
class->initialize = gtk_menu_accessible_initialize;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_accessible_init (GtkMenuAccessible *accessible)
|
||||
{
|
||||
}
|
51
gtk/a11y/gtkmenuaccessible.h
Normal file
51
gtk/a11y/gtkmenuaccessible.h
Normal 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_MENU_ACCESSIBLE_H__
|
||||
#define __GTK_MENU_ACCESSIBLE_H__
|
||||
|
||||
#include "gailmenushell.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_MENU_ACCESSIBLE (gtk_menu_accessible_get_type ())
|
||||
#define GTK_MENU_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU_ACCESSIBLE, GtkMenuAccessible))
|
||||
#define GTK_MENU_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU_ACCESSIBLE, GtkMenuAccessibleClass))
|
||||
#define GTK_IS_MENU_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU_ACCESSIBLE))
|
||||
#define GTK_IS_MENU_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU_ACCESSIBLE))
|
||||
#define GTK_MENU_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU_ACCESSIBLE, GtkMenuAccessibleClass))
|
||||
|
||||
typedef struct _GtkMenuAccessible GtkMenuAccessible;
|
||||
typedef struct _GtkMenuAccessibleClass GtkMenuAccessibleClass;
|
||||
|
||||
struct _GtkMenuAccessible
|
||||
{
|
||||
GailMenuShell parent;
|
||||
};
|
||||
|
||||
struct _GtkMenuAccessibleClass
|
||||
{
|
||||
GailMenuShellClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_menu_accessible_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_MENU_ACCESSIBLE_H__ */
|
@ -113,6 +113,7 @@
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "a11y/gtkmenuaccessible.h"
|
||||
|
||||
#define NAVIGATION_REGION_OVERSHOOT 50 /* How much the navigation region
|
||||
* extends below the submenu
|
||||
@ -882,6 +883,8 @@ gtk_menu_class_init (GtkMenuClass *class)
|
||||
GTK_SCROLL_PAGE_DOWN);
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (GtkMenuPrivate));
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_MENU_ACCESSIBLE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ window1
|
||||
<AtkAction>
|
||||
action 0 name: press
|
||||
<AtkSelection>
|
||||
unnamed-GailMenu-2
|
||||
unnamed-GtkMenuAccessible-2
|
||||
"menu"
|
||||
parent: unnamed-GtkComboBoxAccessible-1
|
||||
index: 0
|
||||
@ -63,7 +63,7 @@ window1
|
||||
<AtkSelection>
|
||||
unnamed-GtkMenuItemAccessible-3
|
||||
"menu item"
|
||||
parent: unnamed-GailMenu-2
|
||||
parent: unnamed-GtkMenuAccessible-2
|
||||
index: 0
|
||||
state: enabled selectable sensitive visible
|
||||
toolkit: gail
|
||||
@ -74,7 +74,7 @@ window1
|
||||
action 0 name: click
|
||||
unnamed-GtkMenuItemAccessible-4
|
||||
"menu item"
|
||||
parent: unnamed-GailMenu-2
|
||||
parent: unnamed-GtkMenuAccessible-2
|
||||
index: 1
|
||||
name: File System
|
||||
state: enabled selectable sensitive visible
|
||||
@ -86,7 +86,7 @@ window1
|
||||
action 0 name: click
|
||||
unnamed-GtkMenuItemAccessible-5
|
||||
"menu item"
|
||||
parent: unnamed-GailMenu-2
|
||||
parent: unnamed-GtkMenuAccessible-2
|
||||
index: 2
|
||||
name: _F15-Livecd-Desk
|
||||
state: enabled selectable sensitive visible
|
||||
@ -98,7 +98,7 @@ window1
|
||||
action 0 name: click
|
||||
unnamed-GtkMenuItemAccessible-6
|
||||
"separator"
|
||||
parent: unnamed-GailMenu-2
|
||||
parent: unnamed-GtkMenuAccessible-2
|
||||
index: 3
|
||||
state: enabled selectable sensitive visible
|
||||
toolkit: gail
|
||||
@ -109,7 +109,7 @@ window1
|
||||
action 0 name: click
|
||||
unnamed-GtkMenuItemAccessible-7
|
||||
"separator"
|
||||
parent: unnamed-GailMenu-2
|
||||
parent: unnamed-GtkMenuAccessible-2
|
||||
index: 4
|
||||
state: enabled selectable sensitive visible
|
||||
toolkit: gail
|
||||
@ -120,7 +120,7 @@ window1
|
||||
action 0 name: click
|
||||
unnamed-GtkMenuItemAccessible-8
|
||||
"menu item"
|
||||
parent: unnamed-GailMenu-2
|
||||
parent: unnamed-GtkMenuAccessible-2
|
||||
index: 5
|
||||
name: Other...
|
||||
state: enabled selectable sensitive visible
|
||||
@ -171,7 +171,7 @@ window1
|
||||
<AtkAction>
|
||||
action 0 name: press
|
||||
<AtkSelection>
|
||||
unnamed-GailMenu-9
|
||||
unnamed-GtkMenuAccessible-9
|
||||
"menu"
|
||||
parent: button1
|
||||
index: 0
|
||||
|
Loading…
Reference in New Issue
Block a user