#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

# this example shows a minimum application with menubar,
# statusbar, toolbar, and main window

load ../src/gnocl.so

# create submenu for menu "File" with standard items "New" and 
# "Quit" (text, icon and accelerator). 'N', 'Q' respectively, 
# are underlined and are also used as accelerators.
set menu [gnocl::menu]
$menu add [gnocl::menuItem label -text "%#_New" -tooltip "Make new" \
      -command {puts "That's new"}]
$menu add [gnocl::menuItem separator]
$menu add [gnocl::menuItem label -text "%#_Quit" -command exit \
      -tooltip "Quit program"]

# create menu "File", 'F' is underlined and used as accelerator
set file [gnocl::menuItem label -text "%__File" -submenu $menu]

# create menu "Help" with standard item "About" 
set menu [gnocl::menu]
$menu add [gnocl::menuItem label -text "%#_About" \
      -tooltip "Show about dialog" \
      -command {puts "Mini example (c) 2001 P.G. Baum"}]
set help [gnocl::menuItem label -text "%__Help" -submenu $menu]

# create toolbar with icons "Quit" and "New"
set toolbar [gnocl::toolbar -style both]
$toolbar add item -text "Quit" -icon "%#Quit" -tooltip "Tooltip Quit" \
            -command exit
$toolbar add space
$toolbar add item -text "New" -icon "%#New" -tooltip "Tooltip new" \
   -command {puts "That's new"}

# create gnome application with a label as main widget
gnocl::app testApp -title "Test Application" -width 250 \
      -menubar [gnocl::menubar -children [list $file $help]] \
      -statusbar [gnocl::appBar] -toolbar $toolbar \
      -contents [gnocl::label -text "here comes the main widget"]

# if sourced from wish withdraw tk toplevel window, else
# enter gtk main loop
if { [info exists tk_patchLevel] } {
   wm withdraw .
} else {
   gnocl::mainLoop
}
