1 /* GAIL - The GNOME Accessibility Implementation Library
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 /* IMPORTANT!!! This source file does NOT contain the implementation
25 * code for AtkUtil - for that code, please see gail/gail.c.
29 * gail_misc_get_extents_from_pango_rectangle:
30 * @widget: The widget that contains the PangoLayout, that contains
32 * @char_rect: The #PangoRectangle from which to calculate extents
33 * @x_layout: The x-offset at which the widget displays the
34 * PangoLayout that contains the PangoRectangle, relative to @widget
35 * @y_layout: The y-offset at which the widget displays the
36 * PangoLayout that contains the PangoRectangle, relative to @widget
37 * @x: The x-position of the #PangoRectangle relative to @coords
38 * @y: The y-position of the #PangoRectangle relative to @coords
39 * @width: The width of the #PangoRectangle
40 * @height: The height of the #PangoRectangle
41 * @coords: An #AtkCoordType enumeration
43 * Gets the extents of @char_rect in device coordinates,
44 * relative to either top-level window or screen coordinates as
45 * specified by @coords.
48 gail_misc_get_extents_from_pango_rectangle (GtkWidget *widget,
49 PangoRectangle *char_rect,
58 gint x_window, y_window, x_toplevel, y_toplevel;
60 gail_misc_get_origins (widget, &x_window, &y_window,
61 &x_toplevel, &y_toplevel);
63 *x = (char_rect->x / PANGO_SCALE) + x_layout + x_window;
64 *y = (char_rect->y / PANGO_SCALE) + y_layout + y_window;
65 if (coords == ATK_XY_WINDOW)
70 else if (coords != ATK_XY_SCREEN)
78 *height = char_rect->height / PANGO_SCALE;
79 *width = char_rect->width / PANGO_SCALE;
85 * gail_misc_get_index_at_point_in_layout:
86 * @widget: A #GtkWidget
87 * @layout: The #PangoLayout from which to get the index at the
89 * @x_layout: The x-offset at which the widget displays the
90 * #PangoLayout, relative to @widget
91 * @y_layout: The y-offset at which the widget displays the
92 * #PangoLayout, relative to @widget
93 * @x: The x-coordinate relative to @coords at which to
95 * @y: The y-coordinate relative to @coords at which to
97 * @coords: An #AtkCoordType enumeration
99 * Gets the byte offset at the specified @x and @y in a #PangoLayout.
101 * Returns: the byte offset at the specified @x and @y in a
105 gail_misc_get_index_at_point_in_layout (GtkWidget *widget,
113 gint index, x_window, y_window, x_toplevel, y_toplevel;
117 gail_misc_get_origins (widget, &x_window, &y_window,
118 &x_toplevel, &y_toplevel);
119 x_temp = x - x_layout - x_window;
120 y_temp = y - y_layout - y_window;
121 if (coords == ATK_XY_WINDOW)
123 x_temp += x_toplevel;
124 y_temp += y_toplevel;
126 else if (coords != ATK_XY_SCREEN)
129 ret = pango_layout_xy_to_index (layout,
130 x_temp * PANGO_SCALE,
131 y_temp * PANGO_SCALE,
135 if (x_temp < 0 || y_temp < 0)
144 * gail_misc_add_attribute:
145 * @attrib_set: The #AtkAttributeSet to add the attribute to
146 * @attr: The AtkTextAttrribute which identifies the attribute to be added
147 * @value: The attribute value
149 * Creates an #AtkAttribute from @attr and @value, and adds it
152 * Returns: A pointer to the new #AtkAttributeSet.
155 gail_misc_add_attribute (AtkAttributeSet *attrib_set,
156 AtkTextAttribute attr,
159 AtkAttributeSet *return_set;
160 AtkAttribute *at = g_malloc (sizeof (AtkAttribute));
161 at->name = g_strdup (atk_text_attribute_get_name (attr));
163 return_set = g_slist_prepend(attrib_set, at);
168 * gail_misc_layout_get_run_attributes:
169 * @attrib_set: The #AtkAttributeSet to add the attribute to
170 * @layout: The PangoLayout from which the attributes will be obtained
172 * @offset: The offset at which the attributes are required
173 * @start_offset: The start offset of the current run
174 * @end_offset: The end offset of the current run
176 * Adds the attributes for the run starting at offset to the specified
179 * Returns: A pointer to the #AtkAttributeSet.
182 gail_misc_layout_get_run_attributes (AtkAttributeSet *attrib_set,
189 PangoAttrIterator *iter;
191 PangoAttrString *pango_string;
192 PangoAttrInt *pango_int;
193 PangoAttrColor *pango_color;
194 PangoAttrLanguage *pango_lang;
195 PangoAttrFloat *pango_float;
196 gint index, start_index, end_index;
197 gboolean is_next = TRUE;
201 len = g_utf8_strlen (text, -1);
202 /* Grab the attributes of the PangoLayout, if any */
203 if ((attr = pango_layout_get_attributes (layout)) == NULL)
209 iter = pango_attr_list_get_iterator (attr);
210 /* Get invariant range offsets */
211 /* If offset out of range, set offset in range */
217 index = g_utf8_offset_to_pointer (text, offset) - text;
218 pango_attr_iterator_range (iter, &start_index, &end_index);
221 if (index >= start_index && index < end_index)
223 *start_offset = g_utf8_pointer_to_offset (text,
225 if (end_index == G_MAXINT)
229 *end_offset = g_utf8_pointer_to_offset (text,
233 is_next = pango_attr_iterator_next (iter);
234 pango_attr_iterator_range (iter, &start_index, &end_index);
237 if ((pango_string = (PangoAttrString*) pango_attr_iterator_get (iter,
238 PANGO_ATTR_FAMILY)) != NULL)
240 value = g_strdup_printf("%s", pango_string->value);
241 attrib_set = gail_misc_add_attribute (attrib_set,
242 ATK_TEXT_ATTR_FAMILY_NAME,
245 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
246 PANGO_ATTR_STYLE)) != NULL)
248 attrib_set = gail_misc_add_attribute (attrib_set,
250 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE, pango_int->value)));
252 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
253 PANGO_ATTR_WEIGHT)) != NULL)
255 value = g_strdup_printf("%i", pango_int->value);
256 attrib_set = gail_misc_add_attribute (attrib_set,
257 ATK_TEXT_ATTR_WEIGHT,
260 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
261 PANGO_ATTR_VARIANT)) != NULL)
263 attrib_set = gail_misc_add_attribute (attrib_set,
264 ATK_TEXT_ATTR_VARIANT,
265 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT, pango_int->value)));
267 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
268 PANGO_ATTR_STRETCH)) != NULL)
270 attrib_set = gail_misc_add_attribute (attrib_set,
271 ATK_TEXT_ATTR_STRETCH,
272 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH, pango_int->value)));
274 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
275 PANGO_ATTR_SIZE)) != NULL)
277 value = g_strdup_printf("%i", pango_int->value / PANGO_SCALE);
278 attrib_set = gail_misc_add_attribute (attrib_set,
282 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
283 PANGO_ATTR_UNDERLINE)) != NULL)
285 attrib_set = gail_misc_add_attribute (attrib_set,
286 ATK_TEXT_ATTR_UNDERLINE,
287 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE, pango_int->value)));
289 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
290 PANGO_ATTR_STRIKETHROUGH)) != NULL)
292 attrib_set = gail_misc_add_attribute (attrib_set,
293 ATK_TEXT_ATTR_STRIKETHROUGH,
294 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH, pango_int->value)));
296 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
297 PANGO_ATTR_RISE)) != NULL)
299 value = g_strdup_printf("%i", pango_int->value);
300 attrib_set = gail_misc_add_attribute (attrib_set,
304 if ((pango_lang = (PangoAttrLanguage*) pango_attr_iterator_get (iter,
305 PANGO_ATTR_LANGUAGE)) != NULL)
307 value = g_strdup( pango_language_to_string( pango_lang->value));
308 attrib_set = gail_misc_add_attribute (attrib_set,
309 ATK_TEXT_ATTR_LANGUAGE,
312 if ((pango_float = (PangoAttrFloat*) pango_attr_iterator_get (iter,
313 PANGO_ATTR_SCALE)) != NULL)
315 value = g_strdup_printf("%g", pango_float->value);
316 attrib_set = gail_misc_add_attribute (attrib_set,
320 if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter,
321 PANGO_ATTR_FOREGROUND)) != NULL)
323 value = g_strdup_printf ("%u,%u,%u",
324 pango_color->color.red,
325 pango_color->color.green,
326 pango_color->color.blue);
327 attrib_set = gail_misc_add_attribute (attrib_set,
328 ATK_TEXT_ATTR_FG_COLOR,
331 if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter,
332 PANGO_ATTR_BACKGROUND)) != NULL)
334 value = g_strdup_printf ("%u,%u,%u",
335 pango_color->color.red,
336 pango_color->color.green,
337 pango_color->color.blue);
338 attrib_set = gail_misc_add_attribute (attrib_set,
339 ATK_TEXT_ATTR_BG_COLOR,
342 pango_attr_iterator_destroy (iter);
347 * gail_misc_get_default_attributes:
348 * @attrib_set: The #AtkAttributeSet to add the attribute to
349 * @layout: The PangoLayout from which the attributes will be obtained
350 * @widget: The GtkWidget for which the default attributes are required.
352 * Adds the default attributes to the specified attribute set.
354 * Returns: A pointer to the #AtkAttributeSet.
357 gail_misc_get_default_attributes (AtkAttributeSet *attrib_set,
361 PangoContext *context;
362 GtkStyle *style_value;
366 attrib_set = gail_misc_add_attribute (attrib_set,
367 ATK_TEXT_ATTR_DIRECTION,
368 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION,
369 gtk_widget_get_direction (widget))));
371 context = pango_layout_get_context (layout);
374 PangoLanguage* language;
375 PangoFontDescription* font;
377 language = pango_context_get_language (context);
380 attrib_set = gail_misc_add_attribute (attrib_set,
381 ATK_TEXT_ATTR_LANGUAGE,
382 g_strdup (pango_language_to_string (language)));
384 font = pango_context_get_font_description (context);
387 attrib_set = gail_misc_add_attribute (attrib_set,
389 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE,
390 pango_font_description_get_style (font))));
391 attrib_set = gail_misc_add_attribute (attrib_set,
392 ATK_TEXT_ATTR_VARIANT,
393 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT,
394 pango_font_description_get_variant (font))));
395 attrib_set = gail_misc_add_attribute (attrib_set,
396 ATK_TEXT_ATTR_STRETCH,
397 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH,
398 pango_font_description_get_stretch (font))));
399 attrib_set = gail_misc_add_attribute (attrib_set,
400 ATK_TEXT_ATTR_FAMILY_NAME,
401 g_strdup (pango_font_description_get_family (font)));
402 attrib_set = gail_misc_add_attribute (attrib_set,
403 ATK_TEXT_ATTR_WEIGHT,
404 g_strdup_printf ("%d",
405 pango_font_description_get_weight (font)));
406 attrib_set = gail_misc_add_attribute (attrib_set,
408 g_strdup_printf ("%i",
409 pango_font_description_get_size (font) / PANGO_SCALE));
412 if (pango_layout_get_justify (layout))
418 PangoAlignment align;
420 align = pango_layout_get_alignment (layout);
421 if (align == PANGO_ALIGN_LEFT)
423 else if (align == PANGO_ALIGN_CENTER)
425 else /* if (align == PANGO_ALIGN_RIGHT) */
428 attrib_set = gail_misc_add_attribute (attrib_set,
429 ATK_TEXT_ATTR_JUSTIFICATION,
430 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION,
432 mode = pango_layout_get_wrap (layout);
433 if (mode == PANGO_WRAP_WORD)
435 else /* if (mode == PANGO_WRAP_CHAR) */
437 attrib_set = gail_misc_add_attribute (attrib_set,
438 ATK_TEXT_ATTR_WRAP_MODE,
439 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_WRAP_MODE,
442 style_value = gtk_widget_get_style (widget);
448 color = style_value->base[GTK_STATE_NORMAL];
449 value = g_strdup_printf ("%u,%u,%u",
450 color.red, color.green, color.blue);
451 attrib_set = gail_misc_add_attribute (attrib_set,
452 ATK_TEXT_ATTR_BG_COLOR,
454 color = style_value->text[GTK_STATE_NORMAL];
455 value = g_strdup_printf ("%u,%u,%u",
456 color.red, color.green, color.blue);
457 attrib_set = gail_misc_add_attribute (attrib_set,
458 ATK_TEXT_ATTR_FG_COLOR,
461 attrib_set = gail_misc_add_attribute (attrib_set,
462 ATK_TEXT_ATTR_FG_STIPPLE,
463 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_FG_STIPPLE,
465 attrib_set = gail_misc_add_attribute (attrib_set,
466 ATK_TEXT_ATTR_BG_STIPPLE,
467 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_BG_STIPPLE,
469 attrib_set = gail_misc_add_attribute (attrib_set,
470 ATK_TEXT_ATTR_STRIKETHROUGH,
471 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH,
473 attrib_set = gail_misc_add_attribute (attrib_set,
474 ATK_TEXT_ATTR_UNDERLINE,
475 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE,
477 attrib_set = gail_misc_add_attribute (attrib_set,
479 g_strdup_printf ("%i", 0));
480 attrib_set = gail_misc_add_attribute (attrib_set,
482 g_strdup_printf ("%g", 1.0));
483 attrib_set = gail_misc_add_attribute (attrib_set,
484 ATK_TEXT_ATTR_BG_FULL_HEIGHT,
485 g_strdup_printf ("%i", 0));
486 attrib_set = gail_misc_add_attribute (attrib_set,
487 ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
488 g_strdup_printf ("%i", 0));
489 attrib_set = gail_misc_add_attribute (attrib_set,
490 ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
491 g_strdup_printf ("%i", 0));
492 attrib_set = gail_misc_add_attribute (attrib_set,
493 ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
494 g_strdup_printf ("%i", 0));
495 attrib_set = gail_misc_add_attribute (attrib_set,
496 ATK_TEXT_ATTR_EDITABLE,
497 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_EDITABLE,
499 attrib_set = gail_misc_add_attribute (attrib_set,
500 ATK_TEXT_ATTR_INVISIBLE,
501 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_INVISIBLE,
503 attrib_set = gail_misc_add_attribute (attrib_set,
504 ATK_TEXT_ATTR_INDENT,
505 g_strdup_printf ("%i", 0));
506 attrib_set = gail_misc_add_attribute (attrib_set,
507 ATK_TEXT_ATTR_RIGHT_MARGIN,
508 g_strdup_printf ("%i", 0));
509 attrib_set = gail_misc_add_attribute (attrib_set,
510 ATK_TEXT_ATTR_LEFT_MARGIN,
511 g_strdup_printf ("%i", 0));
516 * gail_misc_get_origins:
517 * @widget: a #GtkWidget
518 * @x_window: the x-origin of the widget->window
519 * @y_window: the y-origin of the widget->window
520 * @x_toplevel: the x-origin of the toplevel window for widget->window
521 * @y_toplevel: the y-origin of the toplevel window for widget->window
523 * Gets the origin of the widget window, and the origin of the
524 * widgets top-level window.
527 gail_misc_get_origins (GtkWidget *widget,
535 if (GTK_IS_TREE_VIEW (widget))
536 window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
538 window = widget->window;
539 gdk_window_get_origin (window, x_window, y_window);
540 window = gdk_window_get_toplevel (widget->window);
541 gdk_window_get_origin (window, x_toplevel, y_toplevel);
545 * gail_misc_add_to_attr_set:
546 * @attrib_set: An #AtkAttributeSet
547 * @attrs: The #GtkTextAttributes containing the attribute value
548 * @attr: The #AtkTextAttribute to be added
550 * Gets the value for the AtkTextAttribute from the GtkTextAttributes
551 * and adds it to the AttributeSet.
553 * Returns: A pointer to the updated #AtkAttributeSet.
556 gail_misc_add_to_attr_set (AtkAttributeSet *attrib_set,
557 GtkTextAttributes *attrs,
558 AtkTextAttribute attr)
564 case ATK_TEXT_ATTR_LEFT_MARGIN:
565 value = g_strdup_printf ("%i", attrs->left_margin);
567 case ATK_TEXT_ATTR_RIGHT_MARGIN:
568 value = g_strdup_printf ("%i", attrs->right_margin);
570 case ATK_TEXT_ATTR_INDENT:
571 value = g_strdup_printf ("%i", attrs->indent);
573 case ATK_TEXT_ATTR_INVISIBLE:
574 value = g_strdup (atk_text_attribute_get_value (attr, attrs->invisible));
576 case ATK_TEXT_ATTR_EDITABLE:
577 value = g_strdup (atk_text_attribute_get_value (attr, attrs->editable));
579 case ATK_TEXT_ATTR_PIXELS_ABOVE_LINES:
580 value = g_strdup_printf ("%i", attrs->pixels_above_lines);
582 case ATK_TEXT_ATTR_PIXELS_BELOW_LINES:
583 value = g_strdup_printf ("%i", attrs->pixels_below_lines);
585 case ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP:
586 value = g_strdup_printf ("%i", attrs->pixels_inside_wrap);
588 case ATK_TEXT_ATTR_BG_FULL_HEIGHT:
589 value = g_strdup (atk_text_attribute_get_value (attr, attrs->bg_full_height));
591 case ATK_TEXT_ATTR_RISE:
592 value = g_strdup_printf ("%i", attrs->appearance.rise);
594 case ATK_TEXT_ATTR_UNDERLINE:
595 value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.underline));
597 case ATK_TEXT_ATTR_STRIKETHROUGH:
598 value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.strikethrough));
600 case ATK_TEXT_ATTR_SIZE:
601 value = g_strdup_printf ("%i",
602 pango_font_description_get_size (attrs->font) / PANGO_SCALE);
604 case ATK_TEXT_ATTR_SCALE:
605 value = g_strdup_printf ("%g", attrs->font_scale);
607 case ATK_TEXT_ATTR_WEIGHT:
608 value = g_strdup_printf ("%d",
609 pango_font_description_get_weight (attrs->font));
611 case ATK_TEXT_ATTR_LANGUAGE:
612 value = g_strdup ((gchar *)(attrs->language));
614 case ATK_TEXT_ATTR_FAMILY_NAME:
615 value = g_strdup (pango_font_description_get_family (attrs->font));
617 case ATK_TEXT_ATTR_BG_COLOR:
618 value = g_strdup_printf ("%u,%u,%u",
619 attrs->appearance.bg_color.red,
620 attrs->appearance.bg_color.green,
621 attrs->appearance.bg_color.blue);
623 case ATK_TEXT_ATTR_FG_COLOR:
624 value = g_strdup_printf ("%u,%u,%u",
625 attrs->appearance.fg_color.red,
626 attrs->appearance.fg_color.green,
627 attrs->appearance.fg_color.blue);
629 case ATK_TEXT_ATTR_BG_STIPPLE:
630 value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.bg_stipple ? 1 : 0));
632 case ATK_TEXT_ATTR_FG_STIPPLE:
633 value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.fg_stipple ? 1 : 0));
635 case ATK_TEXT_ATTR_WRAP_MODE:
636 value = g_strdup (atk_text_attribute_get_value (attr, attrs->wrap_mode));
638 case ATK_TEXT_ATTR_DIRECTION:
639 value = g_strdup (atk_text_attribute_get_value (attr, attrs->direction));
641 case ATK_TEXT_ATTR_JUSTIFICATION:
642 value = g_strdup (atk_text_attribute_get_value (attr, attrs->justification));
644 case ATK_TEXT_ATTR_STRETCH:
645 value = g_strdup (atk_text_attribute_get_value (attr,
646 pango_font_description_get_stretch (attrs->font)));
648 case ATK_TEXT_ATTR_VARIANT:
649 value = g_strdup (atk_text_attribute_get_value (attr,
650 pango_font_description_get_variant (attrs->font)));
652 case ATK_TEXT_ATTR_STYLE:
653 value = g_strdup (atk_text_attribute_get_value (attr,
654 pango_font_description_get_style (attrs->font)));
660 return gail_misc_add_attribute (attrib_set, attr, value);
664 * gail_misc_buffer_get_run_attributes:
665 * @buffer: The #GtkTextBuffer for which the attributes will be obtained
666 * @offset: The offset at which the attributes are required
667 * @start_offset: The start offset of the current run
668 * @end_offset: The end offset of the current run
670 * Creates an AtkAttributeSet which contains the attributes for the
671 * run starting at offset.
673 * Returns: A pointer to the #AtkAttributeSet.
676 gail_misc_buffer_get_run_attributes (GtkTextBuffer *buffer,
682 AtkAttributeSet *attrib_set = NULL;
684 GSList *tags, *temp_tags;
686 gboolean val_set = FALSE;
689 gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
691 gtk_text_iter_forward_to_tag_toggle (&iter, NULL);
692 *end_offset = gtk_text_iter_get_offset (&iter);
694 gtk_text_iter_backward_to_tag_toggle (&iter, NULL);
695 *start_offset = gtk_text_iter_get_offset (&iter);
697 gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
699 tags = gtk_text_iter_get_tags (&iter);
700 tags = g_slist_reverse (tags);
703 while (temp_tags && !val_set)
705 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
706 PangoFontDescription *font;
708 font = tag->values->font;
712 mask = pango_font_description_get_set_fields (font);
713 val_set = mask & PANGO_FONT_MASK_STYLE;
715 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
716 ATK_TEXT_ATTR_STYLE);
718 temp_tags = temp_tags->next;
723 while (temp_tags && !val_set)
725 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
726 PangoFontDescription *font;
728 font = tag->values->font;
732 mask = pango_font_description_get_set_fields (font);
733 val_set = mask & PANGO_FONT_MASK_VARIANT;
735 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
736 ATK_TEXT_ATTR_VARIANT);
738 temp_tags = temp_tags->next;
743 while (temp_tags && !val_set)
745 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
746 PangoFontDescription *font;
748 font = tag->values->font;
752 mask = pango_font_description_get_set_fields (font);
753 val_set = mask & PANGO_FONT_MASK_STRETCH;
755 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
756 ATK_TEXT_ATTR_STRETCH);
758 temp_tags = temp_tags->next;
763 while (temp_tags && !val_set)
765 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
767 val_set = tag->justification_set;
769 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
770 ATK_TEXT_ATTR_JUSTIFICATION);
771 temp_tags = temp_tags->next;
776 while (temp_tags && !val_set)
778 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
780 if (tag->values->direction != GTK_TEXT_DIR_NONE)
783 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
784 ATK_TEXT_ATTR_DIRECTION);
786 temp_tags = temp_tags->next;
791 while (temp_tags && !val_set)
793 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
795 val_set = tag->wrap_mode_set;
797 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
798 ATK_TEXT_ATTR_WRAP_MODE);
799 temp_tags = temp_tags->next;
804 while (temp_tags && !val_set)
806 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
808 val_set = tag->fg_stipple_set;
810 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
811 ATK_TEXT_ATTR_FG_STIPPLE);
812 temp_tags = temp_tags->next;
817 while (temp_tags && !val_set)
819 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
821 val_set = tag->bg_stipple_set;
823 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
824 ATK_TEXT_ATTR_BG_STIPPLE);
825 temp_tags = temp_tags->next;
830 while (temp_tags && !val_set)
832 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
834 val_set = tag->fg_color_set;
836 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
837 ATK_TEXT_ATTR_FG_COLOR);
838 temp_tags = temp_tags->next;
843 while (temp_tags && !val_set)
845 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
847 val_set = tag->bg_color_set;
849 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
850 ATK_TEXT_ATTR_BG_COLOR);
851 temp_tags = temp_tags->next;
856 while (temp_tags && !val_set)
858 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
859 PangoFontDescription *font;
861 font = tag->values->font;
865 mask = pango_font_description_get_set_fields (font);
866 val_set = mask & PANGO_FONT_MASK_FAMILY;
868 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
869 ATK_TEXT_ATTR_FAMILY_NAME);
871 temp_tags = temp_tags->next;
876 while (temp_tags && !val_set)
878 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
880 val_set = tag->language_set;
882 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
883 ATK_TEXT_ATTR_LANGUAGE);
884 temp_tags = temp_tags->next;
889 while (temp_tags && !val_set)
891 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
892 PangoFontDescription *font;
894 font = tag->values->font;
898 mask = pango_font_description_get_set_fields (font);
899 val_set = mask & PANGO_FONT_MASK_WEIGHT;
901 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
902 ATK_TEXT_ATTR_WEIGHT);
904 temp_tags = temp_tags->next;
910 * scale is special as the scale is the product of all scale values
916 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
921 scale *= tag->values->font_scale;
923 temp_tags = temp_tags->next;
927 at = g_malloc(sizeof(AtkAttribute));
928 at->name = g_strdup(atk_text_attribute_get_name (ATK_TEXT_ATTR_SCALE));
929 at->value = g_strdup_printf("%g", scale);
930 attrib_set = g_slist_prepend(attrib_set, at);
935 while (temp_tags && !val_set)
937 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
938 PangoFontDescription *font;
940 font = tag->values->font;
944 mask = pango_font_description_get_set_fields (font);
945 val_set = mask & PANGO_FONT_MASK_SIZE;
947 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
950 temp_tags = temp_tags->next;
955 while (temp_tags && !val_set)
957 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
959 val_set = tag->strikethrough_set;
961 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
962 ATK_TEXT_ATTR_STRIKETHROUGH);
963 temp_tags = temp_tags->next;
968 while (temp_tags && !val_set)
970 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
972 val_set = tag->underline_set;
974 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
975 ATK_TEXT_ATTR_UNDERLINE);
976 temp_tags = temp_tags->next;
981 while (temp_tags && !val_set)
983 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
985 val_set = tag->rise_set;
987 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
989 temp_tags = temp_tags->next;
994 while (temp_tags && !val_set)
996 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
998 val_set = tag->bg_full_height_set;
1000 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1001 ATK_TEXT_ATTR_BG_FULL_HEIGHT);
1002 temp_tags = temp_tags->next;
1007 while (temp_tags && !val_set)
1009 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1011 val_set = tag->pixels_inside_wrap_set;
1013 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1014 ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP);
1015 temp_tags = temp_tags->next;
1020 while (temp_tags && !val_set)
1022 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1024 val_set = tag->pixels_below_lines_set;
1026 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1027 ATK_TEXT_ATTR_PIXELS_BELOW_LINES);
1028 temp_tags = temp_tags->next;
1033 while (temp_tags && !val_set)
1035 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1037 val_set = tag->pixels_above_lines_set;
1039 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1040 ATK_TEXT_ATTR_PIXELS_ABOVE_LINES);
1041 temp_tags = temp_tags->next;
1046 while (temp_tags && !val_set)
1048 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1050 val_set = tag->editable_set;
1052 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1053 ATK_TEXT_ATTR_EDITABLE);
1054 temp_tags = temp_tags->next;
1059 while (temp_tags && !val_set)
1061 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1063 val_set = tag->invisible_set;
1065 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1066 ATK_TEXT_ATTR_INVISIBLE);
1067 temp_tags = temp_tags->next;
1072 while (temp_tags && !val_set)
1074 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1076 val_set = tag->indent_set;
1078 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1079 ATK_TEXT_ATTR_INDENT);
1080 temp_tags = temp_tags->next;
1085 while (temp_tags && !val_set)
1087 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1089 val_set = tag->right_margin_set;
1091 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1092 ATK_TEXT_ATTR_RIGHT_MARGIN);
1093 temp_tags = temp_tags->next;
1098 while (temp_tags && !val_set)
1100 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1102 val_set = tag->left_margin_set;
1104 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1105 ATK_TEXT_ATTR_LEFT_MARGIN);
1106 temp_tags = temp_tags->next;
1110 g_slist_free (tags);