Toggle Buttons

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

# A.17. Toggle Buttons

    function create_toggle_buttons ()
    {
      local	box1, box2, separator, button;

      win_toggle_buttons = new (GtkWindow);
      win_toggle_buttons.signal ("destroy", #win_toggle_buttons = nil);
      win_toggle_buttons.title = "GtkToggleButton";
      win_toggle_buttons.border_width = 0;

      box1 = new (GtkVBox);
      win_toggle_buttons.add (box1);

      box2 = new (GtkVBox);
      box2.border_width = 10;
      box2.spacing = 10;
      box1.pack_start (box2, TRUE, TRUE, 0);

      button = new (GtkToggleButton);
      button.label = "button1";
      box2.pack_start (button, TRUE, TRUE, 0);

      button = new (GtkToggleButton);
      button.label = "button2";
      box2.pack_start (button, TRUE, TRUE, 0);

      button = new (GtkToggleButton);
      button.label = "button3";
      box2.pack_start (button, TRUE, TRUE, 0);

      separator = new (GtkHSeparator);
      box1.pack_start (separator, FALSE, TRUE, 0);

      box2 = new (GtkVBox);
      box2.border_width = 10;
      box1.pack_start (box2, FALSE, TRUE, 0);

      button = new (GtkButton);
      button.label = "close";
      button.signal ("clicked", `(@win_toggle_buttons).destroy());
      box2.pack_start (button, TRUE, TRUE, 0);
      button.can_default = TRUE;
      button.grab_default();

      win_toggle_buttons.show_all();
      win_toggle_buttons;
    }

    function main ()
    {
      local window, win_toggle_buttons;
      TRUE=1;
      FALSE=0;
      window = create_toggle_buttons ();
      window.signal ("destroy", #exit_program(0));
      init_ipc("toggle_but", "toggle_butq");
      gtk_main ();
    }

Prev | Home | Next
Text | Up | Timers

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