# Description: Adds minimize to systray in Windows package require roxirc 2.0 if {$tcl_platform(platform) != "windows"} { Echo .0 "the systray script is only supported on Windows" {info default} return } set winico [glob -nocomplain [file join [file dirname $::argv0] winico*.dll]] if {$winico != ""} {uplevel #0 [list load [lindex $winico 0]]} if {![catch {package present winico}]} { error "Please download Winico from http://sourceforge.net/projects/tktable/ and place the dll in your RoxIRC directory" } AddToPrefs mintotray [list bool cmd [namespace current]::menu] 0 lappend menu(extras) checkbutton "Minimize to systray" [namespace current]::tosystray [list [namespace current]::menu menu] set tosystray $prefs(mintotray) set icon [winico load TK roxirc.exe] winico taskbar add $icon -pos 5 -callback [list [namespace current]::callback %m %x %y] proc command_systray {args} { variable text variable icons variable curicon switch -- [lindex $args 0] { icon { if {[llength $args] < 2} { return [linsert 0 [winico info $curicon] -file] } if {[string match *.ico [lindex $args 1]]} { if {![info exists icons([lindex $args 1])]} { set tmp } else { } winico taskbar delete $curicon winico taskbar add $icons([lindex $args 1]) -text $text } else { if {[info exists icons([lindex $args 2],[lindex $args 1])]} { } else { } } } text { if {[llength $args] < 2} { return [winico taskbar get $curicon -text ] } else { winico taskbar modify $curicon -text [lindex $args 1] } } show { } hide { } } } proc minimize {w} { variable tosystray if {$w == "." && $tosystray} { wm withdraw . } } proc menu {args} { global prefs variable tosystray if {$args == "menu"} { set prefs(mintotray) $tosystray } else { set tosystray [lindex $args 1] } } proc callback {mes x y} { switch -- $mes { WM_LBUTTONDBLCLK { wm deiconify . raise . } WM_RBUTTONUP { .0.menubar.window.menu post $x $y } } } proc update_tooltip {} { global me server away variable icon if {$server == "-"} { winico taskbar modify $icon -text "RoxIRC - not connected" } else { winico taskbar modify $icon -text "RoxIRC - $me on $server[expr {$away ? " (away)" : ""}]" } } proc unload {} { variable icon winico taskbar delete $icon RemoveFromPrefs mintotray unbind . [namespace current]::minimize unbind . <> "[namespace current]::tooltip %W" } proc help {window line} { Echo $window {[ help ] Variables added by this script: MINTOTRAY} } update_tooltip bind . <> +[namespace current]::update_tooltip after 500 [list bind . +[namespace current]::minimize %W]