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

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

you have to write

   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:

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