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.
26 /* IMPORTANT!!! This source file does NOT contain the implementation
27 * code for AtkUtil - for that code, please see gail/gail.c.
31 * gail_misc_get_extents_from_pango_rectangle:
32 * @widget: The widget that contains the PangoLayout, that contains
34 * @char_rect: The #PangoRectangle from which to calculate extents
35 * @x_layout: The x-offset at which the widget displays the
36 * PangoLayout that contains the PangoRectangle, relative to @widget
37 * @y_layout: The y-offset at which the widget displays the
38 * PangoLayout that contains the PangoRectangle, relative to @widget
39 * @x: The x-position of the #PangoRectangle relative to @coords
40 * @y: The y-position of the #PangoRectangle relative to @coords
41 * @width: The width of the #PangoRectangle
42 * @height: The height of the #PangoRectangle
43 * @coords: An #AtkCoordType enumeration
45 * Gets the extents of @char_rect in device coordinates,
46 * relative to either top-level window or screen coordinates as
47 * specified by @coords.
50 gail_misc_get_extents_from_pango_rectangle (GtkWidget *widget,
51 PangoRectangle *char_rect,
60 gint x_window, y_window, x_toplevel, y_toplevel;
62 gail_misc_get_origins (widget, &x_window, &y_window,
63 &x_toplevel, &y_toplevel);
65 *x = (char_rect->x / PANGO_SCALE) + x_layout + x_window;
66 *y = (char_rect->y / PANGO_SCALE) + y_layout + y_window;
67 if (coords == ATK_XY_WINDOW)
72 else if (coords != ATK_XY_SCREEN)
80 *height = char_rect->height / PANGO_SCALE;
81 *width = char_rect->width / PANGO_SCALE;
87 * gail_misc_get_index_at_point_in_layout:
88 * @widget: A #GtkWidget
89 * @layout: The #PangoLayout from which to get the index at the
91 * @x_layout: The x-offset at which the widget displays the
92 * #PangoLayout, relative to @widget
93 * @y_layout: The y-offset at which the widget displays the
94 * #PangoLayout, relative to @widget
95 * @x: The x-coordinate relative to @coords at which to
97 * @y: The y-coordinate relative to @coords at which to
99 * @coords: An #AtkCoordType enumeration
101 * Gets the byte offset at the specified @x and @y in a #PangoLayout.
103 * Returns: the byte offset at the specified @x and @y in a
107 gail_misc_get_index_at_point_in_layout (GtkWidget *widget,
115 gint index, x_window, y_window, x_toplevel, y_toplevel;
119 gail_misc_get_origins (widget, &x_window, &y_window,
120 &x_toplevel, &y_toplevel);
121 x_temp = x - x_layout - x_window;
122 y_temp = y - y_layout - y_window;
123 if (coords == ATK_XY_WINDOW)
125 x_temp += x_toplevel;
126 y_temp += y_toplevel;
128 else if (coords != ATK_XY_SCREEN)
131 ret = pango_layout_xy_to_index (layout,
132 x_temp * PANGO_SCALE,
133 y_temp * PANGO_SCALE,
137 if (x_temp < 0 || y_temp < 0)
146 * gail_misc_add_attribute:
147 * @attrib_set: The #AtkAttributeSet to add the attribute to
148 * @attr: The AtkTextAttrribute which identifies the attribute to be added
149 * @value: The attribute value
151 * Creates an #AtkAttribute from @attr and @value, and adds it
154 * Returns: A pointer to the new #AtkAttributeSet.
157 gail_misc_add_attribute (AtkAttributeSet *attrib_set,
158 AtkTextAttribute attr,
161 AtkAttributeSet *return_set;
162 AtkAttribute *at = g_malloc (sizeof (AtkAttribute));
163 at->name = g_strdup (atk_text_attribute_get_name (attr));
165 return_set = g_slist_prepend(attrib_set, at);
170 * gail_misc_layout_get_run_attributes:
171 * @attrib_set: The #AtkAttributeSet to add the attribute to
172 * @layout: The PangoLayout from which the attributes will be obtained
174 * @offset: The offset at which the attributes are required
175 * @start_offset: The start offset of the current run
176 * @end_offset: The end offset of the current run
178 * Adds the attributes for the run starting at offset to the specified
181 * Returns: A pointer to the #AtkAttributeSet.
184 gail_misc_layout_get_run_attributes (AtkAttributeSet *attrib_set,
191 PangoAttrIterator *iter;
193 PangoAttrString *pango_string;
194 PangoAttrInt *pango_int;
195 PangoAttrColor *pango_color;
196 PangoAttrLanguage *pango_lang;
197 PangoAttrFloat *pango_float;
198 gint index, start_index, end_index;
199 gboolean is_next = TRUE;
203 len = g_utf8_strlen (text, -1);
204 /* Grab the attributes of the PangoLayout, if any */
205 if ((attr = pango_layout_get_attributes (layout)) == NULL)
211 iter = pango_attr_list_get_iterator (attr);
212 /* Get invariant range offsets */
213 /* If offset out of range, set offset in range */
219 index = g_utf8_offset_to_pointer (text, offset) - text;
220 pango_attr_iterator_range (iter, &start_index, &end_index);
223 if (index >= start_index && index < end_index)
225 *start_offset = g_utf8_pointer_to_offset (text,
227 if (end_index == G_MAXINT)
231 *end_offset = g_utf8_pointer_to_offset (text,
235 is_next = pango_attr_iterator_next (iter);
236 pango_attr_iterator_range (iter, &start_index, &end_index);
239 if ((pango_string = (PangoAttrString*) pango_attr_iterator_get (iter,
240 PANGO_ATTR_FAMILY)) != NULL)
242 value = g_strdup_printf("%s", pango_string->value);
243 attrib_set = gail_misc_add_attribute (attrib_set,
244 ATK_TEXT_ATTR_FAMILY_NAME,
247 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
248 PANGO_ATTR_STYLE)) != NULL)
250 attrib_set = gail_misc_add_attribute (attrib_set,
252 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE, pango_int->value)));
254 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
255 PANGO_ATTR_WEIGHT)) != NULL)
257 value = g_strdup_printf("%i", pango_int->value);
258 attrib_set = gail_misc_add_attribute (attrib_set,
259 ATK_TEXT_ATTR_WEIGHT,
262 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
263 PANGO_ATTR_VARIANT)) != NULL)
265 attrib_set = gail_misc_add_attribute (attrib_set,
266 ATK_TEXT_ATTR_VARIANT,
267 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT, pango_int->value)));
269 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
270 PANGO_ATTR_STRETCH)) != NULL)
272 attrib_set = gail_misc_add_attribute (attrib_set,
273 ATK_TEXT_ATTR_STRETCH,
274 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH, pango_int->value)));
276 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
277 PANGO_ATTR_SIZE)) != NULL)
279 value = g_strdup_printf("%i", pango_int->value / PANGO_SCALE);
280 attrib_set = gail_misc_add_attribute (attrib_set,
284 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
285 PANGO_ATTR_UNDERLINE)) != NULL)
287 attrib_set = gail_misc_add_attribute (attrib_set,
288 ATK_TEXT_ATTR_UNDERLINE,
289 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE, pango_int->value)));
291 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
292 PANGO_ATTR_STRIKETHROUGH)) != NULL)
294 attrib_set = gail_misc_add_attribute (attrib_set,
295 ATK_TEXT_ATTR_STRIKETHROUGH,
296 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH, pango_int->value)));
298 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
299 PANGO_ATTR_RISE)) != NULL)
301 value = g_strdup_printf("%i", pango_int->value);
302 attrib_set = gail_misc_add_attribute (attrib_set,
306 if ((pango_lang = (PangoAttrLanguage*) pango_attr_iterator_get (iter,
307 PANGO_ATTR_LANGUAGE)) != NULL)
309 value = g_strdup( pango_language_to_string( pango_lang->value));
310 attrib_set = gail_misc_add_attribute (attrib_set,
311 ATK_TEXT_ATTR_LANGUAGE,
314 if ((pango_float = (PangoAttrFloat*) pango_attr_iterator_get (iter,
315 PANGO_ATTR_SCALE)) != NULL)
317 value = g_strdup_printf("%g", pango_float->value);
318 attrib_set = gail_misc_add_attribute (attrib_set,
322 if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter,
323 PANGO_ATTR_FOREGROUND)) != NULL)
325 value = g_strdup_printf ("%u,%u,%u",
326 pango_color->color.red,
327 pango_color->color.green,
328 pango_color->color.blue);
329 attrib_set = gail_misc_add_attribute (attrib_set,
330 ATK_TEXT_ATTR_FG_COLOR,
333 if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter,
334 PANGO_ATTR_BACKGROUND)) != NULL)
336 value = g_strdup_printf ("%u,%u,%u",
337 pango_color->color.red,
338 pango_color->color.green,
339 pango_color->color.blue);
340 attrib_set = gail_misc_add_attribute (attrib_set,
341 ATK_TEXT_ATTR_BG_COLOR,
344 pango_attr_iterator_destroy (iter);
349 * gail_misc_get_default_attributes:
350 * @attrib_set: The #AtkAttributeSet to add the attribute to
351 * @layout: The PangoLayout from which the attributes will be obtained
352 * @widget: The GtkWidget for which the default attributes are required.
354 * Adds the default attributes to the specified attribute set.
356 * Returns: A pointer to the #AtkAttributeSet.
359 gail_misc_get_default_attributes (AtkAttributeSet *attrib_set,
363 PangoContext *context;
364 GtkStyle *style_value;
368 attrib_set = gail_misc_add_attribute (attrib_set,
369 ATK_TEXT_ATTR_DIRECTION,
370 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION,
371 gtk_widget_get_direction (widget))));
373 context = pango_layout_get_context (layout);
376 PangoLanguage* language;
377 PangoFontDescription* font;
379 language = pango_context_get_language (context);
382 attrib_set = gail_misc_add_attribute (attrib_set,
383 ATK_TEXT_ATTR_LANGUAGE,
384 g_strdup (pango_language_to_string (language)));
386 font = pango_context_get_font_description (context);
389 attrib_set = gail_misc_add_attribute (attrib_set,
391 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE,
392 pango_font_description_get_style (font))));
393 attrib_set = gail_misc_add_attribute (attrib_set,
394 ATK_TEXT_ATTR_VARIANT,
395 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT,
396 pango_font_description_get_variant (font))));
397 attrib_set = gail_misc_add_attribute (attrib_set,
398 ATK_TEXT_ATTR_STRETCH,
399 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH,
400 pango_font_description_get_stretch (font))));
401 attrib_set = gail_misc_add_attribute (attrib_set,
402 ATK_TEXT_ATTR_FAMILY_NAME,
403 g_strdup (pango_font_description_get_family (font)));
404 attrib_set = gail_misc_add_attribute (attrib_set,
405 ATK_TEXT_ATTR_WEIGHT,
406 g_strdup_printf ("%d",
407 pango_font_description_get_weight (font)));
408 attrib_set = gail_misc_add_attribute (attrib_set,
410 g_strdup_printf ("%i",
411 pango_font_description_get_size (font) / PANGO_SCALE));
414 if (pango_layout_get_justify (layout))
420 PangoAlignment align;
422 align = pango_layout_get_alignment (layout);
423 if (align == PANGO_ALIGN_LEFT)
425 else if (align == PANGO_ALIGN_CENTER)
427 else /* if (align == PANGO_ALIGN_RIGHT) */
430 attrib_set = gail_misc_add_attribute (attrib_set,
431 ATK_TEXT_ATTR_JUSTIFICATION,
432 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION,
434 mode = pango_layout_get_wrap (layout);
435 if (mode == PANGO_WRAP_WORD)
437 else /* if (mode == PANGO_WRAP_CHAR) */
439 attrib_set = gail_misc_add_attribute (attrib_set,
440 ATK_TEXT_ATTR_WRAP_MODE,
441 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_WRAP_MODE,
444 style_value = gtk_widget_get_style (widget);
450 color = style_value->base[GTK_STATE_NORMAL];
451 value = g_strdup_printf ("%u,%u,%u",
452 color.red, color.green, color.blue);
453 attrib_set = gail_misc_add_attribute (attrib_set,
454 ATK_TEXT_ATTR_BG_COLOR,
456 color = style_value->text[GTK_STATE_NORMAL];
457 value = g_strdup_printf ("%u,%u,%u",
458 color.red, color.green, color.blue);
459 attrib_set = gail_misc_add_attribute (attrib_set,
460 ATK_TEXT_ATTR_FG_COLOR,
463 attrib_set = gail_misc_add_attribute (attrib_set,
464 ATK_TEXT_ATTR_FG_STIPPLE,
465 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_FG_STIPPLE,
467 attrib_set = gail_misc_add_attribute (attrib_set,
468 ATK_TEXT_ATTR_BG_STIPPLE,
469 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_BG_STIPPLE,
471 attrib_set = gail_misc_add_attribute (attrib_set,
472 ATK_TEXT_ATTR_STRIKETHROUGH,
473 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH,
475 attrib_set = gail_misc_add_attribute (attrib_set,
476 ATK_TEXT_ATTR_UNDERLINE,
477 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE,
479 attrib_set = gail_misc_add_attribute (attrib_set,
481 g_strdup_printf ("%i", 0));
482 attrib_set = gail_misc_add_attribute (attrib_set,
484 g_strdup_printf ("%g", 1.0));
485 attrib_set = gail_misc_add_attribute (attrib_set,
486 ATK_TEXT_ATTR_BG_FULL_HEIGHT,
487 g_strdup_printf ("%i", 0));
488 attrib_set = gail_misc_add_attribute (attrib_set,
489 ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
490 g_strdup_printf ("%i", 0));
491 attrib_set = gail_misc_add_attribute (attrib_set,
492 ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
493 g_strdup_printf ("%i", 0));
494 attrib_set = gail_misc_add_attribute (attrib_set,
495 ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
496 g_strdup_printf ("%i", 0));
497 attrib_set = gail_misc_add_attribute (attrib_set,
498 ATK_TEXT_ATTR_EDITABLE,
499 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_EDITABLE,
501 attrib_set = gail_misc_add_attribute (attrib_set,
502 ATK_TEXT_ATTR_INVISIBLE,
503 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_INVISIBLE,
505 attrib_set = gail_misc_add_attribute (attrib_set,
506 ATK_TEXT_ATTR_INDENT,
507 g_strdup_printf ("%i", 0));
508 attrib_set = gail_misc_add_attribute (attrib_set,
509 ATK_TEXT_ATTR_RIGHT_MARGIN,
510 g_strdup_printf ("%i", 0));
511 attrib_set = gail_misc_add_attribute (attrib_set,
512 ATK_TEXT_ATTR_LEFT_MARGIN,
513 g_strdup_printf ("%i", 0));
518 * gail_misc_get_origins:
519 * @widget: a #GtkWidget
520 * @x_window: the x-origin of the widget->window
521 * @y_window: the y-origin of the widget->window
522 * @x_toplevel: the x-origin of the toplevel window for widget->window
523 * @y_toplevel: the y-origin of the toplevel window for widget->window
525 * Gets the origin of the widget window, and the origin of the
526 * widgets top-level window.
529 gail_misc_get_origins (GtkWidget *widget,
537 if (GTK_IS_TREE_VIEW (widget))
538 window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
540 window = widget->window;
541 gdk_window_get_origin (window, x_window, y_window);
542 window = gdk_window_get_toplevel (widget->window);
543 gdk_window_get_origin (window, x_toplevel, y_toplevel);
547 * gail_misc_add_to_attr_set:
548 * @attrib_set: An #AtkAttributeSet
549 * @attrs: The #GtkTextAttributes containing the attribute value
550 * @attr: The #AtkTextAttribute to be added
552 * Gets the value for the AtkTextAttribute from the GtkTextAttributes
553 * and adds it to the AttributeSet.
555 * Returns: A pointer to the updated #AtkAttributeSet.
558 gail_misc_add_to_attr_set (AtkAttributeSet *attrib_set,
559 GtkTextAttributes *attrs,
560 AtkTextAttribute attr)
566 case ATK_TEXT_ATTR_LEFT_MARGIN:
567 value = g_strdup_printf ("%i", attrs->left_margin);
569 case ATK_TEXT_ATTR_RIGHT_MARGIN:
570 value = g_strdup_printf ("%i", attrs->right_margin);
572 case ATK_TEXT_ATTR_INDENT:
573 value = g_strdup_printf ("%i", attrs->indent);
575 case ATK_TEXT_ATTR_INVISIBLE:
576 value = g_strdup (atk_text_attribute_get_value (attr, attrs->invisible));
578 case ATK_TEXT_ATTR_EDITABLE:
579 value = g_strdup (atk_text_attribute_get_value (attr, attrs->editable));
581 case ATK_TEXT_ATTR_PIXELS_ABOVE_LINES:
582 value = g_strdup_printf ("%i", attrs->pixels_above_lines);
584 case ATK_TEXT_ATTR_PIXELS_BELOW_LINES:
585 value = g_strdup_printf ("%i", attrs->pixels_below_lines);
587 case ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP:
588 value = g_strdup_printf ("%i", attrs->pixels_inside_wrap);
590 case ATK_TEXT_ATTR_BG_FULL_HEIGHT:
591 value = g_strdup (atk_text_attribute_get_value (attr, attrs->bg_full_height));
593 case ATK_TEXT_ATTR_RISE:
594 value = g_strdup_printf ("%i", attrs->appearance.rise);
596 case ATK_TEXT_ATTR_UNDERLINE:
597 value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.underline));
599 case ATK_TEXT_ATTR_STRIKETHROUGH:
600 value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.strikethrough));
602 case ATK_TEXT_ATTR_SIZE:
603 value = g_strdup_printf ("%i",
604 pango_font_description_get_size (attrs->font) / PANGO_SCALE);
606 case ATK_TEXT_ATTR_SCALE:
607 value = g_strdup_printf ("%g", attrs->font_scale);
609 case ATK_TEXT_ATTR_WEIGHT:
610 value = g_strdup_printf ("%d",
611 pango_font_description_get_weight (attrs->font));
613 case ATK_TEXT_ATTR_LANGUAGE:
614 value = g_strdup ((gchar *)(attrs->language));
616 case ATK_TEXT_ATTR_FAMILY_NAME:
617 value = g_strdup (pango_font_description_get_family (attrs->font));
619 case ATK_TEXT_ATTR_BG_COLOR:
620 value = g_strdup_printf ("%u,%u,%u",
621 attrs->appearance.bg_color.red,
622 attrs->appearance.bg_color.green,
623 attrs->appearance.bg_color.blue);
625 case ATK_TEXT_ATTR_FG_COLOR:
626 value = g_strdup_printf ("%u,%u,%u",
627 attrs->appearance.fg_color.red,
628 attrs->appearance.fg_color.green,
629 attrs->appearance.fg_color.blue);
631 case ATK_TEXT_ATTR_BG_STIPPLE:
632 value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.bg_stipple ? 1 : 0));
634 case ATK_TEXT_ATTR_FG_STIPPLE:
635 value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.fg_stipple ? 1 : 0));
637 case ATK_TEXT_ATTR_WRAP_MODE:
638 value = g_strdup (atk_text_attribute_get_value (attr, attrs->wrap_mode));
640 case ATK_TEXT_ATTR_DIRECTION:
641 value = g_strdup (atk_text_attribute_get_value (attr, attrs->direction));
643 case ATK_TEXT_ATTR_JUSTIFICATION:
644 value = g_strdup (atk_text_attribute_get_value (attr, attrs->justification));
646 case ATK_TEXT_ATTR_STRETCH:
647 value = g_strdup (atk_text_attribute_get_value (attr,
648 pango_font_description_get_stretch (attrs->font)));
650 case ATK_TEXT_ATTR_VARIANT:
651 value = g_strdup (atk_text_attribute_get_value (attr,
652 pango_font_description_get_variant (attrs->font)));
654 case ATK_TEXT_ATTR_STYLE:
655 value = g_strdup (atk_text_attribute_get_value (attr,
656 pango_font_description_get_style (attrs->font)));
662 return gail_misc_add_attribute (attrib_set, attr, value);
666 * gail_misc_buffer_get_run_attributes:
667 * @buffer: The #GtkTextBuffer for which the attributes will be obtained
668 * @offset: The offset at which the attributes are required
669 * @start_offset: The start offset of the current run
670 * @end_offset: The end offset of the current run
672 * Creates an AtkAttributeSet which contains the attributes for the
673 * run starting at offset.
675 * Returns: A pointer to the #AtkAttributeSet.
678 gail_misc_buffer_get_run_attributes (GtkTextBuffer *buffer,
684 AtkAttributeSet *attrib_set = NULL;
686 GSList *tags, *temp_tags;
688 gboolean val_set = FALSE;
691 gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
693 gtk_text_iter_forward_to_tag_toggle (&iter, NULL);
694 *end_offset = gtk_text_iter_get_offset (&iter);
696 gtk_text_iter_backward_to_tag_toggle (&iter, NULL);
697 *start_offset = gtk_text_iter_get_offset (&iter);
699 gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
701 tags = gtk_text_iter_get_tags (&iter);
702 tags = g_slist_reverse (tags);
705 while (temp_tags && !val_set)
707 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
708 PangoFontDescription *font;
710 font = tag->values->font;
714 mask = pango_font_description_get_set_fields (font);
715 val_set = mask & PANGO_FONT_MASK_STYLE;
717 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
718 ATK_TEXT_ATTR_STYLE);
720 temp_tags = temp_tags->next;
725 while (temp_tags && !val_set)
727 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
728 PangoFontDescription *font;
730 font = tag->values->font;
734 mask = pango_font_description_get_set_fields (font);
735 val_set = mask & PANGO_FONT_MASK_VARIANT;
737 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
738 ATK_TEXT_ATTR_VARIANT);
740 temp_tags = temp_tags->next;
745 while (temp_tags && !val_set)
747 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
748 PangoFontDescription *font;
750 font = tag->values->font;
754 mask = pango_font_description_get_set_fields (font);
755 val_set = mask & PANGO_FONT_MASK_STRETCH;
757 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
758 ATK_TEXT_ATTR_STRETCH);
760 temp_tags = temp_tags->next;
765 while (temp_tags && !val_set)
767 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
769 val_set = tag->justification_set;
771 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
772 ATK_TEXT_ATTR_JUSTIFICATION);
773 temp_tags = temp_tags->next;
778 while (temp_tags && !val_set)
780 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
782 if (tag->values->direction != GTK_TEXT_DIR_NONE)
785 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
786 ATK_TEXT_ATTR_DIRECTION);
788 temp_tags = temp_tags->next;
793 while (temp_tags && !val_set)
795 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
797 val_set = tag->wrap_mode_set;
799 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
800 ATK_TEXT_ATTR_WRAP_MODE);
801 temp_tags = temp_tags->next;
806 while (temp_tags && !val_set)
808 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
810 val_set = tag->fg_stipple_set;
812 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
813 ATK_TEXT_ATTR_FG_STIPPLE);
814 temp_tags = temp_tags->next;
819 while (temp_tags && !val_set)
821 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
823 val_set = tag->bg_stipple_set;
825 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
826 ATK_TEXT_ATTR_BG_STIPPLE);
827 temp_tags = temp_tags->next;
832 while (temp_tags && !val_set)
834 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
836 val_set = tag->fg_color_set;
838 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
839 ATK_TEXT_ATTR_FG_COLOR);
840 temp_tags = temp_tags->next;
845 while (temp_tags && !val_set)
847 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
849 val_set = tag->bg_color_set;
851 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
852 ATK_TEXT_ATTR_BG_COLOR);
853 temp_tags = temp_tags->next;
858 while (temp_tags && !val_set)
860 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
861 PangoFontDescription *font;
863 font = tag->values->font;
867 mask = pango_font_description_get_set_fields (font);
868 val_set = mask & PANGO_FONT_MASK_FAMILY;
870 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
871 ATK_TEXT_ATTR_FAMILY_NAME);
873 temp_tags = temp_tags->next;
878 while (temp_tags && !val_set)
880 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
882 val_set = tag->language_set;
884 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
885 ATK_TEXT_ATTR_LANGUAGE);
886 temp_tags = temp_tags->next;
891 while (temp_tags && !val_set)
893 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
894 PangoFontDescription *font;
896 font = tag->values->font;
900 mask = pango_font_description_get_set_fields (font);
901 val_set = mask & PANGO_FONT_MASK_WEIGHT;
903 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
904 ATK_TEXT_ATTR_WEIGHT);
906 temp_tags = temp_tags->next;
912 * scale is special as the scale is the product of all scale values
918 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
923 scale *= tag->values->font_scale;
925 temp_tags = temp_tags->next;
929 at = g_malloc(sizeof(AtkAttribute));
930 at->name = g_strdup(atk_text_attribute_get_name (ATK_TEXT_ATTR_SCALE));
931 at->value = g_strdup_printf("%g", scale);
932 attrib_set = g_slist_prepend(attrib_set, at);
937 while (temp_tags && !val_set)
939 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
940 PangoFontDescription *font;
942 font = tag->values->font;
946 mask = pango_font_description_get_set_fields (font);
947 val_set = mask & PANGO_FONT_MASK_SIZE;
949 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
952 temp_tags = temp_tags->next;
957 while (temp_tags && !val_set)
959 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
961 val_set = tag->strikethrough_set;
963 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
964 ATK_TEXT_ATTR_STRIKETHROUGH);
965 temp_tags = temp_tags->next;
970 while (temp_tags && !val_set)
972 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
974 val_set = tag->underline_set;
976 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
977 ATK_TEXT_ATTR_UNDERLINE);
978 temp_tags = temp_tags->next;
983 while (temp_tags && !val_set)
985 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
987 val_set = tag->rise_set;
989 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
991 temp_tags = temp_tags->next;
996 while (temp_tags && !val_set)
998 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1000 val_set = tag->bg_full_height_set;
1002 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1003 ATK_TEXT_ATTR_BG_FULL_HEIGHT);
1004 temp_tags = temp_tags->next;
1009 while (temp_tags && !val_set)
1011 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1013 val_set = tag->pixels_inside_wrap_set;
1015 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1016 ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP);
1017 temp_tags = temp_tags->next;
1022 while (temp_tags && !val_set)
1024 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1026 val_set = tag->pixels_below_lines_set;
1028 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1029 ATK_TEXT_ATTR_PIXELS_BELOW_LINES);
1030 temp_tags = temp_tags->next;
1035 while (temp_tags && !val_set)
1037 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1039 val_set = tag->pixels_above_lines_set;
1041 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1042 ATK_TEXT_ATTR_PIXELS_ABOVE_LINES);
1043 temp_tags = temp_tags->next;
1048 while (temp_tags && !val_set)
1050 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1052 val_set = tag->editable_set;
1054 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1055 ATK_TEXT_ATTR_EDITABLE);
1056 temp_tags = temp_tags->next;
1061 while (temp_tags && !val_set)
1063 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1065 val_set = tag->invisible_set;
1067 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1068 ATK_TEXT_ATTR_INVISIBLE);
1069 temp_tags = temp_tags->next;
1074 while (temp_tags && !val_set)
1076 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1078 val_set = tag->indent_set;
1080 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1081 ATK_TEXT_ATTR_INDENT);
1082 temp_tags = temp_tags->next;
1087 while (temp_tags && !val_set)
1089 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1091 val_set = tag->right_margin_set;
1093 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1094 ATK_TEXT_ATTR_RIGHT_MARGIN);
1095 temp_tags = temp_tags->next;
1100 while (temp_tags && !val_set)
1102 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1104 val_set = tag->left_margin_set;
1106 attrib_set = gail_misc_add_to_attr_set (attrib_set, tag->values,
1107 ATK_TEXT_ATTR_LEFT_MARGIN);
1108 temp_tags = temp_tags->next;
1112 g_slist_free (tags);