#
# Alternatively of icon, it may provide other arrangements for
# using the provided subwindow. Such a caller should call
-# applet::setup-subwindow \
-# WIDTH HEIGHT DEFAULT-ORIENTATION BORDER-COLOUR BORDER-WIDTH \
-# ON-DESTROYING ON-READY
+# applet::setup-subwindow ON-DESTROYING ON-READY
# Then the main code will call ON-DESTROYING just before
# destroying the inner window and recreating it, and
# [concat ON-READY [list ORIENTATION]]
# just after. The inner window to use is called .i.i.b.
#
+# This uses variables, in the applet namespace,
+# w h border_colour border_width deforient
+# These should be set before setup-subwindow is called and not
+# modified thereafter.
+#
# 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, it may request that a subprocess be spawned
# repeatedly with the xid of a suitable window.
-# applet::setup-subproc \
-# WIDTH HEIGHT DEFAULT-ORIENTATION BORDER-COLOUR BORDER-WIDTH \
-# GET-CMDLINE
+# applet::setup-subproc GET-CMDLINE
# Then the main code will call [concat GET_CMDLINE [list XID ORIENTATION]]
# to get the command line to run.
+#
+# This also uses the same variables as setup-subwindow.
wm withdraw .
variable subwindow_on_destroying
variable subwindow_on_ready
+variable w 50
+variable h 50
+variable deforient horizontal
+variable border_colour darkblue
+variable border_width 1
+
proc subwindow-need-recreate {} {
variable innerwindow_after
debug "IW-EVENT"
variable innerwindow_after
variable subwindow_on_destroying
variable subwindow_on_ready
- variable subwindow_border_colour
- variable subwindow_border_width
- variable subwindow_default_orientation
+ variable border_colour
+ variable border_width
+ variable deforient
unset innerwindow_after
debug RESETUP
set orientation [.i orientation]
debug "orientation $orientation"
if {![string compare $orientation unknown]} {
- set orientation $subwindow_default_orientation
+ set orientation $deforient
}
.i configure -image applet::innerwindow-ph-$orientation
- frame .i.i.b -background darkblue -bd 1
+ frame .i.i.b -background $border_colour -bd $border_width
pack .i.i.b -fill both -side left -expand 1
uplevel #0 $subwindow_on_ready [list $orientation]
}
-proc setup-subwindow {
- w h default_orientation border_colour border_width on_destroying on_ready
-} {
- foreach v {
- default_orientation border_width border_colour on_destroying on_ready
- } {
+proc setup-subwindow {on_destroying on_ready} {
+ variable w
+ variable h
+
+ foreach v {on_destroying on_ready} {
variable subwindow_$v [set $v]
}
variable subproc none
variable ratelimit {}
-proc setup-subproc {w h deforient border_colour border_width get_cmdline} {
+proc setup-subproc {get_cmdline} {
variable subproc_get_cmdline $get_cmdline
- setup-subwindow $w $h $deforient $border_colour $border_width \
- applet::subproc-destroying applet::subproc-ready
+ setup-subwindow applet::subproc-destroying applet::subproc-ready
}
proc subproc-destroying {} {
set ratelimit [lrange $ratelimit 1 end]
}
if {[llength $ratelimit] > 10} {
- debug stderr "crashing repeatedly, quitting $ratelimit"
+ puts stderr "crashing repeatedly, quitting $ratelimit"
exit 127
}