1 # Id: idnconf.tcl,v 1.1.1.1 2003/06/04 00:27:42 marka Exp
3 # idnconf.tcl - configure idn wrapper
6 #############################################################################
7 # Copyright (c) 2000,2002 Japan Network Information Center.
10 # By using this file, you agree to the terms and conditions set forth bellow.
12 # LICENSE TERMS AND CONDITIONS
14 # The following License Terms and Conditions apply, unless a different
15 # license is obtained from Japan Network Information Center ("JPNIC"),
16 # a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
17 # Chiyoda-ku, Tokyo 101-0047, Japan.
19 # 1. Use, Modification and Redistribution (including distribution of any
20 # modified or derived work) in source and/or binary forms is permitted
21 # under this License Terms and Conditions.
23 # 2. Redistribution of source code must retain the copyright notices as they
24 # appear in each source code file, this License Terms and Conditions.
26 # 3. Redistribution in binary form must reproduce the Copyright Notice,
27 # this License Terms and Conditions, in the documentation and/or other
28 # materials provided with the distribution. For the purposes of binary
29 # distribution the "Copyright Notice" refers to the following language:
30 # "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
32 # 4. The name of JPNIC may not be used to endorse or promote products
33 # derived from this Software without specific prior written approval of
36 # 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
37 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
39 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
40 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
41 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
42 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43 # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
46 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
47 #############################################################################
49 global configFile configBack
50 global registryKey registryEnc registryDef
51 global filesCpy filesRen filesDel
56 set configFile
"idnconf.lst" ;# list of wrapped program
57 set configBack
"idnconf.bak" ;# backup of previous data
59 set serverKey
"HKEY_LOCAL_MACHINE\\Software\\JPNIC\\IDN"
60 set serverLogLevel LogLevel
61 set serverLogLevelDef
-1
62 set serverLogLevelNone
-1
63 set serverLogFile LogFile
64 set serverLogFileDef
{C
:\idn_wrapper.log
}
65 set serverConfFile ConfFile
67 set perprogKey
"HKEY_LOCAL_MACHINE\\Software\\JPNIC\\IDN\\PerProg\\"
68 set perprogEnc Encoding
69 set perprogDef Default
71 set logFileNameDef idn_wrapper.log
72 set confFileNameDef idn.conf
74 set filesCpy11
{ "wsock32.dll" }
75 set filesCpy20
{ "wsock32.dll" "ws2_32.dll" }
76 set filesDel11
{ "wsock32.dll" }
77 set filesDel20
{ "wsock32.dll" "ws2_32.dll" }
81 ########################################################################
86 proc get_os_version
{} {
87 global os_version tcl_platform
89 if {[llength [info globals os_version
]] > 0} {
93 switch -- $tcl_platform(os
) {
95 switch -- $tcl_platform(osVersion
) {
97 set os_version
{Windows
95}
100 set os_version
{Windows
98}
103 set os_version
{Windows Me
}
108 switch -- $tcl_platform(osVersion
) {
111 set os_version
{Windows NT
}
114 set os_version
{Windows
2000}
118 set os_version
{Windows XP
}
123 error "idn wrapper does not support Windows 3.1"
126 set os_version
"Unknown"
132 proc support_dll_redirection
{} {
133 global dll_redirection
135 if {[llength [info globals dll_redirection
]] > 0} {
136 return $dll_redirection
139 switch -- [get_os_version
] {
142 # cannot force local DLL reference by .local file.
143 set dll_redirection
0
146 set dll_redirection
1
152 ########################################################################
157 proc getExeName
{ prg
} {
158 set elem
[file split $prg]
159 set leng
[expr {[llength $elem] - 1}]
160 set name
[lindex $elem $leng]
161 set exe
[file rootname
$name]
165 proc getDirName
{ prg
} {
169 proc getSystemDir
{} {
171 switch -- [get_os_version
] {
175 set sysDir
$env(windir
)/system
178 set sysDir
$env(SystemRoot
)/system32
184 ########################################################################
186 # loadList / saveList
188 # loadList - load list of wrapped executables from $configFile
189 # saveList - save list of wrapped executables into $configFile
194 global configFile configBack
196 if { [file exists
$configFile] } {
197 file copy
-force $configFile $configBack
201 set fd
[open $configFile {CREAT RDONLY
}]
202 while { ! [eof $fd]} {
204 if { [string length
$line] > 0} {
205 lappend aList
"$line"
212 proc saveList
{ aList
} {
214 file delete
-force $configFile
215 set fd
[open $configFile {CREAT WRONLY
}]
222 ########################################################################
224 # putList / getList - set/get list to/from listbox
227 proc putList
{ lb aList
} {
233 proc getList
{ lb
} {
237 ########################################################################
239 # checkList / appendList / deleteList - check / append / delete program from/to listbox
242 proc checkList
{ lb prg
} {
244 set lst
[getList
$lb]
247 if { [string compare
$prg $n] == 0 } {
254 proc appendList
{ lb prg
} {
256 if { [checkList
$lb $prg] == 0 } {
261 proc deleteList
{ lb prg
} {
263 set lst
[getList
$lb]
266 if { [string compare
$n $prg] == 0 } {
273 ########################################################################
275 # registry operations
278 proc regGetEncode
{ prg
} {
280 global perprogKey perprogEnc perprogDef
282 if { [string compare
$prg "" ] == 0 } {
289 package require
registry 1.0
291 set name
[getExeName
$prg]
292 set key
$perprogKey$name
294 if { [catch {set enc
[registry get
$key $perprogEnc]} err
] } {
297 if { [string compare
$enc ""] == 0 } {
303 proc regSetEncode
{ prg enc
} {
305 global perprogKey perprogEnc perprogDef
311 package require
registry 1.0
313 set name
[getExeName
$prg]
314 set key
$perprogKey$name
316 if { [string compare
$enc $perprogDef] == 0 } {
319 if { [catch {registry set $key $perprogEnc $enc sz
} ] } {
325 proc regGetLogLevel
{} {
326 global serverKey serverLogLevel serverLogLevelDef
327 regGetValue
$serverKey $serverLogLevel $serverLogLevelDef
330 proc regSetLogLevel
{level
} {
331 global serverKey serverLogLevel
332 regSetValue
$serverKey $serverLogLevel $level dword
335 proc regGetLogFile
{} {
336 global serverKey serverLogFile serverLogFileDef
337 set file [regGetValue
$serverKey $serverLogFile $serverLogFileDef]
338 if {[catch {file attributes
$file -longname} lfile
]} {
339 # Maybe $file doesn't exist (yet). Get the longname of
341 set dir
[file dirname
$file]
342 if {[catch {file attributes
$dir -longname} ldir
]} {
345 set lfile
[file join $ldir [file tail
$file]]
347 file nativename
$lfile
350 proc regSetLogFile
{file} {
351 global serverKey serverLogFile
352 regSetValue
$serverKey $serverLogFile [file nativename
$file]
355 proc regGetConfFile
{} {
356 global serverKey serverConfFile
357 set file [regGetValue
$serverKey $serverConfFile {}]
358 if {[string compare
$file {}] == 0} {
361 if {[catch {file attributes
$file -longname} lfile
]} {
362 # Maybe $file doesn't exist (yet). Get the longname of
364 set dir
[file dirname
$file]
365 if {[catch {file attributes
$dir -longname} ldir
]} {
368 set lfile
[file join $ldir [file tail
$file]]
370 file nativename
$lfile
373 proc regSetConfFile
{file} {
374 global serverKey serverConfFile
375 regSetValue
$serverKey $serverConfFile [file nativename
$file]
378 proc regGetWhere
{} {
380 regGetValue
$serverKey Where
0
383 proc regSetWhere
{where
} {
385 regSetValue
$serverKey Where
$where dword
388 proc regGetValue
{key name
default} {
390 puts "--regGetValue $key $name"
393 package require
registry 1.0
395 if {[catch {registry get
$key $name} value
]} {
398 if {[string compare
$value {}] == 0} {
404 proc regSetValue
{key name value
{type sz
}} {
406 puts "--regSetValue $key $name $value"
410 package require
registry 1.0
412 if {[catch {registry set $key $name $value $type}]} {
418 ########################################################################
420 # install / uninstall DLL s
423 proc fileInstall
{ prg
} {
426 global filesCpy11 filesCpy20
432 switch -- [get_os_version
] {
436 set winDir
$env(windir
)
437 set sysDir
$winDir/system
438 set filesCpy
$filesCpy11
441 set winDir
$env(SystemRoot
)
442 set sysDir
$winDir/system32
443 set filesCpy
$filesCpy20
447 set toDir
[getDirName
$prg ]
449 foreach n
$filesCpy {
450 file copy
-force $n $toDir
455 proc fileRemove
{ prg
} {
457 global filesDel11 filesDel20
463 switch -- [get_os_version
] {
465 set filesDel
$filesDel11
469 set filesDel
$filesDel20
472 set filesDel
$filesDel20
476 set fromDir
[getDirName
$prg ]
478 foreach n
$filesDel {
479 file delete
-force $fromDir/$n
484 ########################################################################
486 # Wrap/Unwrap program
489 proc execWrap
{ pw lb dlg prg enc
} {
491 set prgName
[$prg get
]
492 set encName
[$enc get
]
494 # Make sure the program name is not empty
495 if {[string compare
$prgName {}] == 0} {
496 confErrorDialog
$dlg "Program must be specified.\nClick \"Browse..\" button for browsing."
500 # It is dangerous to wrap programs in the system directory.
501 set prgdir
[file nativename
[getDirName
$prgName]]
502 set sysdir
[file nativename
[getSystemDir
]]
503 if {[string compare
-nocase $prgdir $sysdir] == 0} {
504 tk_messageBox -icon error -type ok
-title "Directory Error" \
506 -message "Cannot wrap applications in the system directory.\nPlease copy the EXE file to elsewhere and wrap the copied one."
511 # Okay, copy the wrapper DLLs.
512 if { [fileInstall
$prgName] } {
513 tk_messageBox -icon warning
-type ok
\
515 -message "Cannot install DLLs" \
520 if { [regSetEncode
$prgName $encName] } {
521 tk_messageBox -icon warning
-type ok
\
523 -message "Cannot set encoding" \
530 # if local flag is on, create $prgName.local.
533 create_dot_local
$prgName $dlg
535 remove_dot_local
$prgName $dlg
538 if { [checkList
$lb $prgName] == 0 } {
539 appendList
$lb $prgName
541 saveList
[getList
$lb]
545 proc execUnwrap
{ pw lb dlg prg
} {
547 set prgName
[$prg get
]
549 if {[support_dll_redirection
] && [file exists
$prgName.local
]} {
550 set ans
[tk_messageBox -icon question
-type yesno
\
551 -title "Confirmation" \
552 -message "Also remove $prgName.local file?" \
554 if {[string compare
$ans yes
] == 0} {
555 remove_dot_local
$prgName $dlg
559 if { [checkList
$lb $prgName] == 1 } {
562 deleteList
$lb $prgName
563 saveList
[getList
$lb]
567 proc create_dot_local
{path
{parent .
}} {
568 set dotlocal
$path.local
569 if {[file exists
$dotlocal]} {
572 if {[catch {open $dotlocal w
} fh
]} {
573 tk_messageBox -icon warning
-type ok
-title "Warning" \
574 -message "Cannot create $dotlocal" -parent $parent
581 proc remove_dot_local
{path
{parent .
}} {
582 set dotlocal
$path.local
583 if {[file exists
$dotlocal] && [catch {file delete
$dotlocal}]} {
584 tk_messageBox -icon warning
-type ok
-title "Warning" \
585 -message "Cannot remove $dotlocal" -parent $parent
591 ########################################################################
593 # dialog for Wrap / Unwrap
596 proc syncEncode
{ v i op
} {
597 global prgName encName
598 set enc
[regGetEncode
$prgName]
599 if { [string compare
$encName $enc] != 0 } {
604 proc confBrowse
{ p ePrg eEnc
} {
607 { "Executable" .exe
}
610 set file [tk_getOpenFile -filetypes $types -parent $p ]
612 if { [string compare
$file ""] == 0 } {
615 set enc
[regGetEncode
$file]
620 proc confWrap
{ pw lb
} {
622 global prgName encName local_dll
624 set idx
[$lb curselection
]
625 if { [llength $idx] == 1 } {
626 set prg
[$lb get
$idx]
627 set local_dll
[file exists
$prg.local
]
635 wm title
$top "idn wrapper - Wrap Executable"
637 frame $top.f1
-bd 1 -relief raised
638 frame $top.f2
-bd 1 -relief raised
639 pack $top.f1
-side top
-fill x
-expand on
640 pack $top.f2
-side top
-fill x
-expand on
643 pack $top.f1.f
-fill both
-expand on
-padx 4 -pady 4
646 label $w.prgtitle
-text "Program:"
647 label $w.enctitle
-text "Encoding:"
649 entry $w.prgname
-relief sunken
-width 56 -textvariable prgName
650 entry $w.encname
-relief sunken
-width 8 -textvariable encName
651 set w_prgname
$w.prgname
652 set w_encname
$w.encname
653 button $w.browse
-text "Browse.." \
654 -command [list confBrowse
$w $w_prgname $w_encname]
657 radiobutton $w.rbf.encdef
-text "Default" -variable encName
\
659 radiobutton $w.rbf.encutf
-text "UTF-8" -variable encName
\
661 pack $w.rbf.encdef
$w.rbf.encutf
-side left
-padx 4
663 grid $w.prgtitle
-row 0 -column 0 -sticky e
664 grid $w.enctitle
-row 1 -column 0 -sticky e
665 grid $w.prgname
-row 0 -column 1 -sticky we
-pady 4 -padx 2 -columnspan 2
666 grid $w.browse
-row 0 -column 3 -sticky w
-pady 4 -padx 4
667 grid $w.encname
-row 1 -column 1 -sticky we
-pady 4 -padx 2
668 grid $w.rbf
-row 1 -column 2 -sticky w
-padx 2
669 if {[support_dll_redirection
]} {
670 checkbutton $w.local
-text "Force local DLL reference" \
672 grid $w.local
-row 2 -column 1 -sticky w
-padx 4 -pady 4
674 grid columnconfig
$w 1 -weight 1 -minsize 20
675 grid columnconfig
$w 2 -weight 2 -minsize 20
677 trace variable prgName w syncEncode
679 $w.prgname delete
0 end
680 $w.prgname insert
0 $prg
685 button $w.wrap
-text "Wrap" \
686 -command [list execWrap
$pw $lb $top $w_prgname $w_encname]
687 button $w.cancel
-text "Cancel" \
688 -command [list destroy $top]
689 pack $w.cancel
-side right
-fill y
-padx 12 -pady 4
690 pack $w.wrap
-side right
-fill y
-padx 12 -pady 4
695 proc confUnwrap
{ pw lb
} {
697 set idx
[$lb curselection
]
698 if { [llength $idx] != 1 } {
699 tk_messageBox -icon warning
-type ok
\
701 -message "first, select unwrapping executable" \
705 set prg
[$lb get
$idx]
706 if { [string length
$prg] == 0 } {
707 tk_messageBox -icon warning
-type ok
\
709 -message "first, select unwrapping executable" \
717 wm title
$top "idn wrapper - Unwrap Executable"
719 frame $top.f1
-bd 1 -relief raised
720 frame $top.f2
-bd 1 -relief raised
721 pack $top.f2
-side bottom
-fill x
722 pack $top.f1
-side bottom
-fill x
-expand on
725 pack $top.f1.f
-padx 4 -pady 4 -fill both
-expand on
727 label $w.prgtitle
-text "Program:"
728 entry $w.prgname
-relief sunken
-width 56 -textvariable prgName
729 $w.prgname delete
0 end
730 $w.prgname insert
0 $prg
732 set w_prgname
$w.prgname
734 grid $w.prgtitle
-row 0 -column 0 -sticky w
735 grid $w.prgname
-row 0 -column 1 -sticky we
-pady 4
736 grid columnconfig
$w 1 -weight 1 -minsize 20
739 button $w.wrap
-text "Unwrap" \
740 -command [list execUnwrap
$pw $lb $top $w_prgname]
741 button $w.cancel
-text "Cancel" \
742 -command [list destroy $top]
744 pack $w.cancel
-side right
-padx 12 -pady 6
745 pack $w.wrap
-side right
-padx 12 -pady 6
751 proc unwrapAll
{pw lb
} {
752 set ans
[tk_messageBox -type yesno
-default no
-icon question
\
753 -parent $pw -title {idn wrapper Configuration
} \
754 -message {Really unwrap all programs?
}]
755 if {[string compare
$ans yes
] != 0} {
759 foreach prog
[$lb get
0 end
] {
763 if {[support_dll_redirection
]} {
765 foreach prog
[$lb get
0 end
] {
766 if {![file exists
$prog.local
]} continue
767 switch -- $delete_type {
770 set delete_type
[dotLocalDialog
$prog $delete_type]
773 switch -- $delete_type {
776 remove_dot_local
$prog $pw
786 proc rewrapAll
{pw lb
} {
787 set ans
[tk_messageBox -type yesno
-default yes
-icon question
\
788 -parent $pw -title {idn wrapper Configuration
} \
789 -message {Really rewrap all programs?
}]
790 if {[string compare
$ans yes
] != 0} {
793 foreach prog
[$lb get
0 end
] {
799 global _logLevel _logFile
804 wm title
$top "idn wrapper - Log Configuration"
805 # wm transient $top $pw
807 set _logLevel
[regGetLogLevel
]
808 set _logFile
[regGetLogFile
]
810 frame $top.f1
-bd 1 -relief raised
811 frame $top.f2
-bd 1 -relief raised
812 pack $top.f2
-side bottom
-fill x
813 pack $top.f1
-side top
-fill both
-expand on
816 label $w.lv_l
-text "Log Level:"
818 global serverLogLevelNone
820 foreach {lvl
text} [list $serverLogLevelNone None
\
821 0 Fatal
1 Error
2 Warning
3 Info
4 Trace
] {
822 radiobutton $w.lv_v.btn
$i -text $text -value $lvl -variable _logLevel
823 pack $w.lv_v.btn
$i -side left
-padx 3
826 label $w.ld_l
-text "Log File:"
828 entry $w.ld_v.e
-width 40 -textvariable _logFile
830 button $w.ld_v.b
-text "Browse.." -command [list selectLog
$top $w.ld_v.e
]
831 pack $w.ld_v.b
-side right
-fill y
-padx 6
832 pack $w.ld_v.e
-side left
-fill both
-expand yes
833 #label $w.lo_l -text "Log Operation:"
835 button $w.lo_v.show
-text "View" -command [list showLog
$top]
836 button $w.lo_v.delete
-text "Delete" -command [list deleteLog
$top]
837 pack $w.lo_v.show
$w.lo_v.delete
-side left
-padx 4
839 grid $w.lv_l
-row 0 -column 0 -sticky e
-padx 4
840 grid $w.ld_l
-row 1 -column 0 -sticky e
-padx 4
841 #grid $w.lo_l -row 2 -column 0 -sticky e -padx 4
842 grid $w.lv_v
-row 0 -column 1 -sticky w
-padx 4 -pady 4
843 grid $w.ld_v
-row 1 -column 1 -sticky we
-padx 4 -pady 4
844 grid $w.lo_v
-row 2 -column 1 -sticky w
-padx 4 -pady 4
847 button $w.ok
-text "OK" -command [list configureLog
$top]
848 button $w.cancel
-text "Cancel" -command [list destroy $top]
849 pack $w.cancel
-side right
-padx 12 -pady 6
850 pack $w.ok
-side right
-padx 12 -pady 6
853 proc configureLog
{top
} {
854 global _logLevel _logFile
856 if {$_logLevel != [regGetLogLevel
] ||
857 [string compare
$_logFile [regGetLogFile
]] != 0} {
858 set dir
[file dirname
$_logFile]
859 if {[string compare
$dir {}]} {
860 if {![file exists
$dir]} {
861 confErrorDialog
$top "Directory $dir doesn't exist"
863 } elseif
{![file isdirectory
$dir]} {
864 confErrorDialog
$top "$dir is not a directory"
868 regSetLogLevel
$_logLevel
869 regSetLogFile
$_logFile
870 tk_messageBox -type ok
-default ok
-icon info -parent $top \
871 -title "idn wrapper Configuration" \
872 -message "Changing log level or file does not affect already running processes."
877 proc selectLog
{top e
} {
878 global logFileNameDef
879 set file [tk_getSaveFile -title {idn wrapper Logfile Selection
} \
880 -defaultextension .log
\
881 -filetypes {{{Log Files
} .log
} {{All Files
} *}} \
882 -initialfile $logFileNameDef \
884 if {[string compare
$file {}]} {
886 $e insert insert
$file
892 if {[catch {exec notepad.exe
$_logFile &} r
]} {
893 confErrorDialog
$top "Cannot execute notepad"
897 proc deleteLog
{top
} {
899 set ans
[tk_messageBox -type yesno
-default no
-icon question
\
900 -parent $top -title "idn wrapper Configuration" \
901 -message "Really delete $_logFile?"]
902 if {[string compare
$ans yes
] == 0} {
903 file delete
$_logFile
907 ########################################################################
909 # dialog for .local deletion
912 proc dotLocalDialog
{path
{default yes
}} {
918 wm iconname
$dlg Dialog
919 wm title
$dlg Confirmation
920 wm transient
$dlg $parent
921 wm protocol
$dlg WM_DELETE_WINDOW
{}
923 frame $dlg.f1
-bd 1 -relief raised
924 frame $dlg.f2
-bd 1 -relief raised
925 pack $dlg.f1
-side top
-fill x
-expand on
-ipadx 2m
-ipady 4m
926 pack $dlg.f2
-side top
-fill x
-ipadx 2m
928 label $dlg.f1.bm
-bitmap question
-bd 0
929 label $dlg.f1.msg
-text "Remove $path.local?" -wraplength 10c
930 pack $dlg.f1.bm
-side left
-padx 3m
-pady 2m
931 pack $dlg.f1.msg
-side left
-padx 2m
-pady 2m
933 global dotlocal_selection
934 foreach {btn lbl
} {yes Yes no No yesall
{Yes to All
} noall
{No to All
}} {
935 set bw
$dlg.f2.btn
$btn
936 button $bw -text $lbl -default normal
\
937 -command [list set dotlocal_selection
$btn]
938 if {[string compare
$default $btn] == 0} {
939 $bw configure
-default active
942 bind $bw <Return
> {%W flash
; %W invoke
}
943 pack $bw -side left
-padx 3m
-pady 2m
947 ::tk::PlaceWindow $dlg widget
$parent
949 vwait dotlocal_selection
951 return $dotlocal_selection
954 ########################################################################
956 # dialog for advanced configuration
959 proc advancedConf
{pw
} {
963 wm title
$top "idn wrapper - Advanced Configuration"
965 global _mdnOperation _confFile
966 set _mdnOperation
[regGetWhere
]
967 set _confFile
[regGetConfFile
]
969 foreach f
{f1 f2 f3
} {
970 frame $top.
$f -bd 1 -relief raised
971 pack $top.
$f -side top
-fill x
975 label $f.lbl
-text {IDN Wrapping Mode
}
978 foreach {rb val txt
} [list \
979 rb1
0 {Wrap both WINSOCK
1.1 and WINSOCK
2.0} \
980 rb2
2 {Wrap only WINSOCK
1.1} \
981 rb3
3 {Wrap only WINSOCK
2.0} \
982 rb4
1 "Wrap only WINSOCK2.0 if it exists.\nOtherwise wrap only WINSOCK1.1"] {
983 radiobutton $w.
$rb -text $txt -variable _mdnOperation
-value $val \
984 -anchor w
-justify left
985 pack $w.
$rb -side top
-fill x
-pady 1
987 pack $f.lbl
-side top
-fill x
-pady 4
988 pack $w -side top
-fill both
-padx 20 -pady 10
991 label $f.lbl
-text {IDN Configuration
}
992 pack $f.lbl
-side top
-fill x
-pady 6
996 pack $w -side top
-fill both
-padx 10 -pady 6
997 label $w.l1
-text {Config File
:}
998 #label $w.l2 -text {Config Operation:}
999 entry $w.e
-width 40 -textvariable _confFile
1001 button $w.br
-text "Browse.." -command [list selectConf
$top $w.e
]
1002 button $w.b
-text Edit
-command [list editConf
$top]
1003 grid $w.l1
-row 0 -column 0 -sticky e
-padx 4
1004 #grid $w.l2 -row 1 -column 0 -sticky e -padx 4
1005 grid $w.e
-row 0 -column 1 -sticky we
-padx 4 -pady 4
1006 grid $w.b
-row 1 -column 1 -sticky w
-padx 4 -pady 4
1007 grid $w.br
-row 0 -column 2 -sticky w
-padx 4 -pady 4
1010 button $w.ok
-text "OK" -command [list advConf
$top]
1011 button $w.cancel
-text "Cancel" -command [list destroy $top]
1012 pack $w.cancel
-side right
-padx 12 -pady 8
1013 pack $w.ok
-side right
-padx 12 -pady 8
1016 proc editConf
{top
} {
1018 if {[catch {exec notepad.exe
$_confFile &} r
]} {
1019 confErrorDialog
$top "Cannot execute notepad"
1023 proc selectConf
{top e
} {
1024 global confFileNameDef
1025 set file [tk_getOpenFile -title {idn wrapper Config File Selection
} \
1026 -defaultextension .conf
\
1027 -filetypes {{{Config Files
} .conf
} {{All Files
} *}} \
1028 -initialfile $confFileNameDef \
1030 if {[string compare
$file {}]} {
1032 $e insert insert
$file
1036 proc advConf
{top
} {
1037 global _mdnOperation _confFile
1038 regSetWhere
$_mdnOperation
1039 regSetConfFile
$_confFile
1043 ########################################################################
1048 proc confErrorDialog
{top
message} {
1049 tk_messageBox -default ok
-icon error -parent $top -type ok
\
1050 -title {idn wrapper Configuration Error
} -message $message
1055 expr {[string compare
$tcl_platform(platform
) "windows"] == 0}
1058 ########################################################################
1060 # config program start here
1063 wm title .
"idn wrapper - Configuration"
1064 wm iconname .
"idn wrapper - Configuration"
1067 label .title
-bd 1 -relief raised
-pady 5 \
1068 -text "idn wrapper Configuration Program version $version"
1070 frame .left
-bd 1 -relief raised
1071 frame .right
-bd 1 -relief raised
1074 label .lst.title
-text "Wrapped Programs" -pady 3
1075 listbox .lst.
list -width 64 -height 16 -setgrid 1 \
1076 -xscrollcommand ".lst.xscroll set" \
1077 -yscrollcommand ".lst.yscroll set"
1078 scrollbar .lst.yscroll
-orient vertical
-command ".lst.list yview"
1079 scrollbar .lst.xscroll
-orient horizontal
-command ".lst.list xview"
1080 grid .lst.title
-row 0 -column 0 -columnspan 2 -sticky news
1081 grid .lst.
list -row 1 -column 0 -sticky news
1082 grid .lst.xscroll
-row 2 -column 0 -sticky news
1083 grid .lst.yscroll
-row 1 -column 1 -sticky news
1084 grid rowconfig .lst
1 -weight 1
1085 grid columnconfig .lst
0 -weight 1
1088 button .btn.wrap
-text "Wrap.." -command [list confWrap . .lst.
list]
1089 button .btn.unwrap
-text "Unwrap.." -command [list confUnwrap . .lst.
list]
1090 button .btn.unwrapall
-text "Unwrap All" -command [list unwrapAll . .lst.
list]
1091 button .btn.rewrapall
-text "Rewrap All" -command [list rewrapAll . .lst.
list]
1092 frame .btn.spacing1
-width 1 -height 12 -bd 0
1093 button .btn.log
-text "Log.." -command [list confLog .
]
1094 frame .btn.spacing2
-width 1 -height 12 -bd 0
1095 button .btn.adv
-text "Advanced.." -command [list advancedConf .
]
1096 button .btn.
exit -text Exit
-command exit
1097 pack .btn.wrap
-side top
-fill x
-pady 4
1098 pack .btn.unwrap
-side top
-fill x
-pady 4
1099 pack .btn.unwrapall
-side top
-fill x
-pady 4
1100 pack .btn.rewrapall
-side top
-fill x
-pady 4
1101 pack .btn.spacing1
-side top
1102 pack .btn.log
-side top
-fill x
-pady 4
1103 pack .btn.spacing2
-side top
1104 pack .btn.adv
-side top
-fill x
-pady 4
1105 pack .btn.
exit -side bottom
-fill x
-pady 4
1107 pack .lst
-in .left
-padx 4 -pady 4 -fill both
-expand on
1108 pack .btn
-in .right
-padx 6 -pady 4 -fill both
-expand on
1110 pack .title
-side top
-fill x
1111 pack .right
-side right
-fill y
1112 pack .left
-side left
-fill y
-expand on
1115 # then set current list into listbox
1118 set theList
[loadList
]
1120 putList .lst.
list $theList
1123 ########################################################################