From 37338efc873355a4ba7ec6994283e75a1fc1d7c3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 9 Jun 2012 21:16:54 +0100 Subject: [PATCH] rationalise borders, comments, etc --- applet.tcl | 45 ++++++++++++++++++++++----------------------- example | 2 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/applet.tcl b/applet.tcl index a83ab84..66d1a81 100644 --- a/applet.tcl +++ b/applet.tcl @@ -47,29 +47,24 @@ package require tktray # applet::setimage IMAGE # as necessary. # -# Alternatively, instead of icon, it may make other arrangements -# to use the provided subwindow -# -# Caller that needs access to inner window should call -# applet::setup-subwindow WIDTH ON-DESTROYING ON-READY +# Alternatively of icon, it may provide other arrangements for +# using the provided subwindow. Such a caller should call +# applet::setup-subwindow WIDTH BORDER-COLOUR BORDER-WIDTH \ +# ON-DESTROYING ON-READY # Then the main code will call ON-DESTROYING just before # destroying the inner window and recreating it, and ON-READY -# just after. In ON-READY the inner window is called .i.i. +# just after. The inner window to use is called .i.i.b. # # The user of the subwindow machinery may call # applet::subwindow-need-recreate # if for any reason the inner window should be destroyed and recreated. # -# Alternatively, -# to run (repeatedly -# if necessary) a subprocess. -# -# proc innerwindow {} { ... } -# and run -# innerwindow -# This will create -# .i.i.b frame to contain container -# .i.i.b.c actual container +# Alternatively, it may request that a subprocess be spawned +# repeatedly with the xid of a suitable window. +# applet::setup-subproc WIDTH BORDER-COLOUR BORDER-WIDTH \ +# GET-CMDLINE +# Then the main code will call [concat GET_CMDLINE [list XID]] +# to get the command line to run. wm withdraw . @@ -206,6 +201,8 @@ proc innerwindow-resetup {} { variable innerwindow_after variable subwindow_on_destroying variable subwindow_on_ready + variable subwindow_border_colour + variable subwindow_border_width unset innerwindow_after puts RESETUP @@ -215,8 +212,6 @@ puts RESETUP destroy [frame .i.i.make-exist] uplevel #0 $subwindow_on_destroying - catch { destroy .i.i.b.c } - catch { destroy .i.i.b } frame .i.i.b -background darkblue -bd 1 @@ -236,9 +231,9 @@ puts RESETUP # } } -proc setup-subwindow {w on_destroying on_ready} { - foreach v {destroying ready} { - variable subwindow_on_$v [set on_$v] +proc setup-subwindow {w border_colour border_width on_destroying on_ready} { + foreach v {border_width border_colour on_destroying on_ready} { + variable subwindow_$v [set $v] } global inner_lastw inner_lasth @@ -260,14 +255,18 @@ proc setup-subwindow {w on_destroying on_ready} { variable subproc none variable ratelimit {} -proc setup-subproc {w get_cmdline} { +proc setup-subproc {w border_colour border_width get_cmdline} { variable subproc_get_cmdline $get_cmdline - setup-subwindow $w applet::subproc-destroying applet::subproc-ready + setup-subwindow $w $border_colour $border_width \ + applet::subproc-destroying applet::subproc-ready } proc subproc-destroying {} { variable subproc puts "DESTROYING $subproc" + + catch { destroy .i.i.b.c } + switch -exact $subproc { none { } old { } diff --git a/example b/example index b9f1c64..4edb404 100755 --- a/example +++ b/example @@ -25,4 +25,4 @@ proc cmdline {id} { return [list xacpi-simple -into $id] } -applet::setup-subproc 40 cmdline +applet::setup-subproc 40 darkblue 1 cmdline -- 2.30.2