Posted to tcl by patthoyts at Thu May 04 21:48:51 GMT 2006view raw

  1.  
  2. # Windows taskbar support.
  3. # At some point I want to support multiple icons for nochat/chat/alert.
  4. #
  5. proc ::tkchat::WinicoInit {} {
  6. ::log::log debug "tk windowingsystem [tk windowingsystem]"
  7. if {[tk windowingsystem] eq "win32" &&
  8. ![catch {package require Winico}]} {
  9. variable TaskbarIcon
  10. variable WinicoWmState [wm state .]
  11.  
  12. set icofile [file join [file dirname [info script]] tkchat.ico]
  13. if {[file exists $icofile]} {
  14. set TaskbarIcon [winico createfrom $icofile]
  15. winico taskbar add $TaskbarIcon \
  16. -pos 0 \
  17. -text [wm title .] \
  18. -callback [list [namespace origin WinicoCallback] %m %i]
  19. bind . <Destroy> [namespace origin WinicoCleanup]
  20. }
  21. } else {
  22. proc ::tkchat::WinicoUpdate {} {return}
  23. }
  24. }
  25.  
  26. proc ::tkchat::WinicoUpdate {} {
  27. variable MessageCounter
  28. variable TaskbarIcon
  29.  
  30. if {[llength [info commands winico]] < 1} { return }
  31. if { $MessageCounter > 0 } {
  32. winico taskbar modify $TaskbarIcon \
  33. -pos 2 \
  34. -text "$MessageCounter - Tcl'ers chat"
  35. } else {
  36. winico taskbar modify $TaskbarIcon \
  37. -pos 0 \
  38. -text "Tcl'ers chat"
  39. }
  40. }
  41.  
  42. proc ::tkchat::WinicoCleanup {} {
  43. variable TaskbarIcon
  44. winico taskbar delete $TaskbarIcon
  45. }
  46.  
  47. proc ::tkchat::WinicoCallback {msg icn} {
  48. variable WinicoWmState
  49. switch -exact -- $msg {
  50. WM_LBUTTONDOWN {
  51. if { [wm state .] eq "withdrawn" } {
  52. wm state . $WinicoWmState
  53. wm deiconify .
  54. focus .eMsg
  55. } else {
  56. set WinicoWmState [wm state .]
  57. wm withdraw .
  58. }
  59. }
  60. }
  61. }
  62.