From: Nickolay V. Shmyrev Date: Sat, 29 Oct 2005 09:04:11 +0000 (+0000) Subject: Initial accessibility support. X-Git-Tag: EVINCE_0_5_0~98 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=a0af7b2e9d42e05aa0108ae6dc9c34deb9723404;p=evince.git Initial accessibility support. * po/POTFILES.in: * shell/Makefile.am: * shell/ev-view-accessible.c: (ev_view_accessible_get_priv), (ev_view_accessible_free_priv), (ev_view_accessible_class_init), (ev_view_accessible_get_text), (ev_view_accessible_get_character_at_offset), (ev_view_accessible_get_text_before_offset), (ev_view_accessible_get_text_at_offset), (ev_view_accessible_get_text_after_offset), (ev_view_accessible_get_character_count), (ev_view_accessible_get_caret_offset), (ev_view_accessible_set_caret_offset), (ev_view_accessible_get_run_attributes), (ev_view_accessible_get_default_attributes), (ev_view_accessible_get_character_extents), (ev_view_accessible_get_offset_at_point), (ev_view_accessible_get_n_selections), (ev_view_accessible_get_selection), (ev_view_accessible_add_selection), (ev_view_accessible_remove_selection), (ev_view_accessible_set_selection), (ev_view_accessible_text_iface_init), (ev_view_accessible_idle_do_action), (ev_view_accessible_action_do_action), (ev_view_accessible_action_get_n_actions), (ev_view_accessible_action_get_description), (ev_view_accessible_action_get_name), (ev_view_accessible_action_set_description), (ev_view_accessible_action_iface_init), (ev_view_accessible_get_type), (ev_view_accessible_new), (ev_view_accessible_factory_get_accessible_type), (ev_view_accessible_factory_create_accessible), (ev_view_accessible_factory_class_init), (ev_view_accessible_factory_get_type): * shell/ev-view-accessible.h: * shell/ev-view-private.h: * shell/ev-view.c: (ev_view_get_accessible), (ev_view_class_init): * shell/ev-view.h: Initial accessibility support. --- diff --git a/ChangeLog b/ChangeLog index 34716111..10bfd1a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +2005-10-29 Nickolay V. Shmyrev + + * po/POTFILES.in: + * shell/Makefile.am: + * shell/ev-view-accessible.c: (ev_view_accessible_get_priv), + (ev_view_accessible_free_priv), (ev_view_accessible_class_init), + (ev_view_accessible_get_text), + (ev_view_accessible_get_character_at_offset), + (ev_view_accessible_get_text_before_offset), + (ev_view_accessible_get_text_at_offset), + (ev_view_accessible_get_text_after_offset), + (ev_view_accessible_get_character_count), + (ev_view_accessible_get_caret_offset), + (ev_view_accessible_set_caret_offset), + (ev_view_accessible_get_run_attributes), + (ev_view_accessible_get_default_attributes), + (ev_view_accessible_get_character_extents), + (ev_view_accessible_get_offset_at_point), + (ev_view_accessible_get_n_selections), + (ev_view_accessible_get_selection), + (ev_view_accessible_add_selection), + (ev_view_accessible_remove_selection), + (ev_view_accessible_set_selection), + (ev_view_accessible_text_iface_init), + (ev_view_accessible_idle_do_action), + (ev_view_accessible_action_do_action), + (ev_view_accessible_action_get_n_actions), + (ev_view_accessible_action_get_description), + (ev_view_accessible_action_get_name), + (ev_view_accessible_action_set_description), + (ev_view_accessible_action_iface_init), + (ev_view_accessible_get_type), (ev_view_accessible_new), + (ev_view_accessible_factory_get_accessible_type), + (ev_view_accessible_factory_create_accessible), + (ev_view_accessible_factory_class_init), + (ev_view_accessible_factory_get_type): + * shell/ev-view-accessible.h: + * shell/ev-view-private.h: + * shell/ev-view.c: (ev_view_get_accessible), (ev_view_class_init): + * shell/ev-view.h: + + Initial accessibility support. + 2005-10-27 Erdal Ronahi * configure.ac: Added ku (Kurdish) to ALL_LINGUAS diff --git a/po/POTFILES.in b/po/POTFILES.in index e14a79f6..0403b313 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -25,6 +25,7 @@ shell/ev-properties-dialog.c shell/ev-properties-fonts.c shell/ev-sidebar-links.c shell/ev-sidebar-thumbnails.c +shell/ev-view-accessible.c shell/ev-view.c shell/ev-window.c shell/ev-window-title.c diff --git a/shell/Makefile.am b/shell/Makefile.am index 27326a71..aa237aea 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -50,6 +50,9 @@ evince_SOURCES= \ ev-properties-fonts.h \ ev-utils.c \ ev-utils.h \ + ev-view-accessible.c \ + ev-view-accessible.h \ + ev-view-private.h \ ev-view.c \ ev-view.h \ ev-window.c \ diff --git a/shell/ev-view-accessible.c b/shell/ev-view-accessible.c new file mode 100644 index 00000000..e53ba35f --- /dev/null +++ b/shell/ev-view-accessible.c @@ -0,0 +1,589 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2004 Red Hat, Inc + * + * Evince is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Evince 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#include + +#include "ev-view-accessible.h" +#include "ev-view-private.h" + +#define EV_TYPE_VIEW_ACCESSIBLE (ev_view_accessible_get_type ()) +#define EV_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_VIEW_ACCESSIBLE, EvViewAccessible)) +#define EV_IS_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EV_TYPE_VIEW_ACCESSIBLE)) + +static gulong accessible_private_data_quark; + +static GType ev_view_accessible_get_type (void); + +enum { + ACTION_SCROLL_UP, + ACTION_SCROLL_DOWN, + LAST_ACTION +}; + +static const gchar *const ev_view_accessible_action_names[] = +{ + N_("Scroll Up"), + N_("Scroll Down"), + NULL +}; + +static const gchar *const ev_view_accessible_action_descriptions[] = +{ + N_("Scroll View Up"), + N_("Scroll View Down"), + NULL +}; + +typedef struct { + /* Action */ + gchar *action_descriptions[LAST_ACTION]; + guint action_idle_handler; + EvScrollType idle_scroll; +} EvViewAccessiblePriv; + +static EvViewAccessiblePriv * +ev_view_accessible_get_priv (AtkObject *accessible) +{ + return g_object_get_qdata (G_OBJECT (accessible), + accessible_private_data_quark); +} + +static void +ev_view_accessible_free_priv (EvViewAccessiblePriv *priv) +{ + int i; + + if (priv->action_idle_handler) + g_source_remove (priv->action_idle_handler); + for (i = 0; i < LAST_ACTION; i++) + if (priv->action_descriptions [i] != NULL) + g_free (priv->action_descriptions [i]); +} + +static void ev_view_accessible_class_init (GtkAccessibleClass * klass) +{ + accessible_private_data_quark = g_quark_from_static_string ("ev-view-accessible-private-data"); + return; +} + +static gchar* +ev_view_accessible_get_text (AtkText *text, + gint start_pos, + gint end_pos) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return NULL; + + return NULL; +} + +static gunichar +ev_view_accessible_get_character_at_offset (AtkText *text, + gint offset) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return '\0'; + + return '\0'; +} + +static gchar* +ev_view_accessible_get_text_before_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type, + gint *start_offset, + gint *end_offset) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return NULL; + + return NULL; +} + +static gchar* +ev_view_accessible_get_text_at_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type, + gint *start_offset, + gint *end_offset) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return NULL; + + return NULL; +} + +static gchar* +ev_view_accessible_get_text_after_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type, + gint *start_offset, + gint *end_offset) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return NULL; + + return NULL; +} + +static gint +ev_view_accessible_get_character_count (AtkText *text) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return 0; + + return 0; +} + +static gint +ev_view_accessible_get_caret_offset (AtkText *text) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return 0; + + return 0; +} + +static gboolean +ev_view_accessible_set_caret_offset (AtkText *text, gint offset) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return FALSE; + + return FALSE; +} + +static AtkAttributeSet* +ev_view_accessible_get_run_attributes (AtkText *text, + gint offset, + gint *start_offset, + gint *end_offset) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return NULL; + + return NULL; +} + +static AtkAttributeSet* +ev_view_accessible_get_default_attributes (AtkText *text) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return NULL; + + return NULL; +} + +static void +ev_view_accessible_get_character_extents (AtkText *text, + gint offset, + gint *x, + gint *y, + gint *width, + gint *height, + AtkCoordType coords) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return; + + return; +} + +static gint +ev_view_accessible_get_offset_at_point (AtkText *text, + gint x, + gint y, + AtkCoordType coords) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return -1; + + return -1; +} + +static gint +ev_view_accessible_get_n_selections (AtkText *text) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return -1; + + return -1; +} + +static gchar* +ev_view_accessible_get_selection (AtkText *text, + gint selection_num, + gint *start_pos, + gint *end_pos) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return NULL; + + return NULL; +} + +static gboolean +ev_view_accessible_add_selection (AtkText *text, + gint start_pos, + gint end_pos) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return FALSE; + + return FALSE; +} + +static gboolean +ev_view_accessible_remove_selection (AtkText *text, + gint selection_num) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return FALSE; + + return FALSE; +} + +static gboolean +ev_view_accessible_set_selection (AtkText *text, + gint selection_num, + gint start_pos, + gint end_pos) +{ + GtkWidget *widget; + + widget = GTK_ACCESSIBLE (text)->widget; + if (widget == NULL) + /* State is defunct */ + return FALSE; + + return FALSE; +} + + +static void ev_view_accessible_text_iface_init (AtkTextIface * iface) +{ + g_return_if_fail (iface != NULL); + + iface->get_text = ev_view_accessible_get_text; + iface->get_character_at_offset = ev_view_accessible_get_character_at_offset; + iface->get_text_before_offset = ev_view_accessible_get_text_before_offset; + iface->get_text_at_offset = ev_view_accessible_get_text_at_offset; + iface->get_text_after_offset = ev_view_accessible_get_text_after_offset; + iface->get_caret_offset = ev_view_accessible_get_caret_offset; + iface->set_caret_offset = ev_view_accessible_set_caret_offset; + iface->get_character_count = ev_view_accessible_get_character_count; + iface->get_n_selections = ev_view_accessible_get_n_selections; + iface->get_selection = ev_view_accessible_get_selection; + iface->add_selection = ev_view_accessible_add_selection; + iface->remove_selection = ev_view_accessible_remove_selection; + iface->set_selection = ev_view_accessible_set_selection; + iface->get_run_attributes = ev_view_accessible_get_run_attributes; + iface->get_default_attributes = ev_view_accessible_get_default_attributes; + iface->get_character_extents = ev_view_accessible_get_character_extents; + iface->get_offset_at_point = ev_view_accessible_get_offset_at_point; + return; +} + +static gboolean +ev_view_accessible_idle_do_action (gpointer data) +{ + EvViewAccessiblePriv* priv = ev_view_accessible_get_priv (ATK_OBJECT (data)); + + ev_view_scroll (EV_VIEW (GTK_ACCESSIBLE (data)->widget), + priv->idle_scroll); + priv->action_idle_handler = 0; + return FALSE; +} + +static gboolean +ev_view_accessible_action_do_action (AtkAction *action, + gint i) +{ + EvViewAccessiblePriv* priv = ev_view_accessible_get_priv (ATK_OBJECT (action)); + + if (GTK_ACCESSIBLE (action)->widget == NULL) + return FALSE; + + if (priv->action_idle_handler) + return FALSE; + + switch (i) { + case ACTION_SCROLL_UP: + priv->idle_scroll = EV_SCROLL_PAGE_BACKWARD; + break; + case ACTION_SCROLL_DOWN: + priv->idle_scroll = EV_SCROLL_PAGE_FORWARD; + break; + default: + return FALSE; + } + priv->action_idle_handler = g_idle_add (ev_view_accessible_idle_do_action, + action); + return TRUE; +} + +static gint +ev_view_accessible_action_get_n_actions (AtkAction *action) +{ + return LAST_ACTION; +} + +static const gchar * +ev_view_accessible_action_get_description (AtkAction *action, + gint i) +{ + EvViewAccessiblePriv* priv = ev_view_accessible_get_priv (ATK_OBJECT (action)); + + if (i < 0 || i >= LAST_ACTION) + return NULL; + + if (priv->action_descriptions[i]) + return priv->action_descriptions[i]; + else + return ev_view_accessible_action_descriptions[i]; +} + +static const gchar * +ev_view_accessible_action_get_name (AtkAction *action, + gint i) +{ + if (i < 0 || i >= LAST_ACTION) + return NULL; + + return ev_view_accessible_action_names[i]; +} + +static gboolean +ev_view_accessible_action_set_description (AtkAction *action, + gint i, + const gchar *description) +{ + EvViewAccessiblePriv* priv = ev_view_accessible_get_priv (ATK_OBJECT (action)); + + if (i < 0 || i >= LAST_ACTION) + return FALSE; + + if (priv->action_descriptions[i]) + g_free (priv->action_descriptions[i]); + + priv->action_descriptions[i] = g_strdup (description); + + return TRUE; +} + +static void ev_view_accessible_action_iface_init (AtkActionIface * iface) +{ + iface->do_action = ev_view_accessible_action_do_action; + iface->get_n_actions = ev_view_accessible_action_get_n_actions; + iface->get_description = ev_view_accessible_action_get_description; + iface->get_name = ev_view_accessible_action_get_name; + iface->set_description = ev_view_accessible_action_set_description; + return; +} + +GType ev_view_accessible_get_type (void) +{ + static GType type = 0; + + if (!type) { + static GTypeInfo tinfo = { + 0, /* class size */ + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) ev_view_accessible_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + 0, /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + static const GInterfaceInfo atk_text_info = { + (GInterfaceInitFunc) + ev_view_accessible_text_iface_init, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + static const GInterfaceInfo atk_action_info = { + (GInterfaceInitFunc) + ev_view_accessible_action_iface_init, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + /* + * Figure out the size of the class and instance + * we are deriving from + */ + AtkObjectFactory *factory; + GType derived_type; + GTypeQuery query; + GType derived_atk_type; + + derived_type = g_type_parent (EV_TYPE_VIEW); + factory = atk_registry_get_factory (atk_get_default_registry (), + derived_type); + derived_atk_type = atk_object_factory_get_accessible_type (factory); + + g_type_query (derived_atk_type, &query); + tinfo.class_size = query.class_size; + tinfo.instance_size = query.instance_size; + + type = g_type_register_static (derived_atk_type, "EvViewAccessible", + &tinfo, 0); + g_type_add_interface_static (type, ATK_TYPE_TEXT, + &atk_text_info); + g_type_add_interface_static (type, ATK_TYPE_ACTION, + &atk_action_info); + } + + return type; +} + +static AtkObject *ev_view_accessible_new(GObject * obj) +{ + AtkObject *accessible; + EvViewAccessiblePriv *priv; + + g_return_val_if_fail(EV_IS_VIEW (obj), NULL); + + accessible = g_object_new (ev_view_accessible_get_type (), NULL); + atk_object_initialize (accessible, obj); + + atk_object_set_name (ATK_OBJECT (accessible), _("Document View")); + atk_object_set_role (ATK_OBJECT (accessible), ATK_ROLE_UNKNOWN); + + priv = g_new0 (EvViewAccessiblePriv, 1); + g_object_set_qdata_full (G_OBJECT (accessible), + accessible_private_data_quark, + priv, + (GDestroyNotify) ev_view_accessible_free_priv); + + return accessible; +} + +GType ev_view_accessible_factory_get_accessible_type(void) +{ + return ev_view_accessible_get_type(); +} + +static AtkObject *ev_view_accessible_factory_create_accessible (GObject * obj) +{ + return ev_view_accessible_new(obj); +} + +static void ev_view_accessible_factory_class_init (AtkObjectFactoryClass * klass) +{ + klass->create_accessible = ev_view_accessible_factory_create_accessible; + klass->get_accessible_type = + ev_view_accessible_factory_get_accessible_type; +} + +GType ev_view_accessible_factory_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo tinfo = { + sizeof(AtkObjectFactoryClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ev_view_accessible_factory_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(AtkObjectFactory), + 0, /* n_preallocs */ + NULL, NULL + }; + + type = g_type_register_static (ATK_TYPE_OBJECT_FACTORY, + "EvViewAccessibleFactory", &tinfo, + 0); + } + return type; +} + + + diff --git a/shell/ev-view-accessible.h b/shell/ev-view-accessible.h new file mode 100644 index 00000000..ca94ed7e --- /dev/null +++ b/shell/ev-view-accessible.h @@ -0,0 +1,31 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2004 Red Hat, Inc + * + * Evince is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Evince 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __EV_VIEW_ACCESSIBLE_H__ +#define __EV_VIEW_ACCESSIBLE_H__ + +#include "ev-view.h" + +GType ev_view_accessible_factory_get_type (void); + +GType ev_view_accessible_factory_get_accessible_type (void); + +#endif /* __EV_VIEW_ACCESSIBLE_H__ */ + diff --git a/shell/ev-view-private.h b/shell/ev-view-private.h new file mode 100644 index 00000000..9cd4a74e --- /dev/null +++ b/shell/ev-view-private.h @@ -0,0 +1,131 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2004 Red Hat, Inc + * + * Evince is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Evince 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __EV_VIEW_PRIVATE_H__ +#define __EV_VIEW_PRIVATE_H__ + +#include "ev-view.h" +#include "ev-pixbuf-cache.h" +#include "ev-page-cache.h" + +/* Information for middle clicking and moving around the doc */ +typedef struct { + gboolean in_drag; + GdkPoint start; + gdouble hadj; + gdouble vadj; +} DragInfo; + +/* Information for handling selection */ +typedef struct { + gboolean in_selection; + gboolean in_drag; + GdkPoint start; + GList *selections; +} SelectionInfo; + +typedef enum { + SCROLL_TO_KEEP_POSITION, + SCROLL_TO_CURRENT_PAGE, + SCROLL_TO_CENTER +} PendingScroll; + +typedef enum { + EV_VIEW_CURSOR_NORMAL, + EV_VIEW_CURSOR_IBEAM, + EV_VIEW_CURSOR_LINK, + EV_VIEW_CURSOR_WAIT, + EV_VIEW_CURSOR_HIDDEN, + EV_VIEW_CURSOR_DRAG +} EvViewCursor; + +struct _EvView { + GtkWidget parent_instance; + + EvDocument *document; + + char *status; + char *find_status; + + /* Scrolling */ + GtkAdjustment *hadjustment; + GtkAdjustment *vadjustment; + + gint scroll_x; + gint scroll_y; + + /* Information for middle clicking and dragging around. */ + DragInfo drag_info; + + /* Selection */ + gint motion_x; + gint motion_y; + guint selection_update_id; + + EvViewSelectionMode selection_mode; + SelectionInfo selection_info; + + int pressed_button; + EvViewCursor cursor; + GtkWidget *link_tooltip; + EvLink *hovered_link; + + EvPageCache *page_cache; + EvPixbufCache *pixbuf_cache; + + gint start_page; + gint end_page; + gint current_page; + + EvJobRender *current_job; + + int find_page; + int find_result; + int spacing; + + int rotation; + double scale; + + gboolean continuous; + gboolean dual_page; + gboolean fullscreen; + gboolean presentation; + EvSizingMode sizing_mode; + + PendingScroll pending_scroll; + gboolean pending_resize; +}; + +struct _EvViewClass { + GtkWidgetClass parent_class; + + void (*set_scroll_adjustments) (EvView *view, + GtkAdjustment *hadjustment, + GtkAdjustment *vadjustment); + void (*binding_activated) (EvView *view, + GtkScrollType scroll, + gboolean horizontal); + void (*zoom_invalid) (EvView *view); + void (*external_link) (EvView *view, + EvLink *link); +}; + +#endif /* __EV_VIEW_PRIVATE_H__ */ + diff --git a/shell/ev-view.c b/shell/ev-view.c index 6f87b6a6..a9418dac 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -30,6 +30,7 @@ #include "ev-marshal.h" #include "ev-view.h" +#include "ev-view-private.h" #include "ev-utils.h" #include "ev-selection.h" #include "ev-document-find.h" @@ -83,15 +84,6 @@ static const GtkTargetEntry targets[] = { static guint signals[N_SIGNALS]; -typedef enum { - EV_VIEW_CURSOR_NORMAL, - EV_VIEW_CURSOR_IBEAM, - EV_VIEW_CURSOR_LINK, - EV_VIEW_CURSOR_WAIT, - EV_VIEW_CURSOR_HIDDEN, - EV_VIEW_CURSOR_DRAG -} EvViewCursor; - typedef enum { EV_VIEW_FIND_NEXT, EV_VIEW_FIND_PREV @@ -103,99 +95,6 @@ typedef enum { #define MIN_SCALE 0.05409 #define MAX_SCALE 4.0 -/* Information for middle clicking and moving around the doc */ -typedef struct { - gboolean in_drag; - GdkPoint start; - gdouble hadj; - gdouble vadj; -} DragInfo; - -/* Information for handling selection */ -typedef struct { - gboolean in_selection; - gboolean in_drag; - GdkPoint start; - GList *selections; -} SelectionInfo; - -typedef enum { - SCROLL_TO_KEEP_POSITION, - SCROLL_TO_CURRENT_PAGE, - SCROLL_TO_CENTER -} PendingScroll; - -struct _EvView { - GtkWidget parent_instance; - - EvDocument *document; - - char *status; - char *find_status; - - /* Scrolling */ - GtkAdjustment *hadjustment; - GtkAdjustment *vadjustment; - - gint scroll_x; - gint scroll_y; - - /* Information for middle clicking and dragging around. */ - DragInfo drag_info; - - /* Selection */ - gint motion_x; - gint motion_y; - guint selection_update_id; - - EvViewSelectionMode selection_mode; - SelectionInfo selection_info; - - int pressed_button; - EvViewCursor cursor; - GtkWidget *link_tooltip; - EvLink *hovered_link; - - EvPageCache *page_cache; - EvPixbufCache *pixbuf_cache; - - gint start_page; - gint end_page; - gint current_page; - - EvJobRender *current_job; - - int find_page; - int find_result; - int spacing; - - int rotation; - double scale; - - gboolean continuous; - gboolean dual_page; - gboolean fullscreen; - gboolean presentation; - EvSizingMode sizing_mode; - - PendingScroll pending_scroll; - gboolean pending_resize; -}; - -struct _EvViewClass { - GtkWidgetClass parent_class; - - void (*set_scroll_adjustments) (EvView *view, - GtkAdjustment *hadjustment, - GtkAdjustment *vadjustment); - void (*binding_activated) (EvView *view, - GtkScrollType scroll, - gboolean horizontal); - void (*zoom_invalid) (EvView *view); - void (*external_link) (EvView *view, - EvLink *link); -}; - /*** Scrolling ***/ static void scroll_to_current_page (EvView *view, GtkOrientation orientation); @@ -287,6 +186,8 @@ static gboolean ev_view_leave_notify_event (GtkWidget static void ev_view_style_set (GtkWidget *widget, GtkStyle *old_style); +static AtkObject *ev_view_get_accessible (GtkWidget *widget); + /*** Drawing ***/ static guint32 ev_gdk_color_to_rgb (const GdkColor *color); static void draw_rubberband (GtkWidget *widget, @@ -1991,7 +1892,6 @@ ev_view_style_set (GtkWidget *widget, GTK_WIDGET_CLASS (ev_view_parent_class)->style_set (widget, old_style); } - /*** Drawing ***/ static guint32 @@ -2297,6 +2197,37 @@ ev_view_set_property (GObject *object, } } +static AtkObject * +ev_view_get_accessible (GtkWidget *widget) +{ + static gboolean first_time = TRUE; + + if (first_time) { + AtkObjectFactory *factory; + AtkRegistry *registry; + GType derived_type; + GType derived_atk_type; + + /* + * Figure out whether accessibility is enabled by looking at the + * type of the accessible object which would be created for + * the parent type of EvView. + */ + derived_type = g_type_parent (EV_TYPE_VIEW); + + registry = atk_get_default_registry (); + factory = atk_registry_get_factory (registry, + derived_type); + derived_atk_type = atk_object_factory_get_accessible_type (factory); + if (g_type_is_a (derived_atk_type, GTK_TYPE_ACCESSIBLE)) + atk_registry_set_factory_type (registry, + EV_TYPE_VIEW, + ev_view_accessible_factory_get_type ()); + first_time = FALSE; + } + return GTK_WIDGET_CLASS (ev_view_parent_class)->get_accessible (widget); +} + static void ev_view_get_property (GObject *object, guint prop_id, @@ -2361,6 +2292,7 @@ ev_view_class_init (EvViewClass *class) widget_class->button_release_event = ev_view_button_release_event; widget_class->focus_in_event = ev_view_focus_in; widget_class->focus_out_event = ev_view_focus_out; + widget_class->get_accessible = ev_view_get_accessible; widget_class->size_request = ev_view_size_request; widget_class->size_allocate = ev_view_size_allocate; widget_class->realize = ev_view_realize; diff --git a/shell/ev-view.h b/shell/ev-view.h index ade26852..0378f285 100644 --- a/shell/ev-view.h +++ b/shell/ev-view.h @@ -24,6 +24,7 @@ #include "ev-document.h" #include "ev-link.h" +#include "ev-view-accessible.h" G_BEGIN_DECLS