[goffice] Ensure that the color palette is correctly displayed.



commit a046d676273df36a07177f8c42e49b76af8fde7c
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sat Sep 24 21:06:10 2011 +0200

    Ensure that the color palette is correctly displayed.

 ChangeLog                      |    6 ++++++
 goffice/gtk/go-color-palette.c |   16 +++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 089d22b..f690f6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-24  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/gtk/go-color-palette.c (draw_color_cb),
+	(go_color_palette_button_new): ensure that the colors are always displayed,
+	even with the most stupid theme.
+
 2011-09-13  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* goffice/utils/go-file.c (go_file_get_owner_name): adjust call
diff --git a/goffice/gtk/go-color-palette.c b/goffice/gtk/go-color-palette.c
index 5f27e2b..b77ae91 100644
--- a/goffice/gtk/go-color-palette.c
+++ b/goffice/gtk/go-color-palette.c
@@ -325,6 +325,18 @@ cb_swatch_key_press (GtkBin *button, GdkEventKey *event, GOColorPalette *pal)
 		return FALSE;
 }
 
+static gboolean
+draw_color_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
+{
+	GtkAllocation allocation;
+	GOColor color = GPOINTER_TO_UINT (data);
+	gtk_widget_get_allocation (widget, &allocation);
+	cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (color));
+	cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+	cairo_fill (cr);
+	return TRUE;
+}
+
 /*
  * Create the individual color buttons
  *
@@ -339,8 +351,10 @@ go_color_palette_button_new (GOColorPalette *pal, GtkTable* table,
 	GdkRGBA   gdk;
 
 	swatch = gtk_drawing_area_new ();
+	g_signal_connect (G_OBJECT (swatch), "draw", G_CALLBACK (draw_color_cb), 
+	                  GUINT_TO_POINTER (color_name->color));
 	gtk_widget_override_background_color (swatch, GTK_STATE_NORMAL,
-		go_color_to_gdk_rgba (color_name->color, &gdk));
+	        go_color_to_gdk_rgba (color_name->color, &gdk));
 	gtk_widget_set_size_request (swatch, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT);
 
 	/* Wrap inside a vbox with a border so that we can see the focus indicator */



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