PROGRAM(color_selection);
// The color selection widget is, not surprisingly, a widget for
// interactive selection of colors.  This composite widget lets the
// user select a color by manipulating RGB (Red, Green, Blue) and HSV
// (Hue, Saturation, Value) triples. This is done either by adjusting
// single values with sliders or entries, or by picking the desired
// color from a hue-saturation wheel/value bar.  Optionally, the
// opacity of the color can also be set.
// IMG: GTK.Color_selection()
INHERIT(vbox);
COMPLEX_FUNCTION(create);
COMPLEX_FUNCTION(set_update_policy,int);
NAME_ARGS(policy);
// one of CONST(GTK_UPDATE)
COMPLEX_FUNCTION(set_opacity,int);

FUNCTION(get_color, "function(void:array(float))")
{
  double vals[4];
  int i;
  gtk_color_selection_get_color( GTK_COLOR_SELECTION( THIS->obj ), vals );
  for(i=0; i<4; i++)
    push_float(vals[i]);
  f_aggregate( 4 );
}

FUNCTION(set_color, "function(array(float):object)")
NAME_ARGS(rgba);
RETURNS(GDK.Color);
{
  gdouble vals[4];
  int i;
  struct array *a;
  get_all_args( "set_color", args, "%a", &a );
  for(i=0; i<a->size; i++)
    if(i>3) 
      break;
    else
      vals[i] = a->item[i].u.float_number;
  gtk_color_selection_set_color( GTK_COLOR_SELECTION( THIS->obj ), vals );
  
  RETURN_THIS();
}
SUBWIDGET( wheel_area, container );
SUBWIDGET( value_area, container );
SUBWIDGET( sample_area, container );
SUBWIDGET( sample_area_eb, container );
