LAST_ACTION
};
-static GtkTextBuffer *
-ev_view_accessible_get_text_buffer (EvView *view)
-{
- EvPageCache *page_cache;
- GtkTextBuffer *buffer;
- const gchar *retval = NULL;
-
- page_cache = view->page_cache;
- if (!page_cache) {
- return NULL;
- }
- retval = ev_page_cache_get_text (page_cache, view->current_page);
- buffer = gtk_text_buffer_new (NULL);
- gtk_text_buffer_set_text (buffer, retval, -1);
-
- return buffer;
-}
-
static const gchar *const ev_view_accessible_action_names[] =
{
N_("Scroll Up"),
gchar *action_descriptions[LAST_ACTION];
guint action_idle_handler;
GtkScrollType idle_scroll;
+ GtkTextBuffer *buffer;
+ guint current_page;
} EvViewAccessiblePriv;
typedef GtkAccessibleClass EvViewAccessibleClass;
+typedef GtkAccessible EvViewAccessible;
#define EV_VIEW_ACCESSIBLE_GET_PRIVATE(inst) (G_TYPE_INSTANCE_GET_PRIVATE ((inst), EV_TYPE_VIEW_ACCESSIBLE, EvViewAccessiblePriv))
g_source_remove (priv->action_idle_handler);
for (i = 0; i < LAST_ACTION; i++)
g_free (priv->action_descriptions [i]);
+ if (priv->buffer)
+ g_object_unref (priv->buffer);
+
}
static void ev_view_accessible_class_init (EvViewAccessibleClass *klass)
g_type_class_add_private (klass, sizeof (EvViewAccessiblePriv));
}
+static GtkTextBuffer *
+ev_view_accessible_get_text_buffer (EvViewAccessible *accessible, EvView *view)
+{
+ EvPageCache *page_cache;
+ const gchar *retval = NULL;
+ EvViewAccessiblePriv* priv = EV_VIEW_ACCESSIBLE_GET_PRIVATE (accessible);
+
+ page_cache = view->page_cache;
+ if (!page_cache) {
+ return NULL;
+ }
+
+ if (view->current_page == priv->current_page && priv->buffer) {
+ return priv->buffer;
+ }
+
+ priv->current_page = view->current_page;
+
+ if (!priv->buffer) {
+ priv->buffer = gtk_text_buffer_new (NULL);
+ }
+
+ retval = ev_page_cache_get_text (page_cache, view->current_page);
+ gtk_text_buffer_set_text (priv->buffer, retval, -1);
+
+ return priv->buffer;
+}
+
static gchar*
ev_view_accessible_get_text (AtkText *text,
gint start_pos,
/* State is defunct */
return NULL;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return NULL;
gtk_text_buffer_get_iter_at_offset (buffer, &start, start_pos);
gtk_text_buffer_get_iter_at_offset (buffer, &end, end_pos);
retval = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
- g_object_unref (buffer);
return retval;
}
/* State is defunct */
return '\0';
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return '\0';
string = gtk_text_buffer_get_slice (buffer, &start, &end, FALSE);
unichar = g_utf8_get_char (string);
g_free(string);
- g_object_unref (buffer);
return unichar;
}
/* State is defunct */
return NULL;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return NULL;
GAIL_BEFORE_OFFSET, boundary_type,
offset, start_offset, end_offset);
g_object_unref (gail_text);
- g_object_unref (buffer);
return retval;
}
/* State is defunct */
return NULL;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return NULL;
GAIL_AT_OFFSET, boundary_type,
offset, start_offset, end_offset);
g_object_unref (gail_text);
- g_object_unref (buffer);
return retval;
}
/* State is defunct */
return NULL;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return NULL;
GAIL_AFTER_OFFSET, boundary_type,
offset, start_offset, end_offset);
g_object_unref (gail_text);
- g_object_unref (buffer);
return retval;
}
/* State is defunct */
return 0;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return 0;
retval = gtk_text_buffer_get_char_count (buffer);
- g_object_unref (buffer);
return retval;
}
/* State is defunct */
return 0;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return 0;
cursor_mark = gtk_text_buffer_get_insert (buffer);
gtk_text_buffer_get_iter_at_mark (buffer, &cursor_itr, cursor_mark);
retval = gtk_text_iter_get_offset (&cursor_itr);
- g_object_unref (buffer);
return retval;
}
/* State is defunct */
return FALSE;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return FALSE;
gtk_text_buffer_get_iter_at_offset (buffer, &pos_itr, offset);
gtk_text_buffer_place_cursor (buffer, &pos_itr);
- g_object_unref (buffer);
return TRUE;
}
/* State is defunct */
return NULL;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return NULL;
retval = gail_misc_buffer_get_run_attributes (buffer, offset,
start_offset, end_offset);
- g_object_unref (buffer);
return retval;
}
/* State is defunct */
return -1;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return -1;
select_start = gtk_text_iter_get_offset (&start);
select_end = gtk_text_iter_get_offset (&end);
- g_object_unref (buffer);
-
if (select_start != select_end)
return 1;
else
if (selection_num != 0)
return NULL;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return NULL;
if (*start_pos != *end_pos)
retval = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
- g_object_unref (buffer);
-
return retval;
}
/* State is defunct */
return FALSE;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return FALSE;
retval = TRUE;
}
- g_object_unref (buffer);
-
return retval;
}
/* State is defunct */
return FALSE;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return FALSE;
retval = TRUE;
}
- g_object_unref (buffer);
-
return retval;
}
/* State is defunct */
return FALSE;
- buffer = ev_view_accessible_get_text_buffer (EV_VIEW (widget));
+ buffer = ev_view_accessible_get_text_buffer (EV_VIEW_ACCESSIBLE (text), EV_VIEW (widget));
if (!buffer)
return FALSE;
retval = TRUE;
}
- g_object_unref (buffer);
-
return retval;
}