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, see <http://www.gnu.org/licenses/>.
25 /* IMPORTANT!!! This source file does NOT contain the implementation
26 * code for AtkUtil - for that code, please see gail/gail.c.
31 * @Short_description: GailMisc is a set of utility functions which may be
32 * useful to implementors of Atk interfaces for custom widgets.
35 * GailMisc is a set of utility function which are used in the implemementation
36 * of Atk interfaces for GTK+ widgets. They may be useful to implementors of
37 * Atk interfaces for custom widgets.
42 * gail_misc_get_extents_from_pango_rectangle:
43 * @widget: The widget that contains the PangoLayout, that contains
45 * @char_rect: The #PangoRectangle from which to calculate extents
46 * @x_layout: The x-offset at which the widget displays the
47 * PangoLayout that contains the PangoRectangle, relative to @widget
48 * @y_layout: The y-offset at which the widget displays the
49 * PangoLayout that contains the PangoRectangle, relative to @widget
50 * @x: The x-position of the #PangoRectangle relative to @coords
51 * @y: The y-position of the #PangoRectangle relative to @coords
52 * @width: The width of the #PangoRectangle
53 * @height: The height of the #PangoRectangle
54 * @coords: An #AtkCoordType enumeration
56 * Gets the extents of @char_rect in device coordinates,
57 * relative to either top-level window or screen coordinates as
58 * specified by @coords.
61 gail_misc_get_extents_from_pango_rectangle (GtkWidget *widget,
62 PangoRectangle *char_rect,
71 gint x_window, y_window, x_toplevel, y_toplevel;
73 gail_misc_get_origins (widget, &x_window, &y_window,
74 &x_toplevel, &y_toplevel);
76 *x = (char_rect->x / PANGO_SCALE) + x_layout + x_window;
77 *y = (char_rect->y / PANGO_SCALE) + y_layout + y_window;
78 if (coords == ATK_XY_WINDOW)
83 else if (coords != ATK_XY_SCREEN)
91 *height = char_rect->height / PANGO_SCALE;
92 *width = char_rect->width / PANGO_SCALE;
98 * gail_misc_get_index_at_point_in_layout:
99 * @widget: A #GtkWidget
100 * @layout: The #PangoLayout from which to get the index at the
102 * @x_layout: The x-offset at which the widget displays the
103 * #PangoLayout, relative to @widget
104 * @y_layout: The y-offset at which the widget displays the
105 * #PangoLayout, relative to @widget
106 * @x: The x-coordinate relative to @coords at which to
107 * calculate the index
108 * @y: The y-coordinate relative to @coords at which to
109 * calculate the index
110 * @coords: An #AtkCoordType enumeration
112 * Gets the byte offset at the specified @x and @y in a #PangoLayout.
114 * Returns: the byte offset at the specified @x and @y in a
118 gail_misc_get_index_at_point_in_layout (GtkWidget *widget,
126 gint index, x_window, y_window, x_toplevel, y_toplevel;
130 gail_misc_get_origins (widget, &x_window, &y_window,
131 &x_toplevel, &y_toplevel);
132 x_temp = x - x_layout - x_window;
133 y_temp = y - y_layout - y_window;
134 if (coords == ATK_XY_WINDOW)
136 x_temp += x_toplevel;
137 y_temp += y_toplevel;
139 else if (coords != ATK_XY_SCREEN)
142 ret = pango_layout_xy_to_index (layout,
143 x_temp * PANGO_SCALE,
144 y_temp * PANGO_SCALE,
148 if (x_temp < 0 || y_temp < 0)
157 * gail_misc_add_attribute:
158 * @attrib_set: The #AtkAttributeSet to add the attribute to
159 * @attr: The AtkTextAttrribute which identifies the attribute to be added
160 * @value: The attribute value
162 * Creates an #AtkAttribute from @attr and @value, and adds it
165 * Returns: A pointer to the new #AtkAttributeSet.
168 gail_misc_add_attribute (AtkAttributeSet *attrib_set,
169 AtkTextAttribute attr,
172 AtkAttributeSet *return_set;
173 AtkAttribute *at = g_malloc (sizeof (AtkAttribute));
174 at->name = g_strdup (atk_text_attribute_get_name (attr));
176 return_set = g_slist_prepend(attrib_set, at);
181 * gail_misc_layout_get_run_attributes:
182 * @attrib_set: The #AtkAttributeSet to add the attribute to
183 * @layout: The PangoLayout from which the attributes will be obtained
185 * @offset: The offset at which the attributes are required
186 * @start_offset: The start offset of the current run
187 * @end_offset: The end offset of the current run
189 * Adds the attributes for the run starting at offset to the specified
192 * Returns: A pointer to the #AtkAttributeSet.
195 gail_misc_layout_get_run_attributes (AtkAttributeSet *attrib_set,
202 PangoAttrIterator *iter;
204 PangoAttrString *pango_string;
205 PangoAttrInt *pango_int;
206 PangoAttrColor *pango_color;
207 PangoAttrLanguage *pango_lang;
208 PangoAttrFloat *pango_float;
209 gint index, start_index, end_index;
210 gboolean is_next = TRUE;
214 len = g_utf8_strlen (text, -1);
215 /* Grab the attributes of the PangoLayout, if any */
216 if ((attr = pango_layout_get_attributes (layout)) == NULL)
222 iter = pango_attr_list_get_iterator (attr);
223 /* Get invariant range offsets */
224 /* If offset out of range, set offset in range */
230 index = g_utf8_offset_to_pointer (text, offset) - text;
231 pango_attr_iterator_range (iter, &start_index, &end_index);
234 if (index >= start_index && index < end_index)
236 *start_offset = g_utf8_pointer_to_offset (text,
238 if (end_index == G_MAXINT)
242 *end_offset = g_utf8_pointer_to_offset (text,
246 is_next = pango_attr_iterator_next (iter);
247 pango_attr_iterator_range (iter, &start_index, &end_index);
250 if ((pango_string = (PangoAttrString*) pango_attr_iterator_get (iter,
251 PANGO_ATTR_FAMILY)) != NULL)
253 value = g_strdup_printf("%s", pango_string->value);
254 attrib_set = gail_misc_add_attribute (attrib_set,
255 ATK_TEXT_ATTR_FAMILY_NAME,
258 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
259 PANGO_ATTR_STYLE)) != NULL)
261 attrib_set = gail_misc_add_attribute (attrib_set,
263 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE, pango_int->value)));
265 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
266 PANGO_ATTR_WEIGHT)) != NULL)
268 value = g_strdup_printf("%i", pango_int->value);
269 attrib_set = gail_misc_add_attribute (attrib_set,
270 ATK_TEXT_ATTR_WEIGHT,
273 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
274 PANGO_ATTR_VARIANT)) != NULL)
276 attrib_set = gail_misc_add_attribute (attrib_set,
277 ATK_TEXT_ATTR_VARIANT,
278 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT, pango_int->value)));
280 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
281 PANGO_ATTR_STRETCH)) != NULL)
283 attrib_set = gail_misc_add_attribute (attrib_set,
284 ATK_TEXT_ATTR_STRETCH,
285 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH, pango_int->value)));
287 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
288 PANGO_ATTR_SIZE)) != NULL)
290 value = g_strdup_printf("%i", pango_int->value / PANGO_SCALE);
291 attrib_set = gail_misc_add_attribute (attrib_set,
295 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
296 PANGO_ATTR_UNDERLINE)) != NULL)
298 attrib_set = gail_misc_add_attribute (attrib_set,
299 ATK_TEXT_ATTR_UNDERLINE,
300 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE, pango_int->value)));
302 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
303 PANGO_ATTR_STRIKETHROUGH)) != NULL)
305 attrib_set = gail_misc_add_attribute (attrib_set,
306 ATK_TEXT_ATTR_STRIKETHROUGH,
307 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH, pango_int->value)));
309 if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
310 PANGO_ATTR_RISE)) != NULL)
312 value = g_strdup_printf("%i", pango_int->value);
313 attrib_set = gail_misc_add_attribute (attrib_set,
317 if ((pango_lang = (PangoAttrLanguage*) pango_attr_iterator_get (iter,
318 PANGO_ATTR_LANGUAGE)) != NULL)
320 value = g_strdup( pango_language_to_string( pango_lang->value));
321 attrib_set = gail_misc_add_attribute (attrib_set,
322 ATK_TEXT_ATTR_LANGUAGE,
325 if ((pango_float = (PangoAttrFloat*) pango_attr_iterator_get (iter,
326 PANGO_ATTR_SCALE)) != NULL)
328 value = g_strdup_printf("%g", pango_float->value);
329 attrib_set = gail_misc_add_attribute (attrib_set,
333 if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter,
334 PANGO_ATTR_FOREGROUND)) != 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_FG_COLOR,
344 if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter,
345 PANGO_ATTR_BACKGROUND)) != NULL)
347 value = g_strdup_printf ("%u,%u,%u",
348 pango_color->color.red,
349 pango_color->color.green,
350 pango_color->color.blue);
351 attrib_set = gail_misc_add_attribute (attrib_set,
352 ATK_TEXT_ATTR_BG_COLOR,
355 pango_attr_iterator_destroy (iter);
360 * gail_misc_get_default_attributes:
361 * @attrib_set: The #AtkAttributeSet to add the attribute to
362 * @layout: The PangoLayout from which the attributes will be obtained
363 * @widget: The GtkWidget for which the default attributes are required.
365 * Adds the default attributes to the specified attribute set.
367 * Returns: A pointer to the #AtkAttributeSet.
370 gail_misc_get_default_attributes (AtkAttributeSet *attrib_set,
374 PangoContext *context;
375 GtkStyleContext *style_context;
381 attrib_set = gail_misc_add_attribute (attrib_set,
382 ATK_TEXT_ATTR_DIRECTION,
383 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION,
384 gtk_widget_get_direction (widget))));
386 context = pango_layout_get_context (layout);
389 PangoLanguage* language;
390 PangoFontDescription* font;
392 language = pango_context_get_language (context);
395 attrib_set = gail_misc_add_attribute (attrib_set,
396 ATK_TEXT_ATTR_LANGUAGE,
397 g_strdup (pango_language_to_string (language)));
399 font = pango_context_get_font_description (context);
402 attrib_set = gail_misc_add_attribute (attrib_set,
404 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE,
405 pango_font_description_get_style (font))));
406 attrib_set = gail_misc_add_attribute (attrib_set,
407 ATK_TEXT_ATTR_VARIANT,
408 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT,
409 pango_font_description_get_variant (font))));
410 attrib_set = gail_misc_add_attribute (attrib_set,
411 ATK_TEXT_ATTR_STRETCH,
412 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH,
413 pango_font_description_get_stretch (font))));
414 attrib_set = gail_misc_add_attribute (attrib_set,
415 ATK_TEXT_ATTR_FAMILY_NAME,
416 g_strdup (pango_font_description_get_family (font)));
417 attrib_set = gail_misc_add_attribute (attrib_set,
418 ATK_TEXT_ATTR_WEIGHT,
419 g_strdup_printf ("%d",
420 pango_font_description_get_weight (font)));
421 attrib_set = gail_misc_add_attribute (attrib_set,
423 g_strdup_printf ("%i",
424 pango_font_description_get_size (font) / PANGO_SCALE));
427 if (pango_layout_get_justify (layout))
433 PangoAlignment align;
435 align = pango_layout_get_alignment (layout);
436 if (align == PANGO_ALIGN_LEFT)
438 else if (align == PANGO_ALIGN_CENTER)
440 else /* if (align == PANGO_ALIGN_RIGHT) */
443 attrib_set = gail_misc_add_attribute (attrib_set,
444 ATK_TEXT_ATTR_JUSTIFICATION,
445 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION,
447 mode = pango_layout_get_wrap (layout);
448 if (mode == PANGO_WRAP_WORD)
450 else /* if (mode == PANGO_WRAP_CHAR) */
452 attrib_set = gail_misc_add_attribute (attrib_set,
453 ATK_TEXT_ATTR_WRAP_MODE,
454 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_WRAP_MODE,
457 style_context = gtk_widget_get_style_context (widget);
459 gtk_style_context_get_background_color (style_context, 0, &color);
460 value = g_strdup_printf ("%u,%u,%u",
461 (guint) ceil (color.red * 65536 - color.red),
462 (guint) ceil (color.green * 65536 - color.green),
463 (guint) ceil (color.blue * 65536 - color.blue));
464 attrib_set = gail_misc_add_attribute (attrib_set,
465 ATK_TEXT_ATTR_BG_COLOR,
468 gtk_style_context_get_color (style_context, 0, &color);
469 value = g_strdup_printf ("%u,%u,%u",
470 (guint) ceil (color.red * 65536 - color.red),
471 (guint) ceil (color.green * 65536 - color.green),
472 (guint) ceil (color.blue * 65536 - color.blue));
473 attrib_set = gail_misc_add_attribute (attrib_set,
474 ATK_TEXT_ATTR_FG_COLOR,
477 attrib_set = gail_misc_add_attribute (attrib_set,
478 ATK_TEXT_ATTR_FG_STIPPLE,
479 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_FG_STIPPLE,
481 attrib_set = gail_misc_add_attribute (attrib_set,
482 ATK_TEXT_ATTR_BG_STIPPLE,
483 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_BG_STIPPLE,
485 attrib_set = gail_misc_add_attribute (attrib_set,
486 ATK_TEXT_ATTR_STRIKETHROUGH,
487 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH,
489 attrib_set = gail_misc_add_attribute (attrib_set,
490 ATK_TEXT_ATTR_UNDERLINE,
491 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE,
493 attrib_set = gail_misc_add_attribute (attrib_set,
495 g_strdup_printf ("%i", 0));
496 attrib_set = gail_misc_add_attribute (attrib_set,
498 g_strdup_printf ("%g", 1.0));
499 attrib_set = gail_misc_add_attribute (attrib_set,
500 ATK_TEXT_ATTR_BG_FULL_HEIGHT,
501 g_strdup_printf ("%i", 0));
502 attrib_set = gail_misc_add_attribute (attrib_set,
503 ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
504 g_strdup_printf ("%i", 0));
505 attrib_set = gail_misc_add_attribute (attrib_set,
506 ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
507 g_strdup_printf ("%i", 0));
508 attrib_set = gail_misc_add_attribute (attrib_set,
509 ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
510 g_strdup_printf ("%i", 0));
511 attrib_set = gail_misc_add_attribute (attrib_set,
512 ATK_TEXT_ATTR_EDITABLE,
513 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_EDITABLE,
515 attrib_set = gail_misc_add_attribute (attrib_set,
516 ATK_TEXT_ATTR_INVISIBLE,
517 g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_INVISIBLE,
519 attrib_set = gail_misc_add_attribute (attrib_set,
520 ATK_TEXT_ATTR_INDENT,
521 g_strdup_printf ("%i", 0));
522 attrib_set = gail_misc_add_attribute (attrib_set,
523 ATK_TEXT_ATTR_RIGHT_MARGIN,
524 g_strdup_printf ("%i", 0));
525 attrib_set = gail_misc_add_attribute (attrib_set,
526 ATK_TEXT_ATTR_LEFT_MARGIN,
527 g_strdup_printf ("%i", 0));
532 * gail_misc_get_origins:
533 * @widget: a #GtkWidget
534 * @x_window: the x-origin of the widget->window
535 * @y_window: the y-origin of the widget->window
536 * @x_toplevel: the x-origin of the toplevel window for widget->window
537 * @y_toplevel: the y-origin of the toplevel window for widget->window
539 * Gets the origin of the widget window, and the origin of the
540 * widgets top-level window.
543 gail_misc_get_origins (GtkWidget *widget,
551 if (GTK_IS_TREE_VIEW (widget))
552 window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
554 window = gtk_widget_get_window (widget);
556 gdk_window_get_origin (window, x_window, y_window);
557 window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
558 gdk_window_get_origin (window, x_toplevel, y_toplevel);
562 * gail_misc_buffer_get_run_attributes:
563 * @buffer: The #GtkTextBuffer for which the attributes will be obtained
564 * @offset: The offset at which the attributes are required
565 * @start_offset: The start offset of the current run
566 * @end_offset: The end offset of the current run
568 * Creates an AtkAttributeSet which contains the attributes for the
569 * run starting at offset.
571 * Returns: A pointer to the #AtkAttributeSet.
574 gail_misc_buffer_get_run_attributes (GtkTextBuffer *buffer,
580 AtkAttributeSet *attrib_set = NULL;
582 GSList *tags, *temp_tags;
584 gboolean val_set = FALSE;
586 gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
588 gtk_text_iter_forward_to_tag_toggle (&iter, NULL);
589 *end_offset = gtk_text_iter_get_offset (&iter);
591 gtk_text_iter_backward_to_tag_toggle (&iter, NULL);
592 *start_offset = gtk_text_iter_get_offset (&iter);
594 gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
596 tags = gtk_text_iter_get_tags (&iter);
597 tags = g_slist_reverse (tags);
600 while (temp_tags && !val_set)
602 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
604 g_object_get (tag, "style-set", &val_set, NULL);
610 g_object_get (tag, "style", &style, NULL);
611 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE, style));
612 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_STYLE, value);
614 temp_tags = temp_tags->next;
619 while (temp_tags && !val_set)
621 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
623 g_object_get (tag, "variant-set", &val_set, NULL);
626 PangoVariant variant;
629 g_object_get (tag, "variant", &variant, NULL);
630 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT, variant));
631 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_VARIANT, value);
633 temp_tags = temp_tags->next;
638 while (temp_tags && !val_set)
640 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
642 g_object_get (tag, "stretch-set", &val_set, NULL);
645 PangoStretch stretch;
648 g_object_get (tag, "stretch", &stretch, NULL);
649 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH, stretch));
650 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_STRETCH, value);
652 temp_tags = temp_tags->next;
657 while (temp_tags && !val_set)
659 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
661 g_object_get (tag, "justification-set", &val_set, NULL);
664 GtkJustification justification;
667 g_object_get (tag, "justification", &justification, NULL);
668 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, justification));
669 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_JUSTIFICATION, value);
671 temp_tags = temp_tags->next;
676 while (temp_tags && !val_set)
678 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
679 GtkTextDirection direction;
681 g_object_get (tag, "direction", &direction, NULL);
683 if (direction != GTK_TEXT_DIR_NONE)
687 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, direction));
688 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_DIRECTION, value);
690 temp_tags = temp_tags->next;
695 while (temp_tags && !val_set)
697 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
699 g_object_get (tag, "wrap-mode-set", &val_set, NULL);
702 GtkWrapMode wrap_mode;
705 g_object_get (tag, "wrap-mode", &wrap_mode, NULL);
706 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_WRAP_MODE, wrap_mode));
707 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_WRAP_MODE, value);
709 temp_tags = temp_tags->next;
714 while (temp_tags && !val_set)
716 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
718 g_object_get (tag, "foreground-set", &val_set, NULL);
724 g_object_get (tag, "foreground-rgba", &rgba, NULL);
725 value = g_strdup_printf ("%u,%u,%u",
726 (guint) rgba->red * 65535,
727 (guint) rgba->green * 65535,
728 (guint) rgba->blue * 65535);
729 gdk_rgba_free (rgba);
730 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_FG_COLOR, value);
732 temp_tags = temp_tags->next;
737 while (temp_tags && !val_set)
739 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
741 g_object_get (tag, "background-set", &val_set, NULL);
747 g_object_get (tag, "background-rgba", &rgba, NULL);
748 value = g_strdup_printf ("%u,%u,%u",
749 (guint) rgba->red * 65535,
750 (guint) rgba->green * 65535,
751 (guint) rgba->blue * 65535);
752 gdk_rgba_free (rgba);
753 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_BG_COLOR, value);
755 temp_tags = temp_tags->next;
760 while (temp_tags && !val_set)
762 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
764 g_object_get (tag, "family-set", &val_set, NULL);
769 g_object_get (tag, "family", &value, NULL);
770 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_FAMILY_NAME, value);
772 temp_tags = temp_tags->next;
777 while (temp_tags && !val_set)
779 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
781 g_object_get (tag, "language-set", &val_set, NULL);
786 g_object_get (tag, "language", &value, NULL);
787 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_LANGUAGE, value);
789 temp_tags = temp_tags->next;
794 while (temp_tags && !val_set)
796 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
798 g_object_get (tag, "weight-set", &val_set, NULL);
805 g_object_get (tag, "weight", &weight, NULL);
806 value = g_strdup_printf ("%d", weight);
807 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_WEIGHT, value);
809 temp_tags = temp_tags->next;
815 * scale is special as the scale is the product of all scale values
821 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
824 g_object_get (tag, "scale-set", &scale_set, NULL);
829 g_object_get (tag, "scale", &font_scale, NULL);
833 temp_tags = temp_tags->next;
837 at = g_malloc(sizeof(AtkAttribute));
838 at->name = g_strdup(atk_text_attribute_get_name (ATK_TEXT_ATTR_SCALE));
839 at->value = g_strdup_printf("%g", scale);
840 attrib_set = g_slist_prepend(attrib_set, at);
845 while (temp_tags && !val_set)
847 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
849 g_object_get (tag, "size-set", &val_set, NULL);
854 g_object_get (tag, "size", &size, NULL);
855 value = g_strdup_printf ("%i", size);
856 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_SIZE, value);
858 temp_tags = temp_tags->next;
863 while (temp_tags && !val_set)
865 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
867 g_object_get (tag, "strikethrough-set", &val_set, NULL);
870 gboolean strikethrough;
872 g_object_get (tag, "strikethrough", &strikethrough, NULL);
873 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH, strikethrough));
874 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_STRIKETHROUGH, value);
876 temp_tags = temp_tags->next;
881 while (temp_tags && !val_set)
883 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
885 g_object_get (tag, "underline-set", &val_set, NULL);
888 PangoUnderline underline;
890 g_object_get (tag, "underline", &underline, NULL);
891 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE, underline));
892 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_UNDERLINE, value);
894 temp_tags = temp_tags->next;
899 while (temp_tags && !val_set)
901 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
903 g_object_get (tag, "rise-set", &val_set, NULL);
908 g_object_get (tag, "rise", &rise, NULL);
909 value = g_strdup_printf ("%i", rise);
910 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_RISE, value);
912 temp_tags = temp_tags->next;
917 while (temp_tags && !val_set)
919 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
921 g_object_get (tag, "background-full-height-set", &val_set, NULL);
924 gboolean bg_full_height;
926 g_object_get (tag, "background-full-height", &bg_full_height, NULL);
927 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_BG_FULL_HEIGHT, bg_full_height));
928 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_BG_FULL_HEIGHT, value);
930 temp_tags = temp_tags->next;
935 while (temp_tags && !val_set)
937 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
939 g_object_get (tag, "pixels-inside-wrap-set", &val_set, NULL);
944 g_object_get (tag, "pixels-inside-wrap", &pixels, NULL);
945 value = g_strdup_printf ("%i", pixels);
946 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP, value);
948 temp_tags = temp_tags->next;
953 while (temp_tags && !val_set)
955 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
957 g_object_get (tag, "pixels-below-lines-set", &val_set, NULL);
962 g_object_get (tag, "pixels-below-lines", &pixels, NULL);
963 value = g_strdup_printf ("%i", pixels);
964 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_PIXELS_BELOW_LINES, value);
966 temp_tags = temp_tags->next;
971 while (temp_tags && !val_set)
973 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
975 g_object_get (tag, "pixels-above-lines-set", &val_set, NULL);
980 g_object_get (tag, "pixels-above-lines", &pixels, NULL);
981 value = g_strdup_printf ("%i", pixels);
982 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_PIXELS_ABOVE_LINES, value);
984 temp_tags = temp_tags->next;
989 while (temp_tags && !val_set)
991 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
993 g_object_get (tag, "editable-set", &val_set, NULL);
998 g_object_get (tag, "editable", &editable, NULL);
999 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_EDITABLE, editable));
1000 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_EDITABLE, value);
1002 temp_tags = temp_tags->next;
1007 while (temp_tags && !val_set)
1009 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1011 g_object_get (tag, "invisible-set", &val_set, NULL);
1016 g_object_get (tag, "invisible", &invisible, NULL);
1017 value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_INVISIBLE, invisible));
1018 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_INVISIBLE, value);
1020 temp_tags = temp_tags->next;
1025 while (temp_tags && !val_set)
1027 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1029 g_object_get (tag, "indent-set", &val_set, NULL);
1034 g_object_get (tag, "indent", &indent, NULL);
1035 value = g_strdup_printf ("%i", indent);
1036 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_INDENT, value);
1038 temp_tags = temp_tags->next;
1043 while (temp_tags && !val_set)
1045 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1047 g_object_get (tag, "right-margin-set", &val_set, NULL);
1052 g_object_get (tag, "right-margin", &margin, NULL);
1053 value = g_strdup_printf ("%i", margin);
1054 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_RIGHT_MARGIN, value);
1056 temp_tags = temp_tags->next;
1061 while (temp_tags && !val_set)
1063 GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
1065 g_object_get (tag, "left-margin-set", &val_set, NULL);
1070 g_object_get (tag, "left-margin", &margin, NULL);
1071 value = g_strdup_printf ("%i", margin);
1072 attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_LEFT_MARGIN, value);
1074 temp_tags = temp_tags->next;
1078 g_slist_free (tags);