diff options
author | Benjamin Otte <otte@redhat.com> | 2011-09-21 03:27:43 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2011-09-22 21:44:05 +0200 |
commit | 14154dac310f6f9f9a7a1d79215ba73abe3b3596 (patch) | |
tree | ca619a0e1ca7a858cf6d41e87dd6e0e3c7623e80 /gtk/gtkfontchooserwidget.c | |
parent | 38af387ee31419a328f35ab855c3d9212ecef5d4 (diff) | |
download | gtk+-14154dac310f6f9f9a7a1d79215ba73abe3b3596.tar.gz |
fontchooser: Set cell data as text + attributes instead of markup
This is quite a bit uglier, but allows more freedom.
Diffstat (limited to 'gtk/gtkfontchooserwidget.c')
-rw-r--r-- | gtk/gtkfontchooserwidget.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c index cf118d4135..4aeabfb650 100644 --- a/gtk/gtkfontchooserwidget.c +++ b/gtk/gtkfontchooserwidget.c @@ -109,8 +109,6 @@ struct _GtkFontChooserWidgetPrivate #define FONT_STYLE_LIST_WIDTH 170 #define FONT_SIZE_LIST_WIDTH 60 -#define ROW_FORMAT_STRING "<span weight=\"bold\" size=\"small\">%s</span>\n<span size=\"x-large\" font_desc=\"%s\">%s</span>" - #define NO_FONT_MATCHED_SEARCH N_("No fonts matched your search. You can revise your search and try again.") enum { @@ -803,24 +801,45 @@ gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column, { GtkFontChooserWidget *fontchooser = user_data; PangoFontDescription *font_desc; - char *to_string, *markup; + PangoAttrList *attrs; + PangoAttribute *attribute; + char *to_string, *text; + gsize to_string_len; font_desc = tree_model_get_font_description (tree_model, iter); to_string = pango_font_description_to_string (font_desc); + to_string_len = strlen (to_string) + 1; + + text = g_strconcat (to_string, "\n", fontchooser->priv->preview_text, NULL); + + attrs = pango_attr_list_new (); + + attribute = pango_attr_weight_new (PANGO_WEIGHT_BOLD); + attribute->end_index = to_string_len; + pango_attr_list_insert (attrs, attribute); + + attribute = pango_attr_scale_new (PANGO_SCALE_SMALL); + attribute->end_index = to_string_len; + pango_attr_list_insert (attrs, attribute); + + attribute = pango_attr_font_desc_new (font_desc); + attribute->start_index = to_string_len; + pango_attr_list_insert (attrs, attribute); - markup = g_markup_printf_escaped (ROW_FORMAT_STRING, - to_string, - to_string, - fontchooser->priv->preview_text); + attribute = pango_attr_scale_new (PANGO_SCALE_X_LARGE); + attribute->start_index = to_string_len; + pango_attr_list_insert (attrs, attribute); g_object_set (cell, - "markup", markup, + "attributes", attrs, + "text", text, NULL); pango_font_description_free (font_desc); + pango_attr_list_unref (attrs); g_free (to_string); - g_free (markup); + g_free (text); } static void |