diff options
author | Alexander Larsson <alexl@redhat.com> | 2001-02-20 16:16:22 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2001-02-20 16:16:22 +0000 |
commit | 699c933422555fc73d55d10c2163bc3b4d2c8d7d (patch) | |
tree | daa79e16667fb0c05d78fd8ebe422b1b37ff24df /gtk/gtkcellrenderertext.c | |
parent | 5efcd1a640bda57935e0c4ad1331ed9911f94309 (diff) | |
download | gtk+-699c933422555fc73d55d10c2163bc3b4d2c8d7d.tar.gz |
Add a "markup" property.
2001-02-20 Alexander Larsson <alexl@redhat.com>
* gtk/gtkcellrenderertext.[ch]:
Add a "markup" property.
* gtk/treestoretest.c:
Use the markup property, remove some leftover stuff from
GtkTreeModelMapping.
Diffstat (limited to 'gtk/gtkcellrenderertext.c')
-rw-r--r-- | gtk/gtkcellrenderertext.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index cf803dd1b8..a37a728705 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -53,6 +53,7 @@ enum { PROP_0, PROP_TEXT, + PROP_MARKUP, /* Style args */ PROP_BACKGROUND, @@ -150,6 +151,14 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) G_PARAM_READWRITE)); g_object_class_install_property (object_class, + PROP_MARKUP, + g_param_spec_string ("markup", + _("Markup"), + _("Marked up text to render"), + NULL, + G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, PROP_BACKGROUND, g_param_spec_string ("background", _("Background color name"), @@ -364,7 +373,10 @@ gtk_cell_renderer_text_finalize (GObject *object) if (celltext->text) g_free (celltext->text); - + + if (celltext->extra_attrs) + pango_attr_list_unref (celltext->extra_attrs); + (* G_OBJECT_CLASS (parent_class)->finalize) (object); } @@ -516,6 +528,7 @@ gtk_cell_renderer_text_get_property (GObject *object, case PROP_BACKGROUND: case PROP_FOREGROUND: + case PROP_MARKUP: default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -655,6 +668,39 @@ gtk_cell_renderer_text_set_property (GObject *object, celltext->text = g_strdup (g_value_get_string (value)); break; + case PROP_MARKUP: + { + const gchar *str; + gchar *text = NULL; + GError *error = NULL; + PangoAttrList *attrs = NULL; + + if (celltext->text) + g_free (celltext->text); + + if (celltext->extra_attrs) + pango_attr_list_unref (celltext->extra_attrs); + + str = g_value_get_string (value); + if (str && !pango_parse_markup (str, + -1, + 0, + &attrs, + &text, + NULL, + &error)) + { + g_warning ("Failed to set cell text from markup due to error parsing markup: %s", + error->message); + g_error_free (error); + return; + } + + celltext->text = text; + celltext->extra_attrs = attrs; + } + break; + case PROP_BACKGROUND: { GdkColor color; @@ -893,8 +939,11 @@ get_layout (GtkCellRendererText *celltext, PangoUnderline uline; layout = gtk_widget_create_pango_layout (widget, celltext->text); - - attr_list = pango_attr_list_new (); + + if (celltext->extra_attrs) + attr_list = pango_attr_list_copy (celltext->extra_attrs); + else + attr_list = pango_attr_list_new (); if (will_render) { |