A.19. Pixmap

function new_pixmap (window_wgt, filename)
{
  local	pixmask;
  
  pixmask = gdk_pixmap_create_from_xpm (window_wgt.get_window(),
					nil, filename);  
  if (!car(pixmask) || !cadr(pixmask))
    {
      princ ("Pixmap load of ", filename, " failed.\n");
      nil;
    }
  else
    gtk_pixmap_new (car(pixmask), cadr(pixmask));
}

function create_pixmap ()
{
  local box1, box2, box3, button, label, separator,
  pixmapwid, pixmap, mask;
  
  win_pixmap = new (GtkWindow);
  win_pixmap.signal ("destroy", #win_pixmap = nil);
  win_pixmap.title = "GtkPixmap";
  win_pixmap.border_width = 0;
  
  box1 = new(GtkVBox);
  win_pixmap.add(box1);
  
  box2 = new(GtkVBox);
  box2.spacing = 10;
  box2.border_width = 10;
  box1.pack_start(box2, TRUE, TRUE, 0);
  
  button = new(GtkButton);
  box2.pack_start(button, FALSE, FALSE, 0);

  pix1 = new_pixmap(win_pixmap, "test.xpm");
  
  label = new(GtkLabel);
  label.set_text("Pixmap\ntest");
  box3 = new(GtkHBox);
  box3.border_width = 2;
  box3.add(pix1);
  box3.add(label);
  button.add(box3);
  
  separator = new(GtkHSeparator);
  box1.pack_start(separator, FALSE, TRUE, 0);
  
  box2 = new(GtkVBox);
  box2.spacing = 10;
  box2.border_width = 10;
  box1.pack_start(box2, FALSE, TRUE, 0);
  
  button = new(GtkButton);
  button.label = "close";
  button.signal("clicked", `(@win_pixmap).destroy());
  box2.pack_start(button, TRUE, TRUE, 0);
  button.can_default = TRUE;
  button.grab_default();
  
  win_pixmap.show_all();
  win_pixmap;
}

function main ()
{
  local window, win_pixmap;
  TRUE=1;
  FALSE=0;
  window = create_pixmap ();
  window.signal ("destroy", #exit_program(0));
  init_ipc("pixmap", "pixmapq");
  gtk_main ();
}