A.8. Entry

function create_entry ()
{
  local	vbox, hbox, frame, label;
  
  cbitems = list("item0");
  cbitems = cons("item1 item1", cbitems);
  cbitems = cons("item2 item2 item2", cbitems);
  cbitems = cons("item3 item3 item3 item3", cbitems);
  cbitems = cons("item4 item4 item4 item4 item4", cbitems);
  cbitems = cons("item5 item5 item5 item5 item5 item5", cbitems);
  cbitems = cons("item6 item6 item6 item6 item6", cbitems);
  cbitems = cons("item7 item7 item7 item7", cbitems);
  cbitems = cons("item8 item8 item8", cbitems);
  cbitems = cons("item9 item9", cbitems);
  cbitems = reverse(cbitems);
  
  win_entry = new (GtkWindow);
  win_entry.signal ("destroy", #win_entry = nil);
  win_entry.title = "entry";
  
  box1 = new(GtkVBox);
  win_entry.add(box1);
  box1.show();
  
  box2 = new(GtkVBox);
  box2.spacing = 10;
  box2.border_width = 10;
  box1.pack_start(box2, TRUE, TRUE, 0);
  box2.show();
  
  entry = new(GtkEntry);
  entry.set_text("hello world");
  entry.select_region(0, 5);
  box2.pack_start(entry, TRUE, TRUE, 0);
  entry.show();
  
  cmb = new(GtkCombo);
  cmb.use_arrows = 0;
  cmb.set_popdown_strings(cbitems);
  cmbentry = car(cmb.children());
  cmbentry.set_text("hello world");
  cmbentry.select_region(0, -1);
  box2.pack_start(cmb, TRUE, TRUE, 0);
  cmb.show();
  
  ed_check = new(GtkCheckButton);
  ed_check.label = "Editable";
  box2.pack_start(ed_check, FALSE, TRUE, 0);
  ed_check.signal("toggled",
		  `(@entry).set_editable((@ed_check).get_active()));
  ed_check.set_active(TRUE);
  ed_check.show();
  
  vis_check = new(GtkCheckButton);
  vis_check.label = "Visible";
  box2.pack_start(vis_check, FALSE, TRUE, 0);
  vis_check.signal("toggled",
		   `(@entry).set_visibility((@vis_check).get_active()));
  vis_check.set_active(TRUE);
  vis_check.show();
  
  sens_check = new(GtkCheckButton);
  sens_check.label = "Sensitive";
  box2.pack_start(sens_check, FALSE, TRUE, 0);
  sens_check.signal("toggled",
		    `(@entry).set_sensitive((@sens_check).get_active()));
  sens_check.set_active(TRUE);
  sens_check.show();
  
  separator = new(GtkHSeparator);
  box1.pack_start(separator, FALSE, TRUE, 0);
  separator.show();
  
  box2 = new (GtkVBox);
  box2.spacing = 10;
  box2.border_width = 10;
  box1.pack_start (box2, FALSE, TRUE, 0);
  box2.show();
  
  button = new(GtkButton);
  button.label = "close";
  button.signal("clicked", `(@win_entry).destroy());
  box2.pack_start (button, TRUE, TRUE, 0);
  button.can_default = TRUE;
  button.grab_default();
  button.show();      

  win_entry.show_all();
  win_entry;
}

function main ()
{
  local window, win_entry;
  TRUE=1;
  FALSE=0;
  window = create_entry ();
  window.signal ("destroy", #exit_program(0));
  init_ipc("entry", "entryq");
  gtk_main ();
}