Dialog

Gamma/GTK: Using Gamma™ with GTK, Version 0.9
Prev | Appendix A. Example Code | Next

# A.5. Dialog

    function label_toggle (button, label)
    {
      if (button.get_active() == TRUE)
        label.show();
      else
        label.hide();
    }

    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("Dialog Test");
      lbl.set_padding(10, 10);
      vbox.pack_start(lbl, TRUE, TRUE, 0);
      lbl.hide();

      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 ();
    }

Prev | Home | Next
Check Buttons | Up | Entry

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.