PROGRAM(radio_button);
// Radio buttons are similar to check buttons except they are grouped
// so that only one may be selected/depressed at a time. This is good
// for places in your application where you need to select from a
// short list of options.  <p> To connect the buttons, use another
// button in the desired group as the second argument to
// GTK.Radio_button(). See below IMG: GTK.Radio_button("Button");
INHERIT(check_button);
FUNCTION(create, "function(string|void,object|void:void)")
NAME_ARGS(title,groupmember);
//  Normal creation:<p>
// object GTK.Radio_button(string title) - First button (with label)<br>
// object GTK.Radio_button()->add(widget) - First button (with widget)<br>
// object GTK.Radio_button(title, another_radio_button) - Second to n:th button (with title)<br>
// object GTK.Radio_button(0,another_radio_button)->add(widget) - Second to n:th button (with widget)<br>
{
  GSList *mylist = NULL;
  gchar *label=NULL;
  struct object *o=NULL;
  if(args)
  {
    if(sp[-args].type == T_STRING)
      label = (gchar *)sp[-args].u.string->str;
    if(args==2 && (sp[-1].type == T_OBJECT))
	o = sp[-1].u.object;
  }

  if(THIS->obj) error("GTK.Radio_button->create() can only be called once.\n");

  if(o) 
    mylist=gtk_radio_button_group(GTK_RADIO_BUTTON(get_gtkobject(o)));

  if(label)
    THIS->obj=GTK_OBJECT(gtk_radio_button_new_with_label(mylist,label));
  else
    THIS->obj=GTK_OBJECT(gtk_radio_button_new(mylist));
  pgtk__init_this_object();
}

FUNCTION(set_group, "function(object:object)")
NAME_ARGS(groupmember);
// the argument is another radio button to whose group this button
// should be added to. It is prefereable to use the second argument to
// the constructor instead, but if you for some reason want to move
// the button to another group, use this function.
{
  struct object *o=NULL;
  GSList *mylist;
  get_all_args("set_group", args, "%o", &o );
  
  mylist = gtk_radio_button_group( GTK_RADIO_BUTTON( get_gtkobject( o ) ));
  gtk_radio_button_set_group( GTK_RADIO_BUTTON( THIS->obj ), mylist );
  RETURN_THIS();
}

/* TODO: group, g_list of members */
