chiark / gitweb /
orientation
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 9 Jun 2012 20:47:33 +0000 (21:47 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 9 Jun 2012 20:47:33 +0000 (21:47 +0100)
applet.tcl
example
xbatmon-simple-tray

index da6d0aac37155b9fcc5a8f87bb7b530b866ca549..5d9a65dc1c4fe487b8191837889d063414456028 100644 (file)
@@ -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
 #
 # 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
 #                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
 #  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.
 #
 # 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
 #                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 .
 #  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_on_ready
     variable subwindow_border_colour
     variable subwindow_border_width
+    variable subwindow_default_orientation
     unset innerwindow_after
 
     debug RESETUP
     unset innerwindow_after
 
     debug RESETUP
@@ -232,19 +236,31 @@ proc innerwindow-resetup {} {
     uplevel #0 $subwindow_on_destroying
     catch { destroy .i.i.b }
 
     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
 
     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]
     }
 
        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]
 
     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 {}
 
 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
     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
 }
 
        applet::subproc-destroying applet::subproc-ready
 }
 
@@ -277,8 +293,9 @@ proc subproc-destroying {} {
     }
 }
 
     }
 }
 
-proc subproc-ready {} {
+proc subproc-ready {orientation} {
     variable subproc
     variable subproc
+    variable subproc_orientation $orientation
     debug "READY $subproc"
 
     frame .i.i.b.c -container 1 -background orange
     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
     variable ratelimit
     variable subproc_get_cmdline
+    variable subproc_orientation
 
     set id [winfo id .i.i.b.c]
 
     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]
 
     debug "RUN-CHILD $subproc"
     set now [clock seconds]
diff --git a/example b/example
index a22ab0bc840914b1f2720180c19111418b390e83..0321c6babae35b53ff2af8b6d7d7a17cdd6e46c2 100755 (executable)
--- a/example
+++ b/example
@@ -21,8 +21,8 @@ foreach b {1 3} {
 applet::setup-tooltip { puts VIS } { puts INVIS }
 applet::tooltip-set "line\nanother"
 
 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]
 }
 
     return [list xacpi-simple -into $id]
 }
 
-applet::setup-subproc 40 darkblue 1 cmdline
+applet::setup-subproc 40 40 horizontal darkblue 1 cmdline
index 6c617c3e446f40aefdf7debf190dc9c40e2422ec..eb206f6f6d0323a0435c813f72b679cab5a5f9f4 100755 (executable)
@@ -4,8 +4,8 @@
 source applet.tcl
 source subproc.tcl
 
 source applet.tcl
 source subproc.tcl
 
-proc cmdline {id} {
+proc cmdline {id orientation} {
     return [list xacpi-simple -into $id]
 }
 
     return [list xacpi-simple -into $id]
 }
 
-applet::setup-subproc 70 darkblue 1 cmdline
+applet::setup-subproc 70 70 horizontal darkblue 1 cmdline