From: Ian Jackson Date: Sat, 9 Jun 2012 20:47:33 +0000 (+0100) Subject: orientation X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-tcl-applet.git;a=commitdiff_plain;h=3d95f708f3791786019a008fc4b98744aa398e6b;ds=sidebyside orientation --- diff --git a/applet.tcl b/applet.tcl index da6d0aa..5d9a65d 100644 --- a/applet.tcl +++ b/applet.tcl @@ -56,10 +56,12 @@ package require tktray # # 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 \ +# applet::setup-subwindow \ +# WIDTH HEIGHT DEFAULT-ORIENTATION 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 +# 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. # # The user of the subwindow machinery may call @@ -68,9 +70,10 @@ package require tktray # # 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 \ +# applet::setup-subproc \ +# WIDTH HEIGHT DEFAULT-ORIENTATION BORDER-COLOUR BORDER-WIDTH \ # GET-CMDLINE -# Then the main code will call [concat GET_CMDLINE [list XID]] +# Then the main code will call [concat GET_CMDLINE [list XID ORIENTATION]] # to get the command line to run. wm withdraw . @@ -222,6 +225,7 @@ proc innerwindow-resetup {} { variable subwindow_on_ready variable subwindow_border_colour variable subwindow_border_width + variable subwindow_default_orientation unset innerwindow_after debug RESETUP @@ -232,19 +236,31 @@ proc innerwindow-resetup {} { uplevel #0 $subwindow_on_destroying catch { destroy .i.i.b } + set orientation [.i orientation] + debug "orientation $orientation" + if {![string compare $orientation unknown]} { + set orientation $subwindow_default_orientation + } + .i configure -image applet::innerwindow-ph-$orientation + frame .i.i.b -background darkblue -bd 1 pack .i.i.b -fill both -side left -expand 1 - uplevel #0 $subwindow_on_ready + uplevel #0 $subwindow_on_ready [list $orientation] } -proc setup-subwindow {w border_colour border_width on_destroying on_ready} { - foreach v {border_width border_colour on_destroying on_ready} { +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 + } { variable subwindow_$v [set $v] } - image create photo applet::innerwindow-ph-dummy -width $w -height 2 - .i configure -image applet::innerwindow-ph-dummy + image create photo applet::innerwindow-ph-horizontal -width $w -height 2 + image create photo applet::innerwindow-ph-vertical -width 2 -height $h + .i configure -image applet::innerwindow-ph-horizontal destroy [frame .i.make-exist] destroy [frame .i.i.make-exist] @@ -258,9 +274,9 @@ proc setup-subwindow {w border_colour border_width on_destroying on_ready} { variable subproc none variable ratelimit {} -proc setup-subproc {w border_colour border_width get_cmdline} { +proc setup-subproc {w h deforient border_colour border_width get_cmdline} { variable subproc_get_cmdline $get_cmdline - setup-subwindow $w $border_colour $border_width \ + setup-subwindow $w $h $deforient $border_colour $border_width \ applet::subproc-destroying applet::subproc-ready } @@ -277,8 +293,9 @@ proc subproc-destroying {} { } } -proc subproc-ready {} { +proc subproc-ready {orientation} { variable subproc + variable subproc_orientation $orientation debug "READY $subproc" frame .i.i.b.c -container 1 -background orange @@ -302,9 +319,10 @@ proc run-child {} { variable subproc variable ratelimit variable subproc_get_cmdline + variable subproc_orientation set id [winfo id .i.i.b.c] - set cmd [uplevel #0 [concat [list $subproc_get_cmdline] $id]] + set cmd [uplevel #0 $subproc_get_cmdline [list $id $subproc_orientation]] debug "RUN-CHILD $subproc" set now [clock seconds] diff --git a/example b/example index a22ab0b..0321c6b 100755 --- a/example +++ b/example @@ -21,8 +21,8 @@ foreach b {1 3} { applet::setup-tooltip { puts VIS } { puts INVIS } applet::tooltip-set "line\nanother" -proc cmdline {id} { +proc cmdline {id orientation} { return [list xacpi-simple -into $id] } -applet::setup-subproc 40 darkblue 1 cmdline +applet::setup-subproc 40 40 horizontal darkblue 1 cmdline diff --git a/xbatmon-simple-tray b/xbatmon-simple-tray index 6c617c3..eb206f6 100755 --- a/xbatmon-simple-tray +++ b/xbatmon-simple-tray @@ -4,8 +4,8 @@ source applet.tcl source subproc.tcl -proc cmdline {id} { +proc cmdline {id orientation} { return [list xacpi-simple -into $id] } -applet::setup-subproc 70 darkblue 1 cmdline +applet::setup-subproc 70 70 horizontal darkblue 1 cmdline