Commit 699c9334 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

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.
parent 5efcd1a6
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.
2001-02-20 Alexander Larsson <alexl@redhat.com>
* gtk/gtklabel.c (gtk_label_set_selectable):
......
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.
2001-02-20 Alexander Larsson <alexl@redhat.com>
* gtk/gtklabel.c (gtk_label_set_selectable):
......
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.
2001-02-20 Alexander Larsson <alexl@redhat.com>
* gtk/gtklabel.c (gtk_label_set_selectable):
......
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.
2001-02-20 Alexander Larsson <alexl@redhat.com>
* gtk/gtklabel.c (gtk_label_set_selectable):
......
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.
2001-02-20 Alexander Larsson <alexl@redhat.com>
* gtk/gtklabel.c (gtk_label_set_selectable):
......
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.
2001-02-20 Alexander Larsson <alexl@redhat.com>
* gtk/gtklabel.c (gtk_label_set_selectable):
......
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.
2001-02-20 Alexander Larsson <alexl@redhat.com>
* gtk/gtklabel.c (gtk_label_set_selectable):
......
......@@ -53,6 +53,7 @@ enum {
PROP_0,
PROP_TEXT,
PROP_MARKUP,
/* Style args */
PROP_BACKGROUND,
......@@ -149,6 +150,14 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class)
NULL,
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",
......@@ -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)
{
......
......@@ -46,6 +46,8 @@ struct _GtkCellRendererText
PangoFontDescription font;
PangoColor foreground;
PangoColor background;
PangoAttrList *extra_attrs;
PangoUnderline underline_style;
......
......@@ -21,7 +21,7 @@ node_set (GtkTreeIter *iter)
gint n;
gchar *str;
str = g_strdup_printf ("Row (%d)", i++);
str = g_strdup_printf ("Row (<span color=\"red\">%d</span>)", i++);
gtk_tree_store_set (base_model, iter, 0, str, -1);
g_free (str);
......@@ -236,9 +236,6 @@ make_window (gint view_type)
case 1:
gtk_window_set_title (GTK_WINDOW (window), "Sorted list");
break;
case 2:
gtk_window_set_title (GTK_WINDOW (window), "Uppercase flipped list");
break;
}
vbox = gtk_vbox_new (FALSE, 8);
......@@ -321,7 +318,7 @@ make_window (gint view_type)
/* The selected column */
cell = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Node ID", cell, "text", 0, NULL);
column = gtk_tree_view_column_new_with_attributes ("Node ID", cell, "markup", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
cell = gtk_cell_renderer_text_new ();
......@@ -352,7 +349,6 @@ main (int argc, char *argv[])
/* FIXME: reverse this */
make_window (0);
make_window (1);
make_window (2);
gtk_main ();
......
......@@ -21,7 +21,7 @@ node_set (GtkTreeIter *iter)
gint n;
gchar *str;
str = g_strdup_printf ("Row (%d)", i++);
str = g_strdup_printf ("Row (<span color=\"red\">%d</span>)", i++);
gtk_tree_store_set (base_model, iter, 0, str, -1);
g_free (str);
......@@ -236,9 +236,6 @@ make_window (gint view_type)
case 1:
gtk_window_set_title (GTK_WINDOW (window), "Sorted list");
break;
case 2:
gtk_window_set_title (GTK_WINDOW (window), "Uppercase flipped list");
break;
}
vbox = gtk_vbox_new (FALSE, 8);
......@@ -321,7 +318,7 @@ make_window (gint view_type)
/* The selected column */
cell = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Node ID", cell, "text", 0, NULL);
column = gtk_tree_view_column_new_with_attributes ("Node ID", cell, "markup", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
cell = gtk_cell_renderer_text_new ();
......@@ -352,7 +349,6 @@ main (int argc, char *argv[])
/* FIXME: reverse this */
make_window (0);
make_window (1);
make_window (2);
gtk_main ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment