Code Search for Developers
 
 
  

pluginslog.tcl from aMSN at Krugle


Show pluginslog.tcl syntax highlighted


::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
}





See more files for this project here

aMSN

A very nice MSN compatible messenger application, aMSN Messenger is a multiplatform MSN messenger clone. Works pretty much like its Windows based counterpart. Perfect for keeping in touch with those friends who have not yet seen the light. Works on linux

Project homepage: http://sourceforge.net/projects/amsn
Programming language(s): C,C++,PHP,Tcl,XML
License: other

  autopackage/
    @tcl.sourceforge.net/
      tcl/
        skeleton.1
      tk/
        skeleton.1
    default.apspec
  debian/
    changelog.in
    compat
    control
    copyright
    dirs
    package.postinst
    package.postrm
    rules
  desktop-icons/
    128x128/
    16x16/
    22x22/
    32x32/
    48x48/
    64x64/
    72x72/
    96x96/
  docs/
    DOCS-HOWTO
    FAQbs
    FAQca
    FAQca_VC
    FAQde
    FAQdu
    FAQee
    FAQel
    FAQes
    FAQfr
    FAQfr.html
    FAQfr_CA
    FAQfur
    FAQhu
    FAQit
    FAQmn
    FAQnl
    FAQno
    FAQpt
    FAQpt_BR
    FAQsl
    FAQsv
    FAQtr
    HELPca
    HELPca_VC
    HELPcs
    HELPda
    HELPde
    HELPee
    HELPel
    HELPes
    HELPfr
    HELPfr_CA
    HELPfur
    HELPhu
    HELPit
    HELPmn
    HELPnl
    HELPno
    HELPpt
    HELPpt_BR
    HELPro
    HELPru
    HELPtr
    HELPzh_TW
    READMEca
    READMEca_VC
    READMEcs
    READMEda
    READMEde
    READMEes
    READMEfr
    READMEfr_CA
    READMEfur
    READMEhu
    READMEit
    READMEmn
    READMEnl
    READMEpt
    READMEpt_BR
    READMEro
    READMEru
    READMEsv
    READMEtr
    READMEzh_TW
  lang/
    LANG-HOWTO
    addkey.tcl
    complete.pl
    convert.tcl
    genlangfiles.c
    genpage.c
    lang1.tmpl
    lang2.tmpl
    lang3.tmpl
    langal
    langast
    langca
    langca_VC
    langchk.sh
    langcs
    langcy
    langda
    langde
    langee
    langel
    langen
    langes
    langeu
    langfi
    langfr
    langfr_CA
    langfri
    langglg
    langgr2
    langhu
    langid
    langis
    langit
    langko
    langlt
    langmk
    langnl
    langno
    langoc
    langpl
    langpt
    langpt_BR
    langro
    langru
    langsk
    langsl
    langsr
    langsv
    langtr
    langzh-CN
    langzh-TW
    missing.py
    sortlang
  plugins/
    Nudge/
    PowerTool/
    WebcamShooter/
    inkdraw/
    remind/
    winks/
  skins/
    default/
  utils/
    TkCximage/
    base64/
    bwidget1.8.0/
    combobox/
    contentmanager/
    dpbrowser/
    drawboard/
    framec/
    http2.4/
    linux/
    log/
    macosx/
    pixmapbutton/
    pixmapmenu/
    pixmapoption/
    pixmapprogbar/
    pixmapscroll/
    scalable-bg/
    sexytile/
    sha1/
  AGREEMENT
  AppMain.tcl
  BWidget_mods.tcl
  CREDITS
  Compile.mk
  FAQ
  GNUGPL
  HELP
  INSTALL
  Makefile.in
  README
  README.macosx
  TODO
  abook.tcl
  alarm.tcl
  amsn
  amsn-remote
  amsn-remote-CLI
  amsn.debianmenu
  amsn.desktop
  amsn.spec
  amsn_des.tcl
  amsncore.tcl
  assistant.tcl
  audio.tcl
  automsg.tcl
  autoupdate.tcl
  balloon.tcl
  bugs.tcl
  chatwindow.tcl
  clgui.tcl
  config.tcl
  configure
  configure.ac
  console.tcl
  contactlist.tcl
  ctthemes.tcl
  debug.tcl
  dock.tcl
  groups.tcl
  gui.tcl
  guicontactlist.tcl
  hotmail.tcl
  hotmlog.htm
  lang.tcl
  langlist
  login_screen.tcl
  loging.tcl
  migmd5.tcl
  msncam.tcl
  msnp2p.tcl
  mutex.tcl
  notes.tcl
  picture.tcl
  plugins.tcl
  pluginslog.tcl
  preferences.tcl
  progressbar.tcl
  protocol.tcl
  proxy.tcl
  remote.help
  remote.tcl
  searchdialog.tcl
  skins.tcl
  smileys.tcl
  soap.tcl
  socks.tcl
  spaces.tcl
  sxml.tcl
  trayicon.tcl