Setting the colour of the button
- From: "Chris Garrett" <garrett91 hotmail com>
- To: gtk-app-devel-list gnome org
- Subject: Setting the colour of the button
- Date: Thu, 21 Nov 2002 01:25:54 +0000
Hi,
I want to have a button that shows the current colour (for a drawing
package). It needs to be able to use rgb values. What is the best way of
doing this?
My current approach is to use a GdkPixbuf, but I am getting errors when I
try to add it to the drawing area which I have added to the button. The
code looks like this:
colorbutton = gtk_button_new();
colordarea = gtk_drawing_area_new();
gtk_widget_set_size_request(colordarea, 40, 40);
gtk_container_add(GTK_CONTAINER(colorbutton), colordarea);
colorpixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE,
8, 40, 40);
gdk_pixbuf_render_to_drawable(colorpixbuf,
colordarea->window,
colordarea->style->fg_gc[GTK_STATE_NORMAL],
0, 0, 0, 0, 40, 40,
GDK_RGB_DITHER_MAX, 0, 0);
The error (at runtime) looks like this:
(draw:2715): Gdk-CRITICAL **: file ../../gdk/gdkpixbuf-render.c: line 182
(gdk_pixbuf_render_to_drawable): assertion `drawable != NULL' failed
I am sure that I initialised the drawing area, so why am I getting the
error?
Best regards,
Chris.
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]