chiark / gitweb /
do not destroy .i.i.make-exist, since this sometimes causes trouble
[chiark-tcl-applet.git] / example
diff --git a/example b/example
index fe9794341f67fdb751d7e7f7a2b7e12198a35b38..2d07e86d135c6cb5a952452febc8c9f1af4c86e0 100755 (executable)
--- a/example
+++ b/example
@@ -1,49 +1,33 @@
-#!/usr/bin/wish8.4
+#!/usr/bin/wish8.4 -f
+# -*- Tcl -*-
 
-#----- general machinery -----
+# usage:
+#  xbatmon-simple-tray
 
-package require tktray
+source applet.tcl
+source subproc.tcl
+source utils.tcl
 
-wm withdraw .
-
-image create bitmap ims -file /usr/share/ghostscript/8.71/lib/gs_s.xbm   
-
-tktray::icon .i -class example
-.i configure -docked 1
-
-set posted 0
+set debug::debug puts
 
 foreach b {1 3} {
-    menu .m$b -tearoff 0
+    applet::setup-button-menu $b
 }
 
-proc pressed {b x y} {
-    global posted
-    if {$posted == $b} {
-       puts "unpost $posted toggle"
-       .m$posted unpost
-       set posted 0
-    } elseif {[winfo exists .m$b]} {
-       if {$posted} {
-           .m$posted unpost
-           puts "unpost $posted other"
-       }
-       puts "post $b"
-       set posted $b
-       .m$b post $x $y
-    }
-}
+.m1 add command -command { applet::msel; puts hi } -label hi
+.m3 add command -command { applet::msel; puts boo } -label boo
 
-proc msel {} {
-    global posted
-    set posted 0
-}
-
-bind .i <ButtonPress> { pressed %b %X %Y }
+#image create bitmap ims -file gs_s.xbm   
+#image create bitmap ims -file /usr/share/ghostscript/8.71/lib/gs_s.xbm   
+#setimage ims
+#setimage ims
 
-#----- specifics -----
+applet::setup-tooltip { puts VIS } { puts INVIS }
+applet::tooltip-set "line\nanother"
 
-.i configure -image ims
-.m1 add command -command { msel; puts hi } -label hi
-.m3 add command -command { msel; puts boo } -label boo
+proc cmdline {id orientation} {
+    global argv
+    return [concat $argv $id]
+}
 
+applet::setup-subproc cmdline