Drop gail_misc_buffer_get_run_attributes
Instead fold the code into the sole caller and get rid of gailmisc usage in the text view accessible altogether.
This commit is contained in:
@ -559,524 +559,3 @@ gail_misc_get_origins (GtkWidget *widget,
|
||||
window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
|
||||
gdk_window_get_origin (window, x_toplevel, y_toplevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* gail_misc_buffer_get_run_attributes:
|
||||
* @buffer: The #GtkTextBuffer for which the attributes will be obtained
|
||||
* @offset: The offset at which the attributes are required
|
||||
* @start_offset: The start offset of the current run
|
||||
* @end_offset: The end offset of the current run
|
||||
*
|
||||
* Creates an AtkAttributeSet which contains the attributes for the
|
||||
* run starting at offset.
|
||||
*
|
||||
* Returns: A pointer to the #AtkAttributeSet.
|
||||
**/
|
||||
AtkAttributeSet*
|
||||
gail_misc_buffer_get_run_attributes (GtkTextBuffer *buffer,
|
||||
gint offset,
|
||||
gint *start_offset,
|
||||
gint *end_offset)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
AtkAttributeSet *attrib_set = NULL;
|
||||
AtkAttribute *at;
|
||||
GSList *tags, *temp_tags;
|
||||
gdouble scale = 1;
|
||||
gboolean val_set = FALSE;
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
|
||||
|
||||
gtk_text_iter_forward_to_tag_toggle (&iter, NULL);
|
||||
*end_offset = gtk_text_iter_get_offset (&iter);
|
||||
|
||||
gtk_text_iter_backward_to_tag_toggle (&iter, NULL);
|
||||
*start_offset = gtk_text_iter_get_offset (&iter);
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
|
||||
|
||||
tags = gtk_text_iter_get_tags (&iter);
|
||||
tags = g_slist_reverse (tags);
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "style-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
PangoStyle style;
|
||||
gchar *value;
|
||||
|
||||
g_object_get (tag, "style", &style, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE, style));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_STYLE, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "variant-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
PangoVariant variant;
|
||||
gchar *value;
|
||||
|
||||
g_object_get (tag, "variant", &variant, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT, variant));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_VARIANT, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "stretch-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
PangoStretch stretch;
|
||||
gchar *value;
|
||||
|
||||
g_object_get (tag, "stretch", &stretch, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH, stretch));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_STRETCH, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "justification-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
GtkJustification justification;
|
||||
gchar *value;
|
||||
|
||||
g_object_get (tag, "justification", &justification, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, justification));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_JUSTIFICATION, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
GtkTextDirection direction;
|
||||
|
||||
g_object_get (tag, "direction", &direction, NULL);
|
||||
|
||||
if (direction != GTK_TEXT_DIR_NONE)
|
||||
{
|
||||
gchar *value;
|
||||
val_set = TRUE;
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, direction));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_DIRECTION, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "wrap-mode-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
GtkWrapMode wrap_mode;
|
||||
gchar *value;
|
||||
|
||||
g_object_get (tag, "wrap-mode", &wrap_mode, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_WRAP_MODE, wrap_mode));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_WRAP_MODE, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "foreground-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
GdkRGBA *rgba;
|
||||
gchar *value;
|
||||
|
||||
g_object_get (tag, "foreground-rgba", &rgba, NULL);
|
||||
value = g_strdup_printf ("%u,%u,%u",
|
||||
(guint) rgba->red * 65535,
|
||||
(guint) rgba->green * 65535,
|
||||
(guint) rgba->blue * 65535);
|
||||
gdk_rgba_free (rgba);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_FG_COLOR, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "background-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
GdkRGBA *rgba;
|
||||
gchar *value;
|
||||
|
||||
g_object_get (tag, "background-rgba", &rgba, NULL);
|
||||
value = g_strdup_printf ("%u,%u,%u",
|
||||
(guint) rgba->red * 65535,
|
||||
(guint) rgba->green * 65535,
|
||||
(guint) rgba->blue * 65535);
|
||||
gdk_rgba_free (rgba);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_BG_COLOR, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "family-set", &val_set, NULL);
|
||||
|
||||
if (val_set)
|
||||
{
|
||||
gchar *value;
|
||||
g_object_get (tag, "family", &value, NULL);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_FAMILY_NAME, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "language-set", &val_set, NULL);
|
||||
|
||||
if (val_set)
|
||||
{
|
||||
gchar *value;
|
||||
g_object_get (tag, "language", &value, NULL);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_LANGUAGE, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "weight-set", &val_set, NULL);
|
||||
|
||||
if (val_set)
|
||||
{
|
||||
gint weight;
|
||||
gchar *value;
|
||||
|
||||
g_object_get (tag, "weight", &weight, NULL);
|
||||
value = g_strdup_printf ("%d", weight);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_WEIGHT, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
* scale is special as the scale is the product of all scale values
|
||||
* specified.
|
||||
*/
|
||||
temp_tags = tags;
|
||||
while (temp_tags)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
gboolean scale_set;
|
||||
|
||||
g_object_get (tag, "scale-set", &scale_set, NULL);
|
||||
if (scale_set)
|
||||
{
|
||||
gdouble font_scale;
|
||||
|
||||
g_object_get (tag, "scale", &font_scale, NULL);
|
||||
val_set = TRUE;
|
||||
scale *= font_scale;
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
if (val_set)
|
||||
{
|
||||
at = g_malloc(sizeof(AtkAttribute));
|
||||
at->name = g_strdup(atk_text_attribute_get_name (ATK_TEXT_ATTR_SCALE));
|
||||
at->value = g_strdup_printf("%g", scale);
|
||||
attrib_set = g_slist_prepend(attrib_set, at);
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "size-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gint size;
|
||||
gchar *value;
|
||||
g_object_get (tag, "size", &size, NULL);
|
||||
value = g_strdup_printf ("%i", size);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_SIZE, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "strikethrough-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gboolean strikethrough;
|
||||
gchar *value;
|
||||
g_object_get (tag, "strikethrough", &strikethrough, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH, strikethrough));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_STRIKETHROUGH, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "underline-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
PangoUnderline underline;
|
||||
gchar *value;
|
||||
g_object_get (tag, "underline", &underline, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE, underline));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_UNDERLINE, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "rise-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gint rise;
|
||||
gchar *value;
|
||||
g_object_get (tag, "rise", &rise, NULL);
|
||||
value = g_strdup_printf ("%i", rise);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_RISE, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "background-full-height-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gboolean bg_full_height;
|
||||
gchar *value;
|
||||
g_object_get (tag, "background-full-height", &bg_full_height, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_BG_FULL_HEIGHT, bg_full_height));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_BG_FULL_HEIGHT, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "pixels-inside-wrap-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gint pixels;
|
||||
gchar *value;
|
||||
g_object_get (tag, "pixels-inside-wrap", &pixels, NULL);
|
||||
value = g_strdup_printf ("%i", pixels);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "pixels-below-lines-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gint pixels;
|
||||
gchar *value;
|
||||
g_object_get (tag, "pixels-below-lines", &pixels, NULL);
|
||||
value = g_strdup_printf ("%i", pixels);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_PIXELS_BELOW_LINES, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "pixels-above-lines-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gint pixels;
|
||||
gchar *value;
|
||||
g_object_get (tag, "pixels-above-lines", &pixels, NULL);
|
||||
value = g_strdup_printf ("%i", pixels);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_PIXELS_ABOVE_LINES, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "editable-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gboolean editable;
|
||||
gchar *value;
|
||||
g_object_get (tag, "editable", &editable, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_EDITABLE, editable));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_EDITABLE, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "invisible-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gboolean invisible;
|
||||
gchar *value;
|
||||
g_object_get (tag, "invisible", &invisible, NULL);
|
||||
value = g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_INVISIBLE, invisible));
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_INVISIBLE, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "indent-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gint indent;
|
||||
gchar *value;
|
||||
g_object_get (tag, "indent", &indent, NULL);
|
||||
value = g_strdup_printf ("%i", indent);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_INDENT, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "right-margin-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gint margin;
|
||||
gchar *value;
|
||||
g_object_get (tag, "right-margin", &margin, NULL);
|
||||
value = g_strdup_printf ("%i", margin);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_RIGHT_MARGIN, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
temp_tags = tags;
|
||||
while (temp_tags && !val_set)
|
||||
{
|
||||
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
|
||||
|
||||
g_object_get (tag, "left-margin-set", &val_set, NULL);
|
||||
if (val_set)
|
||||
{
|
||||
gint margin;
|
||||
gchar *value;
|
||||
g_object_get (tag, "left-margin", &margin, NULL);
|
||||
value = g_strdup_printf ("%i", margin);
|
||||
attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_LEFT_MARGIN, value);
|
||||
}
|
||||
temp_tags = temp_tags->next;
|
||||
}
|
||||
val_set = FALSE;
|
||||
|
||||
g_slist_free (tags);
|
||||
return attrib_set;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user