A.14. Labels

function create_labels ()
{
  local	vbox, hbox, frame, label;
  
  win_labels = new (GtkWindow);
  win_labels.signal ("destroy", #win_labels = nil);
  win_labels.title = "Label";
  
  vbox = new(GtkVBox);
  vbox.spacing = 5;
  hbox = new(GtkHBox);
  hbox.spacing = 5;
  win_labels.add(hbox);
  hbox.pack_start(vbox, FALSE, FALSE, 0);
  win_labels.set_border_width(5);
  
  frame = new(GtkFrame);
  frame.set_label("Normal Label");
  label = new(GtkLabel);
  label.set_text("This is a Normal label");
  frame.add(label);
  vbox.pack_start(frame, FALSE, FALSE, 0);
  
  frame = new(GtkFrame);
  frame.set_label("Multi-Line Label");
  label = new(GtkLabel);
  label.set_text("This is a Multi-line label.\nSecond line\nThird line");
  frame.add(label);
  vbox.pack_start(frame, FALSE, FALSE, 0);
  
  frame = new(GtkFrame);
  frame.set_label("Left Justified Label");
  label = new(GtkLabel);
  label.set_text("This is a Left-Justified\nMulti-line label.\nThird      line");
  label.set_justify(GTK_JUSTIFY_LEFT);
  frame.add(label);
  vbox.pack_start(frame, FALSE, FALSE, 0);
  
  frame = new(GtkFrame);
  frame.set_label("Right Justified Label");
  label = new(GtkLabel);
  label.set_text("This is a Right-Justified\nMulti-line label.\nFourth line, (j/k)");
  label.set_justify(GTK_JUSTIFY_RIGHT);
  frame.add(label);
  vbox.pack_start(frame, FALSE, FALSE, 0);
  
  vbox = new(GtkVBox);
  vbox.spacing = 5;
  hbox.pack_start(vbox, FALSE, FALSE, 0);
  
  frame = new(GtkFrame);
  frame.set_label("Line wrapped label");
  label = new(GtkLabel);
  label.set_text("This is an example of a line-wrapped label.  It should not be taking up the entire             width allocated to it, but automatically wraps the words to fit. The time has come, for all good men, to come to the aid of their party.  The sixth sheik's six sheep's sick.\n     It supports multiple paragraphs correctly, and  correctly   adds many          extra  spaces. ");
  label.set_line_wrap(1);
  frame.add(label);
  vbox.pack_start(frame, FALSE, FALSE, 0);
  
  frame = new(GtkFrame);
  frame.set_label("Filled, wrapped label");
  label = new(GtkLabel);
  label.set_text("This is an example of a line-wrapped, filled label.  It should be taking up the entire              width allocated to it.  Here is a seneance to prove my point.  Here is another sentence. Here comes the sun, do de do de do.\n    This is a new paragraph.\n    This is another newer, longer, better paragraph.  It is coming to an end, unfortunately.");
  label.set_justify(GTK_JUSTIFY_FILL);
  label.set_line_wrap(1);
  frame.add(label);
  vbox.pack_start(frame, FALSE, FALSE, 0);
  
  frame = new(GtkFrame);
  frame.set_label("Underlined label");
  label = new(GtkLabel);
  label.set_text("This label is underlined!\nThis one is underlined in quite a funky fashion");
  label.set_justify(GTK_JUSTIFY_LEFT);
  label.set_pattern("_________________________ _ _________ _ _____ _ __ __  ___ ____ _____");
  frame.add(label);
  vbox.pack_start(frame, FALSE, FALSE, 0);

  win_labels.show_all();
  win_labels;
}

function main ()
{
  local window, win_labels;
  TRUE=1;
  FALSE=0;
  window = create_labels ();
  window.signal ("destroy", #exit_program(0));
  init_ipc("labels", "labelsq");
  gtk_main ();
}