font chooser: Small revision of the UI

Show only the font names in the list, in their own
font, in order to make the list less noisy.
This commit is contained in:
Matthias Clasen 2017-12-19 17:10:34 -05:00
parent 3f68475b6f
commit 78f9193d7e

View File

@ -909,35 +909,20 @@ gtk_font_chooser_widget_get_preview_text_height (GtkFontChooserWidget *fontchoos
static PangoAttrList *
gtk_font_chooser_widget_get_preview_attributes (GtkFontChooserWidget *fontchooser,
const PangoFontDescription *font_desc,
gsize first_line_len)
const PangoFontDescription *font_desc)
{
PangoAttribute *attribute;
PangoAttrList *attrs;
attrs = pango_attr_list_new ();
attribute = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
attribute->end_index = first_line_len;
pango_attr_list_insert (attrs, attribute);
attribute = pango_attr_scale_new (PANGO_SCALE_SMALL);
attribute->end_index = first_line_len;
pango_attr_list_insert (attrs, attribute);
if (font_desc)
{
attribute = pango_attr_font_desc_new (font_desc);
attribute->start_index = first_line_len;
pango_attr_list_insert (attrs, attribute);
}
attribute = pango_attr_fallback_new (FALSE);
attribute->start_index = first_line_len;
pango_attr_list_insert (attrs, attribute);
attribute = pango_attr_size_new_absolute (gtk_font_chooser_widget_get_preview_text_height (fontchooser));
attribute->start_index = first_line_len;
pango_attr_list_insert (attrs, attribute);
return attrs;
@ -953,29 +938,25 @@ gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column,
GtkFontChooserWidget *fontchooser = user_data;
GtkDelayedFontDescription *desc;
PangoAttrList *attrs;
char *preview_title, *text;
gsize first_line_len;
char *preview_title;
gtk_tree_model_get (tree_model, iter,
PREVIEW_TITLE_COLUMN, &preview_title,
FONT_DESC_COLUMN, &desc,
-1);
text = g_strconcat (preview_title, "\n", fontchooser->priv->preview_text, NULL);
first_line_len = strlen (preview_title) + 1;
attrs = gtk_font_chooser_widget_get_preview_attributes (fontchooser,
gtk_delayed_font_description_get (desc),
first_line_len);
attrs = gtk_font_chooser_widget_get_preview_attributes (fontchooser,
gtk_delayed_font_description_get (desc));
g_object_set (cell,
"xpad", 20,
"ypad", 10,
"attributes", attrs,
"text", text,
"text", preview_title,
NULL);
gtk_delayed_font_description_unref (desc);
pango_attr_list_unref (attrs);
g_free (text);
g_free (preview_title);
}
@ -988,13 +969,13 @@ gtk_font_chooser_widget_set_cell_size (GtkFontChooserWidget *fontchooser)
gtk_cell_renderer_set_fixed_size (priv->family_face_cell, -1, -1);
attrs = gtk_font_chooser_widget_get_preview_attributes (fontchooser,
NULL,
1);
attrs = gtk_font_chooser_widget_get_preview_attributes (fontchooser, NULL);
g_object_set (priv->family_face_cell,
"xpad", 20,
"ypad", 10,
"attributes", attrs,
"text", "x\nx",
"text", "x",
NULL);
pango_attr_list_unref (attrs);