From 708d94d514ccfd246944d2d2c4929947321a6ee5 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 10 Mar 2020 15:10:17 +0000 Subject: [PATCH] applet: Introduce applet::become Rather than doing this when applet.tcl is source, which was weird and troublesome. Signed-off-by: Ian Jackson --- applet.tcl | 15 ++++++++------- example | 2 ++ xbatmon-simple-tray | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/applet.tcl b/applet.tcl index 871cf97..5e300ab 100644 --- a/applet.tcl +++ b/applet.tcl @@ -68,16 +68,17 @@ package require tktray # # This also uses the same variables as setup-subwindow. -wm withdraw . - -tktray::icon .i -class example -.i configure -docked 1 +namespace eval applet { -fconfigure stdout -buffering none -fconfigure stderr -buffering none +proc become {} { + wm withdraw . + tktray::icon .i -class example + .i configure -docked 1 -namespace eval applet { + fconfigure stdout -buffering none + fconfigure stderr -buffering none +} # used by both menus and tooltips variable posted 0 diff --git a/example b/example index 7cf6b15..70e74cb 100755 --- a/example +++ b/example @@ -20,6 +20,8 @@ source $lib/applet.tcl source $lib/subproc.tcl source $lib/utils.tcl +applet::become + set debug::debug puts foreach b {1 3} { diff --git a/xbatmon-simple-tray b/xbatmon-simple-tray index 72ed960..292f415 100755 --- a/xbatmon-simple-tray +++ b/xbatmon-simple-tray @@ -14,6 +14,7 @@ set lib . source $lib/subproc.tcl source $lib/utils.tcl source $lib/args.tcl +source $lib/applet.tcl proc cmdline {id orientation} { global argv @@ -201,7 +202,7 @@ proc tt-info {chan} { #----- modes ----- proc mode/normal {} { - uplevel #0 { source $lib/applet.tcl } + uplevel #0 { applet::become } applet::setup-subproc cmdline applet::setup-tooltip tt-show tt-invisible } -- 2.30.2