From e23cf6361dc62c719cbbde1a9915dbb62ab65f52 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 16 Nov 2004 05:19:21 +0000 Subject: [PATCH] Don't use the foreground color for selected cells, Don't use the 2004-11-16 Matthias Clasen * 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) --- ChangeLog | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ gtk/gtkcellrenderertext.c | 44 +++++++++++++++++++++++++++------------ 5 files changed, 59 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80b47e4838..ad27a4f58b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-11-16 Matthias Clasen + + * 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) + Mon Nov 15 19:02:07 2004 Manish Singh * gdk/abicheck.sh diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 80b47e4838..ad27a4f58b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2004-11-16 Matthias Clasen + + * 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) + Mon Nov 15 19:02:07 2004 Manish Singh * gdk/abicheck.sh diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 80b47e4838..ad27a4f58b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2004-11-16 Matthias Clasen + + * 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) + Mon Nov 15 19:02:07 2004 Manish Singh * gdk/abicheck.sh diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 80b47e4838..ad27a4f58b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2004-11-16 Matthias Clasen + + * 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) + Mon Nov 15 19:02:07 2004 Manish Singh * gdk/abicheck.sh 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;