# Description: A window for viewing/modifying the notify list and users currently online lappend menu(extras) command "Notify List" [namespace current]::NotifyWindow procs command_nlist proc command_nlist {window line} { set line [string trim $line] if {$line == "hide" || $line == "close"} { catch {destroy .notify} return } [namespace qualifiers [namespace origin command_nlist]]::NotifyWindow } proc NotifyWindow {} { if {[winfo exists .notify]} { wm deiconify .notify raise .notify return } global notify prefs toplevel .notify wm title .notify "RoxIRC Notify List" wm iconname .notify "Notify List \[RoxIRC\]" frame .notify.bottom -bd [.notify cget -bd] -relief raised ScrolledListbox .notify.top 1 1 -font fixed entry .notify.bottom.entry -width 10 -highlightthickness 0 -font $prefs(font,menu) label .notify.bottom.label -text "Add:" -font $prefs(font,menu) button .notify.bottom.delete -text Remove -command "[namespace current]::DoNotifyWindow remove" pack .notify.bottom -side bottom -fill x -ipadx 4 -ipady 3 pack .notify.bottom.label -side left -padx 5 pack .notify.bottom.entry -side left pack .notify.bottom.delete -side right -padx 4 pack .notify.top -side top -fill both -expand 1 bind .notify.top.list "[namespace current]::DoNotifyWindow double" bind .notify.bottom.entry "[namespace current]::DoNotifyWindow add" bind .notify "destroy .notify" DoNotifyWindow refresh wm withdraw .notify update idletasks wm geometry .notify [expr {round([winfo width .0] * .700)}]x[expr {round([winfo height .0] * .700)}] wm deiconify .notify } proc DoNotifyWindow {cmd} { if {![winfo exists .notify]} {return} switch -exact -- $cmd { refresh { global notify prefs .notify.top.list delete 0 end set l1 0 foreach x $notify(+online) { if {[string length $x] > $l1} {set l1 [string length $x]} } .notify.top.list insert end " Online:" .notify.top.list itemconfigure end -bg [.notify.bottom cget -bg] -selectbackground [.notify.bottom cget -bg] -selectforeground [.notify.top.list cget -fg] foreach x [lsort -dictionary $notify(+online)] { if {[info exists notify([string tolower $x])]} { set addr "([lindex [split [lindex $notify([string tolower $x]) 0] !] 1])" set time [clock format [lindex $notify([string tolower $x]) 1] -format "%R" -gmt $prefs(gmt)] } else { set addr "" set time [clock format [clock seconds] -format "%R" -gmt $prefs(gmt)] } .notify.top.list insert end [format " %s %-${l1}s %s" \[$time\] $x $addr] } .notify.top.list insert end "" " Offline:" .notify.top.list itemconfigure end -bg [.notify.bottom cget -bg] -selectbackground [.notify.bottom cget -bg] -selectforeground [.notify.top.list cget -fg] foreach x [lsort -dictionary $prefs(notify)] { if {[lsearch -exact [string tolower $notify(+online)] [string tolower $x]] == "-1"} { #.notify.top.list insert end " \[--:--\] $x" .notify.top.list insert end " $x" } } } add { if {[set nick [.notify.bottom.entry get]] == ""} {return} .notify.bottom.entry delete 0 end command_notify .0 $nick } remove { if {[set tmp [.notify.top.list curselection]] == ""} {return} set nick [rele [split [.notify.top.list get $tmp]]] if {[llength $nick] > 1} {set nick [list [lindex $nick 1]]} set nick [lindex $nick 0] if {[string match "*line:" $nick]} {return} command_notify .0 -$nick } double { if {[set tmp [.notify.top.list curselection]] == ""} {return} set nick [rele [split [.notify.top.list get $tmp]]] if {[llength $nick] > 1} {set nick [list [lindex $nick 1]]} set nick [lindex $nick 0] if {[string match "*line:" $nick]} {return} command_query .0 $nick } } } proc unload {} { trace remove variable notify {write unset} [list after idle [namespace current]::refresh] trace remove variable prefs(notify) {write unset} [list after idle [namespace current]::refresh] catch {destroy .notify} foreach x [winfo children .] { catch {$x.menubar.window.menu.0 delete "Notify List"} } } proc help {window line} { Echo $window {[ help ] Usage: /nlist [hide|close]} {help default} } proc refresh {args} {DoNotifyWindow refresh} trace add variable notify {write unset} [list after idle [namespace current]::refresh] trace add variable prefs(notify) {write unset} [list after idle [namespace current]::refresh]