manpagez: man pages & more
html files: gtk2
Home | html | info | man

Migrating from GnomeColorPicker to GtkColorButton

Since version 2.6, GTK+ provides the GtkColorButton widget as a replacement for the GnomeColorPicker widget in the libgnomeui library.

Porting an application from GnomeColorPicker to GtkColorButton is very simple. GtkColorButton doesn't support dithering (since it is rarely needed on modern hardware), and it doesn't have setters and getters to set the color from floating point or integer components. So instead of

1
2
3
guint red, green, blue, alpha;
/* ... */
gnome_color_picker_set_i8 (color_picker, red, green, blue, alpha);

you have to write

1
2
3
4
5
6
7
GdkColor color;

color.red = red << 8;
color.green = green << 8;
color.blue = blue << 8;
gtk_color_button_set_color (color_picker, &color);
gtk_color_button_set_alpha (color_picker, alpha << 8);

and similarly for the setters taking other number formats. For gnome_color_picker_set_i16() no conversion is needed, for gnome_color_picker_set_d(), you need to convert the color components like this:

1
2
3
color.red = (guint16) (red * 65535.0 + 0.5);
color.green = (guint16) (green * 65535.0 + 0.5);
color.blue = (guint16) (blue * 65535.0 + 0.5);

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.