chiark / gitweb /
rationalise borders, comments, etc
[chiark-tcl-applet.git] / applet.tcl
index a83ab841c8234c0c6197ad9b967a79d3e745255b..66d1a81251e26ae700dc02f056bacd57d5fe2b93 100644 (file)
@@ -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 { }