GtkTextTag * gimp_text_buffer_get_iter_kerning (GimpTextBuffer *buffer, const GtkTextIter *iter, gint *kerning) { GList *list; for (list = buffer->kerning_tags; list; list = g_list_next (list)) { GtkTextTag *tag = list->data; if (gtk_text_iter_has_tag (iter, tag)) { if (kerning) *kerning = gimp_text_tag_get_kerning (tag); return tag; } } if (kerning) *kerning = 0; return NULL; }
static GtkTextTag * gimp_text_buffer_get_kerning_tag (GimpTextBuffer *buffer, gint kerning) { GList *list; GtkTextTag *tag; gchar name[32]; for (list = buffer->kerning_tags; list; list = g_list_next (list)) { tag = list->data; if (kerning == gimp_text_tag_get_kerning (tag)) return tag; } g_snprintf (name, sizeof (name), "kerning-%d", kerning); tag = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (buffer), name, GIMP_TEXT_PROP_NAME_KERNING, kerning, NULL); buffer->kerning_tags = g_list_prepend (buffer->kerning_tags, tag); return tag; }
static void gimp_text_style_editor_set_kerning (GimpTextStyleEditor *editor, GtkTextTag *kerning_tag) { gint kerning = 0; if (kerning_tag) kerning = gimp_text_tag_get_kerning (kerning_tag); g_signal_handlers_block_by_func (editor->kerning_adjustment, gimp_text_style_editor_kerning_changed, editor); gtk_adjustment_set_value (editor->kerning_adjustment, (gdouble) kerning / PANGO_SCALE); /* make sure the "" really gets replaced */ gtk_adjustment_value_changed (editor->kerning_adjustment); g_signal_handlers_unblock_by_func (editor->kerning_adjustment, gimp_text_style_editor_kerning_changed, editor); }
const gchar * gimp_text_buffer_tag_to_name (GimpTextBuffer *buffer, GtkTextTag *tag, const gchar **attribute, gchar **value) { g_return_val_if_fail (GIMP_IS_TEXT_BUFFER (buffer), NULL); g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), NULL); if (attribute) *attribute = NULL; if (value) *value = NULL; if (tag == buffer->bold_tag) { return "b"; } else if (tag == buffer->italic_tag) { return "i"; } else if (tag == buffer->underline_tag) { return "u"; } else if (tag == buffer->strikethrough_tag) { return "s"; } else if (g_list_find (buffer->size_tags, tag)) { if (attribute) *attribute = GIMP_TEXT_ATTR_NAME_SIZE; if (value) *value = g_strdup_printf ("%d", gimp_text_tag_get_size (tag)); return "span"; } else if (g_list_find (buffer->baseline_tags, tag)) { if (attribute) *attribute = GIMP_TEXT_ATTR_NAME_BASELINE; if (value) *value = g_strdup_printf ("%d", gimp_text_tag_get_baseline (tag)); return "span"; } else if (g_list_find (buffer->kerning_tags, tag)) { if (attribute) *attribute = GIMP_TEXT_ATTR_NAME_KERNING; if (value) *value = g_strdup_printf ("%d", gimp_text_tag_get_kerning (tag)); return "span"; } else if (g_list_find (buffer->font_tags, tag)) { if (attribute) *attribute = GIMP_TEXT_ATTR_NAME_FONT; if (value) *value = gimp_text_tag_get_font (tag); return "span"; } else if (g_list_find (buffer->color_tags, tag)) { if (attribute) *attribute = GIMP_TEXT_ATTR_NAME_COLOR; if (value) { GimpRGB color; guchar r, g, b; gimp_text_tag_get_color (tag, &color); gimp_rgb_get_uchar (&color, &r, &g, &b); *value = g_strdup_printf ("#%02x%02x%02x", r, g, b); } return "span"; } return NULL; }