#!/bin/ksh # # Demonstration on how to use the GTK-server with PDKSH by STDIN. # Tested with the AT&T KSH (1993-12-28) on Slackware Linux 9.0. # # September 27, 2003 by Peter van Eerten. # Revised for GTK-server 1.2 October 7, 2004 # Revised for GTK-server 1.3 December 4, 2004 #------------------------------------------------ # # Communication function; $1 contains the string to be send function gtk { print -p $1 read -p RESULT } # Setup environment export LC_ALL=nl_NL export LD_LIBRARY_PATH=/usr/X11R6/lib # Start GTK-server in STDIN mode gtk-server -stdin |& # Define GUI gtk "gtk_init NULL NULL" gtk "gtk_window_new 0" WINDOW=$RESULT gtk "gtk_window_set_title $WINDOW \"This is a title\"" gtk "gtk_window_set_position $WINDOW 1" gtk "gtk_table_new 10 10 1" TABLE=$RESULT gtk "gtk_container_add $WINDOW $TABLE" gtk "gtk_button_new_with_label \"Click here!\"" BUTTON=$RESULT gtk "gtk_table_attach_defaults $TABLE $BUTTON 5 9 7 9" gtk "gtk_check_button_new_with_label \"Check \t this \n out!\"" CHECK=$RESULT gtk "gtk_table_attach_defaults $TABLE $CHECK 1 6 1 2" gtk "gtk_entry_new" ENTRY=$RESULT gtk "gtk_table_attach_defaults $TABLE $ENTRY 1 6 3 4" gtk "gtk_widget_show_all $WINDOW" # Initialize variables EVENT=0 # Mainloop while [[ $EVENT != $BUTTON ]] do gtk "gtk_server_callback WAIT" EVENT=$RESULT if [[ $EVENT = $ENTRY ]] then gtk "gtk_entry_get_text $ENTRY" print $RESULT fi done # Exit GTK gtk "gtk_server_exit"