mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
Convert GailToplevel to GtkToplevelAccessible
This commit is contained in:
parent
9979e2a443
commit
56fb725a7e
@ -46,7 +46,7 @@ gail_c_sources = \
|
||||
gailtextcell.c \
|
||||
gtktextviewaccessible.c \
|
||||
gtktogglebuttonaccessible.c \
|
||||
gailtoplevel.c \
|
||||
gtktoplevelaccessible.c \
|
||||
gtktreeviewaccessible.c \
|
||||
gailutil.c \
|
||||
gtkwidgetaccessible.c \
|
||||
@ -97,7 +97,7 @@ gail_private_h_sources = \
|
||||
gailtextcell.h \
|
||||
gtktextviewaccessible.h \
|
||||
gtktogglebuttonaccessible.h \
|
||||
gailtoplevel.h \
|
||||
gtktoplevelaccessible.h \
|
||||
gtktreeviewaccessible.h \
|
||||
gailutil.h \
|
||||
gtkwindowaccessible.h
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gtk/gtkx.h>
|
||||
#include "gailtoplevel.h"
|
||||
#include "gailutil.h"
|
||||
|
||||
|
||||
|
@ -1,368 +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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtkx.h>
|
||||
|
||||
#include "gailtoplevel.h"
|
||||
|
||||
static void gail_toplevel_class_init (GailToplevelClass *klass);
|
||||
static void gail_toplevel_init (GailToplevel *toplevel);
|
||||
static void gail_toplevel_initialize (AtkObject *accessible,
|
||||
gpointer data);
|
||||
static void gail_toplevel_object_finalize (GObject *obj);
|
||||
|
||||
/* atkobject.h */
|
||||
|
||||
static gint gail_toplevel_get_n_children (AtkObject *obj);
|
||||
static AtkObject* gail_toplevel_ref_child (AtkObject *obj,
|
||||
gint i);
|
||||
static AtkObject* gail_toplevel_get_parent (AtkObject *obj);
|
||||
|
||||
/* Callbacks */
|
||||
|
||||
|
||||
static void gail_toplevel_window_destroyed (GtkWindow *window,
|
||||
GailToplevel *text);
|
||||
static gboolean gail_toplevel_hide_event_watcher (GSignalInvocationHint *ihint,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer data);
|
||||
static gboolean gail_toplevel_show_event_watcher (GSignalInvocationHint *ihint,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer data);
|
||||
|
||||
/* Misc */
|
||||
|
||||
static void _gail_toplevel_remove_child (GailToplevel *toplevel,
|
||||
GtkWindow *window);
|
||||
static gboolean is_attached_menu_window (GtkWidget *widget);
|
||||
static gboolean is_combo_window (GtkWidget *widget);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GailToplevel, gail_toplevel, ATK_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gail_toplevel_class_init (GailToplevelClass *klass)
|
||||
{
|
||||
AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
|
||||
GObjectClass *g_object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
class->initialize = gail_toplevel_initialize;
|
||||
class->get_n_children = gail_toplevel_get_n_children;
|
||||
class->ref_child = gail_toplevel_ref_child;
|
||||
class->get_parent = gail_toplevel_get_parent;
|
||||
|
||||
g_object_class->finalize = gail_toplevel_object_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gail_toplevel_init (GailToplevel *toplevel)
|
||||
{
|
||||
GtkWindow *window;
|
||||
GtkWidget *widget;
|
||||
GList *l;
|
||||
guint signal_id;
|
||||
|
||||
l = toplevel->window_list = gtk_window_list_toplevels ();
|
||||
|
||||
while (l)
|
||||
{
|
||||
window = GTK_WINDOW (l->data);
|
||||
widget = GTK_WIDGET (window);
|
||||
if (!window ||
|
||||
!gtk_widget_get_visible (widget) ||
|
||||
is_attached_menu_window (widget) ||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GTK_IS_PLUG (window) ||
|
||||
#endif
|
||||
gtk_widget_get_parent (GTK_WIDGET (window)))
|
||||
{
|
||||
GList *temp_l = l->next;
|
||||
|
||||
toplevel->window_list = g_list_delete_link (toplevel->window_list, l);
|
||||
l = temp_l;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_connect (G_OBJECT (window),
|
||||
"destroy",
|
||||
G_CALLBACK (gail_toplevel_window_destroyed),
|
||||
toplevel);
|
||||
l = l->next;
|
||||
}
|
||||
}
|
||||
|
||||
g_type_class_ref (GTK_TYPE_WINDOW);
|
||||
|
||||
signal_id = g_signal_lookup ("show", GTK_TYPE_WINDOW);
|
||||
g_signal_add_emission_hook (signal_id, 0,
|
||||
gail_toplevel_show_event_watcher, toplevel, (GDestroyNotify) NULL);
|
||||
|
||||
signal_id = g_signal_lookup ("hide", GTK_TYPE_WINDOW);
|
||||
g_signal_add_emission_hook (signal_id, 0,
|
||||
gail_toplevel_hide_event_watcher, toplevel, (GDestroyNotify) NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gail_toplevel_initialize (AtkObject *accessible,
|
||||
gpointer data)
|
||||
{
|
||||
ATK_OBJECT_CLASS (gail_toplevel_parent_class)->initialize (accessible, data);
|
||||
|
||||
accessible->role = ATK_ROLE_APPLICATION;
|
||||
accessible->name = g_get_prgname();
|
||||
accessible->accessible_parent = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gail_toplevel_object_finalize (GObject *obj)
|
||||
{
|
||||
GailToplevel *toplevel = GAIL_TOPLEVEL (obj);
|
||||
|
||||
if (toplevel->window_list)
|
||||
g_list_free (toplevel->window_list);
|
||||
|
||||
G_OBJECT_CLASS (gail_toplevel_parent_class)->finalize (obj);
|
||||
}
|
||||
|
||||
static AtkObject*
|
||||
gail_toplevel_get_parent (AtkObject *obj)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
gail_toplevel_get_n_children (AtkObject *obj)
|
||||
{
|
||||
GailToplevel *toplevel = GAIL_TOPLEVEL (obj);
|
||||
|
||||
gint rc = g_list_length (toplevel->window_list);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static AtkObject*
|
||||
gail_toplevel_ref_child (AtkObject *obj,
|
||||
gint i)
|
||||
{
|
||||
GailToplevel *toplevel;
|
||||
gpointer ptr;
|
||||
GtkWidget *widget;
|
||||
AtkObject *atk_obj;
|
||||
|
||||
toplevel = GAIL_TOPLEVEL (obj);
|
||||
ptr = g_list_nth_data (toplevel->window_list, i);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
widget = GTK_WIDGET (ptr);
|
||||
atk_obj = gtk_widget_get_accessible (widget);
|
||||
|
||||
g_object_ref (atk_obj);
|
||||
return atk_obj;
|
||||
}
|
||||
|
||||
/*
|
||||
* Window destroy events on GtkWindow cause a child to be removed
|
||||
* from the toplevel
|
||||
*/
|
||||
static void
|
||||
gail_toplevel_window_destroyed (GtkWindow *window,
|
||||
GailToplevel *toplevel)
|
||||
{
|
||||
_gail_toplevel_remove_child (toplevel, window);
|
||||
}
|
||||
|
||||
/*
|
||||
* Show events cause a child to be added to the toplevel
|
||||
*/
|
||||
static gboolean
|
||||
gail_toplevel_show_event_watcher (GSignalInvocationHint *ihint,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer data)
|
||||
{
|
||||
GailToplevel *toplevel = GAIL_TOPLEVEL (data);
|
||||
AtkObject *atk_obj = ATK_OBJECT (toplevel);
|
||||
GObject *object;
|
||||
GtkWidget *widget;
|
||||
gint n_children;
|
||||
AtkObject *child;
|
||||
|
||||
object = g_value_get_object (param_values + 0);
|
||||
|
||||
if (!GTK_IS_WINDOW (object))
|
||||
return TRUE;
|
||||
|
||||
widget = GTK_WIDGET (object);
|
||||
if (gtk_widget_get_parent (widget) ||
|
||||
is_attached_menu_window (widget) ||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GTK_IS_PLUG (widget) ||
|
||||
#endif
|
||||
is_combo_window (widget))
|
||||
return TRUE;
|
||||
|
||||
child = gtk_widget_get_accessible (widget);
|
||||
if (atk_object_get_role (child) == ATK_ROLE_REDUNDANT_OBJECT)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the window to the list & emit the signal.
|
||||
* Don't do this for tooltips (Bug #150649).
|
||||
*/
|
||||
if (atk_object_get_role (child) == ATK_ROLE_TOOL_TIP)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
toplevel->window_list = g_list_append (toplevel->window_list, widget);
|
||||
|
||||
n_children = g_list_length (toplevel->window_list);
|
||||
|
||||
/*
|
||||
* Must subtract 1 from the n_children since the index is 0-based
|
||||
* but g_list_length is 1-based.
|
||||
*/
|
||||
atk_object_set_parent (child, atk_obj);
|
||||
g_signal_emit_by_name (atk_obj, "children-changed::add",
|
||||
n_children - 1,
|
||||
child, NULL);
|
||||
|
||||
/* Connect destroy signal callback */
|
||||
g_signal_connect (G_OBJECT(object),
|
||||
"destroy",
|
||||
G_CALLBACK (gail_toplevel_window_destroyed),
|
||||
toplevel);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hide events on GtkWindow cause a child to be removed from the toplevel
|
||||
*/
|
||||
static gboolean
|
||||
gail_toplevel_hide_event_watcher (GSignalInvocationHint *ihint,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer data)
|
||||
{
|
||||
GailToplevel *toplevel = GAIL_TOPLEVEL (data);
|
||||
GObject *object;
|
||||
|
||||
object = g_value_get_object (param_values + 0);
|
||||
|
||||
if (!GTK_IS_WINDOW (object))
|
||||
return TRUE;
|
||||
|
||||
_gail_toplevel_remove_child (toplevel, GTK_WINDOW (object));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common code used by destroy and hide events on GtkWindow
|
||||
*/
|
||||
static void
|
||||
_gail_toplevel_remove_child (GailToplevel *toplevel,
|
||||
GtkWindow *window)
|
||||
{
|
||||
AtkObject *atk_obj = ATK_OBJECT (toplevel);
|
||||
GList *l;
|
||||
guint window_count = 0;
|
||||
AtkObject *child;
|
||||
|
||||
if (toplevel->window_list)
|
||||
{
|
||||
GtkWindow *tmp_window;
|
||||
|
||||
/* Must loop through them all */
|
||||
for (l = toplevel->window_list; l; l = l->next)
|
||||
{
|
||||
tmp_window = GTK_WINDOW (l->data);
|
||||
|
||||
if (window == tmp_window)
|
||||
{
|
||||
/* Remove the window from the window_list & emit the signal */
|
||||
toplevel->window_list = g_list_remove (toplevel->window_list,
|
||||
l->data);
|
||||
child = gtk_widget_get_accessible (GTK_WIDGET (window));
|
||||
g_signal_emit_by_name (atk_obj, "children-changed::remove",
|
||||
window_count,
|
||||
child, NULL);
|
||||
atk_object_set_parent (child, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
window_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_attached_menu_window (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *child;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
if (GTK_IS_MENU (child))
|
||||
{
|
||||
GtkWidget *attach;
|
||||
|
||||
attach = gtk_menu_get_attach_widget (GTK_MENU (child));
|
||||
/* Allow for menu belonging to the Panel Menu, which is a GtkButton */
|
||||
if (GTK_IS_MENU_ITEM (attach) ||
|
||||
GTK_IS_BUTTON (attach))
|
||||
ret = TRUE;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_combo_window (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *child;
|
||||
AtkObject *obj;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
|
||||
if (!GTK_IS_EVENT_BOX (child))
|
||||
return FALSE;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (child));
|
||||
|
||||
if (!GTK_IS_FRAME (child))
|
||||
return FALSE;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (child));
|
||||
|
||||
if (!GTK_IS_SCROLLED_WINDOW (child))
|
||||
return FALSE;
|
||||
|
||||
obj = gtk_widget_get_accessible (child);
|
||||
obj = atk_object_get_parent (obj);
|
||||
|
||||
return FALSE;
|
||||
}
|
@ -1,52 +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_TOPLEVEL_H__
|
||||
#define __GAIL_TOPLEVEL_H__
|
||||
|
||||
#include <atk/atk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GAIL_TYPE_TOPLEVEL (gail_toplevel_get_type ())
|
||||
#define GAIL_TOPLEVEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_TOPLEVEL, GailToplevel))
|
||||
#define GAIL_TOPLEVEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_TOPLEVEL, GailToplevelClass))
|
||||
#define GAIL_IS_TOPLEVEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_TOPLEVEL))
|
||||
#define GAIL_IS_TOPLEVEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_TOPLEVEL))
|
||||
#define GAIL_TOPLEVEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_TOPLEVEL, GailToplevelClass))
|
||||
|
||||
typedef struct _GailToplevel GailToplevel;
|
||||
typedef struct _GailToplevelClass GailToplevelClass;
|
||||
|
||||
struct _GailToplevel
|
||||
{
|
||||
AtkObject parent;
|
||||
GList *window_list;
|
||||
};
|
||||
|
||||
GType gail_toplevel_get_type (void);
|
||||
|
||||
struct _GailToplevelClass
|
||||
{
|
||||
AtkObjectClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GAIL_TOPLEVEL_H__ */
|
@ -23,7 +23,7 @@
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "gailutil.h"
|
||||
#include "gailtoplevel.h"
|
||||
#include "gtktoplevelaccessible.h"
|
||||
#include "gtkwindowaccessible.h"
|
||||
|
||||
static void gail_util_class_init (GailUtilClass *klass);
|
||||
@ -320,12 +320,12 @@ gail_util_remove_key_event_listener (guint listener_key)
|
||||
}
|
||||
}
|
||||
|
||||
static AtkObject*
|
||||
static AtkObject *
|
||||
gail_util_get_root (void)
|
||||
{
|
||||
if (!root)
|
||||
{
|
||||
root = g_object_new (GAIL_TYPE_TOPLEVEL, NULL);
|
||||
root = g_object_new (GTK_TYPE_TOPLEVEL_ACCESSIBLE, NULL);
|
||||
atk_object_initialize (root, NULL);
|
||||
}
|
||||
|
||||
|
283
gtk/a11y/gtktoplevelaccessible.c
Normal file
283
gtk/a11y/gtktoplevelaccessible.c
Normal file
@ -0,0 +1,283 @@
|
||||
/* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtkx.h>
|
||||
|
||||
#include "gtktoplevelaccessible.h"
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GtkToplevelAccessible, gtk_toplevel_accessible, ATK_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_toplevel_accessible_initialize (AtkObject *accessible,
|
||||
gpointer data)
|
||||
{
|
||||
ATK_OBJECT_CLASS (gtk_toplevel_accessible_parent_class)->initialize (accessible, data);
|
||||
|
||||
accessible->role = ATK_ROLE_APPLICATION;
|
||||
accessible->name = g_get_prgname ();
|
||||
accessible->accessible_parent = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toplevel_accessible_object_finalize (GObject *obj)
|
||||
{
|
||||
GtkToplevelAccessible *toplevel = GTK_TOPLEVEL_ACCESSIBLE (obj);
|
||||
|
||||
if (toplevel->window_list)
|
||||
g_list_free (toplevel->window_list);
|
||||
|
||||
G_OBJECT_CLASS (gtk_toplevel_accessible_parent_class)->finalize (obj);
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_toplevel_accessible_get_n_children (AtkObject *obj)
|
||||
{
|
||||
GtkToplevelAccessible *toplevel = GTK_TOPLEVEL_ACCESSIBLE (obj);
|
||||
|
||||
return g_list_length (toplevel->window_list);
|
||||
}
|
||||
|
||||
static AtkObject *
|
||||
gtk_toplevel_accessible_ref_child (AtkObject *obj,
|
||||
gint i)
|
||||
{
|
||||
GtkToplevelAccessible *toplevel;
|
||||
GtkWidget *widget;
|
||||
AtkObject *atk_obj;
|
||||
|
||||
toplevel = GTK_TOPLEVEL_ACCESSIBLE (obj);
|
||||
widget = g_list_nth_data (toplevel->window_list, i);
|
||||
if (!widget)
|
||||
return NULL;
|
||||
|
||||
atk_obj = gtk_widget_get_accessible (widget);
|
||||
|
||||
g_object_ref (atk_obj);
|
||||
|
||||
return atk_obj;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_combo_window (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *child;
|
||||
AtkObject *obj;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
|
||||
if (!GTK_IS_EVENT_BOX (child))
|
||||
return FALSE;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (child));
|
||||
|
||||
if (!GTK_IS_FRAME (child))
|
||||
return FALSE;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (child));
|
||||
|
||||
if (!GTK_IS_SCROLLED_WINDOW (child))
|
||||
return FALSE;
|
||||
|
||||
obj = gtk_widget_get_accessible (child);
|
||||
obj = atk_object_get_parent (obj);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_attached_menu_window (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
if (GTK_IS_MENU (child))
|
||||
{
|
||||
GtkWidget *attach;
|
||||
|
||||
attach = gtk_menu_get_attach_widget (GTK_MENU (child));
|
||||
/* Allow for menu belonging to the Panel Menu, which is a GtkButton */
|
||||
if (GTK_IS_MENU_ITEM (attach) || GTK_IS_BUTTON (attach))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toplevel_accessible_class_init (GtkToplevelAccessibleClass *klass)
|
||||
{
|
||||
AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
|
||||
GObjectClass *g_object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
class->initialize = gtk_toplevel_accessible_initialize;
|
||||
class->get_n_children = gtk_toplevel_accessible_get_n_children;
|
||||
class->ref_child = gtk_toplevel_accessible_ref_child;
|
||||
class->get_parent = NULL;
|
||||
|
||||
g_object_class->finalize = gtk_toplevel_accessible_object_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_child (GtkToplevelAccessible *toplevel,
|
||||
GtkWindow *window)
|
||||
{
|
||||
AtkObject *atk_obj = ATK_OBJECT (toplevel);
|
||||
GList *l;
|
||||
guint window_count = 0;
|
||||
AtkObject *child;
|
||||
|
||||
if (toplevel->window_list)
|
||||
{
|
||||
GtkWindow *tmp_window;
|
||||
|
||||
for (l = toplevel->window_list; l; l = l->next)
|
||||
{
|
||||
tmp_window = GTK_WINDOW (l->data);
|
||||
|
||||
if (window == tmp_window)
|
||||
{
|
||||
/* Remove the window from the window_list & emit the signal */
|
||||
toplevel->window_list = g_list_delete_link (toplevel->window_list, l);
|
||||
child = gtk_widget_get_accessible (GTK_WIDGET (window));
|
||||
g_signal_emit_by_name (atk_obj, "children-changed::remove",
|
||||
window_count, child, NULL);
|
||||
atk_object_set_parent (child, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
window_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
show_event_watcher (GSignalInvocationHint *ihint,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer data)
|
||||
{
|
||||
GtkToplevelAccessible *toplevel = GTK_TOPLEVEL_ACCESSIBLE (data);
|
||||
AtkObject *atk_obj = ATK_OBJECT (toplevel);
|
||||
GObject *object;
|
||||
GtkWidget *widget;
|
||||
gint n_children;
|
||||
AtkObject *child;
|
||||
|
||||
object = g_value_get_object (param_values + 0);
|
||||
|
||||
if (!GTK_IS_WINDOW (object))
|
||||
return TRUE;
|
||||
|
||||
widget = GTK_WIDGET (object);
|
||||
if (gtk_widget_get_parent (widget) ||
|
||||
is_attached_menu_window (widget) ||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GTK_IS_PLUG (widget) ||
|
||||
#endif
|
||||
is_combo_window (widget))
|
||||
return TRUE;
|
||||
|
||||
child = gtk_widget_get_accessible (widget);
|
||||
if (atk_object_get_role (child) == ATK_ROLE_REDUNDANT_OBJECT ||
|
||||
atk_object_get_role (child) == ATK_ROLE_TOOL_TIP)
|
||||
return TRUE;
|
||||
|
||||
/* Add the window to the list & emit the signal */
|
||||
toplevel->window_list = g_list_append (toplevel->window_list, widget);
|
||||
n_children = g_list_length (toplevel->window_list);
|
||||
|
||||
atk_object_set_parent (child, atk_obj);
|
||||
g_signal_emit_by_name (atk_obj, "children-changed::add",
|
||||
n_children - 1, child, NULL);
|
||||
|
||||
g_signal_connect_swapped (G_OBJECT(object), "destroy",
|
||||
G_CALLBACK (remove_child), toplevel);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
hide_event_watcher (GSignalInvocationHint *ihint,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer data)
|
||||
{
|
||||
GtkToplevelAccessible *toplevel = GTK_TOPLEVEL_ACCESSIBLE (data);
|
||||
GObject *object;
|
||||
|
||||
object = g_value_get_object (param_values + 0);
|
||||
|
||||
if (!GTK_IS_WINDOW (object))
|
||||
return TRUE;
|
||||
|
||||
remove_child (toplevel, GTK_WINDOW (object));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toplevel_accessible_init (GtkToplevelAccessible *toplevel)
|
||||
{
|
||||
GtkWindow *window;
|
||||
GtkWidget *widget;
|
||||
GList *l;
|
||||
guint signal_id;
|
||||
|
||||
l = toplevel->window_list = gtk_window_list_toplevels ();
|
||||
|
||||
while (l)
|
||||
{
|
||||
window = GTK_WINDOW (l->data);
|
||||
widget = GTK_WIDGET (window);
|
||||
if (!window ||
|
||||
!gtk_widget_get_visible (widget) ||
|
||||
is_attached_menu_window (widget) ||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GTK_IS_PLUG (window) ||
|
||||
#endif
|
||||
gtk_widget_get_parent (GTK_WIDGET (window)))
|
||||
{
|
||||
GList *temp_l = l->next;
|
||||
|
||||
toplevel->window_list = g_list_delete_link (toplevel->window_list, l);
|
||||
l = temp_l;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_connect_swapped (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (remove_child), toplevel);
|
||||
l = l->next;
|
||||
}
|
||||
}
|
||||
|
||||
g_type_class_ref (GTK_TYPE_WINDOW);
|
||||
|
||||
signal_id = g_signal_lookup ("show", GTK_TYPE_WINDOW);
|
||||
g_signal_add_emission_hook (signal_id, 0,
|
||||
show_event_watcher, toplevel, (GDestroyNotify) NULL);
|
||||
|
||||
signal_id = g_signal_lookup ("hide", GTK_TYPE_WINDOW);
|
||||
g_signal_add_emission_hook (signal_id, 0,
|
||||
hide_event_watcher, toplevel, (GDestroyNotify) NULL);
|
||||
}
|
52
gtk/a11y/gtktoplevelaccessible.h
Normal file
52
gtk/a11y/gtktoplevelaccessible.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* 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_TOPLEVEL_ACCESSIBLE_H__
|
||||
#define __GTK_TOPLEVEL_ACCESSIBLE_H__
|
||||
|
||||
#include <atk/atk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_TOPLEVEL_ACCESSIBLE (gtk_toplevel_accessible_get_type ())
|
||||
#define GTK_TOPLEVEL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOPLEVEL_ACCESSIBLE, GtkToplevelAccessible))
|
||||
#define GTK_TOPLEVEL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOPLEVEL_ACCESSIBLE, GtkToplevelAccessibleClass))
|
||||
#define GTK_IS_TOPLEVEL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOPLEVEL_ACCESSIBLE))
|
||||
#define GTK_IS_TOPLEVEL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOPLEVEL_ACCESSIBLE))
|
||||
#define GTK_TOPLEVEL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TOPLEVEL_ACCESSIBLE, GtkToplevelAccessibleClass))
|
||||
|
||||
typedef struct _GtkToplevelAccessible GtkToplevelAccessible;
|
||||
typedef struct _GtkToplevelAccessibleClass GtkToplevelAccessibleClass;
|
||||
|
||||
struct _GtkToplevelAccessible
|
||||
{
|
||||
AtkObject parent;
|
||||
GList *window_list;
|
||||
};
|
||||
|
||||
struct _GtkToplevelAccessibleClass
|
||||
{
|
||||
AtkObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_toplevel_accessible_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_TOPLEVEL_ACCESSIBLE_H__ */
|
@ -24,7 +24,7 @@
|
||||
#include <gtk/gtkx.h>
|
||||
|
||||
#include "gtkwindowaccessible.h"
|
||||
#include "gailtoplevel.h"
|
||||
#include "gtktoplevelaccessible.h"
|
||||
|
||||
enum {
|
||||
ACTIVATE,
|
||||
@ -227,9 +227,9 @@ gtk_window_accessible_get_index_in_parent (AtkObject *accessible)
|
||||
if (GTK_IS_WINDOW (widget))
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW (widget);
|
||||
if (GAIL_IS_TOPLEVEL (atk_obj))
|
||||
if (GTK_IS_TOPLEVEL_ACCESSIBLE (atk_obj))
|
||||
{
|
||||
GailToplevel* toplevel = GAIL_TOPLEVEL (atk_obj);
|
||||
GtkToplevelAccessible *toplevel = GTK_TOPLEVEL_ACCESSIBLE (atk_obj);
|
||||
index = g_list_index (toplevel->window_list, window);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user