Commit 0e2f3271 authored by Matthias Clasen's avatar Matthias Clasen

Convert GailMenu to GtkMenuAccessible

parent ed08bacc
......@@ -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);
......
......@@ -19,108 +19,82 @@
#include "config.h"
#include "gailmenu.h"
#include "gtkmenuaccessible.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)
G_DEFINE_TYPE (GtkMenuAccessible, gtk_menu_accessible, GAIL_TYPE_MENU_SHELL)
static void
gail_menu_class_init (GailMenuClass *klass)
gtk_menu_accessible_initialize (AtkObject *obj,
gpointer data)
{
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);
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));
GINT_TO_POINTER (ATK_LAYER_POPUP));
}
static AtkObject*
gail_menu_get_parent (AtkObject *accessible)
static AtkObject *
gtk_menu_accessible_get_parent (AtkObject *accessible)
{
AtkObject *parent;
GtkWidget *widget, *parent_widget;
parent = accessible->accessible_parent;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
return NULL;
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;
/* 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)
gtk_menu_accessible_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);
return -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);
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)
{
}
......@@ -17,35 +17,35 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_MENU_H__
#define __GAIL_MENU_H__
#ifndef __GTK_MENU_ACCESSIBLE_H__
#define __GTK_MENU_ACCESSIBLE_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))
#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 _GailMenu GailMenu;
typedef struct _GailMenuClass GailMenuClass;
typedef struct _GtkMenuAccessible GtkMenuAccessible;
typedef struct _GtkMenuAccessibleClass GtkMenuAccessibleClass;
struct _GailMenu
struct _GtkMenuAccessible
{
GailMenuShell parent;
};
GType gail_menu_get_type (void);
struct _GailMenuClass
struct _GtkMenuAccessibleClass
{
GailMenuShellClass parent_class;
};
GType gtk_menu_accessible_get_type (void);
G_END_DECLS
#endif /* __GAIL_MENU_H__ */
#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
......
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