# Description: displays a window with a list of other roxirc windows to keep track of open windows and activity procs command_winlist _destroy proc command_winlist {window line} { [namespace qualifiers [namespace origin command_winlist]]::create } proc destroy {win args} { if {$win == ".winlist"} { wm withdraw .winlist after cancel [namespace qualifiers [namespace origin destroy]]::titlepoll return } [namespace qualifiers [namespace origin destroy]]::removewin $win _destroy $win foreach x $args {destroy $x} } proc create {} { if {[winfo exists .winlist]} { after cancel [namespace current]::titlepoll titlepoll set oldfocus [focus] wm deiconify .winlist update if {$oldfocus != ""} {focus $oldfocus} return } set oldfocus [focus] toplevel .winlist wm protocol .winlist WM_DELETE_WINDOW {destroy .winlist} wm title .winlist {RoxIRC Window List} wm iconname .winlist {Windows [RoxIRC]} frame .winlist.frame -relief sunken -borderwidth 1 pack .winlist.frame -fill both -expand 1 -padx 5 -pady 5 -ipadx 5 -ipady 5 bind all <> "+[namespace current]::addwin %W" bind all <> "+[namespace current]::addwin %W" bind all <> "+[namespace current]::addwin %W" bind all <> "+[namespace current]::hilight %W" after 500 [namespace current]::titlepoll update if {$oldfocus != ""} {focus $oldfocus} foreach win [winfo children .] { if {$win != ".winlist" && [wm title $win] != ""} {addwin $win} } } proc addwin {win} { global prefs options winlist button .winlist.frame$win -text [getwinname $win] -command "[namespace current]::click $win" -borderwidth 1 -font $prefs(font,menu) menu .winlist.frame${win}.menu -tearoff 0 -borderwidth 1 -font $prefs(font,menu) .winlist.frame${win}.menu add command -label "Iconify" -command ".winlist.frame$win configure -foreground black -activeforeground black; wm iconify $win" .winlist.frame${win}.menu add command -label "Hide" -command ".winlist.frame$win configure -foreground black -activeforeground black; wm withdraw $win" .winlist.frame${win}.menu add separator .winlist.frame${win}.menu add checkbutton -label "Hilight" -variable winlist(opt,h,$win) set winlist(opt,h,$win) 1 .winlist.frame${win}.menu add checkbutton -label "Hilight Text Only" -variable winlist(opt,t,$win) .winlist.frame${win}.menu add checkbutton -label "Popup" -variable options(popup,$win) .winlist.frame${win}.menu add separator .winlist.frame${win}.menu add command -label "Close" -command "[namespace current]::closewin $win" bind .winlist.frame$win "tk_popup .winlist.frame${win}.menu %X %Y" bind .winlist.frame$win "wm iconify $win ; break" pack .winlist.frame$win -fill x -padx 2 -pady 2 wm protocol $win WM_TAKE_FOCUS "[wm protocol $win WM_TAKE_FOCUS];.winlist.frame$win configure -foreground black -activeforeground black" } proc removewin {win} { catch {destroy .winlist.frame$win} } proc closewin {win} { if {[wm protocol $win WM_DELETE_WINDOW] != ""} { eval [wm protocol $win WM_DELETE_WINDOW] } else { destroy $win } } proc hilight {win} { global winlist info set win [winfo toplevel $win] if {[focus] != "" && [winfo toplevel [focus]] == $win} {return} if {$winlist(opt,t,$win)} { set char [$info(text,$win) get end-2c] if {$char == {[} || $char == {(}} {return} } if {$winlist(opt,h,$win)} { if {[string match *hilight* [$info(text,$win) tag names end-2c]]} { .winlist.frame$win configure -foreground yellow -activeforeground yellow } elseif {[.winlist.frame$win cget -foreground] != "yellow"} { .winlist.frame$win configure -foreground red -activeforeground red } } } proc click {win} { if {[wm state $win] != "normal"} { wm geometry $win [winfo geometry $win] wm deiconify $win } raise $win if {[winfo exists $win.cmdline]} { focus $win.cmdline } else { focus $win } .winlist.frame$win configure -foreground black -activeforeground black } proc getwinname {win} { set name [lrange [split [wm title $win]] 1 end] if {$win == ".0"} { return $name } elseif {[string match {.[1-9]*} $win]} { return "Channel [lindex [split $name] 0]" } elseif {[string match ".q*" $win]} { return "Query [lindex [split [lindex [split $name] 1] !] 0]" } else { return $name } } proc titlepoll {} { if {![winfo exists .winlist]} {return} foreach x [winfo children .] { if {$x == ".winlist" || ![winfo exists .winlist.frame$x]} {continue} .winlist.frame$x configure -text [getwinname $x] if {[focus] != "" && [winfo toplevel [focus]] == $x} { .winlist.frame$x configure -foreground black -activeforeground black } } after 3000 [namespace current]::titlepoll } proc unload {} { global winlist unbind all <> "[namespace current]::addwin %W" unbind all <> "[namespace current]::addwin %W" unbind all <> "[namespace current]::addwin %W" unbind all <> "[namespace current]::hilight %W" after cancel [namespace current]::titlepoll foreach win [winfo children .] { if {[set i [lsearch -glob [split [wm protocol $win WM_TAKE_FOCUS] \;] .winlist*]] != -1} { wm protocol $win WM_TAKE_FOCUS [join [lreplace [split [wm protocol $win WM_TAKE_FOCUS] \;] $i $i] \;] } } unset winlist _destroy .winlist rename ::destroy {} rename ::_destroy ::destroy } proc help {window line} { Echo $window {[ help ] Usage: /winlist} Echo $window {[ help ] Shows the window list} } startup rename ::destroy ::_destroy namespace export destroy namespace eval :: "namespace import [namespace current]::destroy" create