/usr/share/amsn/pluginslog.tcl is in amsn-data 0.98.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | ::Version::setSubversionId {$Id: pluginslog.tcl 8550 2007-05-06 13:13:47Z tomhennigan $}
namespace eval ::pluginslog {
#counter: keeps the count
variable idx -1
#log: this is what keeps track of the log
variable log
#filter: this is the filters
variable filters [list]
#window: the name of window
variable window ".plugins_log"
#followtext: follow text?
variable followtext 1
proc plugins_log {plugin msg} {
variable window
variable idx
variable log
#ensure msg ends in a newline
if { [string index $msg end] != "\n" } {
set msg "$msg\n"
}
incr idx
if { $idx > 499 } {
set idx 0
}
set log($idx) [list $plugin [timestamp] $msg]
if {"[wm state $window]" == "normal"} {
::pluginslog::display
}
}
proc toggle {} {
variable window
if {"[wm state $window]" == "normal"} {
wm state $window withdrawn
} else {
wm state $window normal
::pluginslog::redisplay
raise $window
}
}
proc display {} {
variable idx
variable log
variable window
variable filters
variable followtext
set plugin [lindex $log($idx) 0]
#if no filters, show all
#if in filter, show it.
if {[llength $filters] == 0 || [lsearch $filters $plugin] != -1} {
$window.info insert end "[lindex $log($idx) 1] $plugin: [lindex $log($idx) 2]"
#If option "scroll down when new text is entered"
if {$followtext} {
catch {$window.info yview end}
}
}
}
proc redisplay {} {
variable idx
variable log
variable window
variable filters
set arraysize [array size log]
if { $arraysize == 500 } {
set startpos $idx
} else {
set startpos 0
}
$window.info delete 1.0 end
for {set count 0} {$count < $arraysize} {incr count} {
set x [expr {($count + $startpos)%500}]
set plugin [lindex $log($x) 0]
#if no filters, show all
#if in filter, show it.
if {[llength $filters] == 0 || [lsearch $filters $plugin] != -1} {
$window.info insert end "[lindex $log($x) 1] $plugin: [lindex $log($x) 2]"
}
}
catch {$window.info yview end}
}
proc filter {plugin} {
variable filters
set idx [lsearch $filters $plugin]
if {$idx == -1} {
lappend filters $plugin
} else {
set filters [lreplace $filters $idx $idx]
}
}
proc show_filters {} {
variable window
if {[winfo exists $window.filters] == 1} {
raise $window.filters
return
}
toplevel $window.filters
wm title $window.filters "Plugins Log - [trans filtersx]"
# yes, I am really lazy...
set w $window.filters
label $w.msg -text [trans filtersselect]
grid $w.msg -column 1 -row 1 -columnspan 2
set tmplist [linsert $::plugins::loadedplugins 0 "core"]
set s [llength $tmplist]
set col 1
set row 2
for {set x 0} {$x<$s} {incr x} {
checkbutton $w.check$x -text [lindex $tmplist $x] -command "::pluginslog::filter \"[lindex $tmplist $x]\" ; ::pluginslog::redisplay"
grid $w.check$x -column $col -row $row -sticky w
if {$col == 2} {
set col 1
incr row
} else {
incr col
}
}
incr row
button $w.update -text "[trans close]" -command "destroy $w" ;# "::pluginslog::redisplay"
grid $w.update -columnspan 2 -row $row -column 1
bind $w <Destroy> ;#"::pluginslog::redisplay; bind $w <Destroy> \"\""
moveinscreen $w 30
}
proc draw {} {
variable window
if { [winfo exists $window] } {return}
toplevel $window
wm group $window .
wm state $window withdrawn
wm title $window "Plugins Log - [trans title]"
text $window.info -background white -width 60 -height 30 -wrap word \
-yscrollcommand "$window.ys set"
# -font splainf
scrollbar $window.ys -command "$window.info yview"
checkbutton $window.follow -text "[trans followtext]" -onvalue 1 -offvalue 0 -variable {::pluginslog::followtext}
# -font sboldf
frame $window.bot -relief sunken -borderwidth 1
button $window.bot.filters -text "[trans filters]" -command ::pluginslog::show_filters
button $window.bot.save -text "[trans savetofile]" -command ::pluginslog::save
button $window.bot.clear -text "[trans clear]" -command "$window.info delete 0.0 end"
button $window.bot.close -text "[trans close]" -command {::pluginslog::toggle}
pack $window.bot.filters $window.bot.save $window.bot.close $window.bot.clear -side left
pack $window.bot $window.follow -side bottom
pack $window.ys -side right -fill y
pack $window.info -expand true -fill both
$window.info tag configure green -foreground darkgreen
$window.info tag configure red -foreground red
$window.info tag configure white -foreground white -background black
$window.info tag configure blue -foreground blue
$window.info tag configure error -foreground white -background black
set modifier [GetPlatformModifier]
bind $window <$modifier-w> ::pluginslog::toggle
wm protocol $window WM_DELETE_WINDOW { ::pluginslog::toggle }
}
proc save {} {
set w .filters_save
toplevel $w
wm title $w \"[trans savetofile]\"
label $w.msg -justify center -text "Please give a filename"
pack $w.msg -side top
frame $w.buttons -class Degt
pack $w.buttons -side bottom -fill x -pady 2m
button $w.buttons.dismiss -text Cancel -command "destroy $w"
button $w.buttons.save -text Save -command "::pluginslog::save_file $w.filename.entry; destroy $w"
pack $w.buttons.save $w.buttons.dismiss -side left -expand 1
frame $w.filename -bd 2 -class Degt
entry $w.filename.entry -relief sunken -width 40
label $w.filename.label -text "Filename:"
pack $w.filename.entry -side right
pack $w.filename.label -side left
pack $w.msg $w.filename -side top -fill x
focus $w.filename.entry
chooseFileDialog "plugins_log.txt" "" $w $w.filename.entry save
catch {grab $w}
}
proc save_file { filename } {
variable window
set fd [open [${filename} get] a+]
fconfigure $fd -encoding utf-8
puts $fd "[$window.info get 0.0 end]"
close $fd
}
}
if { $initialize_amsn == 1 } {
::pluginslog::draw
}
|