A.2. Button Box

function create_bbox (horizontal, title, spacing, child_w, child_h, layout)
{
  local		frame, bbox, button;
  
  frame = new (GtkFrame);
  frame.label = title;
  
  if (horizontal == TRUE)
    bbox = new (GtkHButtonBox);
  else
    bbox = new (GtkVButtonBox);
  
  bbox.border_width = 5;
  frame.add (bbox);
  
  bbox.layout_style = layout;
  bbox.bbox_spacing = spacing;
  bbox.child_min_width = child_w;
  bbox.child_min_height = child_h;
  
  button = new (GtkButton);
  button.label = "OK";
  bbox.add (button);
  
  button = new (GtkButton);
  button.label = "Cancel";
  bbox.add (button);
  
  button = new (GtkButton);
  button.label = "Help";
  bbox.add (button);
  
  frame;
}

function create_button_box ()
{
  local	main_vbox, vbox, hbox, frame_horz, frame_vert;
  
  win_button_box = new (GtkWindow);
  win_button_box.title = "Button Boxes";
  win_button_box.border_width = 10;
  win_button_box.signal ("destroy", #win_button_box = nil);
  
  main_vbox = new (GtkVBox);
  win_button_box.add (main_vbox);
  
  frame_horz = new (GtkFrame);
  frame_horz.label = "Horizontal Button Boxes";
  
  main_vbox.pack_start (frame_horz, TRUE, TRUE, 10);
  vbox = new (GtkVBox);
  vbox.border_width = 10;
  frame_horz.add (vbox);
  
  vbox.pack_start (create_bbox (TRUE, "Spread", 40, 85, 20,
				GTK_BUTTONBOX_SPREAD),
		   TRUE, TRUE, 0);
  
  vbox.pack_start (create_bbox (TRUE, "Edge", 40, 85, 20,
				GTK_BUTTONBOX_EDGE),
		   TRUE, TRUE, 5);
  
  vbox.pack_start (create_bbox (TRUE, "Start", 40, 85, 20,
				GTK_BUTTONBOX_START),
		   TRUE, TRUE, 5);
  
  vbox.pack_start (create_bbox (TRUE, "End", 40, 85, 20,
				GTK_BUTTONBOX_END),
		   TRUE, TRUE, 5);
  
  frame_vert = new (GtkFrame);
  frame_vert.label = "Vertical Button Boxes";
  main_vbox.pack_start (frame_vert, TRUE, TRUE, 10);
  
  hbox = new (GtkHBox);
  hbox.border_width = 10;
  frame_vert.add (hbox);
  
  hbox.pack_start (create_bbox (FALSE, "Spread", 30, 85, 20,
				GTK_BUTTONBOX_SPREAD),
		   TRUE, TRUE, 0);
  
  hbox.pack_start (create_bbox (FALSE, "Edge", 30, 85, 20,
				GTK_BUTTONBOX_EDGE),
		   TRUE, TRUE, 5);
  
  hbox.pack_start (create_bbox (FALSE, "Start", 30, 85, 20,
				GTK_BUTTONBOX_START),
		   TRUE, TRUE, 5);
  
  hbox.pack_start (create_bbox (FALSE, "End", 30, 85, 20,
				GTK_BUTTONBOX_END),
		   TRUE, TRUE, 5);

  win_button_box.show_all();
  win_button_box;
}

function main ()
{
  local window, win_button_box;
  TRUE=1;
  FALSE=0;
  window = create_button_box ();
  window.signal ("destroy", #exit_program(0));
  init_ipc("button_box", "button_boxq");
  gtk_main ();
}