23 #include <glib/gi18n-lib.h>
51 N_(
"Scroll View Down"),
77 get_relevant_page (
EvView *view)
88 if (self->priv->children == NULL)
91 for (i = 0; i <
self->priv->children->len; i++) {
92 child = g_ptr_array_index (self->priv->children, i);
93 atk_object_notify_state_change (child, ATK_STATE_DEFUNCT,
TRUE);
96 g_clear_pointer (&self->priv->children, g_ptr_array_unref);
106 g_signal_handlers_disconnect_by_data (priv->
model,
object);
107 g_object_unref (priv->
model);
117 G_OBJECT_CLASS (ev_view_accessible_parent_class)->finalize (
object);
124 if (ATK_OBJECT_CLASS (ev_view_accessible_parent_class)->initialize != NULL)
125 ATK_OBJECT_CLASS (ev_view_accessible_parent_class)->initialize (obj, data);
127 gtk_accessible_set_widget (GTK_ACCESSIBLE (obj), GTK_WIDGET (data));
129 atk_object_set_name (obj,
_(
"Document View"));
130 atk_object_set_role (obj, ATK_ROLE_DOCUMENT_FRAME);
136 return self->priv->children == NULL ? 0 :
self->priv->children->len;
150 view =
EV_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)));
159 return g_object_ref (g_ptr_array_index (self->priv->children, i));
171 GObjectClass *object_class = G_OBJECT_CLASS (klass);
172 AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
188 #if ATK_CHECK_VERSION (2, 11, 3)
190 ev_view_accessible_get_page_count (AtkDocument *atk_document)
198 ev_view_accessible_get_current_page_number (AtkDocument *atk_document)
204 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_document));
209 return get_relevant_page (
EV_VIEW (widget)) + 1;
216 #if ATK_CHECK_VERSION (2, 11, 3)
217 iface->get_current_page_number = ev_view_accessible_get_current_page_number;
218 iface->get_page_count = ev_view_accessible_get_page_count;
240 if (gtk_accessible_get_widget (GTK_ACCESSIBLE (action)) == NULL)
295 const gchar *description)
298 gchar *old_description;
305 g_free (old_description);
330 AtkObject *previous_page = NULL;
331 AtkObject *current_page = NULL;
333 previous_page = g_ptr_array_index (priv->
children,
335 atk_object_notify_state_change (previous_page, ATK_STATE_FOCUSED,
FALSE);
337 current_page = g_ptr_array_index (priv->
children, page);
338 atk_object_notify_state_change (current_page, ATK_STATE_FOCUSED,
TRUE);
340 #if ATK_CHECK_VERSION (2, 11, 2)
342 g_signal_emit_by_name (accessible,
"page-changed", page + 1);
346 page_accessible = g_ptr_array_index (priv->
children, page);
347 g_signal_emit_by_name (page_accessible,
"text-caret-moved", offset);
354 AtkObject *page_accessible;
356 page_accessible = g_ptr_array_index (view_accessible->
priv->
children,
357 get_relevant_page (view));
358 g_signal_emit_by_name (page_accessible,
"text-selection-changed");
367 #if ATK_CHECK_VERSION (2, 11, 2)
370 view =
EV_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
372 g_signal_emit_by_name (accessible,
"page-changed", new_page + 1);
387 self->priv->children = g_ptr_array_new_full (n_pages, (GDestroyNotify) g_object_unref);
388 for (i = 0; i < n_pages; i++) {
390 g_ptr_array_add (self->priv->children, child);
398 if (self->priv->end_page >= n_pages)
399 self->priv->end_page = n_pages - 1;
411 if (document == NULL)
422 g_signal_emit_by_name (accessible,
"reload");
423 g_signal_emit_by_name (accessible,
"load-complete");
432 if (priv->
model == model)
436 g_signal_handlers_disconnect_by_data (priv->
model, accessible);
437 g_object_unref (priv->
model);
440 priv->
model = g_object_ref (model);
443 g_signal_connect (priv->
model,
"page-changed",
446 g_signal_connect (priv->
model,
"notify::document",
453 GdkEventFocus *event,
456 AtkObject *page_accessible;
461 if (self->priv->children == NULL || self->priv->children->len == 0)
464 page_accessible = g_ptr_array_index (self->priv->children,
465 get_relevant_page (
EV_VIEW (widget)));
466 atk_object_notify_state_change (page_accessible,
467 ATK_STATE_FOCUSED, event->in);
475 AtkObject *accessible;
478 g_return_val_if_fail (
EV_IS_VIEW (widget), NULL);
481 atk_object_initialize (accessible, widget);
483 g_signal_connect (widget,
"cursor-moved",
486 g_signal_connect (widget,
"selection-changed",
489 g_signal_connect (widget,
"focus-in-event",
492 g_signal_connect (widget,
"focus-out-event",
511 view =
EV_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
513 return get_relevant_page (view);
521 AtkCoordType coord_type)
524 GdkRectangle view_rect;
525 GtkWidget *widget, *toplevel;
526 gint x_widget, y_widget;
528 view =
EV_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
533 widget = GTK_WIDGET (view);
534 toplevel = gtk_widget_get_toplevel (widget);
535 gtk_widget_translate_coordinates (widget, toplevel, 0, 0, &x_widget, &y_widget);
536 view_rect.x += x_widget;
537 view_rect.y += y_widget;
539 if (coord_type == ATK_XY_SCREEN) {
540 gint x_window, y_window;
541 gdk_window_get_origin (gtk_widget_get_window (toplevel), &x_window, &y_window);
542 view_rect.x += x_window;
543 view_rect.y += y_window;
546 atk_rect->
x1 = view_rect.x;
547 atk_rect->
y1 = view_rect.y;
548 atk_rect->
x2 = view_rect.x + view_rect.width;
549 atk_rect->
y2 = view_rect.y + view_rect.height;
558 GdkRectangle view_rect;
559 GtkAllocation allocation;
563 view =
EV_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
564 if (page < view->start_page || page > view->
end_page)
567 gtk_widget_get_allocation (GTK_WIDGET (view), &allocation);
572 hidden = view_rect.x + view_rect.width < x || view_rect.x > x + allocation.width ||
573 view_rect.y + view_rect.height < y || view_rect.y > y + allocation.height;
588 for (i = accessible->
priv->
start_page; i <= accessible->priv->end_page; i++) {
589 if (i < start || i > end) {
590 page = g_ptr_array_index (accessible->
priv->
children, i);
591 atk_object_notify_state_change (page, ATK_STATE_SHOWING,
FALSE);
595 for (i = start; i <= end; i++) {
596 if (i < accessible->priv->start_page || i > accessible->
priv->
end_page) {
597 page = g_ptr_array_index (accessible->
priv->
children, i);
598 atk_object_notify_state_change (page, ATK_STATE_SHOWING,
TRUE);
618 if (!new_focus || new_focus_page == -1)
621 page = g_ptr_array_index (accessible->
priv->
children, new_focus_page);
634 page = g_ptr_array_index (accessible->
priv->
children, element_page);