[gtk+] fontchooser: Set cell data as text + attributes instead of markup
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] fontchooser: Set cell data as text + attributes instead of markup
- Date: Thu, 22 Sep 2011 21:47:26 +0000 (UTC)
commit 14154dac310f6f9f9a7a1d79215ba73abe3b3596
Author: Benjamin Otte <otte redhat com>
Date: Wed Sep 21 03:27:43 2011 +0200
fontchooser: Set cell data as text + attributes instead of markup
This is quite a bit uglier, but allows more freedom.
gtk/gtkfontchooserwidget.c | 37 ++++++++++++++++++++++++++++---------
1 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index cf118d4..4aeabfb 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]