Posted to tcl by patthoyts at Thu May 04 21:48:51 GMT 2006view raw
- # Windows taskbar support.
- # At some point I want to support multiple icons for nochat/chat/alert.
- #
- proc ::tkchat::WinicoInit {} {
- ::log::log debug "tk windowingsystem [tk windowingsystem]"
- if {[tk windowingsystem] eq "win32" &&
- ![catch {package require Winico}]} {
- variable TaskbarIcon
- variable WinicoWmState [wm state .]
- set icofile [file join [file dirname [info script]] tkchat.ico]
- if {[file exists $icofile]} {
- set TaskbarIcon [winico createfrom $icofile]
- winico taskbar add $TaskbarIcon \
- -pos 0 \
- -text [wm title .] \
- -callback [list [namespace origin WinicoCallback] %m %i]
- bind . <Destroy> [namespace origin WinicoCleanup]
- }
- } else {
- proc ::tkchat::WinicoUpdate {} {return}
- }
- }
- proc ::tkchat::WinicoUpdate {} {
- variable MessageCounter
- variable TaskbarIcon
- if {[llength [info commands winico]] < 1} { return }
- if { $MessageCounter > 0 } {
- winico taskbar modify $TaskbarIcon \
- -pos 2 \
- -text "$MessageCounter - Tcl'ers chat"
- } else {
- winico taskbar modify $TaskbarIcon \
- -pos 0 \
- -text "Tcl'ers chat"
- }
- }
- proc ::tkchat::WinicoCleanup {} {
- variable TaskbarIcon
- winico taskbar delete $TaskbarIcon
- }
- proc ::tkchat::WinicoCallback {msg icn} {
- variable WinicoWmState
- switch -exact -- $msg {
- WM_LBUTTONDOWN {
- if { [wm state .] eq "withdrawn" } {
- wm state . $WinicoWmState
- wm deiconify .
- focus .eMsg
- } else {
- set WinicoWmState [wm state .]
- wm withdraw .
- }
- }
- }
- }