-#!/usr/bin/wish8.4
+#!/usr/bin/wish -f
+# -*- Tcl -*-
-#----- general machinery -----
+# Copyright 2016,2020 Ian Jackson
+# SPDX-License-Identifier: GPL-3.0-or-later
+# There is NO WARRANTY.
-package require tktray
+# usage:
+# .../example program arguments...
+# will run
+# program arguments... WINDOWID
+# and program sbould put up an X11 window as a child of WINDOWID
+#
+# eg, for a silly example:
+# .../example xterm -id
-wm withdraw .
+set lib .
-image create bitmap ims -file /usr/share/ghostscript/8.71/lib/gs_s.xbm
+source $lib/applet.tcl
+source $lib/subproc.tcl
+source $lib/utils.tcl
-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
-}
+#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
-bind .i <ButtonPress> { pressed %b %X %Y }
+applet::setup-tooltip { puts VIS } { puts INVIS }
+applet::tooltip-set "line\nanother"
-#----- specifics -----
-
-.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