Convert GailMenuShell to GtkMenuShellAccessible

This commit is contained in:
Matthias Clasen 2011-07-01 22:42:25 -04:00
parent 0e2f3271b9
commit 64eec8a97a
8 changed files with 115 additions and 169 deletions

View File

@ -24,7 +24,7 @@ gail_c_sources = \
gtklinkbuttonaccessible.c \
gailmisc.c \
gtkmenuaccessible.c \
gailmenushell.c \
gtkmenushellaccessible.c \
gtkmenuitemaccessible.c \
gtknotebookaccessible.c \
gtknotebookpageaccessible.c \
@ -76,7 +76,7 @@ gail_private_h_sources = \
gtklinkbuttonaccessible.h \
gailmisc.h \
gtkmenuaccessible.h \
gailmenushell.h \
gtkmenushellaccessible.h \
gtkmenuitemaccessible.h \
gtknotebookaccessible.h \
gtknotebookpageaccessible.h \

View File

@ -28,7 +28,6 @@
#include "gailcontainer.h"
#include "gailcontainercell.h"
#include "gailimagecell.h"
#include "gailmenushell.h"
#include "gailrenderercell.h"
#include "gailtextcell.h"
#include "gailtoplevel.h"
@ -81,7 +80,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_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)
@ -828,7 +826,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_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);

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_MENU_SHELL_H__
#define __GAIL_MENU_SHELL_H__
#include "gailcontainer.h"
G_BEGIN_DECLS
#define GAIL_TYPE_MENU_SHELL (gail_menu_shell_get_type ())
#define GAIL_MENU_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_MENU_SHELL, GailMenuShell))
#define GAIL_MENU_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_MENU_SHELL, GailMenuShellClass))
#define GAIL_IS_MENU_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_MENU_SHELL))
#define GAIL_IS_MENU_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_MENU_SHELL))
#define GAIL_MENU_SHELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_MENU_SHELL, GailMenuShellClass))
typedef struct _GailMenuShell GailMenuShell;
typedef struct _GailMenuShellClass GailMenuShellClass;
struct _GailMenuShell
{
GailContainer parent;
};
GType gail_menu_shell_get_type (void);
struct _GailMenuShellClass
{
GailContainerClass parent_class;
};
G_END_DECLS
#endif /* __GAIL_MENU_SHELL_H__ */

View File

@ -22,7 +22,7 @@
#include "gtkmenuaccessible.h"
G_DEFINE_TYPE (GtkMenuAccessible, gtk_menu_accessible, GAIL_TYPE_MENU_SHELL)
G_DEFINE_TYPE (GtkMenuAccessible, gtk_menu_accessible, GTK_TYPE_MENU_SHELL_ACCESSIBLE)
static void
gtk_menu_accessible_initialize (AtkObject *obj,

View File

@ -20,7 +20,7 @@
#ifndef __GTK_MENU_ACCESSIBLE_H__
#define __GTK_MENU_ACCESSIBLE_H__
#include "gailmenushell.h"
#include "gtkmenushellaccessible.h"
G_BEGIN_DECLS
@ -36,12 +36,12 @@ typedef struct _GtkMenuAccessibleClass GtkMenuAccessibleClass;
struct _GtkMenuAccessible
{
GailMenuShell parent;
GtkMenuShellAccessible parent;
};
struct _GtkMenuAccessibleClass
{
GailMenuShellClass parent_class;
GtkMenuShellAccessibleClass parent_class;
};
GType gtk_menu_accessible_get_type (void);

View File

@ -20,73 +20,42 @@
#include "config.h"
#include <gtk/gtk.h>
#include "gailmenushell.h"
#include "gtkmenushellaccessible.h"
static void gail_menu_shell_class_init (GailMenuShellClass *klass);
static void gail_menu_shell_init (GailMenuShell *menu_shell);
static void gail_menu_shell_initialize (AtkObject *accessible,
gpointer data);
static void atk_selection_interface_init (AtkSelectionIface *iface);
static gboolean gail_menu_shell_add_selection (AtkSelection *selection,
gint i);
static gboolean gail_menu_shell_clear_selection (AtkSelection *selection);
static AtkObject* gail_menu_shell_ref_selection (AtkSelection *selection,
gint i);
static gint gail_menu_shell_get_selection_count (AtkSelection *selection);
static gboolean gail_menu_shell_is_child_selected (AtkSelection *selection,
gint i);
static gboolean gail_menu_shell_remove_selection (AtkSelection *selection,
gint i);
G_DEFINE_TYPE_WITH_CODE (GailMenuShell, gail_menu_shell, GAIL_TYPE_CONTAINER,
static void atk_selection_interface_init (AtkSelectionIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkMenuShellAccessible, gtk_menu_shell_accessible, GAIL_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
static void
gail_menu_shell_class_init (GailMenuShellClass *klass)
gtk_menu_shell_accessible_initialize (AtkObject *accessible,
gpointer data)
{
AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
atk_object_class->initialize = gail_menu_shell_initialize;
}
static void
gail_menu_shell_init (GailMenuShell *menu_shell)
{
}
static void
gail_menu_shell_initialize (AtkObject *accessible,
gpointer data)
{
ATK_OBJECT_CLASS (gail_menu_shell_parent_class)->initialize (accessible, data);
ATK_OBJECT_CLASS (gtk_menu_shell_accessible_parent_class)->initialize (accessible, data);
if (GTK_IS_MENU_BAR (data))
accessible->role = ATK_ROLE_MENU_BAR;
else
/*
* Accessible object for Menu is created in gailmenu.c
*/
accessible->role = ATK_ROLE_UNKNOWN;
}
static void
atk_selection_interface_init (AtkSelectionIface *iface)
gtk_menu_shell_accessible_class_init (GtkMenuShellAccessibleClass *klass)
{
AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
atk_object_class->initialize = gtk_menu_shell_accessible_initialize;
}
static void
gtk_menu_shell_accessible_init (GtkMenuShellAccessible *menu_shell)
{
iface->add_selection = gail_menu_shell_add_selection;
iface->clear_selection = gail_menu_shell_clear_selection;
iface->ref_selection = gail_menu_shell_ref_selection;
iface->get_selection_count = gail_menu_shell_get_selection_count;
iface->is_child_selected = gail_menu_shell_is_child_selected;
iface->remove_selection = gail_menu_shell_remove_selection;
/*
* select_all_selection does not make sense for a menu_shell
* so no implementation is provided.
*/
}
static gboolean
gail_menu_shell_add_selection (AtkSelection *selection,
gint i)
gtk_menu_shell_accessible_add_selection (AtkSelection *selection,
gint i)
{
GList *kids;
GtkWidget *item;
@ -95,10 +64,7 @@ gail_menu_shell_add_selection (AtkSelection *selection,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
{
/* State is defunct */
return FALSE;
}
kids = gtk_container_get_children (GTK_CONTAINER (widget));
length = g_list_length (kids);
@ -110,23 +76,20 @@ gail_menu_shell_add_selection (AtkSelection *selection,
item = g_list_nth_data (kids, i);
g_list_free (kids);
g_return_val_if_fail (GTK_IS_MENU_ITEM(item), FALSE);
g_return_val_if_fail (GTK_IS_MENU_ITEM (item), FALSE);
gtk_menu_shell_select_item (GTK_MENU_SHELL (widget), item);
return TRUE;
}
static gboolean
gail_menu_shell_clear_selection (AtkSelection *selection)
gtk_menu_shell_accessible_clear_selection (AtkSelection *selection)
{
GtkMenuShell *shell;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
{
/* State is defunct */
return FALSE;
}
shell = GTK_MENU_SHELL (widget);
@ -134,71 +97,55 @@ gail_menu_shell_clear_selection (AtkSelection *selection)
return TRUE;
}
static AtkObject*
gail_menu_shell_ref_selection (AtkSelection *selection,
gint i)
static AtkObject *
gtk_menu_shell_accessible_ref_selection (AtkSelection *selection,
gint i)
{
GtkMenuShell *shell;
AtkObject *obj;
GtkWidget *widget;
GtkWidget *item;
if (i != 0)
return NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
{
/* State is defunct */
return NULL;
}
if (i != 0)
return NULL;
shell = GTK_MENU_SHELL (widget);
item = gtk_menu_shell_get_selected_item (shell);
if (item != NULL)
{
obj = gtk_widget_get_accessible (item);
g_object_ref (obj);
return obj;
}
else
{
return NULL;
}
{
obj = gtk_widget_get_accessible (item);
g_object_ref (obj);
return obj;
}
return NULL;
}
static gint
gail_menu_shell_get_selection_count (AtkSelection *selection)
gtk_menu_shell_accessible_get_selection_count (AtkSelection *selection)
{
GtkMenuShell *shell;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
{
/* State is defunct */
return 0;
}
shell = GTK_MENU_SHELL (widget);
/*
* Identifies the currently selected menu item
*/
if (gtk_menu_shell_get_selected_item (shell) == NULL)
{
return 0;
}
else
{
if (gtk_menu_shell_get_selected_item (shell) != NULL)
return 1;
}
return 0;
}
static gboolean
gail_menu_shell_is_child_selected (AtkSelection *selection,
gint i)
gtk_menu_shell_accessible_is_child_selected (AtkSelection *selection,
gint i)
{
GtkMenuShell *shell;
GList *kids;
@ -208,10 +155,7 @@ gail_menu_shell_is_child_selected (AtkSelection *selection,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
{
/* State is defunct */
return FALSE;
}
shell = GTK_MENU_SHELL (widget);
item = gtk_menu_shell_get_selected_item (shell);
@ -222,37 +166,39 @@ gail_menu_shell_is_child_selected (AtkSelection *selection,
j = g_list_index (kids, item);
g_list_free (kids);
return (j==i);
return j==i;
}
static gboolean
gail_menu_shell_remove_selection (AtkSelection *selection,
gint i)
gtk_menu_shell_accessible_remove_selection (AtkSelection *selection,
gint i)
{
GtkMenuShell *shell;
GtkWidget *widget;
GtkWidget *item;
if (i != 0)
return FALSE;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
{
/* State is defunct */
return FALSE;
}
if (i != 0)
return FALSE;
shell = GTK_MENU_SHELL (widget);
item = gtk_menu_shell_get_selected_item (shell);
if (item && gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)))
{
/*
* Menu item contains a menu and it is the selected menu item
* so deselect it.
*/
gtk_menu_shell_deselect (shell);
}
return TRUE;
}
static void
atk_selection_interface_init (AtkSelectionIface *iface)
{
iface->add_selection = gtk_menu_shell_accessible_add_selection;
iface->clear_selection = gtk_menu_shell_accessible_clear_selection;
iface->ref_selection = gtk_menu_shell_accessible_ref_selection;
iface->get_selection_count = gtk_menu_shell_accessible_get_selection_count;
iface->is_child_selected = gtk_menu_shell_accessible_is_child_selected;
iface->remove_selection = gtk_menu_shell_accessible_remove_selection;
}

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_MENU_SHELL_ACCESSIBLE_H__
#define __GTK_MENU_SHELL_ACCESSIBLE_H__
#include "gailcontainer.h"
G_BEGIN_DECLS
#define GTK_TYPE_MENU_SHELL_ACCESSIBLE (gtk_menu_shell_accessible_get_type ())
#define GTK_MENU_SHELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU_SHELL_ACCESSIBLE, GtkMenuShellAccessible))
#define GTK_MENU_SHELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU_SHELL_ACCESSIBLE, GtkMenuShellAccessibleClass))
#define GTK_IS_MENU_SHELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU_SHELL_ACCESSIBLE))
#define GTK_IS_MENU_SHELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU_SHELL_ACCESSIBLE))
#define GTK_MENU_SHELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU_SHELL_ACCESSIBLE, GtkMenuShellAccessibleClass))
typedef struct _GtkMenuShellAccessible GtkMenuShellAccessible;
typedef struct _GtkMenuShellAccessibleClass GtkMenuShellAccessibleClass;
struct _GtkMenuShellAccessible
{
GailContainer parent;
};
struct _GtkMenuShellAccessibleClass
{
GailContainerClass parent_class;
};
GType gtk_menu_shell_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_MENU_SHELL_ACCESSIBLE_H__ */

View File

@ -52,6 +52,7 @@
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
#include "a11y/gtkmenushellaccessible.h"
#define BORDER_SPACING 0
#define DEFAULT_IPADDING 1
@ -229,6 +230,8 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
GTK_PARAM_READABLE));
g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_MENU_SHELL_ACCESSIBLE);
}
static void