#!/usr/cogent/bin/gamma /* Example: Button-controlled "Hello world!" * This example creates a button in a window that calls * a "Hello, world!" function and then quits GTK, * demonstrating the use of callbacks. */ /* Initialize Cogent interprocess communication, which is * necessary for using Gamma/GTK. */ init_ipc("a", "aq"); /* Write a Hello, world! function. */ function hello() { princ("Hello, world!\n"); } /* Create a GtkWindow and a GtkButton. */ window = new(GtkWindow); window.set_border_width(20); button = new(GtkButton); button.label = " Click me! "; /* Add callbacks to the button to execute the * "Hello, world!" function and quit. */ button.signal("clicked",#hello()); button.signal("clicked",#gtk_main_quit()); /* Add the button to the window, and show them both.*/ window.add(button); window.show_all(); /* Enter the GTK main processing loop.*/ gtk_main();
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.