[gnumeric] Make selction background visible. [#648676]



commit 91fe51542b357676d1e822d5eb7c3d5679416e89
Author: Jean Brefort <jean brefort normalesup org>
Date:   Tue Jun 5 16:01:38 2012 +0200

    Make selction background visible. [#648676]

 ChangeLog       |    6 ++++++
 NEWS            |    1 +
 src/item-bar.c  |   25 ++++++++++++++++---------
 src/item-grid.c |    6 +++++-
 src/pattern.c   |    2 +-
 5 files changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d6a06ab..4ba2e29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-06-05  Jean Brefort  <jean brefort normalesup org>
+
+	* src/item-bar.c (ib_draw_cell): make selction background visible. [#648676]
+	* src/item-grid.c (item_grid_draw_region): ditto.
+	* src/pattern.c (gnumeric_background_set): ditto.
+
 2012-05-31  Morten Welinder  <terra gnome org>
 
 	* src/mstyle.c (gnm_style_update): Use gnm_style_conditions_hash.
diff --git a/NEWS b/NEWS
index 4a3371e..df25e7f 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,7 @@ Andreas:
 
 Jean:
 	* Fix graph series headers when a multiple selection is used. [#675913]
+	* Make selction background visible. [#648676]
 
 Morten:
 	* Minor doc improvement for non-C locales.  [Part of #675000]
diff --git a/src/item-bar.c b/src/item-bar.c
index bf33a62..b780ef2 100644
--- a/src/item-bar.c
+++ b/src/item-bar.c
@@ -250,34 +250,37 @@ ib_draw_cell (ItemBar const * const ib, cairo_t *cr,
 	GdkRGBA rgba;
 	int ascent;
 
+	/* add "button" to the context path */
+	gtk_style_context_save (ctxt);
+	gtk_style_context_add_class (ctxt, GTK_STYLE_CLASS_BUTTON);
 	switch (type) {
 	default:
 	case COL_ROW_NO_SELECTION:
 		font   = ib->normal_font;
-		gtk_style_context_set_state (ctxt, GTK_STATE_NORMAL);
+		gtk_style_context_set_state (ctxt, GTK_STATE_FLAG_NORMAL);
 		gtk_style_context_get_background_color (ctxt, GTK_STATE_NORMAL, &rgba);
 		color = GO_COLOR_FROM_GDK_RGBA (rgba);
-		gtk_style_context_get_color (ctxt, GTK_STATE_NORMAL, &rgba);
+		gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_NORMAL, &rgba);
 		font_color = GO_COLOR_FROM_GDK_RGBA (rgba);
 		ascent = ib->normal_font_ascent;
 		break;
 
 	case COL_ROW_PARTIAL_SELECTION:
 		font   = ib->bold_font;
-		gtk_style_context_set_state (ctxt, GTK_STATE_NORMAL);
-		gtk_style_context_get_background_color (ctxt, GTK_STATE_SELECTED, &rgba);
+		gtk_style_context_set_state (ctxt, GTK_STATE_FLAG_PRELIGHT);
+		gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_PRELIGHT, &rgba);
 		color = GO_COLOR_FROM_GDK_RGBA (rgba);
-		gtk_style_context_get_color (ctxt, GTK_STATE_SELECTED, &rgba);
+		gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_PRELIGHT, &rgba);
 		font_color = GO_COLOR_FROM_GDK_RGBA (rgba);
 		ascent = ib->bold_font_ascent;
 		break;
 
 	case COL_ROW_FULL_SELECTION:
 		font   = ib->bold_font;
-		gtk_style_context_set_state (ctxt, GTK_STATE_SELECTED);
-		gtk_style_context_get_background_color (ctxt, GTK_STATE_SELECTED, &rgba);
+		gtk_style_context_set_state (ctxt, GTK_STATE_FLAG_ACTIVE);
+		gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_ACTIVE, &rgba);
 		color = GO_COLOR_FROM_GDK_RGBA (rgba);
-		gtk_style_context_get_color (ctxt, GTK_STATE_SELECTED, &rgba);
+		gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_ACTIVE, &rgba);
 		font_color = GO_COLOR_FROM_GDK_RGBA (rgba);
 		ascent = ib->bold_font_ascent;
 		break;
@@ -289,12 +292,14 @@ ib_draw_cell (ItemBar const * const ib, cairo_t *cr,
 		cairo_rectangle (cr, rect->x, rect->y, rect->width, rect->height);
 		cairo_fill (cr);
 		cairo_restore (cr);
+		/* restore style context */
+		gtk_style_context_restore (ctxt);
 		return;
 	}
 
+	gtk_render_background (ctxt, cr, rect->x, rect->y, rect->width + 1, rect->height + 1);
 	gtk_render_frame (ctxt, cr, rect->x, rect->y, rect->width + 1, rect->height + 1);
 	cairo_rectangle (cr, rect->x + 1, rect->y + 1, rect->width - 2, rect->height - 2);
-	cairo_fill_preserve (cr);
 	cairo_restore (cr);
 
 	g_return_if_fail (font != NULL);
@@ -311,6 +316,8 @@ ib_draw_cell (ItemBar const * const ib, cairo_t *cr,
 					 rect->y + (rect->height - PANGO_PIXELS (size.height)) / 2 + ascent);
 	pango_cairo_show_glyph_string (cr, font, ib->pango.glyphs);
 	cairo_restore (cr);
+	/* restore style context */
+	gtk_style_context_restore (ctxt);
 }
 
 int
diff --git a/src/item-grid.c b/src/item-grid.c
index e502a25..f18203b 100644
--- a/src/item-grid.c
+++ b/src/item-grid.c
@@ -397,7 +397,9 @@ item_grid_draw_region (GocItem const *item, cairo_t *cr, double x_0, double y_0,
 	WorkbookView *wbv = sv_wbv (sv);
 	gboolean show_function_cell_markers = wbv->show_function_cell_markers;
 	gboolean show_extension_markers = wbv->show_extension_markers;
-	GtkStyleContext *ctxt = gtk_widget_get_style_context (GTK_WIDGET (canvas));
+	 /* we use the selected background color fromÂan entry for selected cells */
+	GtkWidget *entry = gtk_entry_new ();
+	GtkStyleContext *ctxt = gtk_widget_get_style_context (entry);
 
 	/* To ensure that far and near borders get drawn we pretend to draw +-2
 	 * pixels around the target area which would include the surrounding
@@ -799,6 +801,8 @@ plain_draw : /* a quick hack to deal with 142267 */
 			ig_cairo_draw_bound (cr, 1, start_y, 1, y);
 	}
 
+	gtk_widget_destroy (entry);
+
 	g_slist_free (merged_used);	   /* merges with bottom in view */
 	g_slist_free (merged_active_seen); /* merges with bottom the view */
 	g_slist_free (merged_unused);	   /* merges in hidden rows */
diff --git a/src/pattern.c b/src/pattern.c
index bf4bcac..50946cc 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -93,7 +93,7 @@ gnumeric_background_set (GnmStyle const *mstyle, cairo_t *cr,
 				(cr, gs_lavender.red, gs_lavender.green, gs_lavender.blue);
 		else {
 			GdkRGBA rgba;
-			gtk_style_context_get_background_color (ctxt, GTK_STATE_SELECTED, &rgba);
+			gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_SELECTED, &rgba);
 			cairo_set_source_rgba
 				(cr, gnm_get_light (rgba.red),
 				 gnm_get_light (rgba.green),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]