# test menus on GNOME

package require Tk
menu .menu
.menu add cascade -label "File" -menu [menu .menu.file]
.menu.file add command -label "Open..." -underline 0
.menu.file add command -label "Save" -underline 0
.menu.file add command -label "Save As..." -underline 5
.menu.file add separator
.menu.file add cascade -label "Recent files" -menu [menu .menu.file.recent]
foreach f [lrange [glob -directory [pwd] -tails *] 0 20] {
    .menu.file.recent add command -label $f
}
.menu.file add command -label "Exit" -underline 1 -command {destroy .}
.menu add cascade -label "Edit" -menu [menu .menu.edit]
.menu.edit add command -label "Copy" -underline 0
.menu.edit add command -label "Cut" -underline 1
.menu.edit add command -label "Paste" -underline 0

ttk::frame .f -width 200 -height 80
ttk::combobox .c -values [info commands]
ttk::menubutton .mb -text Menubutton -menu .menu
ttk::button .color -text Color -command {tk_chooseColor}
ttk::button .error -text Error -command {bgerror "testing"}
ttk::button .exit -text "Exit" -command {destroy .}
. configure -menu .menu
grid .f - - -sticky news
grid .c - - -sticky ew -padx 2 -pady 2
grid .mb .color .error -sticky e -padx 2 -pady 2
grid .exit - - -sticky se -padx 2 -pady 2
grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1
wm protocol . WM_DELETE_WINDOW {destroy .}
tkwait window .
exit