A.7. Dialog

function label_toggle (button, label)
{
  if (button.get_active() == TRUE)
    label.set_text("Dialog Test");
  else
    label.set_text("");
}


function create_dialog ()
{
  local vbox, vboxchildren, separator, action_area, button, label;
  
  win_dialog = new (GtkDialog);
  win_dialog.signal ("destroy", #win_dialog = nil);
  win_dialog.title = "GtkDialog";
  win_dialog.border_width = 0;
  win_dialog.set_usize(200, 110);
  
  vbox = car(win_dialog.children());
  separator = car(vbox.children());
  action_area = cadr(vbox.children());
  
  button = new(GtkButton);
  button.label = "OK";
  button.can_default = TRUE;
  button.signal("clicked", `(@win_dialog).destroy());
  action_area.pack_start(button, TRUE, TRUE, 0);
  button.grab_default();
  button.show();
  
  lbl = new(GtkLabel);
  lbl.set_text("Press the Toggle button.");
  lbl.set_padding(10, 10);
  vbox.pack_start(lbl, TRUE, TRUE, 0);
  lbl.show();
  
  button = new(GtkToggleButton);
  button.label = "Toggle";
  button.signal("clicked", `label_toggle(@button, @lbl));
  button.can_default = TRUE;
  action_area.pack_start(button, TRUE, TRUE, 0);
  button.show();
  
  win_dialog.show();
  win_dialog;
}

function main ()
{
  local window, win_dialog;
  TRUE=1;
  FALSE=0;
  window = create_dialog ();
  window.signal ("destroy", #exit_program(0));
  init_ipc("dialog", "dialogq");
  gtk_main ();
}