Re: Setting the colour of the button
- From: Olexiy Avramchenko <ath beast stu cn ua>
- To: Chris Garrett <garrett91 hotmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Setting the colour of the button
- Date: Thu, 21 Nov 2002 14:39:06 +0200
Chris Garrett wrote:
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?
GnomeColorPicker widget from gnomeui library, unless you dont use gnome
libraries.
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?
Your drawing area is not realized before gdk_pixbuf_render*. Use
callback on "configure_event*, when it pops up - area is realized for sure.
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]