A.25. Saved Position

function uposition_configure(window, xl, yl)
{
  local		pos;
  
  pos = gdk_window_get_root_origin (window.get_window());
  xl.set_text (string(car(pos)));
  yl.set_text (string(cadr(pos)));
}

function create_saved_position ()
{
  local	main_vbox, vbox, hbox, label, separator, button;
  
  win_saved_position = new (GtkWindow);
  win_saved_position.signal ("destroy", #win_saved_position = nil);
  win_saved_position.title = "Saved Position";
  win_saved_position.border_width = 0;
  
  main_vbox = new (GtkVBox);
  main_vbox.spacing = 5;
  main_vbox.border_width = 0;
  win_saved_position.add (main_vbox);
  
  vbox = new(GtkVBox);
  vbox.homogeneous = FALSE;
  vbox.spacing = 5;
  vbox.border_width = 10;
  main_vbox.pack_start(vbox, TRUE, TRUE, 0);
  vbox.show();
  
  hbox = new(GtkHBox);
  hbox.border_width = 5;
  vbox.pack_start(hbox, FALSE, TRUE, 0);
  
  label = new(GtkLabel);
  label.set_text("X Origin : ");
  label.set_alignment(0, 0.5);
  hbox.pack_start(label, FALSE, TRUE, 0);
  
  x_label = new(GtkLabel);
  x_label.set_text("n/a");
  hbox.pack_start(x_label, TRUE, TRUE, 0);
  
  hbox = new(GtkHBox);
  hbox.border_width = 5;
  vbox.pack_start(hbox, FALSE, TRUE, 0);
  
  label = new(GtkLabel);
  label.set_text("Y Origin : ");
  label.set_alignment(0, 0.5);
  hbox.pack_start(label, FALSE, TRUE, 0);
  
  y_label = new(GtkLabel);
  y_label.set_text("n/a");
  hbox.pack_start(y_label, TRUE, TRUE, 0);
  
  separator = new(GtkHSeparator);
  main_vbox.pack_start(separator, FALSE, TRUE, 0);
  
  hbox = new(GtkHBox);
  hbox.border_width = 10;
  main_vbox.pack_start(hbox, FALSE, TRUE, 0);
  
  button = new (GtkButton);
  button.label = "Close";
  button.signal ("clicked", `(@win_saved_position).destroy());
  hbox.pack_start (button, TRUE, TRUE, 5);
  button.can_default = TRUE;
  button.grab_default();
  
  win_saved_position.signal ("configure_event",
			     `uposition_configure(@win_saved_position,
						  @x_label, @y_label));
  
  win_saved_position.show_all();
  win_saved_position;
}

function main ()
{
  local window, win_saved_position;
  TRUE=1;
  FALSE=0;
  window = create_saved_position ();
  window.signal ("destroy", #exit_program(0));
  init_ipc("saved_pos", "saved_posq");
  gtk_main ();
}