Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-form-field-accessible.c File Reference
#include <config.h>
#include "ev-form-field-accessible.h"
#include "ev-view-private.h"
+ Include dependency graph for ev-form-field-accessible.c:

Go to the source code of this file.

Data Structures

struct  _EvFormFieldAccessiblePrivate
 

Functions

static void ev_form_field_accessible_component_iface_init (AtkComponentIface *iface)
 
 G_DEFINE_TYPE_WITH_CODE (EvFormFieldAccessible, ev_form_field_accessible, ATK_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT, ev_form_field_accessible_component_iface_init))
 
static gboolean ev_form_field_accessible_grab_focus (AtkComponent *atk_component)
 
static gboolean get_indices_in_parent (AtkObject *atk_object, gint *start, gint *end)
 
static gchar * get_text_under_element (AtkObject *atk_object)
 
static const gchar * ev_form_field_accessible_get_name (AtkObject *atk_object)
 
static AtkObject * ev_form_field_accessible_get_parent (AtkObject *atk_object)
 
static AtkRole ev_form_field_accessible_get_role (AtkObject *atk_object)
 
static AtkStateSet * ev_form_field_accessible_ref_state_set (AtkObject *atk_object)
 
void ev_form_field_accessible_update_state (EvFormFieldAccessible *accessible)
 
static void ev_form_field_accessible_finalize (GObject *object)
 
static void ev_form_field_accessible_class_init (EvFormFieldAccessibleClass *klass)
 
static void ev_form_field_accessible_init (EvFormFieldAccessible *accessible)
 
EvFormFieldAccessibleev_form_field_accessible_new (EvPageAccessible *page, EvFormField *form_field, EvRectangle *area)
 
EvFormFieldev_form_field_accessible_get_field (EvFormFieldAccessible *accessible)
 

Function Documentation

static void ev_form_field_accessible_class_init ( EvFormFieldAccessibleClass klass)
static

Definition at line 353 of file ev-form-field-accessible.c.

354 {
355  GObjectClass *object_class = G_OBJECT_CLASS (klass);
356  AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
357 
358  object_class->finalize = ev_form_field_accessible_finalize;
359  atk_class->get_name = ev_form_field_accessible_get_name;
360  atk_class->get_parent = ev_form_field_accessible_get_parent;
361  atk_class->get_role = ev_form_field_accessible_get_role;
362  atk_class->ref_state_set = ev_form_field_accessible_ref_state_set;
363 
364  g_type_class_add_private (klass, sizeof (EvFormFieldAccessiblePrivate));
365 }
static void ev_form_field_accessible_component_iface_init ( AtkComponentIface *  iface)
static

Definition at line 81 of file ev-form-field-accessible.c.

82 {
83  iface->get_extents = ev_form_field_accessible_get_extents;
84  iface->grab_focus = ev_form_field_accessible_grab_focus;
85 }
static void ev_form_field_accessible_finalize ( GObject *  object)
static

Definition at line 341 of file ev-form-field-accessible.c.

342 {
344 
345  g_object_unref (priv->form_field);
346  g_free (priv->name);
347  g_object_unref (priv->saved_states);
348 
349  G_OBJECT_CLASS (ev_form_field_accessible_parent_class)->finalize (object);
350 }

+ Here is the caller graph for this function:

EvFormField* ev_form_field_accessible_get_field ( EvFormFieldAccessible accessible)

Definition at line 393 of file ev-form-field-accessible.c.

394 {
395  return accessible->priv->form_field;
396 }

+ Here is the caller graph for this function:

static const gchar* ev_form_field_accessible_get_name ( AtkObject *  atk_object)
static

Definition at line 178 of file ev-form-field-accessible.c.

179 {
181 
182  priv = EV_FORM_FIELD_ACCESSIBLE (atk_object)->priv;
183  if (priv->name)
184  return priv->name;
185 
186  if (EV_IS_FORM_FIELD_BUTTON (priv->form_field)) {
188 
189  if (button->type == EV_FORM_FIELD_BUTTON_PUSH)
190  priv->name = get_text_under_element (atk_object);
191  }
192 
193  return priv->name;
194 }

+ Here is the caller graph for this function:

static AtkObject* ev_form_field_accessible_get_parent ( AtkObject *  atk_object)
static

Definition at line 197 of file ev-form-field-accessible.c.

198 {
199  EvFormFieldAccessiblePrivate *priv = EV_FORM_FIELD_ACCESSIBLE (atk_object)->priv;
200 
201  return ATK_OBJECT (priv->page);
202 }

+ Here is the caller graph for this function:

static AtkRole ev_form_field_accessible_get_role ( AtkObject *  atk_object)
static

Definition at line 205 of file ev-form-field-accessible.c.

206 {
207  EvFormField *ev_form_field;
208 
209  ev_form_field = EV_FORM_FIELD_ACCESSIBLE (atk_object)->priv->form_field;
210  if (EV_IS_FORM_FIELD_BUTTON (ev_form_field)) {
211  EvFormFieldButton *field_button = EV_FORM_FIELD_BUTTON (ev_form_field);
212 
213  switch (field_button->type) {
215  return ATK_ROLE_CHECK_BOX;
217  return ATK_ROLE_RADIO_BUTTON;
219  return ATK_ROLE_PUSH_BUTTON;
220  default:
221  return ATK_ROLE_UNKNOWN;
222  }
223  }
224 
225  if (EV_IS_FORM_FIELD_CHOICE (ev_form_field)) {
226  EvFormFieldChoice *field_choice = EV_FORM_FIELD_CHOICE (ev_form_field);
227 
228  switch (field_choice->type) {
230  return ATK_ROLE_COMBO_BOX;
232  return ATK_ROLE_LIST_BOX;
233  default:
234  return ATK_ROLE_UNKNOWN;
235  }
236  }
237 
238  if (EV_IS_FORM_FIELD_TEXT (ev_form_field)) {
239  EvFormFieldText *field_text = EV_FORM_FIELD_TEXT (ev_form_field);
240 
241  if (field_text->is_password)
242  return ATK_ROLE_PASSWORD_TEXT;
243  else if (field_text->type == EV_FORM_FIELD_TEXT_MULTILINE)
244  return ATK_ROLE_TEXT;
245  else
246  return ATK_ROLE_ENTRY;
247  }
248 
249  return ATK_ROLE_UNKNOWN;
250 }

+ Here is the caller graph for this function:

static gboolean ev_form_field_accessible_grab_focus ( AtkComponent *  atk_component)
static

Definition at line 68 of file ev-form-field-accessible.c.

69 {
71  EvView *view;
72 
73  self = EV_FORM_FIELD_ACCESSIBLE (atk_component);
74  view = ev_page_accessible_get_view (self->priv->page);
75  _ev_view_focus_form_field (view, self->priv->form_field);
76 
77  return TRUE;
78 }

+ Here is the caller graph for this function:

static void ev_form_field_accessible_init ( EvFormFieldAccessible accessible)
static

Definition at line 368 of file ev-form-field-accessible.c.

369 {
370  accessible->priv = G_TYPE_INSTANCE_GET_PRIVATE (accessible, EV_TYPE_FORM_FIELD_ACCESSIBLE, EvFormFieldAccessiblePrivate);
371  accessible->priv->start_index = -1;
372  accessible->priv->end_index = -1;
373 }
EvFormFieldAccessible* ev_form_field_accessible_new ( EvPageAccessible page,
EvFormField form_field,
EvRectangle area 
)

Definition at line 376 of file ev-form-field-accessible.c.

379 {
380  EvFormFieldAccessible *atk_form_field;
381 
382  atk_form_field = g_object_new (EV_TYPE_FORM_FIELD_ACCESSIBLE, NULL);
383  atk_form_field->priv->page = page;
384  atk_form_field->priv->form_field = g_object_ref (form_field);
385  atk_form_field->priv->area = *area;
386  atk_form_field->priv->saved_states = atk_state_set_new ();
387  ev_form_field_accessible_update_state (atk_form_field);
388 
389  return EV_FORM_FIELD_ACCESSIBLE (atk_form_field);
390 }

+ Here is the caller graph for this function:

static AtkStateSet* ev_form_field_accessible_ref_state_set ( AtkObject *  atk_object)
static

Definition at line 253 of file ev-form-field-accessible.c.

254 {
255  AtkStateSet *state_set;
256  AtkStateSet *copy_set;
257  AtkStateSet *page_accessible_state_set;
258  EvFormFieldAccessible *self;
259  EvFormField *ev_form_field;
260  EvViewAccessible *view_accessible;
261  gint page;
262 
263  self = EV_FORM_FIELD_ACCESSIBLE (atk_object);
264  state_set = ATK_OBJECT_CLASS (ev_form_field_accessible_parent_class)->ref_state_set (atk_object);
265  atk_state_set_clear_states (state_set);
266 
267  page_accessible_state_set = atk_object_ref_state_set (ATK_OBJECT (self->priv->page));
268  copy_set = atk_state_set_or_sets (state_set, page_accessible_state_set);
269 
270  view_accessible = ev_page_accessible_get_view_accessible (self->priv->page);
271  page = ev_page_accessible_get_page (self->priv->page);
272  if (!ev_view_accessible_is_doc_rect_showing (view_accessible, page, &self->priv->area))
273  atk_state_set_remove_state (copy_set, ATK_STATE_SHOWING);
274 
275  ev_form_field = EV_FORM_FIELD_ACCESSIBLE (atk_object)->priv->form_field;
276  if (EV_IS_FORM_FIELD_BUTTON (ev_form_field)) {
277  EvFormFieldButton *field_button = EV_FORM_FIELD_BUTTON (ev_form_field);
278 
279  if (field_button->state) {
280  if (field_button->type == EV_FORM_FIELD_BUTTON_PUSH)
281  atk_state_set_add_state (copy_set, ATK_STATE_PRESSED);
282  else
283  atk_state_set_add_state (copy_set, ATK_STATE_CHECKED);
284  }
285  }
286 
287  else if (EV_IS_FORM_FIELD_CHOICE (ev_form_field)) {
288  EvFormFieldChoice *field_choice = EV_FORM_FIELD_CHOICE (ev_form_field);
289 
290  if (field_choice->is_editable && !ev_form_field->is_read_only)
291  atk_state_set_add_state (copy_set, ATK_STATE_EDITABLE);
292  if (field_choice->multi_select)
293  atk_state_set_add_state (copy_set, ATK_STATE_MULTISELECTABLE);
294  }
295 
296  else if (EV_IS_FORM_FIELD_TEXT (ev_form_field)) {
297  EvFormFieldText *field_text = EV_FORM_FIELD_TEXT (ev_form_field);
298 
299  if (!ev_form_field->is_read_only)
300  atk_state_set_add_state (copy_set, ATK_STATE_EDITABLE);
301  if (field_text->type == EV_FORM_FIELD_TEXT_NORMAL)
302  atk_state_set_add_state (copy_set, ATK_STATE_SINGLE_LINE);
303  else if (field_text->type == EV_FORM_FIELD_TEXT_MULTILINE)
304  atk_state_set_add_state (copy_set, ATK_STATE_MULTI_LINE);
305  }
306 
307  g_object_unref (state_set);
308  g_object_unref (page_accessible_state_set);
309 
310  return copy_set;
311 }

+ Here is the caller graph for this function:

void ev_form_field_accessible_update_state ( EvFormFieldAccessible accessible)

Definition at line 314 of file ev-form-field-accessible.c.

315 {
316  AtkObject *atk_object;
317  AtkStateSet *states;
318  AtkStateSet *changed_states;
319  gint i;
320 
321  atk_object = ATK_OBJECT (accessible);
322  states = ev_form_field_accessible_ref_state_set (atk_object);
323  changed_states = atk_state_set_xor_sets (accessible->priv->saved_states, states);
324  if (changed_states && !atk_state_set_is_empty (accessible->priv->saved_states)) {
325  for (i = 0; i < ATK_STATE_LAST_DEFINED; i++) {
326  if (atk_state_set_contains_state (changed_states, i))
327  atk_object_notify_state_change (atk_object, i, atk_state_set_contains_state (states, i));
328  }
329  }
330 
331  g_object_unref (accessible->priv->saved_states);
332 
333  atk_state_set_clear_states (changed_states);
334  accessible->priv->saved_states = atk_state_set_or_sets (changed_states, states);
335 
336  g_object_unref (changed_states);
337  g_object_unref (states);
338 }

+ Here is the caller graph for this function:

G_DEFINE_TYPE_WITH_CODE ( EvFormFieldAccessible  ,
ev_form_field_accessible  ,
ATK_TYPE_OBJECT  ,
G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT, ev_form_field_accessible_component_iface_init  
)

Definition at line 41 of file ev-form-field-accessible.c.

51 {
53  EvViewAccessible *view_accessible;
54  gint page;
55  EvRectangle atk_rect;
56 
57  self = EV_FORM_FIELD_ACCESSIBLE (atk_component);
58  view_accessible = ev_page_accessible_get_view_accessible (self->priv->page);
59  page = ev_page_accessible_get_page (self->priv->page);
60  _transform_doc_rect_to_atk_rect (view_accessible, page, &self->priv->area, &atk_rect, coord_type);
61  *x = atk_rect.x1;
62  *y = atk_rect.y1;
63  *width = atk_rect.x2 - atk_rect.x1;
64  *height = atk_rect.y2 - atk_rect.y1;
65 }
static gboolean get_indices_in_parent ( AtkObject *  atk_object,
gint *  start,
gint *  end 
)
static

Definition at line 88 of file ev-form-field-accessible.c.

91 {
93  EvView *view;
94  EvRectangle *areas = NULL;
95  guint n_areas = 0;
96  gint last_zero_sized_index = -1;
97  gint i;
98 
99  priv = EV_FORM_FIELD_ACCESSIBLE (atk_object)->priv;
100  if (priv->start_index != -1 && priv->end_index != -1) {
101  *start = priv->start_index;
102  *end = priv->end_index;
103  return TRUE;
104  }
105 
106  view = ev_page_accessible_get_view (priv->page);
107  if (!view->page_cache)
108  return FALSE;
109 
112  &areas, &n_areas);
113  if (!areas)
114  return FALSE;
115 
116  for (i = 0; i < n_areas; i++) {
117  EvRectangle *rect = areas + i;
118  gdouble c_x, c_y;
119 
120  c_x = rect->x1 + (rect->x2 - rect->x1) / 2.;
121  c_y = rect->y1 + (rect->y2 - rect->y1) / 2.;
122 
123  if (c_x >= priv->area.x1 && c_x <= priv->area.x2 &&
124  c_y >= priv->area.y1 && c_y <= priv->area.y2) {
125  priv->start_index = i;
126  break;
127  }
128  }
129 
130  if (priv->start_index == -1)
131  return FALSE;
132 
133  for (i = priv->start_index + 1; i < n_areas; i++) {
134  EvRectangle *rect = areas + i;
135  gdouble c_x, c_y;
136 
137  /* A zero-sized text rect suggests a line break. If it is within the text of the
138  * field, we want to preserve it; if it is the character immediately after, we
139  * do not. We won't know which it is until we find the first text rect that is
140  * outside of the area occupied by the field.
141  */
142  if (rect->y1 == rect->y2) {
143  last_zero_sized_index = i;
144  continue;
145  }
146 
147  c_x = rect->x1 + (rect->x2 - rect->x1) / 2.;
148  c_y = rect->y1 + (rect->y2 - rect->y1) / 2.;
149 
150  if (c_x < priv->area.x1 || c_x > priv->area.x2 ||
151  c_y < priv->area.y1 || c_y > priv->area.y2) {
152  priv->end_index = last_zero_sized_index + 1 == i ? i - 1 : i;
153  break;
154  }
155  }
156 
157  if (priv->end_index == -1)
158  return FALSE;
159 
160  *start = priv->start_index;
161  *end = priv->end_index;
162  return TRUE;
163 }

+ Here is the caller graph for this function:

static gchar* get_text_under_element ( AtkObject *  atk_object)
static

Definition at line 166 of file ev-form-field-accessible.c.

167 {
168  gint start = -1;
169  gint end = -1;
170 
171  if (get_indices_in_parent (atk_object, &start, &end) && start != end)
172  return atk_text_get_text (ATK_TEXT (atk_object_get_parent (atk_object)), start, end);
173 
174  return NULL;
175 }

+ Here is the caller graph for this function: