PROGRAM(radio_menu_item);
// Exactly like radio_button, but it is an menu item.
// IMG: GTK.Radio_menu_item("Menu item")
INHERIT(menu_item);
FUNCTION(create, "function(string|void,object|void:void)")
NAME_ARGS(title,groupmember);
// object GTK.Radio_menu_item(string title) - First button (with label)<br>
// object GTK.Radio_menu_item()->add(widget) - First button (with widget)<br>
// object GTK.Radio_menu_item(title, another_radio_button) - Second to n:th button (with title)<br>
// object GTK.Radio_menu_item(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_group->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_menu_item_new_with_label(mylist,label));
  else
    THIS->obj=GTK_OBJECT(gtk_radio_menu_item_new(mylist));
  pop_n_elems(args);
  pgtk__init_this_object();
}

FUNCTION(set_group, "function(object:object)")
NAME_ARGS(groupmember);
// the argument is another radio menu item 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;
  GSList *mylist;
  get_all_args("set_group", args, "%o", &o );
  mylist=gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(get_gtkobject(o)));
  gtk_radio_menu_item_set_group( GTK_RADIO_MENU_ITEM( THIS->obj ), mylist );
  RETURN_THIS();
}

/* TODO: group, g_list of members */
