#!/usr/bin/wish -f # nEaze 1999/2/xx # nampa2@geocities.co.jp http://www.geocities.co.jp/SiliconValley/1577/ proc lb num { global cnum calist collist maxBtn lock if {$lock == "true"} { return } set cnum $num for {set i 0} {$i < [llength $calist($num)]} {incr i 1} { set cmd "exec " append cmd [lindex [lindex $calist($num) $i] 1] append cmd " &" .nEaze.app$i configure -image a($num,$i) -background [lindex $collist $num] -command $cmd } for {set i $i} {$i < $maxBtn} {incr i 1} { .nEaze.app$i configure -background [lindex $collist $num] -image empty -command "" } } # ボタンの役割を変更する proc btnProp {num} { global cnum calist btnNum lock homeDir # ロック設定 set lock "true" set btnNum $num set alist [lindex $calist($cnum) $num] set iname [lindex $alist 0] set cmd [lindex $alist 1] set new_iname "" set new_cmd "" toplevel .aprop # フレームの準備 frame .aprop.top frame .aprop.icon_fr -relief groove -borderwidth 3 frame .aprop.cmd_fr frame .aprop.btn_fr label .aprop.icon_lb -text "アイコン" label .aprop.icon_img -image a($cnum,$num) -width 64 -height 64 -relief ridge label .aprop.cmd_lb -text "コマンド" entry .aprop.icon_name -width 20 -relief sunken -textvariable new_iname entry .aprop.cmd -width 20 -relief sunken -textvariable new_cmd # OKボタンの準備 button .aprop.ok -text OK -command { global btnNum lock set label OK set new_alist [list $new_iname $new_cmd] #puts $new_alist #変更を実行 if {$btnNum < [llength $calist($cnum)]} { # 現在機能しているボタンの変更 if {[string length $new_iname]==0} { # 削除 set calist($cnum) [lreplace $calist($cnum) $btnNum $btnNum] } else { # 変更 set calist($cnum) [lreplace $calist($cnum) $btnNum $btnNum $new_alist] } } else { if {[string length $new_iname]==0} { # ただOKボタン押しただけ ->変更無し set lock "false" destroy .aprop } else { # 追加 lappend calist($cnum) $new_alist } } #puts $calist($cnum) # アイコンのデータの更新 updateIcon lb $cnum # 設定の保存 saveProp set lock "false" destroy .aprop } # 消去 button .aprop.del -text Delete -command { .aprop.icon_name delete 0 [string length [.aprop.icon_name get]] .aprop.cmd delete 0 [string length [.aprop.cmd get]] } # キャンセルボタンの準備 button .aprop.cancel -text Cancel -command { set label Cancel destroy .aprop.icon_name .aprop.cmd .aprop } pack .aprop.top pack .aprop.icon_fr # アイコンファイル名リスト listbox .aprop.icons -yscrollcommand ".aprop.icons_scr set" pack .aprop.icons -side left -in .aprop.icon_fr scrollbar .aprop.icons_scr -command ".aprop.icons yview" pack .aprop.icons_scr -side left -fill y -in .aprop.icon_fr set dir "$homeDir/.neaze/icons/" cd $dir foreach i [lsort [glob *.gif]] { set str $i .aprop.icons insert end $str } cd bind .aprop.icons { global homeDir set str [selection get] # アイコン名の変更 .aprop.icon_name delete 0 [string length [.aprop.icon_name get]] .aprop.icon_name insert 0 $str # アイコンイメージの変更 set name "$homeDir/.neaze/icons/" append name $str image create photo tmp_img -file $name .aprop.icon_img configure -image tmp_img } pack .aprop.cmd_fr -side top pack .aprop.btn_fr -side bottom pack .aprop.icon_lb -in .aprop.icon_fr -side left pack .aprop.icon_name -in .aprop.icon_fr -side left pack .aprop.icon_img -in .aprop.icon_fr -side right pack .aprop.cmd_lb -side left pack .aprop.cmd -side left pack .aprop.ok -side left -in .aprop.btn_fr pack .aprop.del -side left -in .aprop.btn_fr pack .aprop.cancel -side right -in .aprop.btn_fr #grab set .aprop .aprop.icon_name delete 0 [string length [.aprop.icon_name get]] .aprop.cmd delete 0 [string length [.aprop.cmd get]] .aprop.icon_name insert 0 $iname .aprop.cmd insert 0 $cmd tkwait window .aprop set lock "false" } proc updateIcon {} { global cnum calist homeDir set j 0 foreach i $calist($cnum) { set icn "$homeDir/.neaze/icons/" append icn [lindex $i 0] image create photo a($cnum,$j) -file $icn incr j } for {set j $j} {$j <=5} {incr j} { set icn "$homeDir/.neaze/icons/ND.gif" image create photo a($cnum,$j) -file $icn } } # 表示場所の保存 proc saveProp_geom {} { global f puts $f "#Geometry" puts $f [wm geometry .] } # カテゴリタブ設定情報の保存 proc saveProp_catego {} { global f categName collist set tmp_list "" puts $f "#Categoly" for {set j 0} {$j < [llength $categName]} {incr j} { lappend tmp_list [lindex $categName $j] lappend tmp_list [lindex $collist $j] } puts $f $tmp_list } # ボタン設定情報の保存 proc saveProp_btn {} { global calist f categName puts $f "#Button" for {set i 0} {$i < [llength $categName]} {incr i} { puts $f [join $calist($i)] } } # 設定情報の保存 proc saveProp {} { global calist categName f fPropName set f [open $fPropName w] saveProp_catego saveProp_btn saveProp_geom flush $f close $f } # 表示場所の読み込み proc loadProp_geom {} { global f gets $f line #puts $line set curGeom [split $line +] set movX [lindex $curGeom 1] set movY [lindex $curGeom 2] wm geometry . +${movX}+${movY} } # ボタン設定情報の読み込み proc loadProp_btn {} { global calist f set i 0 while {[gets $f line] >= 0} { if {$line == "#Geometry"} { loadProp_geom return } set calist($i) "" for {set j 0} {$j < [llength $line]} {incr j 2} { set tmp_list "" lappend tmp_list [lindex $line $j] lappend tmp_list [lindex $line [expr $j+1]] #puts $tmp_list lappend calist($i) $tmp_list } #puts $calist($i) incr i } } # カテゴリ設定読み込み proc loadProp_catego {} { global f categName collist set categName "" set collist "" while {[gets $f line] >= 0} { if {$line == "#Button"} { loadProp_btn return } for {set j 0} {$j < [llength $line]} {incr j 2} { lappend categName [lindex $line $j] lappend collist [lindex $line [expr $j+1]] } #puts $categName } } # 設定情報の読み込み proc loadProp {} { global calist f line fPropName set f [open $fPropName r] while {[gets $f line] >= 0} { if {$line == "#Categoly"} { loadProp_catego } } close $f } # 定数の定義 # 設定ファイル名 set homeDir $env(HOME) set fPropName "$homeDir/.neaze/neazerc" # ボタンの数 set maxBtn 8 # カテゴリ名 set categName {"Application" "Sound" "Graphics" "Extra"} # 各カテゴリの配色 set collist {LightSkyBlue LightGreen LightYellow Pink} set calist(0) {{hjb.gif hotjava} {rvplayer.rvplayer.gif rvplayer} {xv.gif xv} {paint.gif gimp} {Mathematica.gif mathematica} {CAD.gif tgif}} set calist(1) {{x11amp.gif gqmpeg} {xmcd.gif xmcd} {Palette.Rosegarden.gif rosegarden}} set calist(2) {{TV.gif xawtv}} # 設定の読み込み loadProp # 現在のカテゴリー番号 set cnum 0 # 準備 image create photo appIcon0 -file $env(HOME)/.neaze/icons/ND.gif image create photo empty -file $env(HOME)/.neaze/icons/ND.gif #枠組の作成 frame .nEaze pack .nEaze # 持つところを作る frame .nEaze.bar_fr pack .nEaze.bar_fr -side left -in .nEaze -fill y # 手前へボタン #label .nEaze.barRaiseBtn -width 1 -height 1 -relief raise -borderwidth 1 #pack .nEaze.barRaiseBtn -side top -in .nEaze.bar_fr # 奥へボタン label .nEaze.barLowBtn -width 1 -relief ridge -borderwidth 3 pack .nEaze.barLowBtn -side top -in .nEaze.bar_fr # 動かすとこ label .nEaze.bar -width 1 -height 3 -relief ridge -borderwidth 2 -background gray50 pack .nEaze.bar -side left -fill y -in .nEaze.bar_fr #bind .nEaze.barRaiseBtn <1> { # raise . #} bind .nEaze.barLowBtn { lower . } bind .nEaze.bar <1> { global startX startY set startX %x set startY %y } bind .nEaze.bar { global startX startY set curX %x set curY %y set curGeom [split [wm geometry .] +] set movX [lindex $curGeom 1] set movY [lindex $curGeom 2] set movX [expr $movX+($curX-$startX)] set movY [expr $movY+($curY-$startY)] wm geometry . +${movX}+${movY} # ウインドウを手前にもってくる raise . # 設定を保存 saveProp } bind .nEaze.bar { global oldX oldY set curX %x set curY %y set curGeom [split [wm geometry .] +] set movX [lindex $curGeom 1] set movY [lindex $curGeom 2] set movX [expr $movX+($curX-$startX)] set movY [expr $movY+($curY-$startY)] wm geometry . +${movX}+${movY} set oldX $curX set oldY $curY } frame .nEaze.tab #frame .base -relief groove -borderwidth 4 frame .nEaze.base wm overrideredirect . true pack .nEaze.tab -side top -anchor w -fill x pack .nEaze.base -side bottom # カテゴリタブの準備と作成 set j 0 foreach i $categName { set cmd "lb " append cmd $j button .nEaze.appLb$j -text $i -command $cmd -background [lindex $collist $j] -font *-*-medium-r-normal--*-80-*-*-*-*-*-* -borderwidth 1 pack .nEaze.appLb$j -in .nEaze.tab -side left bind .nEaze.appLb$j $cmd incr j } # Quitボタン label .nEaze.barQuitBtn -width 1 -height 1 -relief raise -borderwidth 1 -font *-*-medium-r-normal--*-80-*-*-*-*-*-* -text X pack .nEaze.barQuitBtn -side right -in .nEaze.tab bind .nEaze.barQuitBtn <1> { exit } # ボタンイメージの準備 for {set k 0} {$k < [llength $categName]} {incr k} { set j 0 foreach i $calist($k) { set icn "$env(HOME)/.neaze/icons/" append icn [lindex $i 0] image create photo a($k,$j) -file $icn incr j } for {set j [expr $j]} {$j < $maxBtn} {incr j} { set icn "$env(HOME)/.neaze/icons/ND.gif" image create photo a($k,$j) -file $icn } } # ボタンの準備と作成 for {set i 0} {$i < $maxBtn} {incr i} { button .nEaze.app$i -width 64 -height 64 pack .nEaze.app$i -in .nEaze.base -side left # 右クリックされたらプロパティの設定を呼ぶ set cmd "btnProp " append cmd $i bind .nEaze.app$i $cmd } set lock false lb $cnum # とりあえず控え目に。。。 lower .