summaryrefslogtreecommitdiff
path: root/gtk/gtkcellrenderertext.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-11-16 05:19:21 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-11-16 05:19:21 +0000
commite23cf6361dc62c719cbbde1a9915dbb62ab65f52 (patch)
tree4ce41a99a13d119071c07e1a044213a98ce8127c /gtk/gtkcellrenderertext.c
parentf0265b018eb07ccaec9c6e73d33711e952f2288b (diff)
downloadgtk+-e23cf6361dc62c719cbbde1a9915dbb62ab65f52.tar.gz
Don't use the foreground color for selected cells, Don't use the
2004-11-16 Matthias Clasen <mclasen@redhat.com> * gtk/gtkcellrenderertext.c (get_layout): Don't use the foreground color for selected cells, Don't use the background color in unfocused selected cells. Also avoid creating two PangoLayouts per render call. (#154615, #154611, Billy Biggs)
Diffstat (limited to 'gtk/gtkcellrenderertext.c')
-rw-r--r--gtk/gtkcellrenderertext.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index ac41ab5f25..1fff846203 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -1258,7 +1258,8 @@ get_layout (GtkCellRendererText *celltext,
* background_area not the PangoLayout area
*/
- if (celltext->foreground_set)
+ if (celltext->foreground_set
+ && (flags & GTK_CELL_RENDERER_SELECTED) == 0)
{
PangoColor color;
@@ -1324,17 +1325,17 @@ get_layout (GtkCellRendererText *celltext,
}
static void
-gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- GdkRectangle *cell_area,
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height)
+get_size (GtkCellRenderer *cell,
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ PangoLayout *layout,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height)
{
GtkCellRendererText *celltext = (GtkCellRendererText *) cell;
PangoRectangle rect;
- PangoLayout *layout;
GtkCellRendererTextPrivate *priv;
priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (cell);
@@ -1378,7 +1379,10 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
return;
}
- layout = get_layout (celltext, widget, FALSE, 0);
+ if (layout)
+ g_object_ref (layout);
+ else
+ layout = get_layout (celltext, widget, FALSE, 0);
pango_layout_get_pixel_extents (layout, NULL, &rect);
@@ -1430,6 +1434,20 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
g_object_unref (layout);
}
+
+static void
+gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height)
+{
+ get_size (cell, widget, cell_area, NULL,
+ x_offset, y_offset, width, height);
+}
+
static void
gtk_cell_renderer_text_render (GtkCellRenderer *cell,
GdkDrawable *window,
@@ -1450,8 +1468,7 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (cell);
layout = get_layout (celltext, widget, TRUE, flags);
-
- gtk_cell_renderer_text_get_size (cell, widget, cell_area, &x_offset, &y_offset, NULL, NULL);
+ get_size (cell, widget, cell_area, layout, &x_offset, &y_offset, NULL, NULL);
if (!cell->sensitive)
{
@@ -1477,7 +1494,8 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
state = GTK_STATE_NORMAL;
}
- if (celltext->background_set && state != GTK_STATE_SELECTED)
+ if (celltext->background_set &&
+ (flags & GTK_CELL_RENDERER_SELECTED) == 0)
{
GdkColor color;
GdkGC *gc;